<?php

require '../config.php';
session_start();
session_write_close();

$totalCases = $conn->query("
SELECT COUNT(*) total
FROM disciplinary_cases
")->fetch_assoc();

$openCases = $conn->query("
SELECT COUNT(*) total
FROM disciplinary_cases
WHERE status='Open'
")->fetch_assoc();

$suspensions = $conn->query("
SELECT COUNT(*) total
FROM disciplinary_cases
WHERE case_type='Suspension'
")->fetch_assoc();

$warnings = $conn->query("
SELECT COUNT(*) total
FROM disciplinary_cases
WHERE case_type='Warning'
")->fetch_assoc();
?>

<!DOCTYPE html>
<html>
<head>
<title>Disciplinary Dashboard</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="flex bg-gray-100">

<?php include '../sidebar.php'; ?>

<div class="flex-1 p-8" id="main-content">

<h1 class="text-3xl font-bold mb-8">
Disciplinary Dashboard
</h1>

<div class="grid md:grid-cols-4 gap-6">

<div class="bg-white p-6 rounded-xl shadow">
<p>Total Cases</p>
<h2 class="text-4xl font-bold text-blue-700">
<?= $totalCases['total'] ?>
</h2>
</div>

<div class="bg-white p-6 rounded-xl shadow">
<p>Open Cases</p>
<h2 class="text-4xl font-bold text-red-700">
<?= $openCases['total'] ?>
</h2>
</div>

<div class="bg-white p-6 rounded-xl shadow">
<p>Warnings</p>
<h2 class="text-4xl font-bold text-yellow-700">
<?= $warnings['total'] ?>
</h2>
</div>

<div class="bg-white p-6 rounded-xl shadow">
<p>Suspensions</p>
<h2 class="text-4xl font-bold text-purple-700">
<?= $suspensions['total'] ?>
</h2>
</div>

</div>

</div>

</body>
</html>