Automated Out-of-Stock Alert System

Automated Out-of-Stock Alert System

Configure your smart inventory monitoring and notification rules.

System Setup

Inventory Thresholds

Send an alert for any product when its stock level falls below this number.

Specific Rules (Overrides Global)

Notification Settings

System Configuration Summary

Rule: Alert for ${type} '${value}' when stock is below ${threshold} units.

`; }); summaryHtml += `
`; const freq = document.getElementById('alertFrequency'); summaryHtml += `

Notification Settings

Channels: ${document.getElementById('channelEmail').checked ? 'Email' : ''} ${document.getElementById('channelSms').checked ? 'SMS' : ''}

Email Recipients: ${getValue('emailRecipients')}

SMS Recipients: ${getValue('smsRecipients')}

Frequency: ${freq.options[freq.selectedIndex].text}

`; summaryContent.innerHTML = summaryHtml; }; downloadPdfBtn.addEventListener('click', () => { if (typeof window.jspdf === 'undefined' || !window.jspdf.jsPDF.autoTable) return; const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'p', unit: 'pt', format: 'letter' }); const getValue = id => document.getElementById(id).value; const page = { width: doc.internal.pageSize.getWidth(), margin: 72 }; let y = page.margin; // --- PDF Content --- doc.setFont('times', 'bold'); doc.setFontSize(22); doc.text('Out-of-Stock Alert System Configuration', page.width / 2, y, { align: 'center' }); y += 40; doc.setFont('times', 'normal'); doc.setFontSize(14); doc.text(getValue('storeUrl'), page.width / 2, y, { align: 'center' }); y += 40; const addSection = (title, content) => { doc.setFont('times', 'bold'); doc.setFontSize(16); doc.text(title, page.margin, y); y += 20; doc.setFont('times', 'normal'); doc.setFontSize(11); const lines = doc.splitTextToSize(content, page.width - page.margin * 2); doc.text(lines, page.margin, y, { lineHeightFactor: 1.5 }); y += lines.length * 11 * 1.5 + 30; }; addSection('I. System Setup', `System Name: ${getValue('systemName')}\nPrimary Administrator: ${getValue('adminEmail')}`); // Rules Table doc.setFont('times', 'bold'); doc.setFontSize(16); doc.text('II. Threshold Rules', page.margin, y); y += 20; const head = [['Type', 'Identifier', 'Threshold']]; const body = [ ['Global (Default)', 'All Products', getValue('globalThreshold')] ]; document.querySelectorAll('.dynamic-rule').forEach(rule => { body.push([ rule.querySelector('.rule-type').options[rule.querySelector('.rule-type').selectedIndex].text, rule.querySelector('.rule-value').value, rule.querySelector('.rule-threshold').value ]); }); doc.autoTable({ startY: y, head, body, theme: 'grid', headStyles: { fillColor: [79, 70, 229] }, styles: { font: 'times', fontSize: 10 } }); y = doc.autoTable.previous.finalY + 30; const freq = document.getElementById('alertFrequency'); const alertContent = `Channels Enabled: ${document.getElementById('channelEmail').checked ? 'Email' : ''} ${document.getElementById('channelSms').checked ? 'SMS' : ''}\n` + `Email Recipients: ${getValue('emailRecipients')}\n` + `SMS Recipients: ${getValue('smsRecipients')}\n` + `Alert Frequency: ${freq.options[freq.selectedIndex].text}`; addSection('III. Notification Settings', alertContent); doc.save(`${getValue('systemName') || 'Alert-System-Config'}.pdf`); }); // --- Initial Setup --- addRuleBlock(); switchTab('setup'); });
Scroll to Top