<?php
// =============================================
// GOI Dashboard API - Driver List
// GET /api/drivers.php
//
// Header:
//   X-API-Key: GOI_DASHBOARD_2026_SECRET
// =============================================

require_once 'config.php';
validateApiKey();

$pdo = getDB();

// 활성 드라이버만 (dr_status = 'A')
$stmt = $pdo->query("
    SELECT
        dr_uid       AS uid,
        dr_firstname AS firstname,
        dr_lastname  AS lastname,
        dr_initial   AS initial,
        dr_type      AS type
    FROM tbl_driver
    WHERE dr_status = 'A'
    ORDER BY dr_initial ASC
");
$drivers = $stmt->fetchAll(PDO::FETCH_ASSOC);

jsonResponse([
    'success' => true,
    'count'   => count($drivers),
    'drivers' => $drivers
]);
