/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/scheduleteacherbygroupreport.php (37418B)
Schedule Teacher Report

Schedule Report by Group


prepare("SELECT * FROM manager_group_name WHERE Group_ID = ? AND Program_ID = ?"); $stmtGroup->bind_param("ii", $groupID, $programID); $stmtGroup->execute(); $groupData = $stmtGroup->get_result()->fetch_assoc(); $stmtGroup->close(); if (!$groupData) die("Group not found."); $groupName = htmlspecialchars($groupData['Group_Name']); // 1. Load all Holidays $holidays = []; $res = $mysqli->query(" SELECT Event_Title, Event_Start, Event_End, Event_Color FROM Events WHERE Calendar_Year IN ( SELECT DISTINCT YEAR(Start_Date) FROM schedule_course_for_group WHERE Program_ID = $programID AND Group_ID = $groupID ) "); while ($row = $res->fetch_assoc()) { $start = new DateTime($row['Event_Start']); $end = new DateTime($row['Event_End']); while ($start <= $end) { $d = $start->format('Y-m-d'); $holidays[$d] = [ 'title' => $row['Event_Title'], 'color' => $row['Event_Color'] ?: '#FFD700' ]; $start->modify('+1 day'); } } // 2. Load Retake Records $retakes = []; $stmt = $mysqli->prepare(" SELECT Type, Retake_Date FROM retake_records WHERE Program_ID = ? AND Group_ID = ? "); $stmt->bind_param('ii', $programID, $groupID); $stmt->execute(); $stmt->bind_result($rType, $rDate); while ($stmt->fetch()) { $retakes[$rDate] = $rType; } $stmt->close(); // 3. Get Exam Dates per Course $examDates = []; $stmt = $mysqli->prepare(" SELECT Course_ID, MAX(End_Date) FROM schedule_course_for_group WHERE Program_ID = ? AND Group_ID = ? GROUP BY Course_ID "); $stmt->bind_param('ii', $programID, $groupID); $stmt->execute(); $stmt->bind_result($eCourseID, $eDate); while ($stmt->fetch()) { $examDates[$eCourseID] = $eDate; } $stmt->close(); // 4. Load Scheduled Sessions WITH Teacher Info $scheduleRows = []; $stmt = $mysqli->prepare(" SELECT scf.Schedule_ID, scf.Course_ID, scf.Course_Name, scf.Reserve_Course, scf.Start_Date, scf.End_Date, gsm.Time_Slot, gsm.Time_From, gsm.Time_To, tp.First_Name, tp.Last_Name FROM schedule_course_for_group AS scf JOIN group_slot_mapping AS gsm ON scf.Group_Slot_ID = gsm.Group_Slot_ID LEFT JOIN teacher_course_assignments AS tca ON scf.Schedule_ID = tca.Schedule_ID LEFT JOIN teacher_profile AS tp ON tca.Teacher_ID = tp.Teacher_ID WHERE scf.Program_ID = ? AND scf.Group_ID = ? ORDER BY scf.Start_Date, scf.Start_Time "); $stmt->bind_param("ii", $programID, $groupID); $stmt->execute(); $stmt->bind_result( $scheduleID, $courseID, $courseName, $reserveCourse, $startDate, $endDate, $slotLabel, $slotFrom, $slotTo, $firstName, $lastName ); while ($stmt->fetch()) { //echo $firstName .'"-"'. $lastName; $scheduleRows[] = [ 'schedule_id' => $scheduleID, 'course_id' => $courseID, 'course_name' => $courseName, 'reserve' => $reserveCourse, 'start_date' => $startDate, 'end_date' => $endDate, 'slot' => $slotLabel, 'from' => $slotFrom, 'to' => $slotTo, 'teacher' => trim("$firstName $lastName") ]; } $stmt->close(); // 5. Group sessions by date $byDate = []; foreach ($scheduleRows as $r) { $period = new DatePeriod( new DateTime($r['start_date']), new DateInterval('P1D'), (new DateTime($r['end_date']))->modify('+1 day') ); foreach ($period as $dt) { $current = $dt->format('Y-m-d'); $byDate[$current][] = $r; } } // 6. Combine all possible dates $allDates = array_unique( array_merge( array_keys($byDate), array_keys($holidays), array_keys($retakes) ) ); sort($allDates, SORT_STRING); // 7. Render table echo ""; echo ""; echo ""; echo ""; foreach ($allDates as $date) { $dayName = date('l', strtotime($date)); $isHoliday = isset($holidays[$date]); $isRetake = isset($retakes[$date]); // Holiday row if ($isHoliday && !isset($byDate[$date])) { $h = $holidays[$date]; echo ""; continue; } // Retake row if ($isRetake && !isset($byDate[$date])) { echo ""; continue; } // Scheduled sessions foreach ($byDate[$date] as $r) { $isExam = isset($examDates[$r['course_id']]) && $examDates[$r['course_id']] === $date; $type = $isExam ? 'Exam Day' : 'Regular'; $style = $isExam ? "style='background-color:#FFCCCC; font-weight:bold;'" : ""; $timeRange = date("h:i A", strtotime($r['from'])) . " – " . date("h:i A", strtotime($r['to'])); $teacher = $r['teacher'] ?: "-"; echo ""; } } echo "
Schedule for Group: $groupName
Date Time Slot Course Teacher Time Type
($dayName) $date {$h['title']} Holiday
($dayName) $date Retake Session {$retakes[$date]}
($dayName) $date {$r['slot']} {$r['course_name']} " . htmlspecialchars($teacher) . " {$timeRange} {$type}
"; } /************* if (isset($_POST['Program_ID'], $_POST['Group_ID'])) { $Program_ID = intval($_POST['Program_ID']); $Group_ID = intval($_POST['Group_ID']); // 1. Group Info $stmtGroup = $mysqli->prepare("SELECT * FROM manager_group_name WHERE Group_ID = ? AND Program_ID = ?"); $stmtGroup->bind_param("ii", $Group_ID, $Program_ID); $stmtGroup->execute(); $groupData = $stmtGroup->get_result()->fetch_assoc(); $stmtGroup->close(); if (!$groupData) die("Group not found."); $groupName = htmlspecialchars($groupData['Group_Name']); $classDays = array_map('trim', explode(',', $groupData['class_days'])); // 2. Assignments $stmt = $mysqli->prepare("SELECT tca.*, tp.First_Name, tp.Last_Name, c.Course_Name, cg.Time_Slot, cg.Start_Time, cg.End_Time FROM teacher_course_assignments tca JOIN teacher_profile tp ON tca.Teacher_ID = tp.Teacher_ID JOIN Courses c ON tca.Course_ID = c.Course_ID JOIN course_group_schedule_main cg ON tca.Schedule_ID = cg.Schedule_ID WHERE tca.Program_ID = ? AND tca.Group_ID = ?"); $stmt->bind_param("ii", $Program_ID, $Group_ID); $stmt->execute(); $assignments = $stmt->get_result()->fetch_all(MYSQLI_ASSOC); $stmt->close(); // 3. Retakes $stmt = $mysqli->prepare(" SELECT rr.Retake_Date, gsm.Time_Slot FROM retake_records rr JOIN group_slot_mapping gsm ON rr.Group_ID = gsm.Group_ID WHERE rr.Program_ID = ? AND rr.Group_ID = ? "); //$stmt = $mysqli->prepare("SELECT rr.Retake_Date, tsp.Time_Slot // FROM retake_records rr // JOIN time_slot_programs tsp ON rr.time_slot_programs_ID = tsp.time_slot_programs_ID // WHERE rr.Program_ID = ? AND rr.Group_ID = ?"); //$stmt->bind_param("ii", $Program_ID, $Group_ID); //$stmt->execute(); //$retakes = $stmt->get_result()->fetch_all(MYSQLI_ASSOC); //$stmt->close(); // 4. Holidays $holidayMap = []; $res = $mysqli->query("SELECT Event_Title, Event_Start, Event_End, Event_Color FROM Events"); while ($event = $res->fetch_assoc()) { $start = new DateTime($event['Event_Start']); $end = (new DateTime($event['Event_End']))->modify('+1 day'); foreach (new DatePeriod($start, new DateInterval('P1D'), $end) as $dt) { $holidayMap[$dt->format('Y-m-d')] = [ 'title' => $event['Event_Title'], 'color' => $event['Event_Color'] ]; } } // 5. Date Range $dates = array_merge(array_column($assignments, 'Start_Date'), array_column($assignments, 'End_Date')); $start = new DateTime(min($dates)); $end = (new DateTime(max($dates)))->modify('+1 day'); $range = new DatePeriod($start, new DateInterval('P1D'), $end); echo "

Schedule for Group: {$groupName}

"; echo "
"; echo ""; echo ""; foreach ($range as $date) { $current = $date->format('Y-m-d'); $day = $date->format('l'); // Always display holiday regardless of class day //if (isset($holidayMap[$current])) { // $h = $holidayMap[$current]; // echo ""; //} if (isset($holidayMap[$current])) { $h = $holidayMap[$current]; echo ""; continue; // ✅ prevent further rows on this holiday } // Only skip non-class days if not a holiday if (!in_array($day, $classDays) && !isset($holidayMap[$current])) continue; $usedSlots = []; // Holidays (full day event, doesn't skip other events) // Holidays (skip the rest of the loop if it's a holiday) // Holidays (display holiday but still show other events on this day) // Retakes foreach ($retakes as $r) { if ($r['Retake_Date'] === $current) { $slotKey = strtolower(trim($r['Time_Slot'])); if (!in_array($slotKey, $usedSlots)) { $usedSlots[] = $slotKey; echo ""; } } } // Assignments (handle multiple slots per day) foreach ($assignments as $a) { if ($current >= $a['Start_Date'] && $current <= $a['End_Date']) { $slotKey = strtolower(trim($a['Time_Slot'])); if (in_array($slotKey, $usedSlots)) continue; $usedSlots[] = $slotKey; $type = ($current === $a['End_Date']) ? 'Exam Day' : 'Regular'; $bg = ($type === 'Exam Day') ? "style='background-color:#ffeeba'" : ""; $slot = format_time_slot_label($a['Time_Slot'], $day); $time = format_time_slot_range($a['Time_Slot'], $a['Start_Time'], $a['End_Time'], $day); $teacher = htmlspecialchars("{$a['First_Name']} {$a['Last_Name']}"); echo ""; } } } echo "
DateCourseTeacherTime SlotTimeType
$current{$h['title']}---Holiday
$current{$h['title']}---Holiday
$currentRetake-{$r['Time_Slot']}-Retake
$current{$a['Course_Name']}{$teacher}{$slot}{$time}{$type}
"; } ************/ /* if (isset($_POST['Program_ID'], $_POST['Group_ID'])) { $Program_ID = intval($_POST['Program_ID']); $Group_ID = intval($_POST['Group_ID']); // Get Group Name $stmt = $mysqli->prepare("SELECT Group_Name, class_days FROM manager_group_name WHERE Program_ID = ? AND Group_ID = ?"); $stmt->bind_param("ii", $Program_ID, $Group_ID); $stmt->execute(); $groupData = $stmt->get_result()->fetch_assoc(); $stmt->close(); $groupName = $groupData['Group_Name'] ?? 'Unknown Group'; $groupClassDays = explode(',', trim($groupData['class_days'])); // Assignments $stmt = $mysqli->prepare("SELECT tca.*, tp.First_Name, tp.Last_Name, c.Course_Name, cg.Time_Slot, cg.Start_Time, cg.End_Time FROM teacher_course_assignments tca JOIN teacher_profile tp ON tp.Teacher_ID = tca.Teacher_ID JOIN Courses c ON c.Course_ID = tca.Course_ID JOIN course_group_schedule cg ON cg.Schedule_ID = tca.Schedule_ID WHERE tca.Program_ID = ? AND tca.Group_ID = ?"); $stmt->bind_param("ii", $Program_ID, $Group_ID); $stmt->execute(); $assignments = $stmt->get_result()->fetch_all(MYSQLI_ASSOC); $stmt->close(); // Retakes $stmt = $mysqli->prepare("SELECT rr.Retake_Date, tsp.Time_Slot FROM retake_records rr JOIN time_slot_programs tsp ON rr.time_slot_programs_ID = tsp.time_slot_programs_ID WHERE rr.Program_ID = ? AND rr.Group_ID = ?"); $stmt->bind_param("ii", $Program_ID, $Group_ID); $stmt->execute(); $retakes = $stmt->get_result()->fetch_all(MYSQLI_ASSOC); $stmt->close(); // Holidays $holidayMap = []; $res = $mysqli->query("SELECT Event_Title, Event_Start, Event_End, Event_Color FROM Events"); while ($event = $res->fetch_assoc()) { $start = new DateTime($event['Event_Start']); $end = (new DateTime($event['Event_End']))->modify('+1 day'); foreach (new DatePeriod($start, new DateInterval('P1D'), $end) as $dt) { $holidayMap[$dt->format('Y-m-d')] = [ 'title' => $event['Event_Title'], 'color' => $event['Event_Color'] ]; } } // Date range $dates = array_merge(array_column($assignments, 'Start_Date'), array_column($assignments, 'End_Date')); $start = new DateTime(min($dates)); $end = (new DateTime(max($dates)))->modify('+1 day'); $range = new DatePeriod($start, new DateInterval('P1D'), $end); echo "
"; echo ""; echo ""; echo ""; foreach ($range as $date) { $current = $date->format('Y-m-d'); $day = $date->format('l'); $shownSlots = []; if (isset($holidayMap[$current])) { $h = $holidayMap[$current]; echo ""; continue; } foreach ($retakes as $r) { if ($r['Retake_Date'] === $current) { $slot = format_time_slot_label($r['Time_Slot'], $day); echo ""; $shownSlots[] = strtolower(trim($r['Time_Slot'])); } } foreach ($assignments as $a) { if ($current >= $a['Start_Date'] && $current <= $a['End_Date']) { $slotKey = strtolower(trim($a['Time_Slot'])); if (in_array($slotKey, $shownSlots)) continue; $type = ($current === $a['End_Date']) ? 'Exam Day' : 'Regular'; $bg = ($type === 'Exam Day') ? "style='background-color:#ffeeba'" : ""; $slotLabel = format_time_slot_label($a['Time_Slot'], $day); $time = format_time_slot_range($a['Time_Slot'], $a['Start_Time'], $a['End_Time'], $day); $teacher = $a['First_Name'] . ' ' . $a['Last_Name']; echo ""; } } } echo "
Schedule for Group: $groupName
DateCourseTeacherTime SlotTimeType
$current{$h['title']}---Holiday
$currentRetake-$slot-Retake
$current{$a['Course_Name']}$teacher$slotLabel$time$type
"; } */ /* if (isset($_POST['Program_ID'], $_POST['Group_ID'])) { include_once '../includes/db_connect.php'; $Program_ID = intval($_POST['Program_ID']); $Group_ID = intval($_POST['Group_ID']); // 1. Group Details $stmtGroup = $mysqli->prepare("SELECT * FROM manager_group_name WHERE Group_ID = ? AND Program_ID = ?"); $stmtGroup->bind_param("ii", $Group_ID, $Program_ID); $stmtGroup->execute(); $groupData = $stmtGroup->get_result()->fetch_assoc(); $stmtGroup->close(); if (!$groupData) die("Group not found."); $groupName = $groupData['Group_Name']; $classDays = array_map('trim', explode(',', $groupData['class_days'])); // 2. Assignments $stmt = $mysqli->prepare("SELECT tca.*, tp.First_Name, tp.Last_Name, c.Course_Name, cg.Time_Slot, cg.Start_Time, cg.End_Time FROM teacher_course_assignments tca JOIN teacher_profile tp ON tca.Teacher_ID = tp.Teacher_ID JOIN Courses c ON tca.Course_ID = c.Course_ID JOIN course_group_schedule cg ON tca.Schedule_ID = cg.Schedule_ID WHERE tca.Program_ID = ? AND tca.Group_ID = ?"); $stmt->bind_param("ii", $Program_ID, $Group_ID); $stmt->execute(); $assignments = $stmt->get_result()->fetch_all(MYSQLI_ASSOC); $stmt->close(); // 3. Replacements $stmt = $mysqli->prepare("SELECT tra.*, tp.First_Name, tp.Last_Name, c.Course_Name, cg.Time_Slot, cg.Start_Time, cg.End_Time FROM teacher_replacement_assignments tra JOIN teacher_profile tp ON tra.Replacing_Teacher_ID = tp.Teacher_ID JOIN course_group_schedule cg ON tra.Schedule_ID = cg.Schedule_ID JOIN Courses c ON cg.Course_ID = c.Course_ID WHERE cg.Group_ID = ? AND cg.Program_ID = ?"); $stmt->bind_param("ii", $Group_ID, $Program_ID); $stmt->execute(); $replacements = $stmt->get_result()->fetch_all(MYSQLI_ASSOC); $stmt->close(); // 4. Retakes $stmt = $mysqli->prepare("SELECT rr.Retake_Date, tsp.Time_Slot FROM retake_records rr JOIN time_slot_programs tsp ON rr.time_slot_programs_ID = tsp.time_slot_programs_ID WHERE rr.Program_ID = ? AND rr.Group_ID = ?"); $stmt->bind_param("ii", $Program_ID, $Group_ID); $stmt->execute(); $retakes = $stmt->get_result()->fetch_all(MYSQLI_ASSOC); $stmt->close(); // 5. Holidays $holidayMap = []; $res = $mysqli->query("SELECT Event_Title, Event_Start, Event_End, Event_Color FROM Events"); while ($event = $res->fetch_assoc()) { $start = new DateTime($event['Event_Start']); $end = (new DateTime($event['Event_End']))->modify('+1 day'); foreach (new DatePeriod($start, new DateInterval('P1D'), $end) as $dt) { $holidayMap[$dt->format('Y-m-d')] = [ 'title' => $event['Event_Title'], 'color' => $event['Event_Color'] ]; } } // 6. Dates range $dates = array_merge( array_column($assignments, 'Start_Date'), array_column($assignments, 'End_Date'), array_column($replacements, 'Replacement_From'), array_column($replacements, 'Replacement_To') ); $start = new DateTime(min($dates)); $end = (new DateTime(max($dates)))->modify('+1 day'); $range = new DatePeriod($start, new DateInterval('P1D'), $end); echo "

Schedule for Group: " . htmlspecialchars($groupName) . "

"; echo "
"; echo ""; echo ""; foreach ($range as $date) { $current = $date->format('Y-m-d'); $day = $date->format('l'); if (isset($holidayMap[$current])) { echo ""; continue; } $usedSlots = []; foreach ($retakes as $r) { if ($r['Retake_Date'] == $current) { $slot = format_time_slot_label($r['Time_Slot'], $day); echo ""; $usedSlots[] = strtolower(trim($r['Time_Slot'])); } } foreach ($replacements as $r) { if ($current >= $r['Replacement_From'] && $current <= $r['Replacement_To']) { $slotKey = strtolower(trim($r['Time_Slot'])); if (in_array($slotKey, $usedSlots)) continue; $usedSlots[] = $slotKey; $time = format_time_slot_range($r['Time_Slot'], $r['Start_Time'], $r['End_Time'], $day); $slot = format_time_slot_label($r['Time_Slot'], $day); $teacher = htmlspecialchars("{$r['First_Name']} {$r['Last_Name']}"); echo ""; } } foreach ($assignments as $a) { if ($current >= $a['Start_Date'] && $current <= $a['End_Date']) { $slotKey = strtolower(trim($a['Time_Slot'])); if (in_array($slotKey, $usedSlots)) continue; $usedSlots[] = $slotKey; $type = ($current == $a['End_Date']) ? 'Exam Day' : 'Regular'; $bg = ($type === 'Exam Day') ? "style='background-color:#ffeeba'" : ""; $time = format_time_slot_range($a['Time_Slot'], $a['Schedule_Start_Time'], $a['Schedule_End_Time'], $day); $slot = format_time_slot_label($a['Time_Slot'], $day); $teacher = htmlspecialchars("{$a['First_Name']} {$a['Last_Name']}"); echo ""; } } } echo "
DateCourseTeacherTime SlotTimeType
$current{$holidayMap[$current]['title']}---Holiday
$currentRetake-$slot-Retake
$current{$r['Course_Name']}$teacher$slot$timeReplacement
$current{$a['Course_Name']}$teacher$slot$time$type
"; } */ ?>