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

if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    $response = array();
    
    $query = "SELECT tutup_id, tgl_tutup, keterangan_tx FROM dat_jadwal_tutup WHERE deleted_st = 0 ORDER BY tgl_tutup ASC";
    $result = mysqli_query($conn, $query);
    
    if ($result) {
        $data = array();
        while ($row = mysqli_fetch_assoc($result)) {
            $data[] = $row;
        }
        
        $response['status'] = 'sukses';
        $response['data'] = $data;
    } else {
        $response['status'] = 'gagal';
        $response['pesan'] = 'Gagal mengambil data jadwal tutup';
    }
    
    echo json_encode($response);
} else {
    echo json_encode(['status' => 'error', 'pesan' => 'Metode tidak valid']);
}
