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

if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'controller') {
    header("Location: ../auth/login.php");
    exit;
}

$controller_id = $_SESSION['user_id'];
$id = $_GET['id'] ?? null;

if ($id) {
    $stmt = $pdo->prepare("DELETE FROM occurrences WHERE id = ? AND controller_id = ?");
    $stmt->execute([$id, $controller_id]);
}

header("Location: view_occurrences.php");
exit;
