Action Items
${nonCompliantItems.length === 0 ? '
Great job! All checklist items are marked as compliant. It\'s recommended to periodically review these items.
' : `
`}
`;
reportContainer.innerHTML = html;
showTab(3);
}
function downloadPdf() {
if (!appData.checklistResults) { alert('Please generate a report first.'); return; }
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
doc.setFontSize(18);
doc.text("Online Legal Compliance Report", 105, 20, { align: 'center' });
doc.setFontSize(11);
doc.text(`For: ${appData.businessName}`, 105, 28, { align: 'center' });
const compliantCount = appData.checklistResults.filter(r => r.isCompliant).length;
const totalCount = appData.checklistResults.length;
const percentage = totalCount > 0 ? Math.round((compliantCount / totalCount) * 100) : 100;
doc.setFontSize(12);
doc.text(`Overall Compliance Score: ${percentage}%`, 14, 45);
const nonCompliantItems = appData.checklistResults.filter(r => !r.isCompliant);
const tableBody = nonCompliantItems.map(r => [r.category, r.text, r.recommendation]);
if (tableBody.length > 0) {
doc.autoTable({
startY: 55,
head: [['Category', 'Action Item', 'Recommendation']],
body: tableBody,
theme: 'grid',
headStyles: { fillColor: [37, 99, 235] },
columnStyles: { 1: { cellWidth: 70 }, 2: { cellWidth: 70 } }
});
} else {
doc.text("All checklist items were marked as compliant.", 14, 60);
}
doc.save(`Compliance-Report-${appData.businessName.replace(/\s/g, '_')}.pdf`);
}
// --- Event Listeners ---
nextBtn.addEventListener('click', () => {
if (!validateTab(currentTab)) return;
saveTabData();
if (currentTab < totalTabs - 1) {
showTab(currentTab + 1);
} else {
generateReport();
}
});
prevBtn.addEventListener('click', () => {
if (currentTab > 1) {
showTab(currentTab - 1);
}
});
getEl('download-pdf-btn').addEventListener('click', downloadPdf);
// --- Initialization ---
populateChecklist();
updateNavigation();
});