<?php
// File: api/get_jadwal_hari.php
header('Content-Type: application/json');
require_once '../config/database.php';

$hari = $_GET['hari'] ?? '';

if (!$hari) {
    echo json_encode([]);
    exit;
}

// Ambil semua jadwal untuk hari ini dari tabel belloto_jadwal
$stmt = $conn->prepare("SELECT * FROM belloto_jadwal WHERE hari = ? AND aktif = 1 ORDER BY jam ASC");
$stmt->bind_param("s", $hari);
$stmt->execute();
$result = $stmt->get_result();

$schedules = [];
while ($row = $result->fetch_assoc()) {
    $schedules[] = [
        'jam' => substr($row['jam'], 0, 5),
        'kegiatan' => $row['nama_kegiatan'],
        'audio_file' => $row['audio_file'],
        'aktif' => $row['aktif']
    ];
}

echo json_encode($schedules);
$conn->close();
?>