From bad7441af29973499cf5e8250824a1b986ee135b Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Tue, 17 Feb 2026 16:35:20 +0000 Subject: [PATCH] modify sale return --- index.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index 7e49dab..9a68a77 100644 --- a/index.php +++ b/index.php @@ -4935,8 +4935,8 @@ document.addEventListener('DOMContentLoaded', function() { } }; - returnInvoiceSelect.addEventListener('change', async function() { - const invoiceId = this.value; + const handleInvoiceChange = async function() { + const invoiceId = returnInvoiceSelect.value; const container = document.getElementById('return_items_container'); const tbody = document.getElementById('return_items_tbody'); const submitBtn = document.getElementById('submit_return_btn'); @@ -4986,15 +4986,27 @@ document.addEventListener('DOMContentLoaded', function() { if (submitBtn) submitBtn.disabled = true; // Add event listeners for qty changes - tbody.querySelectorAll('.return-qty-input').forEach(input => { + const qtyInputs = tbody.querySelectorAll('.return-qty-input'); + qtyInputs.forEach(input => { input.addEventListener('input', calculateReturnTotal); + input.addEventListener('change', calculateReturnTotal); + input.addEventListener('keyup', calculateReturnTotal); }); + calculateReturnTotal(); + } catch (e) { console.error(e); - Swal.fire('Error', 'Failed to fetch invoice items', 'error'); + if (window.Swal) Swal.fire('Error', 'Failed to fetch invoice items', 'error'); } - }); + }; + + returnInvoiceSelect.addEventListener('change', handleInvoiceChange); + // Also support Select2 + if (window.jQuery && jQuery.fn.select2) { + $(returnInvoiceSelect).on('select2:select', handleInvoiceChange); + $(returnInvoiceSelect).on('change', handleInvoiceChange); + } } // View Return Logic @@ -5025,7 +5037,7 @@ document.addEventListener('DOMContentLoaded', function() { - +