<?php include __DIR__ . '/../includes/header.php'; ?>
<div class="row g-3">
  <div class="col-lg-4"><div class="info-card h-100"><h5>Empleados</h5><p class="text-muted">Legajo base con salida CSV y XLSX.</p><div class="d-flex gap-2 flex-wrap"><a class="btn btn-outline-primary" href="<?= e(base_url('reports/export_employees.php')) ?>">CSV</a><a class="btn btn-primary" href="<?= e(base_url('reports/export_employees_xlsx.php')) ?>">XLSX</a></div></div></div>
  <div class="col-lg-4"><div class="info-card h-100"><h5>Asistencia</h5><p class="text-muted">Marcaciones y control diario en CSV.</p><a class="btn btn-outline-primary" href="<?= e(base_url('reports/export_attendance.php')) ?>">Exportar asistencia</a></div></div>
  <div class="col-lg-4"><div class="info-card h-100"><h5>Permisos y vacaciones</h5><p class="text-muted">Solicitudes con estado y saldo estimado en XLSX.</p><div class="d-flex gap-2 flex-wrap"><a class="btn btn-outline-primary" href="<?= e(base_url('reports/export_leaves.php')) ?>">CSV</a><a class="btn btn-primary" href="<?= e(base_url('reports/export_leaves_xlsx.php')) ?>">XLSX</a></div></div></div>
</div>
<div class="row g-3 mt-1">
  <div class="col-lg-4"><div class="info-card h-100"><h5>Nómina</h5><p class="text-muted">Exportación gerencial por período en XLSX.</p><a class="btn btn-primary" href="<?= e(base_url('reports/export_payroll_xlsx.php')) ?>">Exportar nómina XLSX</a></div></div>
  <div class="col-lg-4"><div class="info-card h-100"><h5>Reclutamiento</h5><p class="text-muted">Vacantes, candidatos y etapas del proceso.</p><a class="btn btn-primary" href="<?= e(base_url('reports/export_recruitment_xlsx.php')) ?>">Exportar reclutamiento</a></div></div>
  <div class="col-lg-4"><div class="info-card h-100"><h5>Resumen imprimible</h5><p class="text-muted">Períodos de nómina para guardar en PDF desde navegador.</p><a class="btn btn-outline-dark" href="#nomina">Ir al resumen</a></div></div>
</div>
<?php if (can_manage_payroll()): ?>
<div class="table-wrap mt-3" id="nomina"><h5 class="mb-3">Períodos de nómina para imprimir</h5><div class="table-responsive"><table class="table table-bordered table-hover"><thead><tr><th>Período</th><th>Estado</th><th>Total neto</th><th>Acción</th></tr></thead><tbody><?php foreach (db()->query("SELECT p.*, (SELECT COALESCE(SUM(net_pay),0) FROM payroll_items pi WHERE pi.period_id=p.id) total_net FROM payroll_periods p ORDER BY p.id DESC LIMIT 12") as $row): ?><tr><td><?= e(month_name_es($row['month']) . ' ' . $row['year']) ?></td><td><span class="badge text-bg-<?= e(status_badge_class($row['status'])) ?>"><?= e($row['status']) ?></span></td><td><?= money_gs($row['total_net']) ?></td><td><a class="btn btn-sm btn-outline-dark" target="_blank" href="<?= e(base_url('reports/payroll_summary.php?id=' . $row['id'])) ?>">Abrir resumen</a></td></tr><?php endforeach; ?></tbody></table></div></div>
<?php endif; ?>
<?php include __DIR__ . '/../includes/footer.php'; ?>