๐Ÿš Kings Packaging

No customer selected
sales@kingspackaging.com.au | ABN: [Your ABN] | Ph: [Your Phone]
GST SALE
Subtotal:$0.00
GST (10%):$0.00
TOTAL: $0.00
CASH SALE
Subtotal:$0.00
GST (10%):$0.00
TOTAL: $0.00
๐Ÿ“Š Cost Prices & Margins

๐Ÿ”’ Admin Access Required

Please enter the admin password to view cost prices and margins.


๐Ÿ’ต Cash Sales History
' + '' + ''; // Save cash sales if (type === 'cash') { cashSales.push({ invoiceNum: invoiceNum, date: now.toISOString(), customer: currentCustomer || 'Walk-in', total: total, items: cart.map(function(i) { return {name: i.name, size: i.size, qty: i.qty, price: i.price}; }) }); localStorage.setItem('kp_cashSales', JSON.stringify(cashSales)); } var frame = document.getElementById('printFrame'); frame.contentDocument.write(printContent); frame.contentDocument.close(); clearCart(type); alert('Invoice printed! ' + invoiceNum); } // Customers function renderCustomers() { var container = document.getElementById('customersList'); container.innerHTML = customers.map(function(c) { return '
' + '
' + c.name + '
' + '
' + (c.phone ? '๐Ÿ“ž ' + c.phone : '') + (c.email ? 'โœ‰๏ธ ' + c.email : '') + '
' + '
' + '' + '' + '
' + '
'; }).join(''); } function filterCustomers() { var search = document.getElementById('customerSearch').value.toLowerCase(); document.querySelectorAll('.customer-card').forEach(function(card) { var name = card.querySelector('.customer-name').textContent.toLowerCase(); card.style.display = name.indexOf(search) !== -1 ? 'block' : 'none'; }); } function startCustomerInvoice(name) { selectCustomer(name); document.getElementById('gstCustomerSelect').value = name; document.getElementById('cashCustomerSelect').value = name; showScreen('screen-gst'); } function viewCustomer(name) { alert('Customer: ' + name + '\nComing soon: Full customer history'); } function showAddCustomer() { document.getElementById('customerModal').classList.add('active'); } function closeCustomerModal() { document.getElementById('customerModal').classList.remove('active'); } function saveCustomer() { var name = document.getElementById('newCustomerName').value; var phone = document.getElementById('newCustomerPhone').value; var email = document.getElementById('newCustomerEmail').value; if (name) { customers.push({ name: name, phone: phone, email: email }); localStorage.setItem('kp_customers', JSON.stringify(customers)); renderCustomers(); populateCustomerSelects(); closeCustomerModal(); } } // Cost Table function renderCostTable() { if (!costUnlocked) return; var tbody = document.getElementById('costTableBody'); if (!tbody) return; tbody.innerHTML = products.map(function(p) { var retail = Math.min.apply(null, p.prices); var margin = ((retail - p.cost) / retail * 100).toFixed(1); var marginClass = margin > 30 ? 'margin-good' : 'margin-bad'; return '' + '' + p.name + '
' + p.category + '' + '$' + p.cost.toFixed(2) + '' + '$' + retail.toFixed(2) + '' + '' + margin + '%' + ''; }).join(''); } // Cash History function renderCashHistory() { var container = document.getElementById('cashHistoryList'); if (cashSales.length === 0) { container.innerHTML = '
No cash sales yet
'; return; } container.innerHTML = cashSales.slice().reverse().map(function(sale) { return '
' + '
' + '' + new Date(sale.date).toLocaleDateString() + '' + '$' + sale.total.toFixed(2) + '' + '
' + '
' + sale.invoiceNum + ' - ' + sale.customer + '
' + '
' + sale.items.map(function(i) { return i.qty + 'x ' + i.name; }).join(', ') + '
' + '
'; }).join(''); } // Polyfill NodeList.forEach for older browsers (iPad Safari) if (window.NodeList && !NodeList.prototype.forEach) { NodeList.prototype.forEach = Array.prototype.forEach; } // Wire up all button clicks via addEventListener (more reliable than inline onclick on tablets) function wireButtons() { // Home screen big buttons var homeButtons = [ { sel: '.btn-gst', screen: 'screen-gst' }, { sel: '.btn-cash', screen: 'screen-cash' }, { sel: '.btn-customers', screen: 'screen-customers' }, { sel: '.btn-cost', screen: 'screen-cost' } ]; homeButtons.forEach(function(btn) { var el = document.querySelector(btn.sel); if (el) { el.addEventListener('click', function() { showScreen(btn.screen); }); } }); // Back buttons var backBtns = document.querySelectorAll('.back-btn'); for (var i = 0; i < backBtns.length; i++) { (function(btn) { btn.addEventListener('click', function() { showScreen('screen-home'); }); })(backBtns[i]); } } // Initialize on load โ€” wrap in DOM ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function() { wireButtons(); init(); }); } else { wireButtons(); init(); }