Online Smart Document Expiry & Renewal Reminder

Smart Document Expiry & Renewal Reminder

Document Expiry Status

Expiry: ${formattedDate}

`; configList.appendChild(docEl); }); }; const handleAddDocument = (e) => { e.preventDefault(); const name = docNameInput.value.trim(); const expiryDate = expiryDateInput.value; if (name && expiryDate) { documents.push({ id: Date.now(), name: name, expiryDate: expiryDate }); renderDashboard(); renderConfigList(); addDocForm.reset(); } else { alert("Please provide both a document name and an expiry date."); } }; const handleDeleteDocument = (e) => { if (e.target.classList.contains('delete-doc-btn')) { const docId = parseInt(e.target.dataset.id, 10); documents = documents.filter(d => d.id !== docId); renderDashboard(); renderConfigList(); } }; const handlePdfDownload = () => { if (documents.length === 0) { alert("There are no documents to export."); return; } const { jsPDF } = window.jspdf; const pdf = new jsPDF(); const tableData = documents.map(doc => { const status = calculateStatus(doc.expiryDate); const formattedDate = new Date(doc.expiryDate + 'T00:00:00').toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); let daysInfo = status.text === 'Expired' ? `-${status.days}` : `${status.days}`; return [doc.name, formattedDate, status.text, daysInfo]; }); pdf.setFontSize(18); pdf.text("Document Expiry Summary", 105, 20, { align: 'center' }); pdf.setFontSize(10); pdf.text(`Report generated on: ${TODAY.toLocaleDateString('en-US')}`, 105, 30, { align: 'center' }); pdf.autoTable({ head: [['Document Name', 'Expiry Date', 'Status', 'Days Remaining']], body: tableData, startY: 40, theme: 'striped', headStyles: { fillColor: [59, 130, 246] }, // blue-500 }); pdf.save('document-expiry-summary.pdf'); }; // --- Event Listeners --- tabs.dashboard.addEventListener('click', () => { currentTab = 'dashboard'; updateTabs(); }); tabs.config.addEventListener('click', () => { currentTab = 'config'; updateTabs(); }); navButtons.next.addEventListener('click', () => { currentTab = 'config'; updateTabs(); }); navButtons.prev.addEventListener('click', () => { currentTab = 'dashboard'; updateTabs(); }); addDocForm.addEventListener('submit', handleAddDocument); configList.addEventListener('click', handleDeleteDocument); downloadPdfBtn.addEventListener('click', handlePdfDownload); // --- Initializations --- currentDateDisplay.textContent = `Based on current date: ${TODAY.toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })}`; updateTabs(); renderDashboard(); renderConfigList(); });
Scroll to Top