🚨 Incident Report Compliance Tracker

Incident Details

Compliance Checklist: ${checkedCount} of ${total} items checked.

`; html += `

Compliance Status: ${statusText}

`; summaryOutput.innerHTML = html; } function generatePDF() { const incidentID = document.getElementById("incidentID").value.trim() || "N/A"; const reportedBy = document.getElementById("reportedBy").value.trim() || "N/A"; const incidentDate = document.getElementById("incidentDate").value || "N/A"; const incidentType = document.getElementById("incidentType").value || "N/A"; const incidentDescription = document.getElementById("incidentDescription").value.trim() || "N/A"; const { checkedCount, total } = calculateCompliance(); const date = new Date().toLocaleDateString(); function loadJsPDF(callback) { if (window.jspdf) return callback(); const script = document.createElement("script"); script.src = "https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"; script.onload = callback; document.head.appendChild(script); } loadJsPDF(() => { const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFont("helvetica"); doc.setFontSize(18); doc.setTextColor("#003366"); doc.text("Incident Report Compliance Tracker Report", 14, 20); doc.setFontSize(12); doc.setTextColor("#000"); doc.text(`Incident ID: ${incidentID}`, 14, 30); doc.text(`Reported By: ${reportedBy}`, 14, 38); doc.text(`Date of Incident: ${incidentDate}`, 14, 46); doc.text(`Incident Type: ${incidentType}`, 14, 54); doc.text(`Report Date: ${date}`, 14, 62); doc.setFontSize(14); doc.text("Incident Description:", 14, 72); const splitDesc = doc.splitTextToSize(incidentDescription, 180); doc.setFontSize(11); doc.text(splitDesc, 14, 80); let y = 80 + splitDesc.length * 7 + 10; doc.setFontSize(14); doc.text("Compliance Checklist:", 14, y); y += 7; doc.setFontSize(11); doc.text(`Items Checked: ${checkedCount} of ${total}`, 14, y); y += 10; const compliancePercent = total ? (checkedCount / total) * 100 : 0; let statusText = "Non-Compliant"; if (compliancePercent === 100) statusText = "Fully Compliant"; else if (compliancePercent >= 60) statusText = "Partially Compliant"; doc.text(`Compliance Status: ${statusText}`, 14, y); doc.save("Incident_Report_Compliance_Report.pdf"); }); } nextBtn.addEventListener("click", () => { if (currentTab === tabs.length - 1) { currentTab = 0; } else if (currentTab === tabs.length - 2) { generateSummary(); currentTab++; } else { currentTab++; } showTab(currentTab); }); prevBtn.addEventListener("click", () => { if (currentTab > 0) { currentTab--; showTab(currentTab); } }); downloadPDFBtn.addEventListener("click", generatePDF); function showTab(index) { tabs.forEach((tab, i) => { tab.style.display = i === index ? "block" : "none"; }); prevBtn.style.display = index === 0 ? "none" : "inline-block"; if (index === tabs.length - 1) { nextBtn.textContent = "Restart"; downloadPDFBtn.style.display = "inline-block"; } else { nextBtn.textContent = "Next ⟶"; downloadPDFBtn.style.display = "none"; } } showTab(currentTab); });
Scroll to Top