Property Inspection Checklist Tool

Property Inspection Checklist

POOR

${statuses['N/A']}

N/A

`; } renderSummaryChart([statuses.Good, statuses.Fair, statuses.Poor]); } function renderSummaryChart(data) { const ctx = document.getElementById('summaryChart'); if (!ctx) return; if (summaryChartInstance) { summaryChartInstance.destroy(); } summaryChartInstance = new Chart(ctx, { type: 'doughnut', data: { labels: ['Good', 'Fair', 'Poor'], datasets: [{ data: data, backgroundColor: ['#10B981', '#F59E0B', '#EF4444'], borderColor: '#FFFFFF', borderWidth: 2, }] }, options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false }, tooltip: { callbacks: { label: function(context) { return `${context.label}: ${context.raw}`; } } } } } }); } function downloadPDF() { const { jsPDF } = window.jspdf; // Create a container for the clean PDF content const reportContainer = document.createElement('div'); reportContainer.id = 'pdf-output'; reportContainer.className = 'p-8'; let reportHTML = `

Property Inspection Report

`; const categories = checklistContainer.querySelectorAll('.border.rounded-lg'); categories.forEach(categoryDiv => { const categoryName = categoryDiv.querySelector('h2').textContent; reportHTML += `

${categoryName}

`; reportHTML += ''; const items = categoryDiv.querySelectorAll('.checklist-item'); items.forEach(itemDiv => { const itemName = itemDiv.querySelector('.font-medium').textContent; const status = itemDiv.querySelector('.status-select').value; const notes = itemDiv.querySelector('.form-textarea').value || 'No notes.'; let statusColor = '#000'; if (status === 'Good') statusColor = '#10B981'; if (status === 'Fair') statusColor = '#F59E0B'; if (status === 'Poor') statusColor = '#EF4444'; reportHTML += ` `; }); reportHTML += '
${itemName} ${status} ${notes}
'; }); reportContainer.innerHTML = reportHTML; document.body.appendChild(reportContainer); // Temporarily add to DOM for rendering html2canvas(reportContainer, { scale: 2 }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgProps = pdf.getImageProperties(imgData); const imgWidth = pdfWidth - 20; const imgHeight = (imgProps.height * imgWidth) / imgProps.width; let heightLeft = imgHeight; let position = 10; pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight); heightLeft -= (pdfHeight - 20); while (heightLeft > 0) { pdf.addPage(); position = heightLeft - imgHeight + 10; pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight); heightLeft -= (pdfHeight - 20); } pdf.save('Property-Inspection-Report.pdf'); document.body.removeChild(reportContainer); // Clean up }); } // --- RUN INITIALIZATION --- init(); });
Scroll to Top