/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_lockup_courses.php (14587B)
 'Unauthorized']); exit; } $Manager_ID = get_effective_id(); $action = $_POST['action'] ?? ''; // Handle assignment action if ($action === 'assign') { $Teacher_ID = (int)($_POST['Teacher_ID'] ?? 0); $Schedule_ID = (int)($_POST['Schedule_ID'] ?? 0); if (!$Teacher_ID || !$Schedule_ID) { echo json_encode(['error' => 'Missing parameters']); exit; } // Get schedule details $stmt = $mysqli->prepare(" SELECT s.Group_ID, s.Course_ID, s.Program_ID, c.Course_Name, s.Time_Slot, s.Start_Date, s.End_Date, s.Course_Hours, g.Group_Name FROM course_group_schedule_main s JOIN Courses c ON s.Course_ID = c.Course_ID JOIN manager_group_name g ON s.Group_ID = g.Group_ID WHERE s.Schedule_ID = ? "); $stmt->bind_param("i", $Schedule_ID); $stmt->execute(); $schedule = $stmt->get_result()->fetch_assoc(); $stmt->close(); if (!$schedule) { echo json_encode(['error' => 'Schedule not found']); exit; } // Check teacher's time slot availability (same as fetch_teacher_conflicts_only.php: skip if no slots) $stmt = $mysqli->prepare("SELECT Time_Slot FROM teacher_profile WHERE Teacher_ID = ?"); $stmt->bind_param("i", $Teacher_ID); $stmt->execute(); $stmt->bind_result($teacherTS); $stmt->fetch(); $stmt->close(); $teacherTS = trim($teacherTS ?? ''); if ($teacherTS !== '') { $teacherSlotList = array_map('trim', explode(',', $teacherTS)); if (!in_array($schedule['Time_Slot'], $teacherSlotList)) { echo json_encode(['error' => 'Teacher is not available during this course period.']); exit; } } // Check if teacher prefers this course (same as fetch_teacher_conflicts_only.php: Course_ID only) $stmt = $mysqli->prepare("SELECT COUNT(*) FROM teacher_course_preferences WHERE Teacher_ID = ? AND Course_ID = ?"); $stmt->bind_param("ii", $Teacher_ID, $schedule['Course_ID']); $stmt->execute(); $stmt->bind_result($prefCount); $stmt->fetch(); $stmt->close(); if ($prefCount == 0) { echo json_encode(['error' => 'This course period does not match the teacher\'s preferred time slot.']); exit; } // Check for scheduling conflict (allow same course/group/program for AM/PM slots) $stmt = $mysqli->prepare("SELECT COUNT(*) FROM teacher_course_assignments WHERE Teacher_ID = ? AND (? <= End_Date AND ? >= Start_Date) AND NOT (Course_ID = ? AND Group_ID = ? AND Program_ID = ?)"); $stmt->bind_param("issiii", $Teacher_ID, $schedule['End_Date'], $schedule['Start_Date'], $schedule['Course_ID'], $schedule['Group_ID'], $schedule['Program_ID']); $stmt->execute(); $stmt->bind_result($conflictCount); $stmt->fetch(); $stmt->close(); if ($conflictCount > 0) { echo json_encode(['error' => 'Teacher already has another course assigned during this time slot.']); exit; } // Check if teacher is unavailable during this period $stmt = $mysqli->prepare("SELECT COUNT(*) FROM teacher_unavailability WHERE Teacher_ID = ? AND status = 'confirmed' AND Unavailable_From <= ? AND Unavailable_To >= ?"); $stmt->bind_param("iss", $Teacher_ID, $schedule['End_Date'], $schedule['Start_Date']); $stmt->execute(); $stmt->bind_result($unavailCount); $stmt->fetch(); $stmt->close(); if ($unavailCount > 0) { echo json_encode(['error' => 'Teacher is not available during this course period.']); exit; } // Check if already assigned to this schedule $stmt = $mysqli->prepare("SELECT COUNT(*) FROM teacher_course_assignments WHERE Schedule_ID = ? AND Teacher_ID = ?"); $stmt->bind_param("ii", $Schedule_ID, $Teacher_ID); $stmt->execute(); $stmt->bind_result($alreadyAssigned); $stmt->fetch(); $stmt->close(); if ($alreadyAssigned > 0) { echo json_encode(['error' => 'This course is already assigned to this teacher.']); exit; } // Insert assignment $stmt = $mysqli->prepare("INSERT INTO teacher_course_assignments (Teacher_ID, Course_ID, Group_ID, Program_ID, Schedule_ID, Time_Slot, Start_Date, End_Date, Assigned_At) VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW())"); $stmt->bind_param("iiiiisss", $Teacher_ID, $schedule['Course_ID'], $schedule['Group_ID'], $schedule['Program_ID'], $Schedule_ID, $schedule['Time_Slot'], $schedule['Start_Date'], $schedule['End_Date']); if ($stmt->execute()) { // Update course_group_schedule_main $stmt1 = $mysqli->prepare("UPDATE course_group_schedule_main SET Assigned = 1 WHERE Schedule_ID = ?"); $stmt1->bind_param("i", $Schedule_ID); $stmt1->execute(); $stmt1->close(); // Update schedule_course_for_group $stmt2 = $mysqli->prepare("UPDATE schedule_course_for_group SET Assigned = 1 WHERE Schedule_ID = ?"); $stmt2->bind_param("i", $Schedule_ID); $stmt2->execute(); $stmt2->close(); echo json_encode(['status' => 'success', 'message' => 'Course assigned successfully.']); } else { echo json_encode(['error' => 'Failed to assign: ' . $stmt->error]); } $stmt->close(); exit; } // Handle unassign action if ($action === 'unassign') { $Teacher_ID = (int)($_POST['Teacher_ID'] ?? 0); $Schedule_ID = (int)($_POST['Schedule_ID'] ?? 0); if (!$Teacher_ID || !$Schedule_ID) { echo json_encode(['error' => 'Missing parameters']); exit; } $stmt = $mysqli->prepare("DELETE FROM teacher_course_assignments WHERE Schedule_ID = ? AND Teacher_ID = ?"); $stmt->bind_param("ii", $Schedule_ID, $Teacher_ID); if ($stmt->execute()) { $stmt1 = $mysqli->prepare("UPDATE course_group_schedule_main SET Assigned = 0 WHERE Schedule_ID = ?"); $stmt1->bind_param("i", $Schedule_ID); $stmt1->execute(); $stmt1->close(); $stmt2 = $mysqli->prepare("UPDATE schedule_course_for_group SET Assigned = 0 WHERE Schedule_ID = ?"); $stmt2->bind_param("i", $Schedule_ID); $stmt2->execute(); $stmt2->close(); echo json_encode(['status' => 'success', 'message' => 'Course unassigned successfully.']); } else { echo json_encode(['error' => 'Failed to unassign: ' . $stmt->error]); } $stmt->close(); exit; } // Debug: return all unassigned schedules if ($action === 'debug_all') { $courses = []; $stmt = $mysqli->prepare("SELECT s.Schedule_ID, c.Course_ID, c.Course_Name, s.Time_Slot, s.Start_Date, s.End_Date, COALESCE(g.Group_Name, 'MISSING_GROUP') AS Group_Name, s.Course_Hours, s.Group_ID, s.Program_ID FROM course_group_schedule_main s JOIN Courses c ON s.Course_ID = c.Course_ID LEFT JOIN manager_group_name g ON s.Group_ID = g.Group_ID WHERE s.Assigned = 0 ORDER BY s.Start_Date ASC"); $stmt->execute(); $resultAll = $stmt->get_result(); while ($row = $resultAll->fetch_assoc()) { $courses[] = $row; } $stmt->close(); echo json_encode(['debug_count' => count($courses), 'courses' => $courses]); exit; } // Load matching courses $Teacher_ID = (int)($_POST['Teacher_ID'] ?? 0); $semesterYear = (int)($_POST['semester_year'] ?? 0); if (!$Teacher_ID || !$semesterYear) { echo json_encode(['error' => 'Missing parameters', 'courses' => []]); exit; } // Semester dates $augustFirst = new DateTime("$semesterYear-08-01"); $dayOfWeek = (int)$augustFirst->format('N'); $daysUntilMonday = ($dayOfWeek === 1) ? 0 : (8 - $dayOfWeek) % 7; $semesterStart = clone $augustFirst; $semesterStart->modify("+$daysUntilMonday days"); $semesterEnd = new DateTime(($semesterYear + 1) . '-06-30'); $semStartStr = $semesterStart->format('Y-m-d'); $semEndStr = $semesterEnd->format('Y-m-d'); // Get teacher's load $stmt = $mysqli->prepare("SELECT Load_Hours FROM teacher_profile WHERE Teacher_ID = ?"); $stmt->bind_param("i", $Teacher_ID); $stmt->execute(); $stmt->bind_result($loadHours); $stmt->fetch(); $stmt->close(); // Get current assigned hours for this teacher (current semester only) $stmt = $mysqli->prepare(" SELECT IFNULL(SUM(uni.Course_Hours), 0) AS AssignedHours FROM ( SELECT tca.Teacher_ID, cgs.Program_ID, cgs.Group_ID, cgs.Course_ID, MAX(cgs.Course_Hours) AS Course_Hours FROM teacher_course_assignments tca JOIN course_group_schedule_main cgs ON tca.Schedule_ID = cgs.Schedule_ID WHERE tca.Teacher_ID = ? AND cgs.Start_Date >= ? AND cgs.End_Date <= ? GROUP BY tca.Teacher_ID, cgs.Program_ID, cgs.Group_ID, cgs.Course_ID ) AS uni "); $stmt->bind_param("iss", $Teacher_ID, $semStartStr, $semEndStr); $stmt->execute(); $stmt->bind_result($currentHours); $stmt->fetch(); $stmt->close(); // Get teacher's available Time_Slot $stmt = $mysqli->prepare("SELECT Time_Slot FROM teacher_profile WHERE Teacher_ID = ?"); $stmt->bind_param("i", $Teacher_ID); $stmt->execute(); $stmt->bind_result($teacherTimeSlot); $stmt->fetch(); $stmt->close(); if ($teacherTimeSlot === null || trim($teacherTimeSlot) === '') { $teacherTimeSlot = ''; } // Pre-fetch teacher's preferred Course_IDs (matching fetch_teacher_conflicts_only.php: Course_ID only, no Program_ID) $preferredCourseIDs = []; $stmt = $mysqli->prepare("SELECT DISTINCT Course_ID FROM teacher_course_preferences WHERE Teacher_ID = ?"); $stmt->bind_param("i", $Teacher_ID); $stmt->execute(); $resultPref = $stmt->get_result(); while ($rowPref = $resultPref->fetch_assoc()) { $preferredCourseIDs[] = $rowPref['Course_ID']; } $stmt->close(); // Pre-fetch ALL teacher's existing assignments for conflict checking (no date filter, matching fetch_teacher_conflicts_only.php) $existingAssignments = []; $stmt = $mysqli->prepare("SELECT Schedule_ID, Time_Slot, Start_Date, End_Date FROM teacher_course_assignments WHERE Teacher_ID = ?"); $stmt->bind_param("i", $Teacher_ID); $stmt->execute(); $resultEA = $stmt->get_result(); while ($rowEA = $resultEA->fetch_assoc()) { $existingAssignments[] = $rowEA; } $stmt->close(); // Pre-fetch teacher's unavailability periods $unavailPeriods = []; $stmt = $mysqli->prepare("SELECT Unavailable_From, Unavailable_To FROM teacher_unavailability WHERE Teacher_ID = ? AND status = 'confirmed'"); $stmt->bind_param("i", $Teacher_ID); $stmt->execute(); $resultUA = $stmt->get_result(); while ($rowUA = $resultUA->fetch_assoc()) { $unavailPeriods[] = $rowUA; } $stmt->close(); // Get all courses: unassigned schedules + schedules already assigned to this teacher $courses = []; $stmt = $mysqli->prepare(" SELECT s.Schedule_ID, c.Course_ID, c.Course_Name, s.Time_Slot, s.Start_Date, s.End_Date, g.Group_Name, p.Program_Name, s.Course_Hours, s.Group_ID, s.Program_ID FROM course_group_schedule_main s JOIN Courses c ON s.Course_ID = c.Course_ID LEFT JOIN manager_group_name g ON s.Group_ID = g.Group_ID LEFT JOIN Programs p ON s.Program_ID = p.Program_ID WHERE s.Assigned = 0 OR s.Schedule_ID IN (SELECT Schedule_ID FROM teacher_course_assignments WHERE Teacher_ID = ?) ORDER BY s.Start_Date ASC "); $stmt->bind_param("i", $Teacher_ID); $stmt->execute(); $resultAll = $stmt->get_result(); $teacherSlotList = array_map('trim', explode(',', $teacherTimeSlot)); $debug_skipped = ['pref' => [], 'timeslot' => [], 'conflict' => [], 'unavail' => []]; $debug_included = []; while ($row = $resultAll->fetch_assoc()) { $scheduleID = (int)$row['Schedule_ID']; $courseID = (int)$row['Course_ID']; $cname = $row['Course_Name'] . ' (#' . $courseID . ')'; // Determine if THIS teacher is already assigned to this schedule $is_assigned = 0; foreach ($existingAssignments as $ea) { if ((int)$ea['Schedule_ID'] === $scheduleID) { $is_assigned = 1; break; } } // Already assigned courses: always show with Unassign (skip validation) if ($is_assigned == 1) { $row['is_assigned'] = 1; $row['Current_Load'] = (int)$currentHours; $row['Load_Hours'] = (int)$loadHours; $row['valid'] = true; $row['message'] = 'Already assigned'; $courses[] = $row; continue; } // For new assignments: run validation matching fetch_teacher_conflicts_only.php // Check 1: Teacher preference (same as fetch_teacher_conflicts_only.php: Course_ID only) if (!in_array($courseID, $preferredCourseIDs)) { $debug_skipped['pref'][] = $cname; continue; } // Check 2: Time slot match (same as fetch_teacher_conflicts_only.php: skip if teacher has no slots) if ($teacherTimeSlot !== '') { if (!in_array($row['Time_Slot'], $teacherSlotList)) { $debug_skipped['timeslot'][] = $cname; continue; } } // Check 3: Conflict with existing assignments (any time slot, overlapping dates) $hasConflict = false; foreach ($existingAssignments as $ea) { if ($row['Start_Date'] <= $ea['End_Date'] && $row['End_Date'] >= $ea['Start_Date']) { $hasConflict = true; break; } } if ($hasConflict) { $debug_skipped['conflict'][] = $cname; continue; } // Check 4: Teacher unavailability (matching fetch_teacher_conflicts_only.php) $isUnavailable = false; foreach ($unavailPeriods as $ua) { if ($row['Start_Date'] <= $ua['Unavailable_To'] && $row['End_Date'] >= $ua['Unavailable_From']) { $isUnavailable = true; break; } } if ($isUnavailable) { $debug_skipped['unavail'][] = $cname; continue; } // Passed all checks $debug_included[] = $cname; $row['is_assigned'] = 0; $row['Current_Load'] = (int)$currentHours; $row['Load_Hours'] = (int)$loadHours; $row['valid'] = true; $row['message'] = 'Teacher is available and can be assigned to this course period.'; $courses[] = $row; } $stmt->close(); echo json_encode([ 'courses' => $courses, '_debug' => [ 'pref_skipped' => $debug_skipped['pref'], 'timeslot_skipped' => $debug_skipped['timeslot'], 'conflict_skipped' => $debug_skipped['conflict'], 'unavail_skipped' => $debug_skipped['unavail'], 'included' => $debug_included ], '_pref_count' => count($preferredCourseIDs), '_total_sql' => $resultAll->num_rows ], JSON_UNESCAPED_UNICODE);