From 8d3e63d1c7115d8f6a469b9e4690d3cbadfb77ab Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Sat, 25 Jul 2026 18:40:38 +0300 Subject: [PATCH] Update: 2026-07-25 18:40:38 --- backend/Admin/AdminRide/getRidesPerMonth.php | 7 +-- backend/Admin/driver/getBestDriver.php | 62 +++++++++---------- backend/Admin/employee/get.php | 9 +-- .../Admin/v2/quality/blacklist_manager.php | 1 - backend/Admin/v2/quality/driver_scorecard.php | 17 ++++- backend/auth/driver/driver_details.php | 2 +- backend/auth/driver/drivers_pending_list.php | 2 +- backend/serviceapp/getPackages.php | 8 +-- dashboard/siro-admin/js/app.js | 15 +++-- 9 files changed, 58 insertions(+), 65 deletions(-) diff --git a/backend/Admin/AdminRide/getRidesPerMonth.php b/backend/Admin/AdminRide/getRidesPerMonth.php index 7b8c523d..4c9fa32f 100644 --- a/backend/Admin/AdminRide/getRidesPerMonth.php +++ b/backend/Admin/AdminRide/getRidesPerMonth.php @@ -43,10 +43,5 @@ foreach ($dailyRides as &$row) { $row['current_month_rides_count'] = $monthRides['current_month_rides_count']; } -// Return result -if ($dailyRides) { - jsonSuccess($dailyRides); -} else { - jsonError("No records found"); -} +jsonSuccess($dailyRides ?: []); ?> \ No newline at end of file diff --git a/backend/Admin/driver/getBestDriver.php b/backend/Admin/driver/getBestDriver.php index 3aac1ff8..5535a422 100644 --- a/backend/Admin/driver/getBestDriver.php +++ b/backend/Admin/driver/getBestDriver.php @@ -3,46 +3,40 @@ require_once __DIR__ . '/../../connect.php'; $sql = "SELECT - COUNT(`car_locations`.driver_id) AS driver_count, - driver.id, - driver.phone, - driver.name_arabic, - MAX(dt.token) AS token -FROM - `car_locations` -LEFT JOIN driver ON driver.id = car_locations.driver_id -LEFT JOIN driverToken dt ON dt.captain_id = driver.id -WHERE - `car_locations`.created_at > TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY)) -GROUP BY - driver.id -ORDER BY - driver_count DESC -LIMIT 19; -"; + COUNT(r.id) AS driver_count, + d.id, + d.phone, + d.first_name, + d.last_name, + d.name_arabic +FROM driver d +LEFT JOIN ride r ON d.id = r.driver_id AND LOWER(r.status) IN ('finished','completed') +GROUP BY d.id, d.phone, d.first_name, d.last_name, d.name_arabic +ORDER BY driver_count DESC +LIMIT 20"; $stmt = $con->prepare($sql); $stmt->execute(); -if ($stmt->rowCount() > 0) { - $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); +$rows = $stmt->fetchAll(PDO::FETCH_ASSOC); - // فك التشفير للحقول الحساسة - foreach ($rows as &$row) { - if (!empty($row['phone'])) { - $row['phone'] = $encryptionHelper->decryptData($row['phone']); - } - if (!empty($row['name_arabic'])) { - $row['name_arabic'] = $encryptionHelper->decryptData($row['name_arabic']); - } - if (!empty($row['token'])) { - $row['token'] = $encryptionHelper->decryptData($row['token']); - } +// فك التشفير للحقول الحساسة +foreach ($rows as &$row) { + if (!empty($row['phone'])) { + $row['phone'] = $encryptionHelper->decryptData($row['phone']) ?: $row['phone']; + } + if (!empty($row['first_name'])) { + $row['first_name'] = $encryptionHelper->decryptData($row['first_name']) ?: $row['first_name']; + } + if (!empty($row['last_name'])) { + $row['last_name'] = $encryptionHelper->decryptData($row['last_name']) ?: $row['last_name']; + } + if (!empty($row['name_arabic'])) { + $row['name_arabic'] = $encryptionHelper->decryptData($row['name_arabic']) ?: $row['name_arabic']; } - - jsonSuccess($rows); -} else { - jsonError($message = "No recent driver location activity found"); } +unset($row); + +jsonSuccess($rows); ?> \ No newline at end of file diff --git a/backend/Admin/employee/get.php b/backend/Admin/employee/get.php index 0dd72e9c..0fe835b0 100644 --- a/backend/Admin/employee/get.php +++ b/backend/Admin/employee/get.php @@ -18,12 +18,5 @@ $stmt->execute(); // Fetch all records as an associative array $employee_data = $stmt->fetchAll(PDO::FETCH_ASSOC); -// Check if any records were retrieved -if ($employee_data) { - // If records were found, print the data as JSON - jsonSuccess($data = $employee_data); -} else { - // If no records were found, print a failure message - jsonError($message = "No employee records found"); -} +jsonSuccess($employee_data ?: []); ?> \ No newline at end of file diff --git a/backend/Admin/v2/quality/blacklist_manager.php b/backend/Admin/v2/quality/blacklist_manager.php index 6b4d706e..8509899b 100644 --- a/backend/Admin/v2/quality/blacklist_manager.php +++ b/backend/Admin/v2/quality/blacklist_manager.php @@ -2,7 +2,6 @@ // Admin/v2/quality/blacklist_manager.php require_once __DIR__ . '/../../../connect.php'; require_once __DIR__ . '/../../../encrypt_decrypt.php'; -require_once __DIR__ . '/../security/audit_logs_helper.php'; // إذا كان متاحاً، وإلا سننفذ الإدخال مباشرة if ($role !== 'admin' && $role !== 'super_admin') { jsonError("Unauthorized", 403); diff --git a/backend/Admin/v2/quality/driver_scorecard.php b/backend/Admin/v2/quality/driver_scorecard.php index 0a2b0312..d035d1a2 100644 --- a/backend/Admin/v2/quality/driver_scorecard.php +++ b/backend/Admin/v2/quality/driver_scorecard.php @@ -10,7 +10,22 @@ if ($role !== 'admin' && $role !== 'super_admin') { $driver_id = filterRequest('driver_id'); if (!$driver_id) { - jsonError("Missing driver_id", 400); + try { + $stmt = $con->prepare("SELECT id, first_name, last_name, phone, status FROM driver ORDER BY id DESC LIMIT 20"); + $stmt->execute(); + $drivers = $stmt->fetchAll(PDO::FETCH_ASSOC); + foreach ($drivers as &$d) { + if (!empty($d['first_name'])) $d['first_name'] = $encryptionHelper->decryptData($d['first_name']) ?: $d['first_name']; + if (!empty($d['last_name'])) $d['last_name'] = $encryptionHelper->decryptData($d['last_name']) ?: $d['last_name']; + if (!empty($d['phone'])) $d['phone'] = $encryptionHelper->decryptData($d['phone']) ?: $d['phone']; + } + unset($d); + jsonSuccess($drivers); + exit; + } catch (Throwable $e) { + jsonSuccess([]); + exit; + } } try { diff --git a/backend/auth/driver/driver_details.php b/backend/auth/driver/driver_details.php index dd172238..356c345a 100644 --- a/backend/auth/driver/driver_details.php +++ b/backend/auth/driver/driver_details.php @@ -1,5 +1,5 @@ prepare($sql); $stmt->execute(); $passenger_data = $stmt->fetchAll(PDO::FETCH_ASSOC); -if ($passenger_data) { - // Print the passenger data as JSON - jsonSuccess($data = $passenger_data); -} else { - // Print a failure message - jsonError($message = "No passenger data found"); -} +jsonSuccess($passenger_data ?: []); ?> \ No newline at end of file diff --git a/dashboard/siro-admin/js/app.js b/dashboard/siro-admin/js/app.js index ed810caf..7e2288a6 100644 --- a/dashboard/siro-admin/js/app.js +++ b/dashboard/siro-admin/js/app.js @@ -507,13 +507,10 @@ 'Contact': 'معلومات الاتصال', 'Click any row to open the full profile': 'اضغط على أي سطر لفتح الملف الشخصي الكامل', 'Search by passenger ID, phone or email': 'البحث برقم الراكب، الهاتف، أو البريد الإلكتروني', + 'Search by captain ID, phone or email': 'البحث برقم الكابتن، الهاتف، أو البريد الإلكتروني', 'Search rides by phone number': 'البحث في الرحلات برقم الهاتف', 'Yes': 'نعم', 'No': 'لا', - 'Click any row to open the full profile': 'اضغط على أي سطر لفتح الملف الشخصي الكامل', - 'Search rides by phone number': 'بحث في الرحلات برقم الهاتف', - 'Search by captain ID, phone or email': 'بحث بمعرّف الكابتن أو البريد الإلكتروني أو الهاتف', - 'Search by passenger ID, phone or email': 'بحث بمعرّف الراكب أو البريد الإلكتروني أو الهاتف', // API error messages ' — the endpoint returned HTML, check the API base URL': ' — الـ API أرجع HTML، تحقق من عنوان الخادم', 'Session rejected by the server': 'الخادم رفض الجلسة', @@ -3389,12 +3386,18 @@ } function humanize(key) { - const s = String(key) + if (!key) return ''; + const rawKey = String(key).trim(); + if (lang === 'ar' && AR[rawKey]) return AR[rawKey]; + + const s = rawKey .replace(/[_-]+/g, ' ') .replace(/([a-z])([A-Z])/g, '$1 $2') .replace(/\b\w/g, (m) => m.toUpperCase()) .trim(); - return t(key) || t(s) || s; + + if (lang === 'ar' && AR[s]) return AR[s]; + return s; } function msgNode(text) {