prepare($queryProgram);
if (!$stmtProgram) {
die("Error preparing program query: " . $mysqli->error);
}
$stmtProgram->bind_param("i", $Program_ID);
$stmtProgram->execute();
$resultProgram = $stmtProgram->get_result();
if ($resultProgram->num_rows > 0) {
$rowProgram = $resultProgram->fetch_assoc();
$Program_Name = $rowProgram['Program_Name'];
} else {
$Program_Name = "Unknown Program";
}
$stmtProgram->close();
$whereYear = "";
$params = array($Program_ID);
$types = "i";
if ($Group_Year !== "") {
$whereYear = " AND g.Group_Year = ?";
$params[] = $Group_Year;
$types .= "s";
}
$query = "SELECT g.Group_ID, g.Group_Name, g.Group_Year,
COUNT(DISTINCT c.Course_ID) AS total_courses,
COUNT(DISTINCT s.Course_ID) AS scheduled_courses
FROM manager_group_name g
JOIN Courses c ON c.Program_ID = g.Program_ID
LEFT JOIN course_group_schedule_main s ON g.Group_ID = s.Group_ID AND c.Course_ID = s.Course_ID AND g.Program_ID = s.Program_ID
WHERE g.Program_ID = ?$whereYear
GROUP BY g.Group_ID, g.Group_Name, g.Group_Year
HAVING COUNT(DISTINCT s.Course_ID) < COUNT(DISTINCT c.Course_ID)
ORDER BY g.Group_Name ASC";
$stmt = $mysqli->prepare($query);
if (!$stmt) {
die("Error preparing group query: " . $mysqli->error);
}
$stmt->bind_param($types, ...$params);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
$total = $row['total_courses'];
$scheduled = $row['scheduled_courses'];
if ($scheduled == 0) {
$status = "Not Scheduled";
} else {
$status = "Partially Scheduled";
}
echo "