Fix admin status handling for the current ride pipeline; extend console

The ride table holds two generations of status values: the legacy CamelCase
set ('Finished', 'CancelFromPassenger') and the lowercase set written by
backend/ride/rides/* today ('completed', 'cancelled_by_passenger'). Admin
queries only matched the legacy set, so on live data:

- get_rides_by_status.php returned nothing meaningful for every filter, and
  the "in progress" default masked it.
- dashbord.php reported total_driver_earnings as NULL, completed_rides as a
  fraction of the real count, and cancelled_rides as 0.
- driver_avg_duration averaged in negative durations, yielding "-00h 22m".

All three now match on LOWER(status) across both families.

Staff/pending.php ran with no authentication at all, exposing pending
admins' names and phone numbers to any caller; it now goes through
connect.php with a role check. It also returned HTTP 400 for everything when
the `users` table was absent — each source is queried independently and
reports its own availability.

Console:
- Render rides from either schema generation (price/date/time and
  start_location coordinates, or the older address/created_at columns).
- Null aggregates render as "—" rather than a measured 0.00.
- Add tariff/promo, WhatsApp send and encryption modules, all super-admin
  gated; pricing remains read-only.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Hamza-Ayed
2026-07-25 01:47:55 +03:00
co-authored by Claude Opus 5
parent 915a148ebf
commit 852c6ece5c
6 changed files with 204 additions and 59 deletions
+13 -5
View File
@@ -18,29 +18,37 @@ try {
$whereClause = ""; // لا يوجد شرط، اجلب الكل
break;
// ملاحظة: قاعدة البيانات تحتوي عائلتين من الحالات — القديمة بصيغة
// CamelCase ('Finished','Begin','CancelFromPassenger') والجديدة التي
// يكتبها خط الرحلات الحالي بأحرف صغيرة ('completed','accepted',
// 'cancelled_by_passenger'). المقارنة تتم بـ LOWER() لتغطية الاثنتين.
case 'Pending':
// الرحلات المعلقة/الجديدة: بانتظار سائق
$whereClause = "WHERE r.status IN ('New','nothing','waiting','wait')";
$whereClause = "WHERE LOWER(r.status) IN ('new','nothing','waiting','wait','pending','searching')";
break;
case 'Begin':
// الرحلات الجارية: من قبول السائق إلى بدء التشغيل
$whereClause = "WHERE r.status IN ('Apply','Applied','Arrived','arrived','Begin')";
$whereClause = "WHERE LOWER(r.status) IN ('apply','applied','arrived','begin','accepted','started','claimed')";
break;
case 'Completed':
// الرحلات المكتملة
$whereClause = "WHERE r.status = 'Finished'";
$whereClause = "WHERE LOWER(r.status) IN ('finished','completed')";
break;
case 'Canceled':
// جميع أنواع الإلغاء
$whereClause = "WHERE r.status IN ('Cancel','CancelFromDriver','CancelFromDriverAfterApply','CancelFromPassenger','TimeOut')";
$whereClause = "WHERE LOWER(r.status) IN (
'cancel','cancelfromdriver','cancelfromdriverafterapply','cancelfrompassenger',
'timeout','refused','cancelled_by_passenger','cancelled_by_driver',
'cancelled_no_driver_found'
)";
break;
default:
// في حال تم إرسال حالة محددة غير المذكورين
$whereClause = "WHERE r.status = ?";
$whereClause = "WHERE LOWER(r.status) = LOWER(?)";
$params[] = $statusFilter;
break;
}