/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/test1.php (22425B)
prepare($scheduleQuery); $stmt->bind_param("iii", $Program_ID, $Group_ID, $Reserve_Course); }else{ $scheduleQuery = "SELECT * FROM course_group_schedule WHERE Assigned = 0 AND Program_ID = ? AND Reserve_Course = ? ORDER BY Time_Slot"; $stmt = $mysqli->prepare($scheduleQuery); $stmt->bind_param("ii", $Program_ID, $Reserve_Course); } if (!$stmt) { die("Error preparing schedule query: " . $mysqli->error); } if (!$stmt->execute()) { die("Error executing schedule query: " . $stmt->error); } $schedulesResult = $stmt->get_result(); $schedules = []; while ($row = $schedulesResult->fetch_assoc()) { $schedules[] = $row; } $stmt->close(); // ----------------------------- // STEP 2: Get teachers for this Program, combining teacher_profile and top_teacher_list. // Ordering: Premium (top) teachers first, then teachers with Seniority_ID = 1 (qualified), // then teachers with Seniority_ID = 2 (unqualified). // ----------------------------- //$teacherQuery = " // SELECT // tp.Teacher_ID, // tp.First_Name, // tp.Last_Name, // tp.Seniority_ID, // tp.Time_Slot AS Availability, // tp.Load_Hours, // ttl.Top_Teacher_ID, // ttl.Teacher_Level // FROM teacher_profile tp // LEFT JOIN top_teacher_list ttl // ON tp.Teacher_ID = ttl.Teacher_ID // AND ttl.Program_ID = ? // WHERE 1 // ORDER BY // CASE // WHEN ttl.Top_Teacher_ID IS NOT NULL THEN 1 // WHEN tp.Seniority_ID = 1 THEN 2 // WHEN tp.Seniority_ID = 2 THEN 3 // ELSE 4 // END, // tp.First_Name ASC, // tp.Last_Name ASC //"; //$stmt = $mysqli->prepare($teacherQuery); //if (!$stmt) { // die("Error preparing teacher query: " . $mysqli->error); //} //$stmt->bind_param("i", $Program_ID); //if (!$stmt->execute()) { // die("Error executing teacher query: " . $stmt->error); //} //$result = $stmt->get_result(); //$teachers = []; //while ($row = $result->fetch_assoc()) { // $teachers[] = $row; //} //$stmt->close(); //// Debug: Optional print teacher list //foreach ($teachers as $teacher) { // $isPremium = !empty($teacher['Top_Teacher_ID']) ? "Premium (Level: " . $teacher['Teacher_Level'] . ")" : ""; // echo $teacher['First_Name'] . " " . $teacher['Last_Name'] . " - Seniority: " . $teacher['Seniority_ID'] . " " . $isPremium . " - Load Hours: " . $teacher['Load_Hours'] . "
"; //} // STEP 2: Get teachers for this Program by combining teacher_profile and top_teacher_list. // (No filtering on teacher_profile by Program_ID because it's not in that table.) $teacherQuery = " SELECT tp.Teacher_ID, tp.First_Name, tp.Last_Name, tp.Seniority_ID, tp.Time_Slot AS Availability, tp.Load_Hours, ttl.Top_Teacher_ID, ttl.Teacher_Level FROM teacher_profile tp LEFT JOIN top_teacher_list ttl ON tp.Teacher_ID = ttl.Teacher_ID AND ttl.Program_ID = ? WHERE 1 ORDER BY tp.First_Name ASC, tp.Last_Name ASC "; $stmt = $mysqli->prepare($teacherQuery); if (!$stmt) { die("Error preparing teacher query: " . $mysqli->error); } $stmt->bind_param("i", $Program_ID); $stmt->execute(); $result = $stmt->get_result(); $allTeachers = []; while ($row = $result->fetch_assoc()) { $allTeachers[] = $row; } $stmt->close(); // Initialize the round-robin pointer $teacherCount = count($teachers); $teacherIndex = 0; // ----------------------------- // STEP 3: Loop through each unassigned schedule and try to assign a teacher // ----------------------------- // Separate teachers into groups $premiumTeachers = []; $qualifiedTeachers = []; $unqualifiedTeachers = []; foreach ($allTeachers as $teacher) { if (!empty($teacher['Top_Teacher_ID'])) { $premiumTeachers[] = $teacher; } elseif ($teacher['Seniority_ID'] == 1) { $qualifiedTeachers[] = $teacher; } elseif ($teacher['Seniority_ID'] == 2) { $unqualifiedTeachers[] = $teacher; } } // Initialize round-robin pointers for each group $ptrPremium = 0; $ptrQualified = 0; $ptrUnqualified = 0; $cntPremium = count($premiumTeachers); $cntQualified = count($qualifiedTeachers); $cntUnqualified = count($unqualifiedTeachers); // (Optional) Debug output: print ordered teacher groups echo "

Premium Teachers:

"; foreach ($premiumTeachers as $t) { echo $t['First_Name']." ".$t['Last_Name']." (Level: ".$t['Teacher_Level'].")
"; } echo "

Qualified Teachers:

"; foreach ($qualifiedTeachers as $t) { echo $t['First_Name']." ".$t['Last_Name']." (Seniority: ".$t['Seniority_ID'].")
"; } echo "

Unqualified Teachers:

"; foreach ($unqualifiedTeachers as $t) { echo $t['First_Name']." ".$t['Last_Name']." (Seniority: ".$t['Seniority_ID'].")
"; } echo "
"; // Helper inline: For each teacher, perform assignment checks. // (Availability, conflict, load hours, preferences) foreach ($schedules as $schedule) { $assigned = false; // Function to check if teacher can be assigned // (We inline the checks here.) $canAssign = function($teacher, $schedule) use ($mysqli, $Program_ID) { // Check availability: Teacher's Availability field is a comma-separated list. $availableSlots = array_map('trim', explode(',', $teacher['Availability'])); if (!in_array($schedule['Time_Slot'], $availableSlots)) { return false; } // Check conflicts: any overlapping assignment in the same time slot. $conflictQuery = "SELECT COUNT(*) AS cnt FROM teacher_course_assignments WHERE Teacher_ID = ? AND Time_Slot = ? AND (? <= End_Date AND ? >= Start_Date)"; $conflictStmt = $mysqli->prepare($conflictQuery); if (!$conflictStmt) { echo "Error preparing conflict query: " . $mysqli->error . "
"; return false; } $conflictStmt->bind_param("isss", $teacher['Teacher_ID'], $schedule['Time_Slot'], $schedule['Start_Date'], $schedule['End_Date']); if (!$conflictStmt->execute()) { echo "Error executing conflict query: " . $conflictStmt->error . "
"; $conflictStmt->close(); return false; } $conflictResult = $conflictStmt->get_result(); $conflictRow = $conflictResult->fetch_assoc(); $conflictCount = $conflictRow['cnt']; $conflictStmt->close(); if ($conflictCount > 0) { return false; } // Check load hours capacity: // 1. Get teacher's current assigned hours. $currentLoadQuery = "SELECT IFNULL(SUM(c.Course_Time), 0) AS total_hours FROM teacher_course_assignments tca JOIN Courses c ON tca.Course_ID = c.Course_ID WHERE tca.Teacher_ID = ?"; $currentLoadStmt = $mysqli->prepare($currentLoadQuery); if (!$currentLoadStmt) { echo "Error preparing current load query: " . $mysqli->error . "
"; return false; } $currentLoadStmt->bind_param("i", $teacher['Teacher_ID']); $currentLoadStmt->execute(); $currentLoadResult = $currentLoadStmt->get_result(); $currentLoadRow = $currentLoadResult->fetch_assoc(); $currentLoad = $currentLoadRow['total_hours']; $currentLoadStmt->close(); // 2. Get new course's hours. $courseQuery = "SELECT Course_Time FROM Courses WHERE Course_ID = ?"; $courseStmt = $mysqli->prepare($courseQuery); if (!$courseStmt) { echo "Error preparing course query: " . $mysqli->error . "
"; return false; } $courseStmt->bind_param("i", $schedule['Course_ID']); $courseStmt->execute(); $courseResult = $courseStmt->get_result(); $courseData = $courseResult->fetch_assoc(); $newCourseTime = $courseData['Course_Time']; $courseStmt->close(); if (($currentLoad + $newCourseTime) > $teacher['Load_Hours']) { return false; } // Check teacher's course preferences. $prefQuery = "SELECT * FROM teacher_course_preferences WHERE Teacher_ID = ? AND Course_ID = ? AND Priority IN (1,2) ORDER BY Priority ASC"; $prefStmt = $mysqli->prepare($prefQuery); if (!$prefStmt) { echo "Error preparing preference query: " . $mysqli->error . "
"; return false; } $prefStmt->bind_param("ii", $teacher['Teacher_ID'], $schedule['Course_ID']); $prefStmt->execute(); $prefResult = $prefStmt->get_result(); $preferences = []; while ($prefRow = $prefResult->fetch_assoc()) { $preferences[] = $prefRow; } $prefStmt->close(); if (empty($preferences)) { return false; } return true; }; // end of anonymous function // Try to assign from premium teachers first if ($cntPremium > 0) { for ($i = 0; $i < $cntPremium; $i++) { $currentIndex = ($ptrPremium + $i) % $cntPremium; $teacher = $premiumTeachers[$currentIndex]; if ($canAssign($teacher, $schedule)) { // Assign this teacher // Insert assignment $insertQuery = "INSERT INTO teacher_course_assignments (Teacher_ID, Course_ID, Group_ID, Program_ID, Schedule_ID, Time_Slot, Start_Date, End_Date, Assigned_At) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; $insertStmt = $mysqli->prepare($insertQuery); if (!$insertStmt) { echo "Error preparing insert query: " . $mysqli->error . "
"; continue; } $assignedAt = date('Y-m-d H:i:s'); $insertStmt->bind_param("iiiiissss", $teacher['Teacher_ID'], $schedule['Course_ID'], $schedule['Group_ID'], $schedule['Program_ID'], $schedule['Schedule_ID'], $schedule['Time_Slot'], $schedule['Start_Date'], $schedule['End_Date'], $assignedAt ); if (!$insertStmt->execute()) { echo "Error executing insert query: " . $insertStmt->error . "
"; $insertStmt->close(); continue; } $insertStmt->close(); // Mark schedule as assigned. $updateQuery = "UPDATE course_group_schedule SET Assigned = 1 WHERE Schedule_ID = ?"; $updateStmt = $mysqli->prepare($updateQuery); if (!$updateStmt) { echo "Error preparing update query: " . $mysqli->error . "
"; continue; } $updateStmt->bind_param("i", $schedule['Schedule_ID']); if (!$updateStmt->execute()) { echo "Error executing update query: " . $updateStmt->error . "
"; $updateStmt->close(); continue; } $updateStmt->close(); // Update pointer for premium group. $ptrPremium = ($currentIndex + 1) % $cntPremium; $assigned = true; break; } } } // If not assigned by premium, try qualified teachers. if (!$assigned && $cntQualified > 0) { for ($i = 0; $i < $cntQualified; $i++) { $currentIndex = ($ptrQualified + $i) % $cntQualified; $teacher = $qualifiedTeachers[$currentIndex]; if ($canAssign($teacher, $schedule)) { $insertQuery = "INSERT INTO teacher_course_assignments (Teacher_ID, Course_ID, Group_ID, Program_ID, Schedule_ID, Time_Slot, Start_Date, End_Date, Assigned_At) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; $insertStmt = $mysqli->prepare($insertQuery); if (!$insertStmt) { echo "Error preparing insert query: " . $mysqli->error . "
"; continue; } $assignedAt = date('Y-m-d H:i:s'); $insertStmt->bind_param("iiiiissss", $teacher['Teacher_ID'], $schedule['Course_ID'], $schedule['Group_ID'], $schedule['Program_ID'], $schedule['Schedule_ID'], $schedule['Time_Slot'], $schedule['Start_Date'], $schedule['End_Date'], $assignedAt ); if (!$insertStmt->execute()) { echo "Error executing insert query: " . $insertStmt->error . "
"; $insertStmt->close(); continue; } $insertStmt->close(); $updateQuery = "UPDATE course_group_schedule SET Assigned = 1 WHERE Schedule_ID = ?"; $updateStmt = $mysqli->prepare($updateQuery); if (!$updateStmt) { echo "Error preparing update query: " . $mysqli->error . "
"; continue; } $updateStmt->bind_param("i", $schedule['Schedule_ID']); if (!$updateStmt->execute()) { echo "Error executing update query: " . $updateStmt->error . "
"; $updateStmt->close(); continue; } $updateStmt->close(); $ptrQualified = ($currentIndex + 1) % $cntQualified; $assigned = true; break; } } } // If still not assigned, try unqualified teachers. if (!$assigned && $cntUnqualified > 0) { for ($i = 0; $i < $cntUnqualified; $i++) { $currentIndex = ($ptrUnqualified + $i) % $cntUnqualified; $teacher = $unqualifiedTeachers[$currentIndex]; if ($canAssign($teacher, $schedule)) { $insertQuery = "INSERT INTO teacher_course_assignments (Teacher_ID, Course_ID, Group_ID, Program_ID, Schedule_ID, Time_Slot, Start_Date, End_Date, Assigned_At) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; $insertStmt = $mysqli->prepare($insertQuery); if (!$insertStmt) { echo "Error preparing insert query: " . $mysqli->error . "
"; continue; } $assignedAt = date('Y-m-d H:i:s'); $insertStmt->bind_param("iiiiissss", $teacher['Teacher_ID'], $schedule['Course_ID'], $schedule['Group_ID'], $schedule['Program_ID'], $schedule['Schedule_ID'], $schedule['Time_Slot'], $schedule['Start_Date'], $schedule['End_Date'], $assignedAt ); if (!$insertStmt->execute()) { echo "Error executing insert query: " . $insertStmt->error . "
"; $insertStmt->close(); continue; } $insertStmt->close(); $updateQuery = "UPDATE course_group_schedule SET Assigned = 1 WHERE Schedule_ID = ?"; $updateStmt = $mysqli->prepare($updateQuery); if (!$updateStmt) { echo "Error preparing update query: " . $mysqli->error . "
"; continue; } $updateStmt->bind_param("i", $schedule['Schedule_ID']); if (!$updateStmt->execute()) { echo "Error executing update query: " . $updateStmt->error . "
"; $updateStmt->close(); continue; } $updateStmt->close(); $ptrUnqualified = ($currentIndex + 1) % $cntUnqualified; $assigned = true; break; } } } } // Build the query to retrieve teacher assignments along with related details $query = " SELECT tca.Assignment_ID, tca.Teacher_ID, tca.Course_ID, tca.Group_ID, tca.Program_ID, tca.Schedule_ID, tca.Time_Slot, tca.Start_Date, tca.End_Date, tca.Assigned_At, tp.First_Name, tp.Last_Name, p.Program_Name, c.Course_Name, g.Group_Name FROM teacher_course_assignments tca JOIN teacher_profile tp ON tca.Teacher_ID = tp.Teacher_ID JOIN Programs p ON tca.Program_ID = p.Program_ID JOIN Courses c ON tca.Course_ID = c.Course_ID JOIN manager_group_name g ON tca.Group_ID = g.Group_ID ORDER BY tca.Assigned_At DESC "; // Execute the query $result = $mysqli->query($query); if (!$result) { die("Error executing query: " . $mysqli->error); } ?> fetch_assoc()) { ?>
Assignment ID Teacher Course Group Program Time Slot Start Date End Date Assigned At
Assignment ID Teacher Course Group Program Time Slot Start Date End Date Assigned At
query($query); if (!$result) { die("Error fetching teachers: " . $mysqli->error); } echo "

Teacher Assigned Hours

"; echo ""; echo ""; while ($teacher = $result->fetch_assoc()) { $teacher_id = $teacher['Teacher_ID']; $teacherName = $teacher['First_Name'] . " " . $teacher['Last_Name']; $load_hours = $teacher['Load_Hours']; // Query to sum Course_Time for all assignments of this teacher. // Assumes Course_Time is stored in a numeric format (e.g., integer or decimal) representing hours. $stmt = $mysqli->prepare(" SELECT IFNULL(SUM(c.Course_Time), 0) AS total_hours FROM teacher_course_assignments tca JOIN Courses c ON tca.Course_ID = c.Course_ID WHERE tca.Teacher_ID = ? "); if (!$stmt) { die("Error preparing sum query: " . $mysqli->error); } $stmt->bind_param("i", $teacher_id); if (!$stmt->execute()) { die("Error executing sum query: " . $stmt->error); } $result2 = $stmt->get_result(); $sum_row = $result2->fetch_assoc(); $total_hours = $sum_row['total_hours']; $stmt->close(); echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
Teacher Load Hours Total Assigned Hours
" . htmlspecialchars($teacherName) . "" . htmlspecialchars($load_hours) . "" . htmlspecialchars($total_hours) . "
"; //} else { //echo "Program ID and Group ID are required."; //} ?>