-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_timewindows.php
More file actions
31 lines (25 loc) · 909 Bytes
/
get_timewindows.php
File metadata and controls
31 lines (25 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
include("inc/db.php");
include("inc/header.php");
header("Content-Type: application/json; charset=UTF-8");
if (!isset($_GET["day"]) or !($_GET["day"])) {
http_response_code(400);
exit;
}
$sql_timewindows = "SELECT zeitfensterID, von, bis, maxTeilnehmer FROM zeitfenster WHERE tagID = ? ORDER BY von, bis";
$query = $db->query($sql_timewindows, array($_GET["day"]));
$data_timewindows = $query->fetchAll();
$timewindows = array();
foreach ($data_timewindows as $timewindow) {
$max_participants = $timewindow["maxTeilnehmer"];
$participants = $db->get_participants(null, array($timewindow["zeitfensterID"]));
$timewindow["participants"] = $participants;
if ($participants >= $max_participants) {
$timewindow["disabled"] = true;
} else {
$timewindow["disabled"] = false;
}
array_push($timewindows, $timewindow);
}
echo json_encode($timewindows);
?>