-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_expert_schedules.php
More file actions
48 lines (42 loc) · 974 Bytes
/
get_expert_schedules.php
File metadata and controls
48 lines (42 loc) · 974 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
header('Content-Type: application/json');
require_once 'db/config.php';
if (!isset($_GET['expert_id'])) {
echo json_encode([]);
exit();
}
$expert_id = $_GET['expert_id'];
// Get available schedules for the expert
$sql = "
SELECT
s.shid,
s.eid,
s.schedule_date,
s.start_time,
s.end_time,
s.session_type,
s.max_appointments,
s.current_appointments,
s.notes,
s.status
FROM schedule s
WHERE s.eid = ?
AND s.schedule_date >= CURDATE()
AND s.status = 'available'
ORDER BY s.schedule_date ASC, s.start_time ASC
";
$stmt = $conn->prepare($sql);
if ($stmt) {
$stmt->bind_param("i", $expert_id);
$stmt->execute();
$result = $stmt->get_result();
$schedules = [];
while ($row = $result->fetch_assoc()) {
$schedules[] = $row;
}
echo json_encode($schedules);
$stmt->close();
} else {
echo json_encode([]);
}
?>