/home/techb158/workloadmatch.com/workloadmatch.com/Manager
Edit: /home/techb158/workloadmatch.com/workloadmatch.com/Manager/ajax_fetch_schedule.php (3760B)
prepare($query);
$stmt->bind_param("ii", $Program_ID, $Group_ID);
$stmt->execute();
$result = $stmt->get_result();
// Get group info
$queryw = "SELECT Group_ID, Group_Name FROM Manager_Group_Name WHERE Group_ID = ? AND Program_ID = ?";
$stmtw = $mysqli->prepare($queryw);
$stmtw->bind_param("ii", $Group_ID, $Program_ID);
$stmtw->execute();
$resultw = $stmtw->get_result();
$rowsw = $resultw->fetch_assoc();
$stmtw->close();
while ($row = $result->fetch_assoc()) {
// Get Course Name from Courses table.
$queryq = "SELECT Course_ID, Course_Name FROM Courses WHERE Course_ID = ? AND Program_ID = ? ORDER BY Course_ID";
$stmtq = $mysqli->prepare($queryq);
$stmtq->bind_param("ii", $row['Course_ID'], $Program_ID);
$stmtq->execute();
$resultsq = $stmtq->get_result();
$rowsq = $resultsq->fetch_assoc();
$stmtq->close();
// If the schedule is assigned, fetch teacher name from Teacher_Course_Assignments joined with Teacher_Profile.
$teacherName = "";
if ($row['Assigned']) {
$queryt = "SELECT tp.First_Name, tp.Last_Name
FROM Teacher_Course_Assignments tca
JOIN Teacher_Profile tp ON tca.Teacher_ID = tp.Teacher_ID
WHERE tca.Schedule_ID = ?";
$stmtt = $mysqli->prepare($queryt);
$stmtt->bind_param("i", $row['Schedule_ID']);
$stmtt->execute();
$resultt = $stmtt->get_result();
if ($resultt && $resultt->num_rows > 0) {
$rowt = $resultt->fetch_assoc();
$teacherName = $rowt['First_Name'] . " " . $rowt['Last_Name'];
}
$stmtt->close();
}
// Get real End Date from Schedule_Course_for_Group (if sessions are split)
$query_end = "SELECT MAX(End_Date) as Last_Session
FROM Schedule_Course_for_Group
WHERE Schedule_ID = ?";
$stmt_end = $mysqli->prepare($query_end);
$stmt_end->bind_param("i", $row['Schedule_ID']);
$stmt_end->execute();
$res_end = $stmt_end->get_result();
$lastSession = '';
if ($res_end && $res_end->num_rows > 0) {
$r_end = $res_end->fetch_assoc();
$lastSession = $r_end['Last_Session'];
}
$stmt_end->close();
echo "
|
" . htmlspecialchars($rowsw['Group_Name']) . " |
" . htmlspecialchars($teacherName) . " |
" . htmlspecialchars($rowsq['Course_Name']) . " |
" . htmlspecialchars($row['Time_Slot']) . " |
" . htmlspecialchars($row['Start_Date']) . " |
" . htmlspecialchars($lastSession ?: $row['End_Date']) . " |
" . ($row['Assigned'] ? "Yes" : "No") . " |
";
}
$stmt->close();
}
?>