<?php
require_once __DIR__ . '/../includes/bootstrap.php'; require_login();
$rows = [];
$stmt = db()->query("SELECT e.full_name, e.document_number, d.name department, p.name position, e.hire_date, e.salary, e.email, e.phone, e.status FROM employees e LEFT JOIN departments d ON d.id=e.department_id LEFT JOIN positions p ON p.id=e.position_id ORDER BY e.full_name");
foreach ($stmt as $r) { $rows[] = [$r['full_name'],$r['document_number'],$r['department'],$r['position'],$r['hire_date'],$r['salary'],$r['email'],$r['phone'],$r['status']]; }
download_xlsx('empleados.xlsx', ['Nombre','Cédula','Departamento','Cargo','Ingreso','Salario','Email','Teléfono','Estado'], $rows);
