<?php
// File: API_KONEKSI/admin/antrean/update_status.php
error_reporting(0);
header('Content-Type: application/json');
include '../../config/koneksi.php';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $reservasi_id = $_POST['reservasi_id'] ?? '';
    $status_baru = $_POST['status_baru'] ?? ''; // 'Proses' atau 'Selesai'

    if (empty($reservasi_id) || empty($status_baru)) {
        echo json_encode(["status" => "gagal", "pesan" => "Data tidak lengkap"]);
        exit;
    }

    $query = "UPDATE dat_reservasi SET reservasi_st = ? WHERE reservasi_id = ?";
    $stmt = $conn->prepare($query);
    $stmt->bind_param("ss", $status_baru, $reservasi_id);

    if ($stmt->execute()) {
        echo json_encode(["status" => "sukses", "pesan" => "Status berhasil diperbarui"]);
    } else {
        echo json_encode(["status" => "gagal", "pesan" => "Gagal memperbarui status"]);
    }

    $stmt->close();
    $conn->close();
}
?>