Employee Work Log Generator

Add New Work Log Entry

Today's Entries / Uncommitted

Date Start End Duration Task Category Actions
No entries added yet for today.

Generate Work Log Report

Manage Projects/Categories

Projects/Categories

    Employee: ${employeeName || 'N/A'}

    `; if (ewlEmployeeIdEl.value) previewInfoDiv.innerHTML += `

    ID: ${ewlEmployeeIdEl.value}

    `; if (ewlDepartmentEl.value) previewInfoDiv.innerHTML += `

    Department: ${ewlDepartmentEl.value}

    `; previewInfoDiv.innerHTML += `

    Log Period: ${new Date(startDate+'T00:00:00').toLocaleDateString()} - ${new Date(endDate+'T00:00:00').toLocaleDateString()}

    `; if (ewlPreviewedEntries.length === 0) { noPreviewDataMsg.style.display = 'block'; document.querySelector('#ewlPreviewSection .ewl-preview-table thead').style.display = 'none'; ewlDownloadPdfBtn.style.display = 'none'; } else { noPreviewDataMsg.style.display = 'none'; document.querySelector('#ewlPreviewSection .ewl-preview-table thead').style.display = ''; ewlDownloadPdfBtn.style.display = 'inline-block'; let totalDurationMs = 0; ewlPreviewedEntries.forEach(entry => { const row = previewTableBody.insertRow(); row.insertCell().textContent = new Date(entry.date+'T00:00:00').toLocaleDateString(); row.insertCell().textContent = entry.startTime; row.insertCell().textContent = entry.endTime; row.insertCell().textContent = ewlFormatDuration(entry.durationMs); row.insertCell().textContent = entry.taskDescription; row.insertCell().textContent = entry.projectCategory || 'N/A'; row.insertCell().textContent = entry.comments || 'N/A'; totalDurationMs += entry.durationMs; }); document.getElementById('ewlTotalHoursPreview').textContent = `Total Hours for Period: ${ewlFormatDuration(totalDurationMs)}`; } ewlPreviewSection.style.display = 'block'; } // PDF Download function ewlDownloadPDF() { if (ewlPreviewedEntries.length === 0) { alert("No data previewed to export. Please click 'Preview Log' first."); return; } const employeeName = ewlEmployeeNameEl.value.trim() || "N/A"; const employeeId = ewlEmployeeIdEl.value.trim() || "N/A"; const department = ewlDepartmentEl.value.trim() || "N/A"; const logStartDate = ewlLogStartDateEl.value; const logEndDate = ewlLogEndDateEl.value; const { jsPDF } = window.jspdf; const doc = new jsPDF('p', 'pt', 'a4'); // Using points for better control with autoTable const primaryColorPDF = getComputedStyle(document.documentElement).getPropertyValue('--ewl-primary-color').trim(); const whiteColorPDF = getComputedStyle(document.documentElement).getPropertyValue('--ewl-white-color').trim(); let yPos = 40; doc.setFontSize(18); doc.setTextColor(primaryColorPDF); doc.text("Employee Work Log", 40, yPos); yPos += 30; doc.setFontSize(11); doc.setTextColor(50); // Grey doc.text(`Employee Name: ${employeeName}`, 40, yPos); yPos += 15; if (ewlEmployeeIdEl.value) { doc.text(`Employee ID: ${employeeId}`, 40, yPos); yPos += 15;} if (ewlDepartmentEl.value) {doc.text(`Department: ${department}`, 40, yPos); yPos += 15;} doc.text(`Log Period: ${new Date(logStartDate+'T00:00:00').toLocaleDateString()} - ${new Date(logEndDate+'T00:00:00').toLocaleDateString()}`, 40, yPos); yPos += 15; doc.text(`Report Generated: ${new Date().toLocaleString()}`, 40, yPos); yPos += 25; const tableColumn = ["Date", "Start", "End", "Duration", "Task Description", "Project/Category", "Comments"]; const tableRows = []; let totalDurationMsPDF = 0; ewlPreviewedEntries.forEach(entry => { tableRows.push([ new Date(entry.date+'T00:00:00').toLocaleDateString(), entry.startTime, entry.endTime, ewlFormatDuration(entry.durationMs), entry.taskDescription, entry.projectCategory || 'N/A', entry.comments || 'N/A' ]); totalDurationMsPDF += entry.durationMs; }); doc.autoTable({ head: [tableColumn], body: tableRows, startY: yPos, theme: 'grid', headStyles: { fillColor: primaryColorPDF, textColor: whiteColorPDF, fontStyle: 'bold' }, styles: { fontSize: 9, cellPadding: 5, overflow: 'linebreak' }, // overflow linebreak for long text columnStyles: { 0: { cellWidth: 55 }, // Date 1: { cellWidth: 40 }, // Start 2: { cellWidth: 40 }, // End 3: { cellWidth: 50 }, // Duration 4: { cellWidth: 150 }, // Task Description 5: { cellWidth: 80 }, // Category 6: { cellWidth: 'auto'} // Comments }, didDrawPage: function (data) { // Add footer to each page if needed // doc.setFontSize(9); // doc.text('Page ' + doc.internal.getNumberOfPages(), data.settings.margin.left, doc.internal.pageSize.height - 10); } }); yPos = doc.lastAutoTable.finalY + 20; if (yPos > doc.internal.pageSize.height - 30) { // Check for page break before summary doc.addPage(); yPos = 40; } doc.setFontSize(12); doc.setFont(undefined, 'bold'); doc.setTextColor(primaryColorPDF); doc.text(`Total Hours for Period: ${ewlFormatDuration(totalDurationMsPDF)}`, 40, yPos); doc.save(`WorkLog_${employeeName.replace(/\s+/g, '_')}_${logStartDate}_to_${logEndDate}.pdf`); }
    Scroll to Top