<?php
require_once __DIR__ . '/../includes/bootstrap.php'; require_login();
$rows = [];
$stmt = db()->query("SELECT v.title, v.department, v.status, c.full_name, c.document_number, c.phone, a.stage, a.score, a.applied_at FROM recruitment_applications a JOIN recruitment_candidates c ON c.id=a.candidate_id JOIN recruitment_vacancies v ON v.id=a.vacancy_id ORDER BY a.id DESC");
foreach ($stmt as $r) { $rows[] = [$r['title'],$r['department'],$r['status'],$r['full_name'],$r['document_number'],$r['phone'],$r['stage'],$r['score'],$r['applied_at']]; }
download_xlsx('reclutamiento.xlsx', ['Vacante','Departamento','Estado vacante','Candidato','Cédula','Teléfono','Etapa','Puntaje','Fecha'], $rows);
