/home/techb158/workloadmatch.com/workloadmatch.com/api/reports
NameSizeModeActions
schedule-by-course.php30630644editdlrm
schedule-by-group.php23210644editdlrm
Edit: /home/techb158/workloadmatch.com/workloadmatch.com/api/reports/schedule-by-group.php (2321B)
"error", "message" => "Unauthorized: Please log in." ]); exit(); } $teacherId = $_SESSION['user_id']; // Build the query to fetch schedule records for the logged-in teacher. // This query joins: // - Teacher_Course_Assignments (alias s) // - Programs (p) to get Program_Name // - Courses (c) to get Course_Name // - Manager_Group_Name (g) to get Group_Name // - Course_Group_Schedule (cs) to retrieve scheduling details // And it filters records by s.Teacher_ID. $query = "SELECT s.Schedule_ID, s.Program_ID, p.Program_Name, s.Course_ID, c.Course_Name, s.Group_ID, g.Group_Name, cs.Time_Slot, cs.Start_Date, cs.End_Date, cs.Start_Time, cs.End_Time, cs.Assigned FROM Teacher_Course_Assignments s JOIN Programs p ON p.Program_ID = s.Program_ID JOIN Courses c ON s.Course_ID = c.Course_ID JOIN Manager_Group_Name g ON g.Group_ID = s.Group_ID JOIN Course_Group_Schedule cs ON cs.Schedule_ID = s.Schedule_ID WHERE s.Teacher_ID = ? ORDER BY s.Group_ID, cs.Start_Date"; if ($stmt = $mysqli->prepare($query)) { $stmt->bind_param("i", $teacherId); $stmt->execute(); $result = $stmt->get_result(); $data = []; // Group the records by Group_ID while ($row = $result->fetch_assoc()) { $data[$row['Group_ID']][] = $row; } echo json_encode([ "status" => "success", "data" => $data ]); $stmt->close(); } else { http_response_code(500); echo json_encode([ "status" => "error", "message" => "Database error: " . $mysqli->error ]); } exit(); ?>