<?php
require_once "../../includes/db.php";
require_once "../../includes/functions.php";
require_once "../../includes/auth.php";
ensure_manager();

$id = intval($_GET['id']);
$restaurant_id = $_SESSION['restaurant_id'];

// جلب الصور لحذفها
$row = fetch_one("SELECT cover_image, cover_video FROM branches WHERE id=? AND restaurant_id=?", [$id,$restaurant_id]);
if(!$row) die("not found");

delete_file($row['cover_image']);
delete_file($row['cover_video']);

db()->prepare("DELETE FROM branches WHERE id=? AND restaurant_id=?")->execute([$id,$restaurant_id]);

echo "deleted";
