diff --git a/assets/pasted-20260505-042538-9c56fd70.png b/assets/pasted-20260505-042538-9c56fd70.png new file mode 100644 index 0000000..7cf65e5 Binary files /dev/null and b/assets/pasted-20260505-042538-9c56fd70.png differ diff --git a/eid_orders.php b/eid_orders.php index 502b547..bf3f342 100644 --- a/eid_orders.php +++ b/eid_orders.php @@ -441,9 +441,18 @@ require __DIR__ . '/includes/header.php'; - -
-
# ·
+ +
#
+
+ 0): ?> + : + + + +
inTransaction()) { + ensure_sales_table(); + } $seedStmt = $pdo->query("SELECT COALESCE(MAX(eid_serial_no), 0) + 1 FROM sales_orders WHERE order_type = 'eid'"); $seed = max(1, (int) $seedStmt->fetchColumn()); @@ -1918,7 +1920,9 @@ function reset_eid_serial_next(PDO $pdo, int $nextNumber = 1): void function next_eid_serial_no(PDO $pdo): int { - ensure_sales_table(); + if (!$pdo->inTransaction()) { + ensure_sales_table(); + } $settingKey = eid_serial_setting_key(); $seedValue = current_eid_serial_next($pdo); @@ -1952,7 +1956,10 @@ function create_sale(array $data): int ensure_sales_table(); $pdo = db(); - $pdo->beginTransaction(); + $ownsTransaction = !$pdo->inTransaction(); + if ($ownsTransaction) { + $pdo->beginTransaction(); + } try { $receiptNo = isset($data['receipt_no']) && trim((string) $data['receipt_no']) !== '' ? trim((string) $data['receipt_no']) @@ -2010,10 +2017,12 @@ function create_sale(array $data): int $saleId = (int) $pdo->lastInsertId(); sync_order_stock_reservation([], 'completed', $data['items'] ?? [], (string) ($data['status'] ?? 'completed')); - $pdo->commit(); + if ($ownsTransaction && $pdo->inTransaction()) { + $pdo->commit(); + } return $saleId; } catch (Throwable $e) { - if ($pdo->inTransaction()) { + if ($ownsTransaction && $pdo->inTransaction()) { $pdo->rollBack(); } throw $e; diff --git a/includes/footer_settings.php b/includes/footer_settings.php index e7f8b73..a1fcd5b 100644 --- a/includes/footer_settings.php +++ b/includes/footer_settings.php @@ -129,28 +129,29 @@
-
-
-

+
+
+
+
+

+
-
-
-
-
+
+
+
+
-
@@ -355,9 +356,18 @@ margin-top: -0.125rem; } + #settingsModal .settings-eid-header-row { + flex-wrap: nowrap; + } + #settingsModal .settings-eid-reset-box { - padding-top: 0.875rem; - padding-bottom: 0.875rem; + flex: 0 0 auto; + min-width: 290px; + align-self: flex-start; + } + + #settingsModal .settings-eid-inline-controls { + justify-content: space-between; } #settingsModal .settings-inline-save { @@ -380,6 +390,15 @@ width: 100%; justify-content: flex-end; } + + #settingsModal .settings-eid-header-row { + flex-wrap: wrap; + } + + #settingsModal .settings-eid-reset-box { + width: 100%; + min-width: 0; + } } #wablasSettingsModal { diff --git a/includes/sale_form.php b/includes/sale_form.php index 333df6b..d022d01 100644 --- a/includes/sale_form.php +++ b/includes/sale_form.php @@ -15,6 +15,7 @@ $savePrintLabel = $savePrintLabel ?? tr('حفظ مع الطباعة', 'Save with $error = ''; $paymentAmountInput = (string) ($_POST['payment_amount'] ?? ''); $catalog = catalog(); +$globalVatPercent = max(0, (float) get_setting('vat_percentage', 5)); $allowedBranches = get_user_branches($user); $deliveryOptions = eid_delivery_status_options(); $selectedDeliveryStatus = trim((string) ($_POST['delivery_status'] ?? ($isEidOrder ? 'pending' : ''))); @@ -110,8 +111,7 @@ $itemNote = trim((string) ($item['item_note'] ?? '')); : (float) $product['price']; $lineTotal = $price * $qty; - $vatPercent = (float) ($product['vat'] ?? 0); - // Assuming price is inclusive of VAT: + $vatPercent = $globalVatPercent; $itemVat = $lineTotal * ($vatPercent / 100); $totalVat += $itemVat; @@ -547,7 +547,7 @@ require __DIR__ . '/header.php'; 0.000
- + 0.000
@@ -879,7 +879,7 @@ function renderInvoice() { const item = invoiceItems[sku]; const lineTotal = item.qty * item.price; - const vatPercent = parseFloat(catalogData[sku].vat) || 0; + const vatPercent = ; const itemVat = lineTotal * (vatPercent / 100); totalVat += itemVat;