<?php
require_once '../db/config.php';

$promotion_id = $_GET['id'];

// First, update menu_items to remove the promotion_id
$stmt = db()->prepare("UPDATE menu_items SET promotion_id = NULL WHERE promotion_id = ?");
$stmt->execute([$promotion_id]);

// Then, delete the promotion
$stmt = db()->prepare("DELETE FROM special_promotions WHERE id = ?");
$stmt->execute([$promotion_id]);

header('Location: promotions.php');
exit;
?>