<?php
// admin/dashboard.php
require_once '../includes/auth_check.php';
checkAccess('admin'); // Only admins can view this page
require_once '../config/database.php';

// Fetch quick stats
$student_count = $pdo->query("SELECT COUNT(*) FROM students")->fetchColumn();
$teacher_count = $pdo->query("SELECT COUNT(*) FROM users WHERE role = 'teacher'")->fetchColumn();
$class_count = $pdo->query("SELECT COUNT(*) FROM classes")->fetchColumn();
?>

<!DOCTYPE html>
<html>
<head>
    <title>Admin Dashboard</title>
    <link rel="stylesheet" href="../assets/css/style.css"> </head>
<body>
    <?php include '../includes/header.php'; ?>

    <h1>Welcome, <?php echo $_SESSION['name']; ?></h1>
    
    <div style="display: flex; gap: 20px;">
        <div style="padding: 20px; border: 1px solid #ccc;">
            <h3>Students</h3>
            <p><?php echo $student_count; ?></p>
        </div>
        <div style="padding: 20px; border: 1px solid #ccc;">
            <h3>Teachers</h3>
            <p><?php echo $teacher_count; ?></p>
        </div>
        <div style="padding: 20px; border: 1px solid #ccc;">
            <h3>Classes</h3>
            <p><?php echo $class_count; ?></p>
        </div>
    </div>

    <hr>
    <ul>
        <li><a href="academic/classes.php">Manage Classes</a></li>
        <li><a href="academic/subjects.php">Manage Subjects</a></li>
        <li><a href="users/teachers.php">Register Teachers</a></li>
        <li><a href="users/students.php">Register Students</a></li>
        <li><a href="pins/generate.php">Generate Result PINs</a></li>
    </ul>

    <?php include '../includes/footer.php'; ?>
</body>
</html>