Files
intaleq/backend/ride/rides/updateStausFromSpeed.php
T
Hamza-AyedandClaude Opus 5 92dc6b3641 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>
2026-07-27 05:10:29 +03:00

79 lines
3.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
//updateStausFromSpeed.php";
require_once __DIR__ . '/../../connect.php';
$rideId = filterRequest("id");
$status = filterRequest("status");
$driverId = filterRequest("driver_id");
// لم نعد نحتاج لمتغير $rideTimeStart لربطه بالـ SQL، لكن نتركه لاستلام القيمة من الطلب
$rideTimeStart = filterRequest("rideTimeStart");
// 🚀 1. تسجيل بداية الطلب والبيانات المستلمة
error_log("🚀 [accept_ride.php] Request Started. RideID: $rideId | DriverID: $driverId | Status: $status");
if (!$rideId || !$driverId || !$status) {
error_log("❌ [accept_ride.php] Missing required parameters.");
jsonError("Missing required parameters.");
exit;
}
try {
// ---------------------------------------------------------
// 1. التحديث على سيرفر التتبع (صاحب القرار)
// ---------------------------------------------------------
error_log("🔄 [accept_ride.php] Attempting to update REMOTE Tracking DB for Ride ID: $rideId");
$stmtRideRemote = $con_ride->prepare("UPDATE `ride`
SET `status` = :status,
`driver_id` = :driverId,
`rideTimeStart` = NOW()
WHERE `id` = :id
AND `status` IN ('waiting', 'wait')
");
$stmtRideRemote->execute([
':status' => $status,
':driverId' => $driverId,
':id' => $rideId
]);
$count = $stmtRideRemote->rowCount();
error_log("ℹ️ [accept_ride.php] Remote DB Rows Affected: $count");
// نتحقق: هل نجح التحديث في سيرفر التتبع؟
if ($count > 0) {
// ---------------------------------------------------------
// 2. التحديث على السيرفر الرئيسي (تثبيت السجل فقط)
// ---------------------------------------------------------
error_log("🔄 [accept_ride.php] Remote success. Updating LOCAL Main DB...");
$sqlUpdate = "UPDATE `ride`
SET `driver_id` = :driverId,
`status` = :status,
`rideTimeStart` = NOW()
WHERE id = :rideId
AND `status` IN ('waiting', 'wait') ";
$stmtUpdate = $con->prepare($sqlUpdate);
$stmtUpdate->bindParam(":driverId", $driverId);
$stmtUpdate->bindParam(":status", $status);
$stmtUpdate->bindParam(":rideId", $rideId);
$stmtUpdate->execute();
error_log("✅ [accept_ride.php] Ride accepted and started successfully for Driver: $driverId");
jsonSuccess(null, "Ride accepted and started successfully at " . date('Y-m-d H:i:s'));
} else {
error_log("⚠️ [accept_ride.php] Failed to accept ride. It might be already taken, canceled, or invalid status.");
jsonError("Ride cannot be accepted (Already taken, Canceled, or Invalid Status).");
}
} catch (PDOException $e) {
error_log("❌ [accept_ride.php] Database Error: " . $e->getMessage());
jsonError("An internal error occurred. Please try again later.");
}
?>