chore: استيراد أولي من سيرو (ecfe7568) — بلا أي تعديل
نسخة كاملة من مستودع سيرو عند ecfe7568 لتكون أساس تطبيق «انطلق». نُسخ المتعقَّب في git فقط (12,509 ملفاً / 302 م.ب) بـ git archive، لا `cp -r` — فاستُثنيت تلقائياً مخلفات البناء (build · node_modules · .dart_tool · .gradle · Pods ≈ 10.7 غ.ب) وكل ما يستثنيه .gitignore. هذا الكوميت **بلا أي تعديل عمداً** حتى يكون كل ما يليه فرقاً مقروءاً مقابل سيرو الأصلي. سيرو نفسه لم يُمسّ. ⚠️ لا يبني بعد: `.env` و`lib/env/env.g.dart` غير متعقَّبين في سيرو (وهذا صحيح — أسرار لكل مستأجر). كل تطبيق فلاتر هنا يحتاج .env خاصاً بانطلق ثم توليد env.g.dart عبر build_runner. لا تُنسخ أسرار سيرو. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// transit/trip/cancel.php — المشرف يلغي رحلة (قبل بدئها عادة — عطل مركبة، غياب سائق...)
|
||||
// POST: trip_id, [reason]
|
||||
|
||||
require_once __DIR__ . '/../../transit/connect_admin.php';
|
||||
|
||||
$tripId = filterRequest('trip_id', 'int');
|
||||
if (!$tripId) jsonError('trip_id is required', 400);
|
||||
|
||||
$st = $transit_con->prepare(
|
||||
"SELECT t.id, t.status, t.route_id, r.name_ar AS route_name
|
||||
FROM transit_trips t JOIN transit_routes r ON r.id = t.route_id
|
||||
WHERE t.id=? AND t.org_id=? LIMIT 1"
|
||||
);
|
||||
$st->execute([$tripId, $transit_org_id]);
|
||||
$trip = $st->fetch();
|
||||
if (!$trip) jsonError('Trip not found or access denied', 404);
|
||||
|
||||
if (in_array($trip['status'], ['completed', 'cancelled'])) {
|
||||
jsonError('Trip is already ' . $trip['status'], 409);
|
||||
}
|
||||
|
||||
$wasStarted = $trip['status'] === 'started';
|
||||
|
||||
$transit_con->prepare(
|
||||
"UPDATE transit_trips SET status='cancelled', delay_reason=?, updated_at=NOW() WHERE id=?"
|
||||
)->execute([filterRequest('reason'), $tripId]);
|
||||
|
||||
// إن كانت الرحلة قد بدأت فعلياً، أوقف بث الباص وحرّر ملكية الرحلة فوراً
|
||||
if ($wasStarted) {
|
||||
transitClearTripOwner($tripId);
|
||||
global $redisLocation;
|
||||
if ($redisLocation) $redisLocation->del("transit:trip:{$tripId}:pos");
|
||||
global $redis;
|
||||
if ($redis) $redis->del("transit:trip:{$tripId}:status");
|
||||
}
|
||||
|
||||
transitSendTopicNotification(
|
||||
transitRouteTopic((int)$trip['route_id']),
|
||||
'تم إلغاء الرحلة',
|
||||
'أُلغيت رحلة خط ' . $trip['route_name'] . ' اليوم.',
|
||||
['type' => 'transit_cancelled', 'trip_id' => (string)$tripId]
|
||||
);
|
||||
|
||||
appLog("[TRANSIT][TRIP][cancel] trip #{$tripId} org#{$transit_org_id} cancelled by admin #{$transit_admin_id}");
|
||||
|
||||
jsonSuccess(['trip_id' => $tripId, 'status' => 'cancelled'], 'Trip cancelled');
|
||||
Reference in New Issue
Block a user