Billing Page

Billing

Items: 0 Qty: 0 Total: ₹0
#Product Qty MRP Sell Pric Total action

Held Bills : 0

'); printWindow.document.close(); printWindow.print(); } // Shortcut keys document.addEventListener('keydown', function (e) { if (e.ctrlKey && e.key === 's') { e.preventDefault(); document.getElementById('billingForm').addEventListener('submit', function (e) { e.preventDefault(); const formData = new FormData(this); formData.append('products', JSON.stringify(productList)); fetch('billing_page.php', { method: 'POST', body: formData }) .then(response => response.json()) .then(data => { if (data.success) { alert('Bill saved successfully!'); if (confirm('Do you want to print the bill?')) { printBill(); } clearBill(); // Fetch the updated total number of rows and set the new bill number fetch('get_total_bills.php') .then(response => response.json()) .then(data => { const totalRows = data.totalRows; const newBillNo = totalRows + 1; document.getElementById('bill_no').value = newBillNo; document.getElementById('bill_no_display').value = newBillNo; }); window.location.reload(true); } else { alert('Error saving bill: ' + data.error); } }) .catch(error => { console.error('Error submitting the form:', error); alert('Error submitting the bill.'); }); }); } if (e.ctrlKey && e.key === 'b') { e.preventDefault(); clearBill(); } if (e.ctrlKey && e.key === 'B') { e.preventDefault(); clearBill(); } if (e.ctrlKey && e.key === 'p') { e.preventDefault(); printBill(); } if (e.ctrlKey && e.key === 'h') { e.preventDefault(); holdBill(); } if (e.ctrlKey && e.key.toLowerCase() === 'm') { e.preventDefault(); const input = document.getElementById('product_code'); if (input) { input.focus(); input.select(); // optional: selects existing value } } if (e.ctrlKey && e.key.toLowerCase() === 'i') { e.preventDefault(); const inputx = document.getElementById('manual_product_code'); if (inputx) { inputx.focus(); inputx.select(); // optional: selects existing value } } if (e.ctrlKey && e.key.toLowerCase() === 'y') { e.preventDefault(); const inputx = document.getElementById('search_product'); if (inputx) { inputx.focus(); inputx.select(); // optional: selects existing value } } }); // Load products and held bills from localStorage on page load loadFromLocalStorage(); loadHeldBills();