diff --git a/eid_orders.php b/eid_orders.php index eb8eab0..4ce013b 100644 --- a/eid_orders.php +++ b/eid_orders.php @@ -3,6 +3,38 @@ require_once __DIR__ . '/includes/app.php'; $user = require_permission('sales', 'show'); ensure_sales_table(); +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'mark_as_paid') { + $id = (int)$_POST['id']; + try { + $sale = fetch_sale($id); + if ($sale && $sale['order_type'] === 'eid') { + $summary = sale_payment_summary($sale); + if ($summary['due_amount'] > 0.0005) { + apply_sale_payment($id, $summary['due_amount'], false); + set_flash('success', tr('تم تحويل حالة الدفع إلى مدفوع بنجاح.', 'Payment status updated to paid successfully.')); + } else { + set_flash('info', tr('الفاتورة مدفوعة مسبقاً.', 'Invoice is already paid.')); + } + } + } catch (Exception $e) { + set_flash('danger', tr('تعذر تحديث حالة الدفع.', 'Failed to update payment status.')); + } + redirect_to('eid_orders.php', $_GET); +} + +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'update_delivery_status') { + $id = (int)$_POST['id']; + $newStatus = trim((string)($_POST['status'] ?? 'pending')); + $allowedStatuses = array_keys(eid_delivery_status_options()); + if (in_array($newStatus, $allowedStatuses, true)) { + $stmt = db()->prepare("UPDATE sales_orders SET delivery_status = :status WHERE id = :id AND order_type = 'eid'"); + $stmt->execute([':status' => $newStatus, ':id' => $id]); + set_flash('success', tr('تم تحديث حالة التجهيز بنجاح.', 'Prep status updated successfully.')); + } + redirect_to('eid_orders.php', $_GET); +} + + $activeNav = 'eid_orders'; $pageTitle = tr('طلبات العيد', 'Eid Orders'); $metaDescription = tr('متابعة طلبات العيد مع الفلاتر والمدى الزمني.', 'Track Eid orders with filters and date range.'); @@ -250,7 +282,7 @@ require __DIR__ . '/includes/header.php'; $branchLabel): ?> - + @@ -280,25 +312,25 @@ require __DIR__ . '/includes/header.php';
| = h(tr('الهاتف', 'Phone')) ?> | = h(tr('تسليم', 'Delivery')) ?> @@ -377,8 +410,34 @@ require __DIR__ . '/includes/header.php'; |
= h($order['receipt_no']) ?>
|
+
- = h((string) ($order['customer_name'] ?: tr('عميل نقدي', 'Walk-in customer'))) ?>
+ = h($rawCustomerName) ?>
+ |
+ + |
= h(date('Y-m-d', strtotime((string) $effectiveDelivery))) ?>
@@ -396,7 +455,40 @@ require __DIR__ . '/includes/header.php';
|
= h(number_format((float) ($order['total_amount'] ?? 0), 3)) ?> |
-
+
+ = h(payment_status_label((string) ($order['payment_status'] ?? 'paid'))) ?>
+
+ |
+
+ + diff --git a/patch.py b/patch.py deleted file mode 100644 index 8562f0f..0000000 --- a/patch.py +++ /dev/null @@ -1,57 +0,0 @@ -import sys - -with open()eid_orders.php', 'r') as f: - content = f.read() - -search1 = """ |
|---|---|---|---|---|---|---|---|---|
|
- = h($order['receipt_no']) ?>
- |
-
- = h((string) ($order['customer_name'] ?: tr('عميل نقدن', 'Walk-in customer'))) ?>
- | """
-
-replace1 = """
- |||||||
|
- = h($order['receipt_no']) ?>
- |
-
- = h(${cName}) ?>
-
- = h($cPhone) ?>
-
- | """
-
-search2 = """ = h(number_format((float) ($order['total_amount'] ?? 0), 3)) ?> | -
- """
-
-replace2 = """ = h(number_format((float) ($order['total_amount'] ?? 0), 3)) ?> |
-
- = h(payment_status_label((string) ($order['payment_status'] ?? 'paid'))) ?>
- |
-
- | """
-
-content = content.replace(search1, replace1)
-content = content.replace(search2, replace2)
-
-with open()eid_orders.php', 'w') as f:
- f.write(content)
diff --git a/patch_boxes.py b/patch_boxes.py
new file mode 100644
index 0000000..6f03c1b
--- /dev/null
+++ b/patch_boxes.py
@@ -0,0 +1,18 @@
+import re
+
+with open('eid_orders.php', 'r') as f:
+ content = f.read()
+
+colors = ['bg-primary-subtle', 'bg-info-subtle', 'bg-warning-subtle', 'bg-success-subtle']
+parts = content.split(' ')
+
+if len(parts) == 5:
+ new_content = parts[0]
+ for i in range(4):
+ new_content += f' ' + parts[i+1]
+
+ with open('eid_orders.php', 'w') as f:
+ f.write(new_content)
+ print("Patched successfully")
+else:
+ print(f"Found {len(parts)} parts, expected 5.")
|