Workload Adjustment Recommender

Workload Adjustment Recommender

Analysis Period (Optional for immediate load assessment)

Current Tasks/Projects

    Your Capacity & Well-being

    Input your workload and capacity details on the first tab, then click "Get Adjustment Recommendations".

    Your Action Plan Notes:

    Total Estimated Work Hours Remaining: ${totalWorkloadHours.toFixed(1)}h

    Analysis Period Capacity: ${capacityHours.toFixed(1)}h (over ${analysisWeeks} week(s) at ${availableHoursPerWeek}h/week)

    ${workloadAnalysisText}

    `; reportHTML += `

    Your Well-being Input

    Current Stress Level: ${stressLevel}/5

    Current Energy Level: ${energyLevel}/5

    ${contributingFactors.length > 0 ? `

    Reported Factors: ${contributingFactors.join(', ')}

    ` : ''}
    `; reportHTML += `

    Recommended Adjustments & Strategies

    `; if (recommendations.length > 0) { reportHTML += `
      `; recommendations.forEach(rec => reportHTML += `
    • ${rec}
    • `); reportHTML += `
    `; } else { reportHTML += `

    No specific automated recommendations triggered. Review your inputs for personal insights.

    `; } reportHTML += `
    `; const reportDisplayEl = document.getElementById('war-recommendation-report-display'); if(reportDisplayEl) reportDisplayEl.innerHTML = reportHTML; warReportData.recommendationsHTML = reportHTML; // Store for PDF warOpenTab(null, 'war-report'); warUpdateNavButtons(); } // PDF Download function warDownloadPDF() { const reportDisplayElement = document.getElementById('war-recommendation-report-display'); if (!reportDisplayElement || reportDisplayElement.innerHTML.includes("Input your workload") || !warReportData.tasks) { alert("Please get recommendations first."); return; } let pdfHTML = `

    Workload Adjustment Report

    `; pdfHTML += `

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

    `; pdfHTML += `

    1. Your Current Workload

    `; pdfHTML += ``; const sortedTasksForPDF = [...warReportData.tasks].sort((a, b) => { const prioA = WAR_PRIORITY_MAP_PDF[a.priority] || 99; const prioB = WAR_PRIORITY_MAP_PDF[b.priority] || 99; if (prioA !== prioB) return prioA - prioB; if (a.dueDateObj && b.dueDateObj) return a.dueDateObj - b.dueDateObj; if (a.dueDateObj) return -1; if (b.dueDateObj) return 1; return 0; }); sortedTasksForPDF.forEach(task => { let dueDateDisplay = task.dueDate ? new Date(task.dueDate + "T00:00:00").toLocaleDateString() : "N/A"; pdfHTML += ``; }); pdfHTML += `
    Task NameEst. Hrs Rem.PriorityDue Date
    ${task.name}${task.effort.toFixed(1)}${task.priority}${dueDateDisplay}
    `; pdfHTML += `

    Total Estimated Work Hours: ${warReportData.tasks.reduce((sum,t)=>sum+t.effort,0).toFixed(1)}h

    `; pdfHTML += `

    2. Your Capacity & Well-being

    `; pdfHTML += `

    Analysis Period: Next ${warReportData.analysisWeeks} week(s)

    `; pdfHTML += `

    Available Work Hours Per Week: ${warReportData.availableHoursPerWeek}h

    `; pdfHTML += `

    Current Stress Level: ${warReportData.stressLevel}/5

    `; pdfHTML += `

    Current Energy Level: ${warReportData.energyLevel}/5

    `; if(warReportData.contributingFactors.length > 0) { pdfHTML += `

    Reported Contributing Factors:

      `; warReportData.contributingFactors.forEach(f => pdfHTML += `
    • ${f}
    • `); pdfHTML += `
    `; } // Use the already generated HTML for analysis and recommendations from the display // Need to extract the specific parts from warReportData.recommendationsHTML or re-generate for PDF context const workloadSnapshotHTML = reportDisplayElement.querySelector('.war-report-section:first-of-type') ? reportDisplayElement.querySelector('.war-report-section:first-of-type').innerHTML : ''; const recommendationsHTMLSection = Array.from(reportDisplayElement.querySelectorAll('.war-report-section')).find(el => el.textContent.includes("Recommended Adjustments")); const recommendationsContent = recommendationsHTMLSection ? recommendationsHTMLSection.innerHTML : '

    No recommendations generated.

    '; pdfHTML += `
    ${workloadSnapshotHTML.replace('

    Workload Snapshot

    ', '

    3. Workload Analysis

    ')}`; pdfHTML += `
    ${recommendationsContent.replace('

    Recommended Adjustments & Strategies

    ', '

    4. Recommended Adjustments & Strategies

    ')}`; const actionPlanNotes = document.getElementById('war-action-plan-notes').value.trim(); if (actionPlanNotes) { pdfHTML += `

    5. Your Action Plan Notes

    `; pdfHTML += `

    ${actionPlanNotes.replace(/\n/g, '
    ')}

    `; } const pdfContainer = document.getElementById('war-report-content-for-pdf'); pdfContainer.innerHTML = pdfHTML; // Apply critical styles that might be lost by html2pdf pdfContainer.querySelectorAll('.workload-comparison').forEach(el => { if (el.classList.contains('workload-high')) { el.style.backgroundColor = getComputedStyle(document.documentElement).getPropertyValue('--danger-color'); el.style.color = 'white';} else if (el.classList.contains('workload-balanced')) { el.style.backgroundColor = getComputedStyle(document.documentElement).getPropertyValue('--success-color'); el.style.color = 'white';} else if (el.classList.contains('workload-low')) { el.style.backgroundColor = getComputedStyle(document.documentElement).getPropertyValue('--warning-color'); el.style.color = getComputedStyle(document.documentElement).getPropertyValue('--text-color');} }); const opt = { margin: [0.6, 0.5, 0.6, 0.5], filename: 'Workload_Adjustment_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