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

$captain_id = filterRequest("captain_id");

$sql = "SELECT * FROM `driverToken` WHERE `captain_id` = :captain_id";
$stmt = $con->prepare($sql);
$stmt->bindParam(':captain_id', $captain_id, PDO::PARAM_STR);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);

if ($data) {
    // فك تشفير token فقط
    foreach ($data as &$item) {
        $item['token'] = $encryptionHelper->decryptData($item['token']);
        // fingerPrint يبقى كما هو
    }

    echo json_encode([
        'status' => 'success',
        'data' => $data
    ]);
} else {
    jsonError("No driver token found");
}
?>