From af4b79251bab1d6db6074af7503739c85169f874 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 18 Feb 2026 14:12:04 +0000 Subject: [PATCH] customer display --- customer-display.php | 271 +++++++++++++++++++++++++++++++++++++++++++ index.php | 41 +++++++ post_debug.log | 2 + 3 files changed, 314 insertions(+) create mode 100644 customer-display.php diff --git a/customer-display.php b/customer-display.php new file mode 100644 index 0000000..d9580e8 --- /dev/null +++ b/customer-display.php @@ -0,0 +1,271 @@ + + + + + + Customer Display + + + + + + +
+ +
+ Welcome +
+
+ + + +
+
+ +
+

Welcome

+

Next customer, please.

+
+ + + + diff --git a/index.php b/index.php index dadc300..adee7c4 100644 --- a/index.php +++ b/index.php @@ -2868,6 +2868,7 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
Cart
+ @@ -2965,6 +2966,39 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; } echo json_encode($custData); ?>, + broadcast() { + try { + const subtotal = this.items.reduce((sum, item) => sum + (parseFloat(item.price) * item.qty), 0); + let discountAmount = 0; + if (this.discount) { + discountAmount = this.discount.type === 'percentage' ? subtotal * (parseFloat(this.discount.value) / 100) : parseFloat(this.discount.value); + } + const redeemSwitch = document.getElementById('redeemLoyalty'); + const redeemRate = (this.loyaltySettings && this.loyaltySettings.redeemPointsPerUnit) ? this.loyaltySettings.redeemPointsPerUnit : 100; + let loyaltyRedeemed = (redeemSwitch && redeemSwitch.checked) ? Math.min(Math.max(0, subtotal - discountAmount), (parseFloat(this.customerPoints) || 0) / redeemRate) : 0; + const total = Math.max(0, subtotal - discountAmount - loyaltyRedeemed); + + const customerSelect = document.getElementById('posCustomer'); + const customerName = customerSelect ? customerSelect.options[customerSelect.selectedIndex].text : ''; + + const payload = { + items: this.items.map(i => ({ + name: (document.documentElement.lang === 'ar' ? (i.nameAr || i.nameEn) : (i.nameEn || i.nameAr)), + price: parseFloat(i.price), + qty: parseFloat(i.qty) + })), + subtotal: subtotal, + discount: discountAmount, + loyalty: loyaltyRedeemed, + total: total, + customerName: customerName, + theme: document.body.className, + timestamp: Date.now() + }; + + localStorage.setItem('pos_cart_update', JSON.stringify(payload)); + } catch (e) { console.error('Broadcast error', e); } + }, add(product) { if (!this.items) this.items = []; const allowZeroStock = (typeof companySettings !== 'undefined' && String(companySettings.allow_zero_stock_sell) === '1'); @@ -3216,6 +3250,7 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; if (subtotalEl) subtotalEl.innerText = 'OMR 0.000'; if (totalEl) totalEl.innerText = 'OMR 0.000'; if (checkoutBtn) checkoutBtn.disabled = true; + this.broadcast(); return; } @@ -3285,6 +3320,7 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; const checkoutBtn = document.getElementById('checkoutBtn'); if (checkoutBtn) checkoutBtn.disabled = false; + this.broadcast(); } catch (e) { console.error('Cart render error:', e); } @@ -3692,6 +3728,11 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; placeholder: 'Select Customer', dropdownParent: $('#posPaymentModal') }); + + // Initial broadcast to sync customer display (theme & empty state) + if (typeof cart !== 'undefined' && cart.broadcast) { + cart.broadcast(); + } }); diff --git a/post_debug.log b/post_debug.log index 2b80d3d..76a0eda 100644 --- a/post_debug.log +++ b/post_debug.log @@ -17,3 +17,5 @@ 2026-02-18 13:05:39 - POST: {"settings":{"company_name":"Bahjet Al-Safa Trading","company_phone":"99359472","company_email":"aalabry@gmail.com","vat_number":"OM25418","company_address":"AL Hamra\r\nOman","allow_zero_stock_sell":"0","loyalty_enabled":"0","loyalty_points_per_unit":"1","loyalty_redeem_points_per_unit":"100"},"update_settings":""} 2026-02-18 13:06:21 - POST: {"settings":{"company_name":"Bahjet Al-Safa Trading","company_phone":"99359472","company_email":"aalabry@gmail.com","vat_number":"OM25418","company_address":"AL Hamra\r\nOman","allow_zero_stock_sell":"1","loyalty_enabled":"0","loyalty_points_per_unit":"1","loyalty_redeem_points_per_unit":"100"},"update_settings":""} 2026-02-18 13:33:14 - POST: {"action":"save_pos_transaction","customer_id":"1","payments":"[{\"method\":\"credit\",\"amount\":1.19}]","total_amount":"1.19","discount_code_id":"","discount_amount":"0","loyalty_redeemed":"0","items":"[{\"id\":1,\"qty\":2,\"price\":0.3825},{\"id\":2,\"qty\":2,\"price\":0.2125}]"} +2026-02-18 14:03:07 - POST: {"action":"hold_pos_cart","cart_name":"Cart 6:03:04 PM","items":"[{\"id\":1,\"nameEn\":\"Tomato\",\"nameAr\":\"\u0637\u0645\u0627\u0637\u0645\",\"price\":0.3825,\"stock_quantity\":-17.5,\"qty\":1}]","customer_id":""} +2026-02-18 14:03:18 - POST: {"action":"delete_held_cart","id":"9"}