Task Progress Tracker

Task Progress Tracker

Add New Task

Current Tasks

Task Name Priority Due Date Assigned To Status Actions

Progress Summary

Overall Completion:

0%

${completedTasks}

In Progress

${inProgressTasks}

To Do

${toDoTasks}

Blocked

${blockedTasks}

`; } const progressBar = document.getElementById('tpt-overall-progress-bar'); if(progressBar) { progressBar.style.width = `${completionPercentage}%`; progressBar.textContent = `${completionPercentage}% Completed`; } } // PDF Download function tptDownloadPDF() { if (tptTasks.length === 0) { alert("No tasks to include in the report."); return; } let pdfHTML = `

Task Progress Report

`; pdfHTML += `

Report Date: ${new Date().toLocaleDateString()}

`; // Summary Section for PDF const totalTasks = tptTasks.length; const completedTasks = tptTasks.filter(t => t.status === 'Completed').length; const activeTasks = totalTasks - tptTasks.filter(t => t.status === 'Cancelled').length; const completionPercentage = activeTasks > 0 ? Math.round((completedTasks / activeTasks) * 100) : 0; pdfHTML += `

Progress Summary

`; pdfHTML += `
`; // Using classes for potential styling, though grid won't work same in PDF pdfHTML += `

Total Tasks: ${totalTasks}

`; pdfHTML += `

Completed: ${completedTasks}

`; pdfHTML += `

In Progress: ${tptTasks.filter(t => t.status === 'InProgress').length}

`; pdfHTML += `

To Do: ${tptTasks.filter(t => t.status === 'ToDo').length}

`; pdfHTML += `

Blocked: ${tptTasks.filter(t => t.status === 'Blocked').length}

`; pdfHTML += `
`; pdfHTML += `

Overall Completion: ${completionPercentage}% (Completed / (Total - Cancelled))

`; // Task List Table for PDF (Full list, not filtered/sorted as on screen, or apply default sort) pdfHTML += `

All Tasks

`; pdfHTML += ``; const sortedForPDF = [...tptTasks].sort((a,b) => a.priorityScore - b.priorityScore || (a.dueDateObj && b.dueDateObj ? a.dueDateObj - b.dueDateObj : 0)); sortedForPDF.forEach(task => { let dueDateDisplay = task.dueDate ? new Date(task.dueDate+"T00:00:00").toLocaleDateString() : 'N/A'; pdfHTML += ` `; }); pdfHTML += `
Task NamePriorityDue DateAssigned ToStatus
${task.name} ${task.priority} ${dueDateDisplay} ${task.assignee} ${task.status.replace(/([A-Z])/g, ' $1').trim()}
`; const pdfContainer = document.getElementById('tpt-report-content-for-pdf'); if(!pdfContainer) return; pdfContainer.innerHTML = pdfHTML; // Ensure status tag colors are applied directly for html2pdf pdfContainer.querySelectorAll('.tpt-status-tag').forEach(tag => { const statusClass = Array.from(tag.classList).find(cls => cls.startsWith('status-')); if(statusClass) { tag.style.backgroundColor = getComputedStyle(document.documentElement).getPropertyValue(`--${statusClass}-bg`).trim(); tag.style.color = getComputedStyle(document.documentElement).getPropertyValue(`--${statusClass}-text`).trim(); } }); const opt = { margin: [0.5, 0.3, 0.5, 0.3], filename: 'Task_Progress_Report.pdf', image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true, logging: false }, jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }, pagebreak: { mode: ['avoid-all', 'css', 'legacy'] } }; html2pdf().from(pdfContainer).set(opt).save().then(() => { pdfContainer.innerHTML = ''; }).catch(err => { console.error("Error generating PDF:", err); pdfContainer.innerHTML = ''; alert("An error occurred while generating the PDF. Check console for details."); }); }
Scroll to Top