<?php
header('Content-Type: application/json');
include '../config/koneksi.php';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $tutup_id = isset($_POST['tutup_id']) ? $_POST['tutup_id'] : '';

    if (empty($tutup_id)) {
        echo json_encode(['status' => 'error', 'pesan' => 'ID tutup tidak boleh kosong']);
        exit;
    }

    $query = "UPDATE dat_jadwal_tutup SET deleted_st = 1 WHERE tutup_id = '$tutup_id'";
    $result = mysqli_query($conn, $query);

    if ($result) {
        echo json_encode(['status' => 'sukses', 'pesan' => 'Jadwal tutup berhasil dihapus']);
    } else {
        echo json_encode(['status' => 'gagal', 'pesan' => 'Gagal menghapus jadwal']);
    }
} else {
    echo json_encode(['status' => 'error', 'pesan' => 'Metode tidak valid']);
}
