<?php
require_once __DIR__ . '/../../config/auth.php';

$resumen = [
    'Colaboradores activos' => $conn->query("SELECT COUNT(*) total FROM colaboradores WHERE estado='Activo'")->fetch_assoc()['total'],
    'Departamentos' => $conn->query("SELECT COUNT(*) total FROM departamentos WHERE activo=1")->fetch_assoc()['total'],
    'Ausencias pendientes' => $conn->query("SELECT COUNT(*) total FROM ausencias WHERE estado='Pendiente'")->fetch_assoc()['total'],
    'Planillas de Salarios pendientes' => $conn->query("SELECT COUNT(*) total FROM nominas WHERE estado IN ('Abierta','Procesado')")->fetch_assoc()['total'],
    'Documentos por vencer (30 días)' => $conn->query("SELECT COUNT(*) total FROM documentos_rrhh WHERE fecha_vencimiento BETWEEN CURDATE() AND DATE_ADD(CURDATE(),INTERVAL 30 DAY)")->fetch_assoc()['total'],
    'Capacitaciones planificadas' => $conn->query("SELECT COUNT(*) total FROM capacitaciones WHERE estado='Planificada'")->fetch_assoc()['total'],
];

include __DIR__ . '/../../includes/header.php';
include __DIR__ . '/../../includes/sidebar.php';
?>
<main class="main">
  <?php include __DIR__ . '/../../includes/topbar.php'; ?>
  <div class="content">
    <h3 class="page-title mb-1"><i class="fa fa-chart-pie me-2"></i>Reportes</h3>
    <p class="text-muted mb-4">Indicadores operativos del sistema de Recursos Humanos.</p>
    <div class="row g-3">
      <?php foreach ($resumen as $nombre => $total): ?>
        <div class="col-md-6 col-xl-4">
          <div class="kpi h-100">
            <div class="label"><?= e($nombre) ?></div>
            <div class="value"><?= e(numero_py($total)) ?></div>
          </div>
        </div>
      <?php endforeach; ?>
    </div>
  </div>
</main>
<?php include __DIR__ . '/../../includes/footer.php'; ?>
