Surplus
${document.getElementById('surplusStockItems').textContent}
Total Inventory Value
${document.getElementById('inventoryValue').textContent}
${a.time}: ${a.message}
`).join(''); const reportEl = document.getElementById('pdf-report'); reportEl.classList.remove('hidden'); const canvas = await html2canvas(reportEl, { scale: 2 }); reportEl.classList.add('hidden'); const imgData = canvas.toDataURL('image/png'); const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'p', unit: 'in', format: 'letter' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (canvas.height * pdfWidth) / canvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); pdf.save('Inventory-Report.pdf'); } function setupEventListeners() { document.getElementById('inventoryTableBody').addEventListener('focusout', e => { if (e.target.classList.contains('editable-cell')) { const id = parseInt(e.target.dataset.id); const field = e.target.dataset.field; const value = parseInt(e.target.textContent) || 0; const item = inventory.find(i => i.id === id); if (item) { item[field] = value; updateDashboard(); } } }); document.getElementById('downloadPdfBtn').addEventListener('click', generatePdf); } function initialize() { updateDashboard(); setupEventListeners(); startSimulation(); } initialize(); });