schedule api

This commit is contained in:
Sundog Jones 2024-09-22 12:41:58 -04:00
parent 3c5e901950
commit a9d007f851

11
schedule.php Normal file → Executable file
View File

@ -4,13 +4,20 @@
if (isset($_GET['date']) && $_GET['date'] !== "") {
// get info about single day's schedule
$query = $db->prepare("SELECT * FROM schedules WHERE date = :date");
$query->bindValue(":date", intval($_GET['date']));
$query = $db->prepare("SELECT * FROM schedules s
LEFT JOIN schedules_blocks sb ON s.id = sb.schedule_id
LEFT JOIN blocks b ON sb.block_id = b.id
WHERE s.date = :date");
$query->bindValue(":date", intval(strtotime($_GET['date'])));
$result = $query->execute();
if ($result) {
$row = $result->fetchArray(SQLITE3_ASSOC);
echo(json_encode($row));
}
} else if (isset($_POST['id']) && intval($_POST['id']) > 0) {
// update single schedule
} else if (isset($_POST['date']) && strtotime($_POST['date'])) {
// add new schedule
} else {
echo("{}");
}