diff --git a/eid_orders.php b/eid_orders.php index 76fc09f..4d7029b 100644 --- a/eid_orders.php +++ b/eid_orders.php @@ -157,7 +157,14 @@ try { ? ', sale_date DESC' : ', COALESCE(delivery_date, DATE(sale_date)) ASC, sale_date DESC'; - $sql = 'SELECT * FROM sales_orders' . $where . ' ORDER BY ' . $primarySort . $secondarySort . ' LIMIT :limit OFFSET :offset'; + $sql = "SELECT sales_orders.*, ( + SELECT COUNT(*) + FROM sales_orders AS seq + WHERE seq.order_type = sales_orders.order_type + AND seq.sale_mode = sales_orders.sale_mode + AND seq.id <= sales_orders.id + ) AS mode_serial_no + FROM sales_orders" . $where . ' ORDER BY ' . $primarySort . $secondarySort . ' LIMIT :limit OFFSET :offset'; $stmt = db()->prepare($sql); foreach ($params as $key => $value) { $stmt->bindValue($key, $value); @@ -408,7 +415,13 @@ require __DIR__ . '/includes/header.php'; -
+ +
+
# ·
$saleId]); + if ($submitAction === 'save') { + if ($isEidOrder) { + redirect_to('eid_sale.php'); + } + if ($saleMode === 'normal') { + redirect_to('normal_sale.php'); + } + redirect_to('pos.php'); + } + + $redirectParams = ['id' => $saleId, 'print' => 1]; + redirect_to('sale.php', $redirectParams); } } } @@ -482,9 +500,15 @@ require __DIR__ . '/header.php'; - +
+ + +
+
diff --git a/patch.php b/patch.php new file mode 100644 index 0000000..e69de29 diff --git a/pos.php b/pos.php index ccefa77..03aa5bd 100644 --- a/pos.php +++ b/pos.php @@ -6,6 +6,10 @@ $pageTitle = tr('نقاط البيع', 'Smart POS'); $activeNav = 'pos'; $error = ''; $paymentAmountInput = (string) ($_POST['payment_amount'] ?? ''); +$submitAction = trim((string) ($_POST['submit_action'] ?? 'save_print')); +if (!in_array($submitAction, ['save', 'save_print'], true)) { + $submitAction = 'save_print'; +} $catalog = catalog(); $allowedBranches = get_user_branches($user); @@ -102,7 +106,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { wablas_notify_sale_invoice($saleId); set_flash('success', tr('تم حفظ عملية POS بنجاح.', 'POS sale saved successfully.')); - redirect_to('print_receipt.php', ['id' => $saleId]); + if ($submitAction === 'save') { + redirect_to('pos.php'); + } + redirect_to('print_receipt.php', ['id' => $saleId, 'print' => 1]); } } } @@ -594,6 +601,7 @@ require __DIR__ . '/includes/header.php'; + @@ -612,17 +620,28 @@ require __DIR__ . '/includes/header.php';
+
+ +
+ + + + + +
+
+
- - - -
@@ -973,10 +992,18 @@ function openPaymentModal() { paidField.value = total.toFixed(3); paidField.dataset.manual = '0'; } + const saveActionPrint = document.getElementById('saveActionPrint'); + if (saveActionPrint) { + saveActionPrint.checked = true; + } updateModalDueHint(); paymentModalObj.show(); } +function getSelectedSubmitAction() { + return document.getElementById('saveActionOnly')?.checked ? 'save' : 'save_print'; +} + function submitSale(method) { const branch = document.getElementById('posBranch').value || ''; const customer = document.getElementById('posCustomer').value; @@ -1014,6 +1041,7 @@ function submitSale(method) { document.getElementById('inputCustomer').value = customer; document.getElementById('inputPayment').value = method; document.getElementById('inputPaymentAmount').value = paidAmount.toFixed(3); + document.getElementById('inputSubmitAction').value = getSelectedSubmitAction(); document.getElementById('inputCart').value = JSON.stringify(itemsArr); document.getElementById('checkoutForm').submit(); diff --git a/print_receipt.php b/print_receipt.php index ec4e59a..d0c8944 100644 --- a/print_receipt.php +++ b/print_receipt.php @@ -2,6 +2,7 @@ require_once __DIR__ . '/includes/app.php'; $user = require_permission('sales', 'show'); $id = (int) ($_GET['id'] ?? 0); +$autoPrint = isset($_GET['print']) && $_GET['print'] === '1'; $sale = null; $dbError = null; if ($id > 0) { @@ -295,14 +296,16 @@ $registerNo = 'REG-01'; + + \ No newline at end of file diff --git a/sale.php b/sale.php index 7e11052..dbf1e20 100644 --- a/sale.php +++ b/sale.php @@ -15,6 +15,7 @@ if ($id > 0) { } $paymentSummary = $sale ? sale_payment_summary($sale) : ['paid_amount' => 0, 'due_amount' => 0, 'payment_status' => 'paid']; $isEidSale = $sale && (($sale['order_type'] ?? 'standard') === 'eid'); +$autoPrint = isset($_GET['print']) && $_GET['print'] === '1'; // Company Info for Invoice $companyName = current_lang() === 'ar' ? get_setting('company_name_ar', 'حلوى الريامي') : get_setting('company_name_en', 'Al Riyami Sweets'); @@ -490,4 +491,14 @@ require __DIR__ . '/includes/header.php'; - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/shop.php b/shop.php index 50703d4..2e2f33c 100644 --- a/shop.php +++ b/shop.php @@ -46,7 +46,7 @@ foreach ($items as $item) { } -body { background-color: #f8f9fa; } +body { background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%); background-attachment: fixed; min-height: 100vh; } /* Hide scrollbar for category filter */ .category-filter-container::-webkit-scrollbar { @@ -88,9 +88,18 @@ body { background-color: #f8f9fa; }
-
-

-

+
+ + Logo + +
+ +
+ +
+

+

+