<?php
include("../includes/db_connection.php");
include("../includes/auth.php");

// Counts
$total_associates = $conn->query("SELECT COUNT(*) as total FROM 
associates")->fetch_assoc()['total'];
$total_clients = $conn->query("SELECT COUNT(*) as total FROM 
clients")->fetch_assoc()['total'];
$total_certificates = $conn->query("SELECT COUNT(*) as total FROM 
certificates")->fetch_assoc()['total'];

$active = $conn->query("SELECT COUNT(*) as total FROM certificates WHERE 
status='active'")->fetch_assoc()['total'];
$suspended = $conn->query("SELECT COUNT(*) as total FROM certificates WHERE 
status='suspended'")->fetch_assoc()['total'];
$withdrawn = $conn->query("SELECT COUNT(*) as total FROM certificates WHERE 
status='withdrawn'")->fetch_assoc()['total'];
?>

<?php include("partials/header.php"); ?>

<div class="container py-4">
<div class="row g-4">

<div class="col-md-4 col-12">
<div class="card text-white bg-primary p-3 shadow">
<h5>Total Associates</h5>
<h3><?= $total_associates ?></h3>
</div>
</div>

<div class="col-md-4 col-12">
<div class="card text-white bg-success p-3 shadow">
<h5>Total Clients</h5>
<h3><?= $total_clients ?></h3>
</div>
</div>

<div class="col-md-4 col-12">
<div class="card text-white bg-dark p-3 shadow">
<h5>Total Certificates</h5>
<h3><?= $total_certificates ?></h3>
</div>
</div>

<div class="col-md-4 col-12">
<div class="card text-white bg-info p-3 shadow">
<h5>Active Certificates</h5>
<h3><?= $active ?></h3>
</div>
</div>

<div class="col-md-4 col-12">
<div class="card text-white bg-warning p-3 shadow">
<h5>Suspended Certificates</h5>
<h3><?= $suspended ?></h3>
</div>
</div>

<div class="col-md-4 col-12">
<div class="card text-white bg-danger p-3 shadow">
<h5>Withdrawn Certificates</h5>
<h3><?= $withdrawn ?></h3>
</div>
</div>

</div>
</div>

<?php include("partials/footer.php"); ?>