<?php
require_once __DIR__ . '/../lib/core.php';
dc_require_login();

$counts = array();
foreach (array('projects' => 'door_cert_projects', 'categories' => 'door_cert_categories', 'standards' => 'door_cert_standards', 'doors' => 'door_cert_doors') as $key => $table) {
    $stmt = dc_db()->query('SELECT COUNT(*) FROM ' . $table);
    $counts[$key] = (int)$stmt->fetchColumn();
}

dc_admin_header('Door Certificate Dashboard');
?>
<div class="dc-card">
  <h2>Summary</h2>
  <table>
    <tr><th>Projects</th><td><?php echo $counts['projects']; ?></td></tr>
    <tr><th>Categories</th><td><?php echo $counts['categories']; ?></td></tr>
    <tr><th>Standards</th><td><?php echo $counts['standards']; ?></td></tr>
    <tr><th>Doors</th><td><?php echo $counts['doors']; ?></td></tr>
  </table>
  <div class="dc-actions">
    <a class="dc-btn" href="door-form.php">Add Door</a>
    <a class="dc-btn secondary" href="projects.php">Manage Projects</a>
    <a class="dc-btn secondary" href="categories.php">Manage Categories</a>
    <a class="dc-btn secondary" href="standards.php">Manage Standards</a>
  </div>
</div>
<?php dc_footer(); ?>
