<?php
header('Content-Type: application/json');
require_once __DIR__ . '/../config/database.php';

$sql = "SELECT id AS __backendId, employee_no, full_name, department, position, created_at FROM personnel ORDER BY id DESC";
$result = $mysqli->query($sql);
$data = [];
if ($result) {
    while ($row = $result->fetch_assoc()) {
        $data[] = $row;
    }
}

echo json_encode($data);
?>
