Legal Statutory Limitations Tracking Tool

Legal Statutory Limitations Tracking Tool

Track and manage crucial deadlines for legal statutes of limitations.

Deadline: ${formatDate(deadline)}

${daysRemaining < 0 ? '—' : daysRemaining}

${daysRemaining < 0 ? 'Deadline has passed' : 'Days Remaining'}

`; dashboardList.appendChild(card); }); }; const renderConfig = () => { configList.innerHTML = ''; if (cases.length === 0) { configList.innerHTML = `

No cases to manage.

`; return; } cases.forEach(caseItem => { const itemEl = document.createElement('div'); itemEl.className = 'flex justify-between items-center p-3 bg-gray-50 rounded-md border'; itemEl.innerHTML = `

${caseItem.name} (Incident: ${caseItem.incidentDate})

`; configList.appendChild(itemEl); }); }; // --- TAB NAVIGATION --- const showTab = (tabIndex) => { tabs.forEach((tab, index) => tab.classList.toggle('hidden', index !== tabIndex)); tabNavs.forEach((nav, index) => nav.classList.toggle('active', index === tabIndex)); prevBtn.style.visibility = tabIndex === 0 ? 'hidden' : 'visible'; nextBtn.textContent = tabIndex === tabs.length - 1 ? 'Go to Dashboard' : 'Next'; }; const nextPrev = (direction) => { const newTab = currentTab + direction; if (newTab >= 0 && newTab < tabs.length) { currentTab = newTab; showTab(currentTab); } else if (newTab === tabs.length) { currentTab = 0; // Loop back to dashboard showTab(currentTab); } }; // --- EVENT HANDLERS --- addCaseForm.addEventListener('submit', (e) => { e.preventDefault(); const newCase = { id: Date.now(), name: document.getElementById('case-name').value, incidentDate: document.getElementById('incident-date').value, limitPeriod: parseInt(document.getElementById('limit-period').value, 10), limitUnit: document.getElementById('limit-unit').value }; cases.push(newCase); renderAll(); addCaseForm.reset(); }); configList.addEventListener('click', (e) => { if (e.target.matches('.delete-btn')) { const id = parseInt(e.target.dataset.id, 10); cases = cases.filter(c => c.id !== id); renderAll(); } }); const downloadPDF = () => { const { jsPDF } = window.jspdf; if (!dashboardList || cases.length === 0) return; const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const todayStr = formatDate(new Date()); const margin = 15; let y = margin; pdf.setFontSize(20); pdf.text("Statute of Limitations Dashboard", pdf.internal.pageSize.getWidth() / 2, y, { align: 'center' }); y += 8; pdf.setFontSize(10); pdf.text(`Report Generated on ${todayStr}`, pdf.internal.pageSize.getWidth() / 2, y, { align: 'center' }); y += 15; const sortedCases = cases.slice().sort((a,b) => calculateDaysRemaining(calculateDeadline(a.incidentDate, a.limitPeriod, a.limitUnit)) - calculateDaysRemaining(calculateDeadline(b.incidentDate, b.limitPeriod, b.limitUnit))); sortedCases.forEach(caseItem => { if (y > 270) { // Page break pdf.addPage(); y = margin; } const deadline = calculateDeadline(caseItem.incidentDate, caseItem.limitPeriod, caseItem.limitUnit); const daysRemaining = calculateDaysRemaining(deadline); const urgency = getUrgency(daysRemaining); pdf.setFontSize(14); pdf.setFont(undefined, 'bold'); pdf.text(caseItem.name, margin, y); pdf.setFontSize(10); pdf.setFont(undefined, 'normal'); const statusText = `${urgency.text} (${daysRemaining} days remaining)`; const statusWidth = pdf.getStringUnitWidth(statusText) * pdf.getFontSize() / pdf.internal.scaleFactor; pdf.text(statusText, pdf.internal.pageSize.getWidth() - margin - statusWidth, y); y += 7; pdf.text(`Incident Date: ${formatDate(new Date(caseItem.incidentDate + 'T00:00:00'))}`, margin, y); y += 5; pdf.text(`Limitation Period: ${caseItem.limitPeriod} ${caseItem.limitUnit}`, margin, y); y += 5; pdf.setFont(undefined, 'bold'); pdf.text(`Calculated Deadline: ${formatDate(deadline)}`, margin, y); y += 10; pdf.setDrawColor(220, 220, 220); pdf.line(margin, y, pdf.internal.pageSize.getWidth() - margin, y); y += 5; }); pdf.save('Statutory-Limitations-Report.pdf'); }; // --- INITIALIZATION --- const renderAll = () => { renderDashboard(); renderConfig(); }; prevBtn.addEventListener('click', () => nextPrev(-1)); nextBtn.addEventListener('click', () => nextPrev(1)); downloadPdfBtn.addEventListener('click', downloadPDF); tabNavs.forEach((nav, index) => { nav.addEventListener('click', () => { currentTab = index; showTab(index); }); }); showTab(currentTab); renderAll(); });
Scroll to Top