<?php
require_once __DIR__ . "/includes/auth.php";
ensure_super_admin();

require_once __DIR__ . "/includes/db.php";

$id = (int)$_POST['id'];

$current = fetch_value("SELECT active FROM restaurants WHERE id = ?", [$id]);

$new = ($current == 1 ? 0 : 1);

db()->prepare("UPDATE restaurants SET active = ? WHERE id = ?")
   ->execute([$new, $id]);

echo "done";
