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

$phoneNumber = filterRequest("phone_number");

// تشفير الرقم قبل البحث
$phoneNumber_encrypted = $encryptionHelper->encryptData($phoneNumber);

try {
    // الاستعلام عن السائق حسب رقم الهاتف وحالة التحقق
    $stmt = $con->prepare("
        SELECT * FROM phone_verification 
        WHERE phone_number = ? AND is_verified = 1
    ");
    $stmt->execute([$phoneNumber_encrypted]);
    $driver = $stmt->fetch(PDO::FETCH_ASSOC);

    if ($driver) {
        jsonSuccess(null, "Phone number is verified.");
    } else {
        jsonError("Phone number is not verified or does not exist.");
    }

} catch (PDOException $e) {
    jsonError("Database error: " . $e->getMessage());
}