<?php
// admin/get-courier.php
require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/../includes/functions.php';

if (!isAdmin()) {
    exit;
}

$id = intval($_GET['id'] ?? 0);
if ($id > 0) {
    try {
        $stmt = $pdo->prepare("SELECT * FROM couriers WHERE id = ?");
        $stmt->execute([$id]);
        $courier = $stmt->fetch();
        echo json_encode($courier);
    } catch (Exception $e) {
        echo json_encode(['error' => $e->getMessage()]);
    }
} else {
    echo json_encode(['error' => 'Invalid ID']);
}
?>