Smart Worklog Generator

Smart Worklog Generator

Create/Edit Task Template

Your Task Templates

NameDescriptionCategoryEst. DurationActions

Quick Add From Templates:

Log Custom or Template-Based Task:

Worklog for

Total Time Logged: 00:00

DescriptionCategory/ProjectStartEndDurationNotesActions
'; } } // PDF Download function swg_downloadPDF() { const logDate = document.getElementById('swg_logDate').value; const entriesForDate = swg_dailyWorklogEntries.filter(e => e.date === logDate).sort((a,b) => a.startTime.localeCompare(b.startTime)); if (entriesForDate.length === 0) { alert("No worklog entries for this date to download."); return; } const doc = new jsPDF(); const primaryColorPDF = getComputedStyle(document.documentElement).getPropertyValue('--primary-color').trim(); const textColorPDF = getComputedStyle(document.documentElement).getPropertyValue('--text-color').trim(); const whiteColorPDF = '#FFFFFF'; doc.setFontSize(18); doc.setTextColor(primaryColorPDF); doc.text("Daily Worklog Report", 14, 20); doc.setFontSize(10); doc.setTextColor(textColorPDF); doc.text(`Date: ${logDate}`, 14, 28); doc.text(`Generated On: ${SWG_GENERATED_ON_STRING}`, 14, 33); let currentY = 45; let totalMinutes = 0; const categoryTimesPDF = {}; entriesForDate.forEach(entry => { totalMinutes += entry.durationMinutes; categoryTimesPDF[entry.category] = (categoryTimesPDF[entry.category] || 0) + entry.durationMinutes; }); doc.setFontSize(12); doc.setFont(undefined, 'bold'); doc.setTextColor(primaryColorPDF); doc.text("Summary:", 14, currentY); currentY += 7; doc.setFontSize(10); doc.setFont(undefined, 'normal'); doc.setTextColor(textColorPDF); doc.text(`Total Hours Logged: ${swg_formatMinutesToHHMM(totalMinutes)}`, 16, currentY); currentY += 7; doc.setFont(undefined, 'bold'); doc.text("Time by Category/Project:", 16, currentY); currentY +=6; doc.setFont(undefined, 'normal'); if (Object.keys(categoryTimesPDF).length > 0) { Object.entries(categoryTimesPDF).sort((a,b)=>b[1]-a[1]).forEach(([cat, min]) => { if (currentY > 270) { doc.addPage(); currentY = 20;} doc.text(`- ${cat}: ${swg_formatMinutesToHHMM(min)}`, 18, currentY); currentY +=5; }); } else { doc.text("- No categories logged.", 18, currentY); currentY +=5; } currentY += 5; doc.setFontSize(12); doc.setFont(undefined, 'bold'); doc.setTextColor(primaryColorPDF); if (currentY > 250) { doc.addPage(); currentY = 20; } doc.text("Detailed Worklog:", 14, currentY); currentY += 7; const tableData = entriesForDate.map(e => [ e.description, e.category, e.startTime, e.endTime, swg_formatMinutesToHHMM(e.durationMinutes), e.notes || '-' ]); doc.autoTable({ startY: currentY, head: [['Description', 'Category/Project', 'Start', 'End', 'Duration', 'Notes']], body: tableData, theme: 'grid', headStyles: { fillColor: primaryColorPDF, textColor: whiteColorPDF, fontSize: 9 }, styles: { fontSize: 8, cellPadding: 1.5, overflow: 'linebreak' }, columnStyles: { 0: { cellWidth: 60 }, 5: { cellWidth: 'auto'} } }); doc.save(`Daily_Worklog_${logDate}.pdf`); }
Scroll to Top