`;
// I. Applicant Data
html += `
`;
container.innerHTML = html;
}
function zafgSwitchTab(tabId) {
document.querySelectorAll('.zafg-tab-btn').forEach(b => b.classList.remove('active'));
document.querySelectorAll('.zafg-content').forEach(c => c.classList.remove('active'));
const idx = tabId === 'builder' ? 0 : 1;
document.querySelectorAll('.zafg-tab-btn')[idx].classList.add('active');
document.getElementById('zafg-' + tabId).classList.add('active');
if (tabId === 'preview') {
zafgRenderForm();
}
}
/* --- PDF Generation --- */
async function zafgGeneratePDF() {
zafgRenderForm(); // Final render check
const data = {
applicant: document.getElementById('inp-applicant').value || "N/A Applicant",
site: document.getElementById('inp-site-address').value || "N/A Site",
apn: document.getElementById('inp-apn').value || "N/A APN",
actionType: document.getElementById('inp-action-type').value,
projectDesc: document.getElementById('inp-project-desc').value || "No description provided.",
justification: document.getElementById('inp-justification').value || "No justification provided."
};
const { jsPDF } = window.jspdf;
const doc = new jsPDF('p', 'mm', 'a4');
const navy = [30, 58, 138];
let y = 20;
// 1. Header
doc.setFillColor(...navy);
doc.rect(0, 0, 210, 20, 'F');
doc.setTextColor(255, 255, 255);
doc.setFontSize(16);
doc.text(`ZONING APPLICATION FORM`, 105, 13, { align: 'center' });
doc.setFontSize(10);
doc.text(`Request for ${data.actionType}`, 105, 17, { align: 'center' });
y = 35;
// 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 += 5;
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) + 10;
};
// 2. Identity and Property
doc.setFontSize(10);
doc.setFont("times", "bold");
doc.setTextColor(0, 0, 0);
doc.text(`Applicant:`, 14, y);
doc.text(`Property Address:`, 105, y);
y += 5;
doc.setFont("times", "normal");
doc.setTextColor(50, 50, 50);
doc.text(data.applicant, 14, y);
doc.text(data.site, 105, y);
y += 10;
// 3. Project Description
y = addSection("PROJECT DESCRIPTION", data.projectDesc, y);
// 4. Justification
y = addSection("STATEMENT OF JUSTIFICATION", data.justification, y);
// 5. Signature Block
if (y > 240) { doc.addPage(); y = 20; }
doc.setFont("times", "normal");
doc.setTextColor(0, 0, 0);
doc.setFontSize(10);
doc.text("DECLARATION:", 14, y);
doc.setFontSize(9);
doc.text("I hereby certify that the information contained herein is true and correct to the best of my knowledge and belief.", 14, y + 5);
y += 20;
doc.line(14, y, 90, y);
doc.text("Applicant Signature", 14, y + 5);
doc.line(110, y, 186, y);
doc.text("Date", 110, y + 5);
doc.save(`Zoning_Application_${data.apn}.pdf`);
}
I. APPLICANT INFORMATION
`;
html += `Applicant Name: ${data.applicant}
`;
html += `Mailing Address: ${data.mailing}
`;
html += `Contact: ${data.contact}
`;
// II. Property Details
html += `II. PROPERTY & ZONING DATA
`;
html += `Site Address: ${data.site}
`;
html += `Assessor's Parcel Number (APN): ${data.apn}
`;
html += `Current Zoning: ${data.currentZone} | Requested Zoning: ${data.requestedZone}
`;
// III. Project Details
html += `III. PROJECT DESCRIPTION
`;
html += `Type of Action Requested: ${data.actionType}
`;
html += `Proposed Use:
`;
html += `${data.projectDesc}
`;
// IV. Justification
html += `IV. STATEMENT OF JUSTIFICATION
`;
html += `Legal Argument (Attach Exhibits if Necessary):
`;
html += `${data.justification}
`;
// V. Declaration & Signature
html += `DECLARATION: I hereby certify that the information contained herein is true and correct to the best of my knowledge and belief. I understand that falsification of information may result in the denial of this application and legal penalties.
Applicant Signature: ___________________________________
Date: ___________________________
