<?php
require_once __DIR__ . '/../../connect.php';

$order_id = filterRequest("order_id");

$sql = "SELECT `id`, `driver_id`, `order_id`, `created_at`, `status` FROM `driver_orders` WHERE `order_id` = :order_id";

$stmt = $con->prepare($sql);
$stmt->bindParam(":order_id", $order_id, PDO::PARAM_STR);
$stmt->execute();

$row = $stmt->fetch(PDO::FETCH_ASSOC);

if ($row) {
    echo json_encode([
        "status" => "success",
        "data" => $row
    ]);
} else {
    echo json_encode([
        "status" => "failure",
        "message" => "No driver order data found for the specified order_id"
    ]);
}
?>