<?php
require_once 'includes/session.php';

if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
    header("Location: login.php");
    exit;
}

require 'includes/db_connect.php';
include 'includes/header.php';
include 'includes/sidebar.php';
?>

<h3>Welcome to Street Naming & House Numbering Project</h3>

<div class="row mt-4">
    <div class="col-md-4">
        <div class="card text-center shadow">
            <div class="card-body">
                <h5 class="card-title text-orange">Total Mails</h5>
                <p class="card-text fs-4">
                    <?php
                    $result = $conn->query("SELECT COUNT(*) as total FROM associations");
                    echo $result->fetch_assoc()['total'];
                    ?>
                </p>
            </div>
        </div>
    </div>

    <div class="col-md-4">
        <div class="card text-center shadow">
            <div class="card-body">
                <h5 class="card-title text-orange">Permanent Staff</h5>
                <p class="card-text fs-4">
                    <?php
                    $result = $conn->query("SELECT COUNT(*) as total FROM associations");
                    echo $result->fetch_assoc()['total'];
                    ?>
                </p>
            </div>
        </div>
    </div>

    <div class="col-md-4">
        <div class="card text-center shadow">
            <div class="card-body">
                <h5 class="card-title text-orange">Political Appointees</h5>
                <p class="card-text fs-4">
                    <?php
                    $result = $conn->query("SELECT COUNT(*) as total FROM associations");
                    echo $result->fetch_assoc()['total'];
                    ?>
                </p>
            </div>
        </div>
    </div>
</div>

<div class="row mt-4">
    <div class="col-md-4">
        <div class="card text-center shadow">
            <div class="card-body">
                <h5 class="card-title text-orange">Total Staff</h5>
                <p class="card-text fs-4">
                    <?php
                    $result = $conn->query("SELECT COUNT(*) as total FROM associations");
                    echo $result->fetch_assoc()['total'];
                    ?>
                </p>
            </div>
        </div>
    </div>

    <div class="col-md-4">
        <div class="card text-center shadow">
            <div class="card-body">
                <h5 class="card-title text-orange">Queries Issued</h5>
                <p class="card-text fs-4">
                    <?php
                    $result = $conn->query("SELECT COUNT(*) as total FROM associations");
                    echo $result->fetch_assoc()['total'];
                    ?>
                </p>
            </div>
        </div>
    </div>
</div>

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