<?php
header("Content-Type: application/json");
header("Access-Control-Allow-Origin: *");

include '../../config.php';


// Fetch only names and phone
$sql = "SELECT `id`, `firstname`, `lastname`, `phone` FROM `users`";
$result = $conn->query($sql);

$staff = [];
if ($result) {
    while ($row = $result->fetch_assoc()) {
        $fullName = trim($row['firstname'] . ' ' . $row['lastname']);
        $staff[] = [
            'id'        => (string)$row['id'],
            'full_name' => $fullName,
            'phone'     => $row['phone'],
        ];
    }
}

echo json_encode($staff);
$conn->close();
