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

if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['role'] === 'admin') {
    $id = $_POST['incident_id'];
    $status = $_POST['status'];
    $comment = $_POST['admin_comment'];

    $stmt = $pdo->prepare("UPDATE incident_reports SET status = ?, admin_comment = ? WHERE id = ?");
    $stmt->execute([$status, $comment, $id]);

    $_SESSION['toast'] = "Incident #$id has been " . strtoupper($status);
}

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