<?php

require_once __DIR__ . '/includes/auth.php';
require_once __DIR__ . '/config/db.php';

include 'includes/header.php';
include 'includes/navbar.php';

$schools = mysqli_fetch_row(mysqli_query($conn,"SELECT COUNT(*) FROM schools"))[0];
$surveys = mysqli_fetch_row(mysqli_query($conn,"SELECT COUNT(*) FROM surveys"))[0];
$users    = mysqli_fetch_row(mysqli_query($conn,"SELECT COUNT(*) FROM users"))[0];
$today    = mysqli_fetch_row(mysqli_query($conn,"SELECT COUNT(*) FROM surveys WHERE DATE(survey_date)=CURDATE()"))[0];

?>

<main class="container mt-3">

    <div class="row g-3">

        <div class="col-lg-3 col-md-6">

            <div class="card shadow-sm border-0 text-center h-100">

                <div class="card-body py-3">

                    <i class="fa-solid fa-school fa-2x text-primary mb-2"></i>

                    <h6 class="text-muted mb-1">
                        Total Schools
                    </h6>

                    <h2 class="fw-bold text-primary">
                        <?= $schools ?>
                    </h2>

                </div>

            </div>

        </div>

        <div class="col-lg-3 col-md-6">

            <div class="card shadow-sm border-0 text-center h-100">

                <div class="card-body py-3">

                    <i class="fa-solid fa-file-lines fa-2x text-success mb-2"></i>

                    <h6 class="text-muted mb-1">
                        Total Surveys
                    </h6>

                    <h2 class="fw-bold text-success">
                        <?= $surveys ?>
                    </h2>

                </div>

            </div>

        </div>

        <div class="col-lg-3 col-md-6">

            <div class="card shadow-sm border-0 text-center h-100">

                <div class="card-body py-3">

                    <i class="fa-solid fa-calendar-day fa-2x text-warning mb-2"></i>

                    <h6 class="text-muted mb-1">
                        Today's Surveys
                    </h6>

                    <h2 class="fw-bold text-warning">
                        <?= $today ?>
                    </h2>

                </div>

            </div>

        </div>

        <div class="col-lg-3 col-md-6">

            <div class="card shadow-sm border-0 text-center h-100">

                <div class="card-body py-3">

                    <i class="fa-solid fa-users fa-2x text-danger mb-2"></i>

                    <h6 class="text-muted mb-1">
                        Total Users
                    </h6>

                    <h2 class="fw-bold text-danger">
                        <?= $users ?>
                    </h2>

                </div>

            </div>

        </div>

    </div>

</main>

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