<?php
// =====================================================
// GET /get-all-lineman.php
// Response: { status, data: [ { id, name, phone, role, permissions } ] }
// =====================================================
require_once 'config.php';

$conn = getConnection();

$result = $conn->query("SELECT id, name, phone, role FROM line_man ORDER BY id DESC");

$data = [];
while ($row = $result->fetch_assoc()) {
    $data[] = [
        "id"          => (string)$row['id'],
        "name"        => $row['name'],
        "phone"       => $row['phone'],
        "role"        => $row['role'],
        "permissions" => ''
    ];
}

echo json_encode([
    "status" => "success",
    "data"   => $data
]);

$conn->close();
