/home/techb158/workloadmatch.com/workloadmatch.com/Manager
NameSizeModeActions
core/-0755rm
css/-0755rm
data/-0755rm
fonts/-0755rm
Inc/-0755rm
js/-0755rm
php/-0755rm
accesscontrol.php160390644editdlrm
AddClient.php39300644editdlrm
addcourse.php177360644editdlrm
addcoursesession.php205280644editdlrm
addcoursetime.php173050644editdlrm
addgroup - Copy.php212120644editdlrm
addgroup.php229990644editdlrm
addgroup1.php206670644editdlrm
addholiday.php180190644editdlrm
addmanager.php187650644editdlrm
addremediation.php178770644editdlrm
addretake.php219140644editdlrm
adduser.php300790644editdlrm
adduser1.php235270644editdlrm
Add_Course_Session.php65290644editdlrm
add_event.php19600644editdlrm
Add_Teacher_Unavailability.php17460644editdlrm
adminreports.php162190644editdlrm
AI_Generate_Schedule - Copy.php122170644editdlrm
AI_Generate_Schedule.php107310644editdlrm
ajax_course_group_Backup.php172700644editdlrm
ajax_course_group_Backup_1.php187420644editdlrm
ajax_fetch_schedule.php37600644editdlrm
ajax_get_group_slots.php8720644editdlrm
ajax_replace_saturday -Completed.php187390644editdlrm
ajax_replace_saturday - Copy (2).php187390644editdlrm
ajax_replace_saturday - Copy (3).php265540644editdlrm
ajax_replace_saturday - Copy (4).php266150644editdlrm
ajax_replace_saturday - Copy (5).php283740644editdlrm
ajax_replace_saturday - Copy.php134520644editdlrm
ajax_replace_saturday - Good.php172700644editdlrm
ajax_replace_saturday.php307790644editdlrm
ajax_swap_courses.php42790644editdlrm
assign_course_group-BackUp.php213310644editdlrm
assign_course_group - Copy (BackUp).php183150644editdlrm
assign_course_group - Copy.php213180644editdlrm
assign_course_group.php183150644editdlrm
assign_course_group1.php209620644editdlrm
Assign_Course_Report.php13750644editdlrm
assign_teacher_manual-1.php210950644editdlrm
assign_teacher_manual - Copy (2).php223280644editdlrm
assign_teacher_manual - Copy.php223880644editdlrm
assign_teacher_manual-Not work.php205850644editdlrm
assign_teacher_manual.php223280644editdlrm
assign_teacher_manual_force_conflicts.php223590644editdlrm
availableteacherreport.php137180644editdlrm
Available_Teacher_Report - Copy.php22360644editdlrm
Available_Teacher_Report.php76910644editdlrm
brokerreports.php163180644editdlrm
calendar - Copy (2).php168910644editdlrm
calendar - Copy.php231930644editdlrm
calendar.php306530644editdlrm
changestatus.php8650644editdlrm
Check_if_Teacher_Report.php15870644editdlrm
complete_schedule_report_by_teacher.php193120644editdlrm
courseflagtime.php34110644editdlrm
Create_Group_Schedule_Algorithm.php38280644editdlrm
Create_Schedule_Algorithm - Copy (2).php414120644editdlrm
Create_Schedule_Algorithm - Copy (3).php463520644editdlrm
Create_Schedule_Algorithm - Copy (4).php535690644editdlrm
Create_Schedule_Algorithm - Copy (5).php679560644editdlrm
Create_Schedule_Algorithm - Copy (6).php711340644editdlrm
Create_Schedule_Algorithm - Copy (7).php725290644editdlrm
Create_Schedule_Algorithm - Copy (8).php730840644editdlrm
Create_Schedule_Algorithm - Copy (9).php735770644editdlrm
Create_Schedule_Algorithm - Copy (10).php765050644editdlrm
Create_Schedule_Algorithm - Copy (11).php767640644editdlrm
Create_Schedule_Algorithm - Copy (12).php863240644editdlrm
Create_Schedule_Algorithm - Copy (13).php831330644editdlrm
Create_Schedule_Algorithm - Copy (14).php872740644editdlrm
Create_Schedule_Algorithm - Copy (get info only).php697470644editdlrm
Create_Schedule_Algorithm - Copy (with 2 course 2nd SPECIAL ).php823140644editdlrm
Create_Schedule_Algorithm - Copy.php405810644editdlrm
Create_Schedule_Algorithm.php882760644editdlrm
Create_Schedule_Algorithm_1.php414120644editdlrm
Create_Schedule_Algorithm_2.php765050644editdlrm
Create_Schedule_Algorithm_2_combined.php897640644editdlrm
Create_Schedule_Algorithm_2_combined_both_slots.php919320644editdlrm
Create_Schedule_Algorithm_2_fixed.php768290644editdlrm
Create_Schedule_Algorithm_3.php872740644editdlrm
Create_Schedule_Algorithm_4.php872740644editdlrm
dashboard-BackUp.php188060644editdlrm
dashboard.php225070644editdlrm
deleteschedulefromgroup.php168190644editdlrm
delete_course.php5800644editdlrm
delete_course_from_teacher.php49900644editdlrm
delete_course_from_teacher_backup.php30940644editdlrm
delete_event.php12120644editdlrm
delete_group.php18580644editdlrm
delete_holiday.php7150644editdlrm
delete_retake.php12760644editdlrm
delete_schedule_from_group-1.php18700644editdlrm
delete_schedule_from_group.php18500644editdlrm
delete_teacher_level.php7980644editdlrm
delete_teacher_unavailability.php13470644editdlrm
delete_timeslot.php5970644editdlrm
display_schedule-1.php188460644editdlrm
display_schedule.php188460644editdlrm
do_remove_saturday.php61700644editdlrm
edit_event.php16120644editdlrm
error_log740700644editdlrm
examschedulereport.php162670644editdlrm
Exam_Schedule_Report.php26770644editdlrm
export_absences.php12210644editdlrm
fetch_all_scheduled_courses.php63180644editdlrm
fetch_courses - BackUp.php97110644editdlrm
fetch_courses - Copy.php77190644editdlrm
fetch_courses.php91670644editdlrm
fetch_courses_for_program.php7880644editdlrm
fetch_courses_for_program_by_schedule - Copy.php22970644editdlrm
fetch_courses_for_program_by_schedule.php39350644editdlrm
fetch_courses_teacher_preference.php38520644editdlrm
fetch_course_for_added_group.php8970644editdlrm
fetch_course_hours.php6910644editdlrm
fetch_disabled_dates.php5180644editdlrm
fetch_events.php9750644editdlrm
fetch_exist_dates.php10990644editdlrm
fetch_groups_exist_in_schedule.php9560644editdlrm
fetch_groups_for_program.php8430644editdlrm
fetch_group_timeslot.php8470644editdlrm
fetch_reserve_courses.php74290644editdlrm
fetch_retake_courses.php9230644editdlrm
fetch_scheduled_courses.php21780644editdlrm
fetch_schedule_report_by_group.php54400644editdlrm
fetch_teachers_by_group.php44210644editdlrm
fetch_teachers_by_program.php18210644editdlrm
fetch_teachers_for_group.php31700644editdlrm
fetch_teacher_assignment.php247760644editdlrm
fetch_teacher_by_course.php38800644editdlrm
fetch_teacher_conflicts.php56820644editdlrm
fetch_teacher_conflicts_only.php76650644editdlrm
fetch_teacher_conflicts_only_force_conflicts.php71140644editdlrm
fetch_teacher_conflicts_showonly.php104470644editdlrm
fetch_teacher_load.php14820644editdlrm
fetch_teacher_prefrence_courses_accounting.php16060644editdlrm
find_replacement-1.php160750644editdlrm
find_replacement.php181610644editdlrm
followup.php161600644editdlrm
Generate Group Schedule.php169870644editdlrm
Generate Group Schedule 1.php181210644editdlrm
generateschedule.php157060644editdlrm
Generate_Schedule.php336200644editdlrm
generate_schedule_handler.php70950644editdlrm
Generate_Schedule_Script.php297310644editdlrm
getlang.php3260644editdlrm
getrefer.php43490644editdlrm
getstatus.php12600644editdlrm
get_groups_by_program.php6080644editdlrm
get_schedule_ai-1.php377550644editdlrm
get_schedule_ai - Copy.php364590644editdlrm
get_schedule_ai.php368550644editdlrm
get_schedule_report.php23930644editdlrm
group_schedule_form - Copy.php169940644editdlrm
group_schedule_form.php169940644editdlrm
main-header-inc.php11960644editdlrm
main-header.php166710644editdlrm
managecategory.php92330644editdlrm
managerreports.php250560644editdlrm
Preference_Accounting.php225030644editdlrm
profile.php206800644editdlrm
reference_list.php82070644editdlrm
remove_saturday_course.php195030644editdlrm
report_absence.php192870644editdlrm
report_absence_1.php61600644editdlrm
reserve_course.php189570644editdlrm
rewrite_ajax_replace_saturday.php128000644editdlrm
rewrite_Create_Schedule_Algorithm.php883180644editdlrm
rewrite_Create_Schedule_Algorithm_2.php889000644editdlrm
save_schedule.php29700644editdlrm
save_schedule_group_course.php253670644editdlrm
schedulereportbygroup.php177310644editdlrm
schedulereportbyteacher.php191110644editdlrm
scheduleteacherbygroupreport - Copy.php319860644editdlrm
scheduleteacherbygroupreport.php365560644editdlrm
scheduleteacherreport.php281500644editdlrm
schedule_report.php176640644editdlrm
Schedule_Report_by_Group.php36470644editdlrm
Schedule_Report_by_Teacher.php924330644editdlrm
selectuser.php11720644editdlrm
swapcourses.php194690644editdlrm
teacher_preference.php181820644editdlrm
teacher_preference_by_course.php192440644editdlrm
teacher_unavailability.php178350644editdlrm
test.php138950644editdlrm
test1.php218370644editdlrm
transfer_reference.php272880644editdlrm
unassigncoursereport.php160290644editdlrm
unassign_course.php190110644editdlrm
Unassign_Course_Report.php16970644editdlrm
unscheduledgroupreport.php156750644editdlrm
Unscheduled_Group_Report.php20070644editdlrm
updateclient.php147650644editdlrm
updatecourse.php216260644editdlrm
updatecoursesessionhours.php181970644editdlrm
updatecoursetime.php218310644editdlrm
updategroup - Copy.php245340644editdlrm
updategroup.php180010644editdlrm
updateholiday.php224930644editdlrm
updateteacherlevel.php245320644editdlrm
updateteacherunavailability.php141840644editdlrm
UpdateUser.php182140644editdlrm
Update_Course_Hours.php21350644editdlrm
Update_Follow_Up.php46180644editdlrm
update_reserve_course.php19340644editdlrm
update_teacher_level25080644editdlrm
update_teacher_level.php24300644editdlrm
useraccesslist.php128750644editdlrm
users.php90490644editdlrm
view_swap_log.php8940644editdlrm
Edit: /home/techb158/workloadmatch.com/workloadmatch.com/Manager/fetch_teacher_assignment.php (24776B)
prepare($sql); if (!$stmtGroup) { die("Error preparing group query: " . $mysqli->error); } // Bind parameters in the same order as the placeholders (Teacher_ID first, then Program_ID). $stmtGroup->bind_param("ii", $Teacher_ID, $Program_ID); $stmtGroup->execute(); $resultGroup = $stmtGroup->get_result(); $stmtGroup->close(); // Check if any rows were returned. if ($resultGroup->num_rows === 0) { echo ""; echo ""; echo "Course not found."; echo ""; echo ""; echo ""; } else { // Output each row as a table row. while ($row = $resultGroup->fetch_assoc()) { $timeFromFormatted = date("h:i A", strtotime($row['time_from'])); $timeToFormatted = date("h:i A", strtotime($row['time_to'])); $startDate = !empty($row['Start_Date']) ? htmlspecialchars($row['Start_Date']) : '-'; $endDate = !empty($row['End_Date']) ? htmlspecialchars($row['End_Date']) : '-'; echo ' ' . htmlspecialchars($row['program_name']) . ' ' . htmlspecialchars($row['group_name']) . ' ' . htmlspecialchars($row['course_name']) . ' ' . htmlspecialchars($row['time_slot']) . ' ' . htmlspecialchars($timeFromFormatted . '-' . $timeToFormatted) . ' ' . $startDate . ' ' . $endDate . ' '; } } } /* // Loop through and output the table rows. while ($row = $resultGroup->fetch_assoc()) { echo " " . htmlspecialchars($row['program_name']) . " " . htmlspecialchars($row['group_name']) . " " . htmlspecialchars($row['course_name']) . " " . htmlspecialchars($row['time_slot']) . " " . htmlspecialchars($row['time_from'] . ' ' . $row['time_to']) . " Regular "; } */ //} /* include_once '../includes/db_connect.php'; include_once '../includes/functions.php'; sec_session_start(); if (isset($_POST["Program_ID"]) && isset($_POST["Group_ID"]) && isset($_POST["Teacher_ID"])) { // Retrieve POST parameters. $Program_ID = $_POST['Program_ID']; $Group_ID = $_POST['Group_ID']; $Teacher_ID = $_POST['Teacher_ID']; if ($Program_ID <= 0 || $Group_ID <= 0 || $Teacher_ID <= 0) { die("Invalid parameters."); } // --------------------------------------------------- // 1. Retrieve group details from Manager_Group_Name // --------------------------------------------------- $groupQuery = "SELECT * FROM Manager_Group_Name WHERE Group_ID = ? AND Program_ID = ?"; $stmtGroup = $mysqli->prepare($groupQuery); if (!$stmtGroup) { die("Error preparing group query: " . $mysqli->error); } $stmtGroup->bind_param("ii", $Group_ID, $Program_ID); $stmtGroup->execute(); $resultGroup = $stmtGroup->get_result(); $groupData = $resultGroup->fetch_assoc(); $stmtGroup->close(); if (!$groupData) { die("Group not found."); } // Retrieve group details. $groupTimeSlot = trim($groupData['Time_Slot']); // e.g., "Morning,Afternoon" $groupStartTime = $groupData['Time_From']; // e.g., "08:30:00" $groupEndTime = $groupData['Time_To']; // e.g., "15:30:00" $weekendClass = isset($groupData['Weekend_Class']) ? intval($groupData['Weekend_Class']) : 0; // 0 = no Saturday // New custom days field (comma‑separated string) $groupClassDays = trim($groupData['class_days']); // e.g., "Monday,Wednesday,Friday" or default ("Monday,Tuesday,Wednesday,Thursday,Friday") // --------------------------------------------------- // 2. Retrieve assignments for this teacher // --------------------------------------------------- $query = "SELECT tca.*, c.Course_Name, c.Course_Time FROM Teacher_Course_Assignments tca JOIN Courses c ON tca.Course_ID = c.Course_ID WHERE tca.Program_ID = ? AND tca.Group_ID = ? AND tca.Teacher_ID = ? ORDER BY tca.Assigned_At DESC"; $stmt = $mysqli->prepare($query); if (!$stmt) { die("Error preparing assignment query: " . $mysqli->error); } $stmt->bind_param("iii", $Program_ID, $Group_ID, $Teacher_ID); if (!$stmt->execute()) { die("Error executing assignment query: " . $stmt->error); } $result = $stmt->get_result(); $assignments = []; while ($row = $result->fetch_assoc()) { $assignments[] = $row; } $stmt->close(); // --------------------------------------------------- // 3. Retrieve holiday events from the Events table // --------------------------------------------------- $eventQuery = "SELECT Event_Title, Event_Color, Event_Start, Event_End FROM Events"; $stmtEvent = $mysqli->prepare($eventQuery); if ($stmtEvent) { $stmtEvent->execute(); $eventResult = $stmtEvent->get_result(); $holidayMapping = []; // key: date (Y-m-d) => array of event details while ($event = $eventResult->fetch_assoc()) { $startEvent = new DateTime($event['Event_Start']); $endEvent = new DateTime($event['Event_End']); $endEvent->modify('+1 day'); // include last day $interval = new DateInterval('P1D'); $period = new DatePeriod($startEvent, $interval, $endEvent); foreach ($period as $dt) { $d = $dt->format('Y-m-d'); $holidayMapping[$d][] = [ 'title' => $event['Event_Title'], 'color' => $event['Event_Color'] ]; } } $stmtEvent->close(); } else { $holidayMapping = []; } // --------------------------------------------------- // 4. Retrieve retake dates from Retake_Records table. // --------------------------------------------------- $retakeQuery = "SELECT Retake_Date FROM Retake_Records WHERE Program_ID = ? AND Group_ID = ?"; $stmtRetake = $mysqli->prepare($retakeQuery); if ($stmtRetake) { $stmtRetake->bind_param("ii", $Program_ID, $Group_ID); $stmtRetake->execute(); $retakeResult = $stmtRetake->get_result(); $retakes = []; while ($r = $retakeResult->fetch_assoc()) { $retakes[] = $r['Retake_Date']; } $stmtRetake->close(); } else { $retakes = []; } // --------------------------------------------------- // 5. Determine a global date range for the report (based on assignments). // --------------------------------------------------- if (!empty($assignments)) { $globalStart = new DateTime($assignments[0]['Start_Date']); $globalEnd = new DateTime($assignments[0]['End_Date']); foreach ($assignments as $assignment) { $d1 = new DateTime($assignment['Start_Date']); $d2 = new DateTime($assignment['End_Date']); if ($d1 < $globalStart) { $globalStart = $d1; } if ($d2 > $globalEnd) { $globalEnd = $d2; } } $globalEnd->modify('+1 day'); // inclusive $globalPeriod = new DatePeriod($globalStart, new DateInterval('P1D'), $globalEnd); } else { $globalStart = new DateTime(); $globalEnd = clone $globalStart; $globalEnd->modify('+30 days'); $globalPeriod = new DatePeriod($globalStart, new DateInterval('P1D'), $globalEnd); } // --------------------------------------------------- // 6. Generate the day-by-day report. // --------------------------------------------------- // Loop through each day in the global date period. foreach ($globalPeriod as $date) { // Ensure $date is a valid DateTime object. if (!($date instanceof DateTime)) { continue; } $currentDate = $date->format('Y-m-d'); $dayOfWeek = $date->format('N'); // 1 (Monday) to 7 (Sunday) $currentDay = $date->format('l'); // Full day name, e.g., "Monday" // --- Custom Days Check --- // If groupClassDays is defined (non-empty) then we only process this day if it is in that list. if (!empty($groupClassDays)) { $customDays = array_map('trim', explode(',', $groupClassDays)); if (!in_array($currentDay, $customDays)) { continue; // Skip this date } } else { // No custom days defined; use default: // Always skip Sunday. if ($dayOfWeek == 7) { continue; } // Skip Saturday if weekendClass is not enabled. if ($dayOfWeek == 6 && $weekendClass == 0) { continue; } } // --- Exclusion Check for Holidays and Retakes --- if (isset($holidayMapping[$currentDate])) { foreach ($holidayMapping[$currentDate] as $event) { echo " " . htmlspecialchars($currentDate) . " " . htmlspecialchars($event['title']) . " - - Holiday "; } continue; } if (in_array($currentDate, $retakes)) { echo " " . htmlspecialchars($currentDate) . " Retake Day - - Retake "; continue; } // --- Regular Class Days --- $foundAssignment = false; foreach ($assignments as $assignment) { $assignStart = new DateTime($assignment['Start_Date']); $assignEnd = new DateTime($assignment['End_Date']); $assignEnd->modify('+1 day'); // inclusive if ($date >= $assignStart && $date < $assignEnd) { // Determine time range based on assignment’s Time_Slot. $timeRange = ""; if (isset($groupPeriods) && count($groupPeriods) > 1) { if ($assignment['Time_Slot'] === $firstPeriodStr) { $timeRange = $firstPeriodStart->format("h:i A") . " - " . $firstPeriodEnd->format("h:i A"); } elseif ($assignment['Time_Slot'] === $secondPeriodStr) { $timeRange = $secondPeriodStart->format("h:i A") . " - " . $secondPeriodEnd->format("h:i A"); } else { $timeRange = "N/A"; } } else { // Define singlePeriodStart and singlePeriodEnd if not already defined. // For example, use the group's overall start and end times: $singlePeriodStart = new DateTime($groupStartTime); $singlePeriodEnd = new DateTime($groupEndTime); $timeRange = $singlePeriodStart->format("h:i A") . " - " . $singlePeriodEnd->format("h:i A"); } echo " " . htmlspecialchars($currentDate) . " " . htmlspecialchars($assignment['Course_Name']) . " " . htmlspecialchars($assignment['Time_Slot']) . " " . htmlspecialchars($timeRange) . " Regular "; $foundAssignment = true; // If multiple assignments apply, additional rows could be output. } } if (!$foundAssignment) { // For Free days, output a row in a different color (e.g., light blue). echo " " . htmlspecialchars($currentDate) . " No Class - - Free "; } } } */ /* if (isset($_POST["Program_ID"]) && isset($_POST["Group_ID"])&& isset($_POST["Teacher_ID"])) { // Get parameters via GET (or fixed for testing) //$Program_ID = isset($_GET['Program_ID']) ? intval($_GET['Program_ID']) : 1; //$Group_ID = isset($_GET['Group_ID']) ? intval($_GET['Group_ID']) : 4; //$Teacher_ID = isset($_GET['Teacher_ID']) ? intval($_GET['Teacher_ID']) : 250598; $Program_ID = $_POST['Program_ID']; $Group_ID = $_POST['Group_ID']; $Teacher_ID = $_POST['Teacher_ID']; if ($Program_ID <= 0 || $Group_ID <= 0 || $Teacher_ID <= 0) { die("Invalid parameters."); } // --------------------------------------------------- // 1. Retrieve group details from Manager_Group_Name // --------------------------------------------------- $groupQuery = "SELECT * FROM Manager_Group_Name WHERE Group_ID = ? AND Program_ID = ?"; $stmtGroup = $mysqli->prepare($groupQuery); if (!$stmtGroup) { die("Error preparing group query: " . $mysqli->error); } $stmtGroup->bind_param("ii", $Group_ID, $Program_ID); $stmtGroup->execute(); $resultGroup = $stmtGroup->get_result(); $groupData = $resultGroup->fetch_assoc(); $stmtGroup->close(); if (!$groupData) { die("Group not found."); } // Expected columns: Time_Slot, Time_From, Time_To, Weekend_Class $groupTimeSlot = trim($groupData['Time_Slot']); // e.g., "Morning,Afternoon" or "Morning" $groupStartTime = $groupData['Time_From']; // e.g., "08:30:00" $groupEndTime = $groupData['Time_To']; // e.g., "15:30:00" $weekendClass = isset($groupData['Weekend_Class']) ? intval($groupData['Weekend_Class']) : 0; // 0 = no Saturday class // Split the group's time slot field into periods. $groupPeriods = array_map('trim', explode(',', $groupTimeSlot)); if (count($groupPeriods) > 1) { $firstPeriodStr = $groupPeriods[0]; // e.g., "Morning" $secondPeriodStr = $groupPeriods[1]; // e.g., "Afternoon" $groupStartDT = new DateTime($groupStartTime); $groupEndDT = new DateTime($groupEndTime); // For the first period, assume duration of 3 hours from group start. $firstPeriodStart = clone $groupStartDT; $firstPeriodEnd = clone $groupStartDT; $firstPeriodEnd->modify('+3 hours'); // e.g., 08:30 -> 11:30 // For the second period, assume duration of 3 hours before group end. $secondPeriodEnd = clone $groupEndDT; $secondPeriodStart = clone $groupEndDT; $secondPeriodStart->modify('-3 hours'); // e.g., 15:30 -> 12:30 } else { $singlePeriod = $groupPeriods[0]; // e.g., "Morning" $singlePeriodStart = new DateTime($groupStartTime); $singlePeriodEnd = new DateTime($groupEndTime); } // --------------------------------------------------- // 2. Retrieve assignments for this teacher // --------------------------------------------------- $query = "SELECT tca.*, c.Course_Name, c.Course_Time FROM Teacher_Course_Assignments tca JOIN Courses c ON tca.Course_ID = c.Course_ID WHERE tca.Program_ID = ? AND tca.Group_ID = ? AND tca.Teacher_ID = ? ORDER BY tca.Assigned_At DESC"; $stmt = $mysqli->prepare($query); if (!$stmt) { die("Error preparing assignment query: " . $mysqli->error); } $stmt->bind_param("iii", $Program_ID, $Group_ID, $Teacher_ID); if (!$stmt->execute()) { die("Error executing assignment query: " . $stmt->error); } $result = $stmt->get_result(); $assignments = []; while ($row = $result->fetch_assoc()) { $assignments[] = $row; } $stmt->close(); // --------------------------------------------------- // 3. Retrieve holiday events from the Events table // --------------------------------------------------- $eventQuery = "SELECT Event_Title, Event_Color, Event_Start, Event_End FROM Events"; $stmtEvent = $mysqli->prepare($eventQuery); if ($stmtEvent) { //$stmtEvent->bind_param("i", $Program_ID); $stmtEvent->execute(); $eventResult = $stmtEvent->get_result(); $holidayMapping = []; // key: date (Y-m-d) => array of event details while ($event = $eventResult->fetch_assoc()) { // Generate dates from Event_Start to Event_End (inclusive) $startEvent = new DateTime($event['Event_Start']); $endEvent = new DateTime($event['Event_End']); $endEvent->modify('+1 day'); // include the last day $interval = new DateInterval('P1D'); $period = new DatePeriod($startEvent, $interval, $endEvent); foreach ($period as $dt) { $d = $dt->format('Y-m-d'); $holidayMapping[$d][] = [ 'title' => $event['Event_Title'], 'color' => $event['Event_Color'] ]; } } $stmtEvent->close(); } else { $holidayMapping = []; } // --------------------------------------------------- // 4. Retrieve retake dates from Retake_Records table. // --------------------------------------------------- $retakeQuery = "SELECT Retake_Date FROM Retake_Records WHERE Program_ID = ? AND Group_ID = ?"; $stmtRetake = $mysqli->prepare($retakeQuery); if ($stmtRetake) { $stmtRetake->bind_param("ii", $Program_ID, $Group_ID); $stmtRetake->execute(); $retakeResult = $stmtRetake->get_result(); $retakes = []; while ($r = $retakeResult->fetch_assoc()) { $retakes[] = $r['Retake_Date']; } $stmtRetake->close(); } else { $retakes = []; } // --------------------------------------------------- // 5. Determine a global date range for the report (based on assignments). // --------------------------------------------------- if (!empty($assignments)) { $globalStart = new DateTime($assignments[0]['Start_Date']); $globalEnd = new DateTime($assignments[0]['End_Date']); foreach ($assignments as $assignment) { $d1 = new DateTime($assignment['Start_Date']); $d2 = new DateTime($assignment['End_Date']); if ($d1 < $globalStart) { $globalStart = $d1; } if ($d2 > $globalEnd) { $globalEnd = $d2; } } $globalEnd->modify('+1 day'); // Make inclusive $globalPeriod = new DatePeriod($globalStart, new DateInterval('P1D'), $globalEnd); } else { $globalStart = new DateTime(); $globalEnd = clone $globalStart; $globalEnd->modify('+30 days'); $globalPeriod = new DatePeriod($globalStart, new DateInterval('P1D'), $globalEnd); } // --------------------------------------------------- // 6. Generate the day-by-day report. // --------------------------------------------------- //echo "

Daily Course Schedule Report for Teacher $Teacher_ID, Group $Group_ID, Program $Program_ID

"; //echo ""; //echo " // // // // // // "; foreach ($globalPeriod as $date) { $currentDate = $date->format('Y-m-d'); $dayOfWeek = $date->format('N'); // ISO-8601: 6 = Saturday, 7 = Sunday // --- Weekend Check --- if ($dayOfWeek == 7) { // Always skip Sunday. continue; } if ($dayOfWeek == 6 && $weekendClass == 0) { continue; } // --- Exclusion Check: If current date is a holiday or retake, output those rows and skip class row. if (isset($holidayMapping[$currentDate])) { foreach ($holidayMapping[$currentDate] as $event) { echo ""; } // Skip regular class row for this date. continue; } if (in_array($currentDate, $retakes)) { echo ""; continue; } // --- Regular Class Days --- $foundAssignment = false; foreach ($assignments as $assignment) { $assignStart = new DateTime($assignment['Start_Date']); $assignEnd = new DateTime($assignment['End_Date']); $assignEnd->modify('+1 day'); // Make inclusive if ($date >= $assignStart && $date < $assignEnd) { // Determine time range based on assignment's Time_Slot. $timeRange = ""; if (count($groupPeriods) > 1) { if ($assignment['Time_Slot'] === $firstPeriodStr) { $timeRange = $firstPeriodStart->format("h:i A") . " - " . $firstPeriodEnd->format("h:i A"); } elseif ($assignment['Time_Slot'] === $secondPeriodStr) { $timeRange = $secondPeriodStart->format("h:i A") . " - " . $secondPeriodEnd->format("h:i A"); } else { $timeRange = "N/A"; } } else { $timeRange = $singlePeriodStart->format("h:i A") . " - " . $singlePeriodEnd->format("h:i A"); } echo ""; $foundAssignment = true; // If multiple assignments apply, additional rows could be output. } } if (!$foundAssignment) { echo ""; } } //echo "
DateCourse Name / StatusTime SlotTimeType
" . htmlspecialchars($currentDate) . " " . htmlspecialchars($event['title']) . " - - Holiday
" . htmlspecialchars($currentDate) . " Retake Day - - Retake
" . htmlspecialchars($currentDate) . " " . htmlspecialchars($assignment['Course_Name']) . " " . htmlspecialchars($assignment['Time_Slot']) . " " . htmlspecialchars($timeRange) . " Regular
" . htmlspecialchars($currentDate) . " No Class - - Free
"; } */ ?>