Employee Engagement Tracker

Log Engagement Entry


Rate the following factors (1=Very Low, 5=Very High):


Qualitative Notes:

View Engagement Data

Historical Log Entries:

No engagement logs found for this subject.

No data for chart.

'; eetTrendObservationEl.textContent = ""; } } } function eetEditLogEntry(logId){ const logEntry = eetEngagementLogs.find(log => log.logId === logId); if(logEntry){ eetLogIdEl.value = logEntry.logId; eetLogSubjectEl.value = logEntry.subjectName; eetLogDateEl.value = logEntry.date; eetEngagementFactors.forEach(factor => { const slider = document.getElementById(`factor-${factor.id}`); const score = logEntry.factorScores[factor.id] || 3; // Default to 3 if not found slider.value = score; if(slider.nextElementSibling) slider.nextElementSibling.textContent = score; }); eetNotesPositiveEl.value = logEntry.notesPositive; eetNotesChallengesEl.value = logEntry.notesChallenges; eetNotesNextStepsEl.value = logEntry.notesNextSteps; eetOpenTab(null, 'eetDataEntryTab'); // Switch to entry tab } } function eetRenderFactorBarChart(factorScoresData) { // [{label, value (1-5)}] if(!eetFactorAverageScoresChartEl) return; eetFactorAverageScoresChartEl.innerHTML = ''; // Clear previous const maxValue = 5; // Max score for factors factorScoresData.forEach(item => { const barDiv = document.createElement('div'); barDiv.classList.add('eet-factor-bar'); const labelSpan = document.createElement('span'); labelSpan.classList.add('eet-factor-bar-label'); labelSpan.textContent = item.label; const valueBar = document.createElement('div'); valueBar.classList.add('eet-factor-bar-value'); const percentageWidth = (item.value / maxValue) * 100; valueBar.style.width = `${percentageWidth}%`; valueBar.textContent = item.value.toFixed(1); if(item.value < 2.5) valueBar.classList.add('low'); else if (item.value < 3.5) valueBar.classList.add('medium'); // Default is accent (greenish) for high barDiv.appendChild(labelSpan); barDiv.appendChild(valueBar); eetFactorAverageScoresChartEl.appendChild(barDiv); }); } // PDF Download function eetDownloadPDF() { const selectedSubject = eetViewSubjectEl.value; const numEntriesToShow = eetViewDateRangeEl.value === 'all' ? Infinity : parseInt(eetViewDateRangeEl.value); if (!selectedSubject ) { alert("Please select a subject to generate a report."); return; } const subjectLogs = eetEngagementLogs.filter(log => log.subjectName === selectedSubject) .sort((a,b) => new Date(a.date) - new Date(b.date)) // Oldest first for PDF .slice(0, numEntriesToShow); if (subjectLogs.length === 0) { alert("No logs to export for this subject/period."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF('p', 'pt', 'a4'); const primaryColorPDF = getComputedStyle(document.documentElement).getPropertyValue('--eet-primary-color').trim(); const accentColorPDF = getComputedStyle(document.documentElement).getPropertyValue('--eet-accent-color').trim(); const whiteColorPDF = getComputedStyle(document.documentElement).getPropertyValue('--eet-text-color-light').trim(); const textColorPDF = getComputedStyle(document.documentElement).getPropertyValue('--eet-text-color-dark').trim(); let yPos = 40; const leftMargin = 40; const contentWidth = doc.internal.pageSize.getWidth() - (2 * leftMargin); const lineSpacing = 14; doc.setFontSize(18); doc.setTextColor(primaryColorPDF); doc.text(`Employee Engagement Report: ${selectedSubject}`, doc.internal.pageSize.getWidth() / 2, yPos, { align: 'center' }); yPos += 20; doc.setFontSize(10); doc.setTextColor(textColorPDF); const dateRangeText = `Report for ${subjectLogs[0].date} to ${subjectLogs[subjectLogs.length-1].date} (or recent ${numEntriesToShow} entries)`; doc.text(dateRangeText, doc.internal.pageSize.getWidth() / 2, yPos, { align: 'center' }); yPos += 30; // Summary of latest/average if (eetOverallAvgScoreEl && eetOverallAvgScoreEl.textContent !== 'N/A') { doc.setFontSize(12); doc.setFont(undefined, 'bold'); doc.setTextColor(primaryColorPDF); doc.text("Latest/Period Summary:", leftMargin, yPos); yPos += 18; doc.setFontSize(10); doc.setFont(undefined, 'normal'); doc.setTextColor(textColorPDF); doc.text(`Overall Engagement Score (Avg. of factors): ${eetOverallAvgScoreEl.textContent}`, leftMargin + 10, yPos); yPos += 15; const factorScoresDataForChart = []; // Rebuild for PDF const latestLogForSummary = subjectLogs[subjectLogs.length-1]; // Use latest log for this summary in PDF too if(latestLogForSummary){ eetEngagementFactors.forEach(f => { factorScoresDataForChart.push({label: f.label, value: latestLogForSummary.factorScores[f.id] || 0}); }); factorScoresDataForChart.forEach(fs => { yPos = checkPdfPageBreak(doc, yPos, lineSpacing); doc.text(`${fs.label}: ${fs.value.toFixed(1)}/5`, leftMargin + 10, yPos); yPos+=lineSpacing; }); } if(eetTrendObservationEl.textContent) { yPos = checkPdfPageBreak(doc, yPos, lineSpacing); doc.setFont(undefined, 'italic'); doc.text(eetTrendObservationEl.textContent, leftMargin + 10, yPos); yPos+=lineSpacing; doc.setFont(undefined, 'normal'); } yPos += 10; } // Historical Log Table yPos = checkPdfPageBreak(doc, yPos, 40); doc.setFontSize(12); doc.setFont(undefined, 'bold'); doc.setTextColor(primaryColorPDF); doc.text("Historical Log Entries:", leftMargin, yPos); yPos += 20; const tableColumns = ["Date"]; eetEngagementFactors.forEach(f => tableColumns.push(f.label.split(' ')[0])); // Short labels tableColumns.push("Overall Avg"); tableColumns.push("Positives"); tableColumns.push("Challenges"); tableColumns.push("Next Steps"); const tableRows = subjectLogs.map(log => { const rowData = [new Date(log.date+'T00:00:00Z').toLocaleDateString()]; let sum = 0, count = 0; eetEngagementFactors.forEach(f => { const score = log.factorScores[f.id] || 0; rowData.push(score); sum += score; count++; }); rowData.push(count > 0 ? (sum/count).toFixed(1) : 'N/A'); rowData.push(log.notesPositive.substring(0,30)+(log.notesPositive.length>30?'...':'')); rowData.push(log.notesChallenges.substring(0,30)+(log.notesChallenges.length>30?'...':'')); rowData.push(log.notesNextSteps.substring(0,30)+(log.notesNextSteps.length>30?'...':'')); return rowData; }); doc.autoTable({ head: [tableColumns], body: tableRows, startY: yPos, theme: 'grid', headStyles: { fillColor: primaryColorPDF, textColor: whiteColorPDF, fontSize: 7, fontStyle: 'bold', cellPadding:2 }, styles: { fontSize: 7, cellPadding: 2, textColor: textColorPDF, overflow: 'linebreak' }, columnStyles: { 0: {cellWidth: 50} } // Date column fixed width }); doc.save(`EngagementReport_${selectedSubject.replace(/\s+/g, '_')}.pdf`); } function checkPdfPageBreak(doc, currentY, spaceNeeded) { if (currentY + spaceNeeded > doc.internal.pageSize.getHeight() - 40) { // 40 for bottom margin doc.addPage(); return 40; } return currentY; }
Scroll to Top