<?php
    session_start();
    if(!isset($_SESSION["admin"]))
    {
        header("location:./index.php");
    }

    include "../backend/connection.php";
    $configure = new DefaultDatabase();
    $conf = $configure->connect();
    //fetch school detailss
    $schools = mysqli_query($conf,"SELECT COUNT(*) as total FROM schools");
    $school = mysqli_fetch_assoc($schools);

    //fetch participant details
    $pupils = mysqli_query($conf,"SELECT COUNT(*) as total FROM participants");
    $pupil = mysqli_fetch_assoc($pupils);

    //fetch school admin details
    $admins = mysqli_query($conf,"SELECT COUNT(*) as total FROM school_admin");
    $admin = mysqli_fetch_assoc($admins);

    //fetch adjudicators details
    $judges = mysqli_query($conf,"SELECT COUNT(*) as total FROM adjudicator");
    $judge = mysqli_fetch_assoc($judges);

    //fetch reports details
    $reports = mysqli_query($conf,"SELECT COUNT(*) as total FROM reports");
    $report = mysqli_fetch_assoc($reports);

    //fetch materials details
    $materials = mysqli_query($conf,"SELECT COUNT(*) as total FROM material");
    $material = mysqli_fetch_assoc($materials);
?>
<div class="dashboard-container">
    <h2>REGIONAL PERFOMANCE SUMMERY</h2>
    <div class="cards">
        <div class="card">
            <h3>TOTAL PARTICIPANTS</h3>
            <p id="participantsCount"><?php echo $pupil["total"] ?></p>
        </div>
        <div class="card">
            <h3>TOTAL SCHOOLS</h3>
            <p id="schoolsCount"><?php echo $school["total"] ?></p>
        </div>
        <div class="card">
            <h3>TOTAL SCHOOL ADMINS</h3>
            <p id="staffCount"><?php echo $admin["total"] ?></p>
        </div>
        <div class="card">
            <h3>TOTAL ADJUDICATORS</h3>
            <p id="districtsCount"><?php echo $judge["total"] ?></p>
        </div>
        <div class="card">
            <h3>TOTAL REPORTS</h3>
            <p id="categoriesCount"><?php echo $report["total"] ?></p>
        </div>
        <div class="card">
            <h3>TOTAL STUDY MATERIALS</h3>
            <p id="materialsCount"><?php echo $material["total"] ?></p>
        </div>
    </div>
</div>