/home/techb158/workloadmatch.com/Manager
NameSizeModeActions
core/-0755rm
css/-0755rm
data/-0755rm
fonts/-0755rm
Inc/-0755rm
js/-0755rm
php/-0755rm
addcourse.php180030644editdlrm
addcoursesession.php144240644editdlrm
addcoursesession_bak.php.disabled208600644editdlrm
addcoursetime.php175640644editdlrm
addgroup.php234650644editdlrm
addgroup1.php204630644editdlrm
addholiday.php182830644editdlrm
addmanager.php190600644editdlrm
addremediation.php181400644editdlrm
addretake.php222840644editdlrm
adduser.php304850644editdlrm
adduser1.php231660644editdlrm
Add_Course_Session.php69310644editdlrm
Add_Course_Session_bak.php.disabled69310644editdlrm
add_event.php20040644editdlrm
Add_Teacher_Unavailability.php17240644editdlrm
AI_Generate_Schedule.php110310644editdlrm
ai_schedule.php199750644editdlrm
ajax_fetch_schedule.php38560644editdlrm
ajax_get_group_slots.php8970644editdlrm
ajax_replace_saturday.php316740644editdlrm
ajax_replace_saturday_backup_latest.php314740644editdlrm
ajax_replace_saturday_bak.php.disabled318120644editdlrm
ajax_swap_courses.php43940644editdlrm
approve_teacher_absence.php22300644editdlrm
approve_teacher_unavailability.php22740644editdlrm
assign_course_group.php181150644editdlrm
assign_course_group1.php207520644editdlrm
Assign_Course_Report.php23180644editdlrm
assign_teacher_legacy.php164900644editdlrm
assign_teacher_manual.php175510644editdlrm
assign_teacher_manual_bak.php.disabled227180644editdlrm
assign_teacher_manual_force_conflicts.php227490644editdlrm
availableteacherreport.php125950644editdlrm
Available_Teacher_Report.php35540644editdlrm
batch_schedule.php95820644editdlrm
calendar.php315020644editdlrm
calendar_schedule.php80860644editdlrm
chat.php164370644editdlrm
chat_bak.php.disabled102650644editdlrm
Check_if_Teacher_Report.php16390644editdlrm
complete_schedule_report_by_teacher.php197990644editdlrm
courseflagtime.php35180644editdlrm
Create_Group_Schedule_Algorithm.php39390644editdlrm
Create_Schedule_Algorithm.php906290644editdlrm
Create_Schedule_Algorithm_1.php424300644editdlrm
Create_Schedule_Algorithm_2.php785320644editdlrm
Create_Schedule_Algorithm_2_combined.php921570644editdlrm
Create_Schedule_Algorithm_2_combined_both_slots.php945460644editdlrm
Create_Schedule_Algorithm_2_combined_both_slots_bak.php.disabled946110644editdlrm
Create_Schedule_Algorithm_2_fixed.php788690644editdlrm
Create_Schedule_Algorithm_3.php895940644editdlrm
Create_Schedule_Algorithm_4.php895940644editdlrm
dashboard.php211030644editdlrm
deletecoursesession.php85910644editdlrm
deleteschedulefromgroup.php174240644editdlrm
delete_course.php6070644editdlrm
delete_course_from_teacher.php51260644editdlrm
delete_course_session_handler.php7910644editdlrm
delete_duplicate_assignments.php25370644editdlrm
delete_event.php12550644editdlrm
delete_group.php19130644editdlrm
delete_holiday.php7430644editdlrm
delete_retake.php13240644editdlrm
delete_schedule_from_group.php19400644editdlrm
delete_teacher_absence.php10150644editdlrm
delete_teacher_level.php8280644editdlrm
delete_teacher_unavailability.php13500644editdlrm
delete_timeslot.php6260644editdlrm
display_schedule.php186620644editdlrm
do_remove_saturday.php64020644editdlrm
duplicate_assignment_report.php94230644editdlrm
edit_event.php16630644editdlrm
examschedulereport.php165100644editdlrm
Exam_Schedule_Report.php27620644editdlrm
export_absences.php12580644editdlrm
fetch_all_scheduled_courses.php63250644editdlrm
fetch_courses.php93730644editdlrm
fetch_courses_for_program.php8150644editdlrm
fetch_courses_for_program_by_schedule.php40470644editdlrm
fetch_courses_teacher_preference.php39540644editdlrm
fetch_course_for_added_group.php10460644editdlrm
fetch_course_hours.php7140644editdlrm
fetch_course_sessions.php14050644editdlrm
fetch_dashboard_charts.php42820644editdlrm
fetch_disabled_dates.php5430644editdlrm
fetch_duplicate_assignments.php49020644editdlrm
fetch_events.php10140644editdlrm
fetch_exist_dates.php11410644editdlrm
fetch_groups_exist_in_schedule.php9590644editdlrm
fetch_groups_for_program.php8710644editdlrm
fetch_groups_for_program_legacy.php7750644editdlrm
fetch_group_timeslot.php8780644editdlrm
fetch_lockup_courses-1-1.php140860644editdlrm
fetch_lockup_courses.php145870644editdlrm
fetch_lockup_courses_1.php136380644editdlrm
fetch_lockup_courses_2.php138500644editdlrm
fetch_lockup_courses_bak.php88990644editdlrm
fetch_reserve_courses.php75670644editdlrm
fetch_retake_courses.php9570644editdlrm
fetch_scheduled_courses.php22540644editdlrm
fetch_schedule_report_by_group.php55540644editdlrm
fetch_teachers_by_group.php48880644editdlrm
fetch_teachers_by_group_legacy.php24210644editdlrm
fetch_teachers_by_program.php18710644editdlrm
fetch_teachers_for_group.php32650644editdlrm
fetch_teacher_assignment.php254050644editdlrm
fetch_teacher_by_course.php39820644editdlrm
fetch_teacher_conflicts-1-1.php57930644editdlrm
fetch_teacher_conflicts.php57660644editdlrm
fetch_teacher_conflicts_only-1-1.php82750644editdlrm
fetch_teacher_conflicts_only-1.php87370644editdlrm
fetch_teacher_conflicts_only.php77250644editdlrm
fetch_teacher_conflicts_only_force_conflicts.php72870644editdlrm
fetch_teacher_conflicts_only_legacy.php67020644editdlrm
fetch_teacher_conflicts_showonly-1-1.php106560644editdlrm
fetch_teacher_conflicts_showonly.php105310644editdlrm
fetch_teacher_load.php16330644editdlrm
fetch_teacher_load_legacy.php11440644editdlrm
fetch_teacher_prefrence_courses.php18480644editdlrm
fetch_teacher_prefrence_courses_accounting.php16470644editdlrm
fetch_workload_data.php45200644editdlrm
fetch_workload_hours-1.php22910644editdlrm
fetch_workload_hours-2.php21470644editdlrm
fetch_workload_hours.php23410644editdlrm
find_replacement-1-1.php186030644editdlrm
find_replacement.php183130644editdlrm
Generate Group Schedule.php173300644editdlrm
Generate Group Schedule 1.php184900644editdlrm
generateschedule.php159460644editdlrm
Generate_Schedule.php347430644editdlrm
generate_schedule_handler.php73750644editdlrm
Generate_Schedule_Script.php307290644editdlrm
getlang.php3510644editdlrm
get_groups_by_program.php6290644editdlrm
get_schedule_ai.php377120644editdlrm
get_schedule_report.php24710644editdlrm
group_schedule_form.php173370644editdlrm
Lockup_to_Assign.php120520644editdlrm
Lockup_to_Assign_bak.php113010644editdlrm
main-header-inc.php77940644editdlrm
main-header.php196560644editdlrm
Preference_Accounting.php98100644editdlrm
preference_accounting.php96030644editdlrm
preference_secretarial.php98100644editdlrm
profile.php209760644editdlrm
remove_saturday_course.php193130644editdlrm
report_absence.php210560644editdlrm
report_absence_1.php63850644editdlrm
reserve_course.php192850644editdlrm
rewrite_ajax_replace_saturday.php131890644editdlrm
rewrite_Create_Schedule_Algorithm.php906720644editdlrm
rewrite_Create_Schedule_Algorithm_2.php912680644editdlrm
save_schedule.php31020644editdlrm
save_schedule_group_course.php263010644editdlrm
save_teacher_preference.php22160644editdlrm
schedulereportbygroup.php180130644editdlrm
schedulereportbyteacher.php194240644editdlrm
scheduleteacherbygroupreport.php374180644editdlrm
scheduleteacherreport.php287880644editdlrm
schedule_report.php179440644editdlrm
Schedule_Report_by_Group.php37410644editdlrm
Schedule_Report_by_Teacher.php946340644editdlrm
swapcourses.php198130644editdlrm
teacher_notes.php189360644editdlrm
teacher_preference.php184960644editdlrm
teacher_preference_by_course.php195870644editdlrm
teacher_report_visibility.php157610644editdlrm
teacher_unavailability.php205770644editdlrm
test.php142780644editdlrm
test1.php224250644editdlrm
unassigncoursereport.php150750644editdlrm
unassign_course.php193240644editdlrm
Unassign_Course_Report.php20580644editdlrm
unscheduledgroupreport.php163960644editdlrm
Unscheduled_Group_Report.php24110644editdlrm
updatecourse.php224540644editdlrm
updatecoursesessionhours.php189050644editdlrm
updatecoursetime.php226700644editdlrm
updategroup.php186190644editdlrm
updateholiday.php233320644editdlrm
updateteacherlevel.php254330644editdlrm
updateteacherunavailability.php118330644editdlrm
UpdateUser.php192610644editdlrm
Update_Course_Hours.php20270644editdlrm
update_reserve_course.php20040644editdlrm
update_teacher_absence.php121350644editdlrm
update_teacher_level25080644editdlrm
update_teacher_level.php24990644editdlrm
useraccesslist.php131450644editdlrm
users.php91710644editdlrm
view_swap_log.php9290644editdlrm
workloadhoursreport.php81820644editdlrm
Edit: /home/techb158/workloadmatch.com/Manager/fetch_teacher_assignment.php (25405B)
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
"; } */ ?>