/home/techb158/workloadmatch.com/workloadmatch.com/BackUp/Manager
Edit: /home/techb158/workloadmatch.com/workloadmatch.com/BackUp/Manager/dashboard.php (22507B)
prepare("SELECT COUNT(*) FROM teacher_profile WHERE Manager_ID = ?");
if (!$stmt) { die("Prepare failed (Total Teachers): " . $mysqli->error); }
$stmt->bind_param("s", $Manager_ID);
$stmt->execute();
$stmt->bind_result($totalTeachers);
$stmt->fetch();
$stmt->close();
// Total Groups
$stmt = $mysqli->prepare("SELECT COUNT(*) FROM manager_group_name WHERE Manager_ID = ?");
if (!$stmt) { die("Prepare failed (Total Groups): " . $mysqli->error); }
$stmt->bind_param("s", $Manager_ID);
$stmt->execute();
$stmt->bind_result($totalGroups);
$stmt->fetch();
$stmt->close();
// Total Courses (across all programs)
$stmt = $mysqli->prepare("SELECT COUNT(*) FROM Courses WHERE Program_ID IN (SELECT Program_ID FROM Programs)");
if (!$stmt) { die("Prepare failed (Total Courses): " . $mysqli->error); }
$stmt->execute();
$stmt->bind_result($totalCourses);
$stmt->fetch();
$stmt->close();
// Total Assignments
$stmt = $mysqli->prepare("SELECT COUNT(*) FROM teacher_course_assignments WHERE Teacher_ID IN (SELECT Teacher_ID FROM teacher_profile WHERE Manager_ID = ?)");
if (!$stmt) { die("Prepare failed (Total Assignments): " . $mysqli->error); }
$stmt->bind_param("s", $Manager_ID);
$stmt->execute();
$stmt->bind_result($totalAssignments);
$stmt->fetch();
$stmt->close();
// Unassigned Courses
$stmt = $mysqli->prepare("SELECT COUNT(*) FROM Courses WHERE Course_ID NOT IN (SELECT DISTINCT Course_ID FROM teacher_course_assignments)");
if (!$stmt) { die("Prepare failed (Unassigned Courses): " . $mysqli->error); }
$stmt->execute();
$stmt->bind_result($unassignedCourses);
$stmt->fetch();
$stmt->close();
// Teacher Utilization Rate
$stmt = $mysqli->prepare("SELECT COUNT(DISTINCT tp.Teacher_ID) FROM teacher_course_assignments tca JOIN teacher_profile tp ON tca.Teacher_ID = tp.Teacher_ID WHERE tp.Manager_ID = ?");
if (!$stmt) { die("Prepare failed (Assigned Teachers): " . $mysqli->error); }
$stmt->bind_param("s", $Manager_ID);
$stmt->execute();
$stmt->bind_result($assignedTeacherCount);
$stmt->fetch();
$stmt->close();
$stmt = $mysqli->prepare("SELECT COUNT(*) FROM teacher_profile WHERE Manager_ID = ?");
if (!$stmt) { die("Prepare failed (Total Teacher Count): " . $mysqli->error); }
$stmt->bind_param("s", $Manager_ID);
$stmt->execute();
$stmt->bind_result($totalTeacherCount);
$stmt->fetch();
$stmt->close();
$teacherUtilization = ($totalTeacherCount > 0) ? ($assignedTeacherCount / $totalTeacherCount) * 100 : 0;
// Most Requested Course (by teacher preference)
$stmt = $mysqli->prepare("SELECT C.Course_Name, COUNT(*) AS PreferenceCount
FROM Teacher_Course_Preferences tcp
JOIN Courses C ON tcp.Course_ID = C.Course_ID
WHERE C.Program_ID IN (SELECT Program_ID FROM Programs)
GROUP BY C.Course_ID
ORDER BY PreferenceCount DESC
LIMIT 1");
if (!$stmt) { die("Prepare failed (Most Requested Course): " . $mysqli->error); }
$stmt->execute();
$stmt->bind_result($topCourse, $preferenceCount);
$stmt->fetch();
$stmt->close();
// Unwanted Assignments (assignments where the teacher’s assigned time slot is NOT among their preferences)
$stmt = $mysqli->prepare("
SELECT COUNT(*)
FROM teacher_course_assignments tca
WHERE tca.Teacher_ID IN (SELECT Teacher_ID FROM teacher_profile WHERE Manager_ID = ?)
AND NOT EXISTS (
SELECT 1
FROM Teacher_Course_Preferences tcp
WHERE tcp.Teacher_ID = tca.Teacher_ID
AND tcp.Course_ID = tca.Course_ID
)
");
if (!$stmt) { die("Prepare failed (Unwanted Assignments): " . $mysqli->error); }
$stmt->bind_param("s", $Manager_ID);
$stmt->execute();
$stmt->bind_result($unwantedAssignments);
$stmt->fetch();
$stmt->close();
// Monthly assignments data for charts.
$json_data = array();
$queryMonthly = "
SELECT MONTH(Assigned_At) AS Month, COUNT(*) AS Count
FROM teacher_course_assignments
WHERE Teacher_ID IN (
SELECT Teacher_ID FROM teacher_profile WHERE Manager_ID = ?
)
GROUP BY MONTH(Assigned_At)
";
$stmt = $mysqli->prepare($queryMonthly);
if (!$stmt) { die("Prepare failed (Monthly Assignments): " . $mysqli->error); }
$stmt->bind_param("s", $Manager_ID);
$stmt->execute();
$resultMonthly = $stmt->get_result();
while ($row = $resultMonthly->fetch_assoc()) {
$json_data[] = array(
'label' => $row['Month'],
'item1' => $row['Count']
);
}
$stmt->close();
// (Optional Debug) Uncomment the next line to see the JSON data output:
// echo "
" . print_r($json_data, true) . "
";
?>
Course Management System | Dashboard
Notification! " . $mesg . "
";
}
include 'main-header-inc.php';
?>