Update: 2026-07-14 00:34:22
This commit is contained in:
@@ -9,7 +9,7 @@ $action = filterRequest('action');
|
||||
if (!$driverId) jsonError('driver_id is required', 400);
|
||||
if (!in_array($action, ['suspend', 'activate'])) jsonError('action must be suspend or activate', 400);
|
||||
|
||||
$chk = $transit_con->prepare("SELECT id, status FROM transit_drivers WHERE id=? AND org_id=? LIMIT 1");
|
||||
$chk = $transit_con->prepare("SELECT id, status, main_driver_id FROM transit_drivers WHERE id=? AND org_id=? LIMIT 1");
|
||||
$chk->execute([$driverId, $transit_org_id]);
|
||||
$driver = $chk->fetch();
|
||||
if (!$driver) jsonError('Driver not found or access denied', 404);
|
||||
@@ -22,6 +22,11 @@ if ($action === 'activate' && $driver['status'] !== 'suspended') {
|
||||
$newStatus = $action === 'suspend' ? 'suspended' : 'active';
|
||||
$transit_con->prepare("UPDATE transit_drivers SET status=? WHERE id=?")->execute([$newStatus, $driverId]);
|
||||
|
||||
// إبطال كاش السائق فوراً — عند التعليق يجب أن تُرفض رحلاته في الطلب التالي مباشرة
|
||||
if (!empty($driver['main_driver_id'])) {
|
||||
transitInvalidateDriverCache((string)$driver['main_driver_id']);
|
||||
}
|
||||
|
||||
appLog("[TRANSIT][DRIVER][suspend] driver #{$driverId} org#{$transit_org_id} → {$newStatus}");
|
||||
|
||||
jsonSuccess(['driver_id' => $driverId, 'status' => $newStatus]);
|
||||
|
||||
Reference in New Issue
Block a user