<?php

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

$sql = "SELECT id as driverId, first_name, last_name,phone as phone_number, status FROM driver WHERE status != 'actives'";


$stmt = $con->prepare($sql);
$stmt->execute();

if ($stmt->rowCount() > 0) {
    $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);

    // فك تشفير أرقام الهواتف فقط للإخراج
   foreach ($rows as &$row) {
        if (!empty($row['phone_number'])) {
            $row['phone_number'] = $encryptionHelper->decryptData($row['phone_number']);
        }
        if (!empty($row['first_name'])) {
            $row['first_name'] = $encryptionHelper->decryptData($row['first_name']);
        }
       if (isset($row['last_name'])) {
        $row['last_name'] = $encryptionHelper->decryptData($row['last_name']);
    }
    }
 

    jsonSuccess($rows);
} else {
    jsonError("No Phone verified yet found");
}
?>