`;
// 1. Case Metadata
html += `
`;
container.innerHTML = html;
}
function wirtSwitchTab(tabId) {
document.querySelectorAll('.wirt-tab-btn').forEach(b => b.classList.remove('active'));
document.querySelectorAll('.wirt-content').forEach(c => c.classList.remove('active'));
const idx = tabId === 'builder' ? 0 : 1;
document.querySelectorAll('.wirt-tab-btn')[idx].classList.add('active');
document.getElementById('wirt-' + tabId).classList.add('active');
if (tabId === 'preview') {
wirtRenderReport();
}
}
function wirtLoadExample() {
if(!confirm("Overwrite current inputs with example harassment case data?")) return;
document.getElementById('inp-case-id').value = "HR-INV-2025-045";
document.getElementById('inp-report-date').valueAsDate = new Date();
document.getElementById('inp-complainant').value = "Sarah K. Smith (Marketing Analyst)";
document.getElementById('inp-respondent').value = "David M. Jones (VP of Sales)";
document.getElementById('inp-allegation').value = "Violation of Anti-Harassment Policy (Hostile Work Environment)";
document.getElementById('inp-incident').value = "The Complainant alleges repeated, unwanted comments regarding her appearance and gender bias in project assignment occurring between January and October 2025. The Respondent denies all claims.";
document.getElementById('inp-interviews').value = "Complainant (S. Smith), Respondent (D. Jones), Witness 1 (M. Chen, Colleague), Witness 2 (L. Patel, HR Manager)";
document.getElementById('inp-evidence').value = "Email Chain from D. Jones to S. Smith (2025-09-01), Witness 1's contemporaneous written notes, Respondent's disciplinary history file (Clean).";
document.getElementById('inp-conclusion-status').value = "Substantiated";
document.getElementById('inp-rationale').value = "The investigation found sufficient credible evidence, primarily the corroborating testimony of Witness 1 regarding the Respondent's statements and the detailed written record maintained by the Complainant. The Respondent's denial was inconsistent with established facts and documented communications.";
wirtRenderReport();
wirtSwitchTab('preview');
}
/* --- PDF Generation --- */
async function wirtGeneratePDF() {
wirtRenderReport(); // Final render check
const data = {
caseId: document.getElementById('inp-case-id').value || "HR-INV-000",
reportDate: document.getElementById('inp-report-date').value || "N/A",
complainant: document.getElementById('inp-complainant').value || "N/A",
respondent: document.getElementById('inp-respondent').value || "N/A",
allegation: document.getElementById('inp-allegation').value || "No allegation specified.",
incident: document.getElementById('inp-incident').value || "Incident details pending.",
interviews: document.getElementById('inp-interviews').value || "No interviews conducted.",
evidence: document.getElementById('inp-evidence').value || "No documents reviewed.",
conclusionStatus: document.getElementById('inp-conclusion-status').value,
rationale: document.getElementById('inp-rationale').value || "No rationale provided."
};
const { jsPDF } = window.jspdf;
const doc = new jsPDF('p', 'mm', 'a4');
const red = [192, 57, 43];
const navy = [30, 58, 138];
let y = 20;
// Header
doc.setFillColor(...red);
doc.rect(0, 0, 210, 20, 'F');
doc.setTextColor(255, 255, 255);
doc.setFontSize(16);
doc.text(`CONFIDENTIAL INVESTIGATION REPORT`, 14, 13);
doc.setFontSize(10);
doc.text(`Case File: ${data.caseId} | Date: ${data.reportDate}`, 14, 17);
y = 30;
// Helper function to add structured text sections
const addSection = (title, content, startY) => {
if (startY > 270) { doc.addPage(); startY = 20; }
doc.setFont("times", "bold");
doc.setFontSize(12);
doc.setTextColor(navy);
doc.text(title, 14, startY);
startY += 6;
doc.setFont("times", "normal");
doc.setFontSize(10);
doc.setTextColor(50, 50, 50);
const splitContent = doc.splitTextToSize(content, 180);
doc.text(splitContent, 18, startY);
return startY + (splitContent.length * 5) + 8;
};
// 1. Case Metadata
doc.setFontSize(10);
doc.setFont("times", "bold");
doc.text("I. CASE METADATA", 14, y);
doc.setFont("times", "normal");
doc.text(`Complainant: ${data.complainant}`, 14, y + 6);
doc.text(`Respondent: ${data.respondent}`, 105, y + 6);
y += 12;
// 2. Scope & Incident
y = addSection("II. SCOPE OF INVESTIGATION", null, y);
y = addSection("Allegation:", data.allegation, y);
y = addSection("Incident Details & Policy Violated:", data.incident, y);
// 3. Methodology
y = addSection("III. INVESTIGATION METHODOLOGY", null, y);
y = addSection("Interviewed Parties:", data.interviews, y);
y = addSection("Evidence Reviewed:", data.evidence, y);
// 4. Findings & Conclusion
y = addSection("IV. FINDINGS AND CONCLUSION", null, y);
// Conclusion Box
if (y > 250) { doc.addPage(); y = 20; }
doc.setFont("times", "bold");
doc.setTextColor(navy);
doc.text(`DETERMINATION: ${data.conclusionStatus.toUpperCase()}`, 14, y);
y += 8;
y = addSection("Rationale and Determination of Facts:", data.rationale, y);
// 5. Signature Block
y += 15;
if (y > 270) { doc.addPage(); y = 20; }
doc.setFontSize(10);
doc.text("___________________________________", 14, y);
doc.text("Investigator Signature", 14, y + 5);
doc.text(`___________________________________`, 120, y);
doc.text("Reviewed By (General Counsel/HR)", 120, y + 5);
doc.save(`Investigation_Report_${data.caseId}.pdf`);
}
CASE METADATA
`;
html += `Complainant: ${data.complainant}
`;
html += `Respondent: ${data.respondent}
`;
html += `Allegation: ${data.allegation}
`;
// 2. Scope & Incident
html += `I. SCOPE OF INVESTIGATION
`;
html += `1.1. Alleged Incident and Policy Violated
`;
html += `${data.incident}
`;
// 3. Methodology & Evidence
html += `II. INVESTIGATION METHODOLOGY
`;
html += `2.1. Interviewed Parties
`;
html += `${data.interviews}
`;
html += `2.2. Documentary Evidence Reviewed
`;
html += `${data.evidence}
`;
// 4. Findings & Conclusion
html += `III. FINDINGS AND CONCLUSION
`;
html += `3.1. Conclusion Status
`;
html += `
DETERMINATION: The allegation is determined to be ${data.conclusionStatus.toUpperCase()}.
`;
html += `3.2. Rationale and Determination of Facts
`;
html += `${data.rationale}
`;
// 5. Signature Block
html += `Investigator Signature: ___________________________________
Date Signed: ${data.reportDate}
