<?php
include "../config/koneksi.php";
include "../middleware/auth.php";

if ($_SESSION['role'] != 'admin') {
    die("Akses ditolak");
}

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    header("Location: data_komplain.php?filter=total");
    exit;
}

$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;

if ($id <= 0) {
    header("Location: data_komplain.php?filter=total");
    exit;
}

mysqli_query($conn, "DELETE FROM komplain WHERE id = '{$id}'");

header("Location: data_komplain.php?filter=total");
exit;
?>
