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

    include "../backend/connection.php";
    $configure = new DefaultDatabase();
    $conf = $configure->connect();
    //fetch school detailss
    $details = mysqli_query($conf,"SELECT * FROM school_admin WHERE username = '".$_SESSION["school_admin"]."'");
    $det = mysqli_fetch_array($details);
    //fetch statistics
    $reports = mysqli_query($conf,"SELECT COUNT(*) AS reports FROM reports WHERE school = '".$det["school"]."'");
    $rep = mysqli_fetch_array($reports);

    $material = mysqli_query($conf, "SELECT COUNT(*) AS material FROM material WHERE posted_by = '".$det["school"]."'");
    $mat = mysqli_fetch_array($material);

    $pupils = mysqli_query($conf, "SELECT COUNT(*) AS pupils FROM participants WHERE school = '".$det["school"]."'");
    $pup = mysqli_fetch_array($pupils)

?>
<div class="dashboard-container">
    <h2>SCHOOL PERFOMANCE SUMMERY</h2>
    <div class="cards">
        <div class="card">
            <h3>PARTICIPANTS</h3>
            <p id="participantsCount"><?php echo $pup["pupils"] ?></p>
        </div>
        <div class="card">
            <h3>REPORTS</h3>
            <p id="reportCount"><?php echo $rep["reports"] ?></p>
        </div>
        <div class="card">
            <h3>JETS MATERIAL</h3>
            <p id="materialcount"><?php echo $mat["material"] ?></p>
        </div>
    </div>
</div>