Update: 2026-07-02 15:35:12

This commit is contained in:
Hamza-Ayed
2026-07-02 15:35:12 +03:00
parent 2adf195b36
commit 75e6fc42d7
17 changed files with 389 additions and 19 deletions
+17
View File
@@ -539,6 +539,23 @@ function sendFCM_Internal(
return $fcm->send($target, $title, $body, is_array($customData) ? $customData : [], $category, $tone);
}
// 🆕 دالة ذكية لإرسال وإرساء إشعارات السائقين في قاعدة البيانات (لضمان بقائها حتى لو لم يقرأها)
function sendAndSaveDriverNotification($con, $driver_id, $token, $title, $body, $customData = [], $category = 'System', $tone = 'ding') {
// 1. حفظ في قاعدة البيانات (لتظهر في صفحة الإشعارات داخل التطبيق)
try {
$stmt = $con->prepare("INSERT INTO notificationCaptain (driverID, title, body) VALUES (?, ?, ?)");
$stmt->execute([$driver_id, $title, $body]);
} catch (Exception $e) {
error_log("[sendAndSaveDriverNotification] DB Save Error: " . $e->getMessage());
}
// 2. إرسال Push Notification
if (!empty($token) && $token !== 'all') {
return sendFCM_Internal($token, $title, $body, $customData, $category, false, $tone);
}
return true;
}
function logAudit($con, $adminId, $action, $tableName = null, $recordId = null, $details = null) {