Update: 2026-07-13 18:23:52
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// transit/trip/stop_passengers.php — جلب قائمة ركاب المحطة (للسائق)
|
||||
// POST: stop_id
|
||||
|
||||
require_once __DIR__ . '/../../transit/connect_app.php';
|
||||
|
||||
$stopId = (int)filterRequest('stop_id');
|
||||
if (!$stopId) jsonError('Missing stop_id', 400);
|
||||
|
||||
// 1. تحقق من السائق ورحلته
|
||||
$stTrip = $transit_con->prepare(
|
||||
"SELECT id, org_id FROM transit_trips WHERE driver_id=? AND status='started' LIMIT 1"
|
||||
);
|
||||
$stTrip->execute([$transit_driver_id]);
|
||||
$trip = $stTrip->fetch();
|
||||
|
||||
if (!$trip) {
|
||||
jsonError('لا توجد رحلة نشطة حالياً', 403);
|
||||
}
|
||||
|
||||
$tripId = (int)$trip['id'];
|
||||
$orgId = (int)$trip['org_id'];
|
||||
|
||||
// 2. جلب جميع الركاب المشتركين الذين محطتهم المفضلة هي هذه المحطة (أو جميع ركاب الخط إن لم يكن هناك تخصيص)
|
||||
// سنكتفي بجلب المخصصين لهذه المحطة + عرض حالة صعودهم
|
||||
$stPass = $transit_con->prepare(
|
||||
"SELECT e.passenger_id, e.student_id, e.member_name AS name,
|
||||
(SELECT COUNT(id) FROM transit_boardings b
|
||||
WHERE b.trip_id = ? AND b.enrollment_id = e.id) AS is_boarded
|
||||
FROM transit_enrollments e
|
||||
WHERE e.org_id = ? AND e.status = 'active' AND e.preferred_stop_id = ?"
|
||||
);
|
||||
$stPass->execute([$tripId, $orgId, $stopId]);
|
||||
$passengers = $stPass->fetchAll();
|
||||
|
||||
// تحويل 0/1 إلى true/false
|
||||
foreach ($passengers as &$p) {
|
||||
$p['is_boarded'] = (bool)$p['is_boarded'];
|
||||
}
|
||||
unset($p);
|
||||
|
||||
jsonSuccess($passengers);
|
||||
Reference in New Issue
Block a user