<?php
session_start();
require_once '../db/config.php';

// Check if the user is logged in as an admin
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
    header('Location: login.php');
    exit;
}

$id = $_GET['id'] ?? null;
$restaurant_id = $_GET['restaurant_id'] ?? null;

if ($id) {
    $pdo = db();
    $stmt = $pdo->prepare("DELETE FROM menu_items WHERE id = ?");
    $stmt->execute([$id]);
}

if ($restaurant_id) {
    header('Location: menu.php?restaurant_id=' . $restaurant_id);
} else {
    header('Location: index.php');
}
exit;
?>
