Update: 2026-06-18 16:46:30

This commit is contained in:
Hamza-Ayed
2026-06-18 16:46:30 +03:00
parent 8b52d2f115
commit f13faa8c31
12 changed files with 693 additions and 169 deletions

View File

@@ -16,6 +16,7 @@ try {
$driverID = filterRequest("driverID");
$user_phone = filterRequest("user_phone");
$phone = filterRequest("phone");
$amount_raw = filterRequest("amount");
// تسجيل البيانات بعد الفلترة
@@ -46,10 +47,11 @@ try {
// --- 4a. تحديث الفاتورة المعلقة الحالية ---
// error_log("[CreateInvoice] Found existing pending invoice (ID: {$existing['id']}). Updating it.");
$sql_update = "UPDATE invoices_sms SET invoice_number = :invoice_number, amount = :amount, created_at = NOW() WHERE id = :id";
$sql_update = "UPDATE invoices_sms SET invoice_number = :invoice_number, phone = :phone, amount = :amount, created_at = NOW() WHERE id = :id";
$stmt_update = $con->prepare($sql_update);
$stmt_update->execute([
':invoice_number' => $new_invoice_number,
':phone' => $phone ?: null,
':amount' => $amount,
':id' => $existing['id']
]);
@@ -65,11 +67,12 @@ try {
// --- 4b. إنشاء فاتورة جديدة ---
// error_log("[CreateInvoice] No pending invoice found. Creating a new one.");
$sql_insert = "INSERT INTO invoices_sms (invoice_number, driverID, user_phone, amount, status) VALUES (:invoice_number, :driverID, :user_phone, :amount, 'pending')";
$sql_insert = "INSERT INTO invoices_sms (invoice_number, driverID, phone, user_phone, amount, status) VALUES (:invoice_number, :driverID, :phone, :user_phone, :amount, 'pending')";
$stmt_insert = $con->prepare($sql_insert);
$ok = $stmt_insert->execute([
':invoice_number' => $new_invoice_number,
':driverID' => $driverID,
':phone' => $phone ?: null,
':user_phone' => $user_phone,
':amount' => $amount
]);