Automated Inventory Level Alert System

Inventory Level Alert System

Simulating real-time monitoring of product stock levels.

Total Products

0

Items with Low Stock

0

Items with Surplus Stock

0

Total Inventory Value

$0

Inventory Status

Status Product Current Stock Re-Order Point Max Stock

Live Alert Log

Waiting for inventory events...

${document.getElementById('lowStockItems').textContent}

Surplus

${document.getElementById('surplusStockItems').textContent}

Total Inventory Value

${document.getElementById('inventoryValue').textContent}

`; const tableClone = document.querySelector('table').cloneNode(true); tableClone.querySelectorAll('[contenteditable="true"]').forEach(el => el.removeAttribute('contenteditable')); tableClone.classList.add("w-full", "text-xs"); document.getElementById('pdf-table-container').innerHTML = ''; document.getElementById('pdf-table-container').appendChild(tableClone); const criticalAlerts = alerts.filter(a => a.color.includes('red')).slice(0, 5); document.getElementById('pdf-alerts-container').innerHTML = criticalAlerts.map(a => `

${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(); });
Scroll to Top