57 lines
1.5 KiB
PHP
Executable File
57 lines
1.5 KiB
PHP
Executable File
<?php
|
|
require_once __DIR__ . '/../connect.php';
|
|
|
|
/*
|
|
المطلوب:
|
|
- جلب كل أرقام الهاتف من phone_verification
|
|
والتي غير موجودة في جدول driver
|
|
- فك تشفير الهاتف والإيميل
|
|
- فقط السجلات خلال آخر 5 أيام
|
|
*/
|
|
|
|
$sql = "
|
|
SELECT
|
|
pv.id,
|
|
pv.phone_number,
|
|
pv.created_at
|
|
FROM
|
|
phone_verification pv
|
|
LEFT JOIN driver d
|
|
ON pv.phone_number = d.phone
|
|
LEFT JOIN notesForDriverService n
|
|
ON pv.phone_number = n.phone
|
|
WHERE
|
|
d.phone IS NULL -- لم يقم بالتسجيل كسائق بعد
|
|
AND n.phone IS NULL -- لم يتم التواصل معه سابقاً (لا يوجد ملاحظات)
|
|
AND pv.created_at >= (NOW() - INTERVAL 6 DAY) -- تم الإنشاء خلال آخر 3 أيام
|
|
ORDER BY RAND()
|
|
LIMIT 1;
|
|
|
|
";
|
|
|
|
$stmt = $con->prepare($sql);
|
|
$stmt->execute();
|
|
|
|
if ($stmt->rowCount() > 0) {
|
|
|
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
// فك تشفير أرقام الهاتف والإيميل
|
|
foreach ($rows as &$r) {
|
|
|
|
if (isset($r['phone_number']) && $r['phone_number'] != null) {
|
|
$r['phone_number'] = $encryptionHelper->decryptData($r['phone_number']);
|
|
}
|
|
|
|
if (isset($r['email']) && $r['email'] != null) {
|
|
$r['email'] = $encryptionHelper->decryptData($r['email']);
|
|
}
|
|
}
|
|
|
|
jsonSuccess($rows);
|
|
|
|
} else {
|
|
jsonError("No phone numbers found in the last 5 days");
|
|
}
|
|
?>
|