OCC Invoice

www.onlineconceptclasses.com

Create Invoice

Fill details below, then Download PDF or Print

📋 Invoice Details
👤 Bill To (Client Details)
🛒 Items / Services
Description Qty Unit Price (₹) Amount
' ); printWin.document.close(); printWin.focus(); setTimeout(function(){ printWin.print(); }, 800); };// ── Save to DB ── window.occSaveInvoice = function() { var d = occData(); if (!d.client_name) { occMsg('❗ Client name is required.', 'error'); return; } if (!d.invoice_no) { occMsg('❗ Invoice number is required.', 'error'); return; } if (!d.items.length) { occMsg('❗ Add at least one item.', 'error'); return; } occMsg('⏳ Saving...', 'info'); var fd = new FormData(); fd.append('action', 'occ_save_invoice'); fd.append('nonce', OCC.nonce); fd.append('data', JSON.stringify(d)); fetch(OCC.ajaxUrl, { method:'POST', body: fd, credentials:'same-origin' }) .then(function(r){ return r.json(); }) .then(function(res) { if (res.success) occMsg('✅ Invoice saved! Invoice ID: #' + res.data.id, 'success'); else occMsg('❌ ' + (res.data || 'Could not save invoice.'), 'error'); }) .catch(function(){ occMsg('❌ Network error. Please try again.', 'error'); }); };// ── Reset ── window.occResetForm = function() { if (!confirm('Reset all fields? Unsaved data will be lost.')) return; ['occ_client_name','occ_client_email','occ_client_phone','occ_client_gstin','occ_client_address'].forEach(function(id){ document.getElementById(id).value = ''; }); document.getElementById('occ_notes').value = OCC.footer; document.getElementById('occ_discount').value = '0'; document.getElementById('occ_tax_rate').value = OCC.defTax; document.getElementById('occ_status').value = 'draft'; document.getElementById('occ_invoice_date').value = new Date().toISOString().split('T')[0]; document.getElementById('occ_due_date').value = ''; document.getElementById('occ-items-list').innerHTML = ''; occAddItem(); occAddItem(); occAddItem(); occCalc(); occMsg('🔄 Form has been reset.', 'info'); };// ── Message helper ── function occMsg(text, type) { var el = document.getElementById('occ-msg'); el.textContent = text; el.style.display = 'block'; el.className = 'occ-msg occ-msg-' + type; clearTimeout(el._t); el._t = setTimeout(function(){ el.style.display='none'; }, 6000); } window.occMsg = occMsg;})();