<?php
ob_start(); // penting supaya tidak error header

require_once "../config/db.php";
require_once "../inc/auth_admin.php";

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

$id      = intval($_POST['id']);
$status  = $_POST['status'];
$biaya   = intval($_POST['biaya'] ?? 0);
$catatan = $_POST['catatan_admin'] ?? '';

/* ===============================
   UPDATE STATUS + BIAYA + CATATAN
================================ */
$stmt = $conn->prepare("
    UPDATE laporan 
    SET status=?, biaya=?, catatan_admin=?, notifikasi=1
    WHERE id=?
");

$stmt->bind_param("sisi", $status, $biaya, $catatan, $id);
$stmt->execute();

/* ===============================
   REDIRECT KEMBALI KE DATA LAPORAN
================================ */
header("Location: laporan.php?success=1");
exit;