Auto Work Shift Rotator

Auto Work Shift Rotator

Schedule Period

Employees

    Shifts

    Define shifts in the desired rotation order (e.g., M, E, N, OFF). Include a shift for 'Day Off' if needed.

      Please complete the setup on the first tab and click "Generate Roster".

      Employees: ${awsrEmployees.join(', ')}

      Shifts Defined: ${awsrShifts.join(', ')}

      `; awsrEmployees.forEach(empName => { tableHTML += ``; }); tableHTML += ``; rosterData.forEach(dayEntry => { tableHTML += ``; awsrEmployees.forEach(empName => { tableHTML += ``; }); tableHTML += ``; }); tableHTML += `
      Date${empName}
      ${awsrFormatRosterDate(dayEntry.date)}${dayEntry.assignments[empName] || '-'}
      `; const rosterOutputEl = document.getElementById('awsr-roster-output'); if (rosterOutputEl) rosterOutputEl.innerHTML = tableHTML; awsrOpenTab(null, 'awsr-roster'); awsrUpdateNavButtons(); } function awsrDownloadPDF() { const rosterOutputElement = document.getElementById('awsr-roster-output'); if (!rosterOutputElement || rosterOutputElement.innerHTML.includes("Please complete the setup")) { alert("Please generate a roster first before downloading."); return; } // For PDF, we might want a slightly different structure or to ensure all content is visible const pdfContentClone = rosterOutputElement.cloneNode(true); const titleElement = document.createElement('h2'); titleElement.innerText = "Work Shift Roster"; const pdfContainer = document.getElementById('awsr-report-content-for-pdf'); if(!pdfContainer) return; pdfContainer.innerHTML = ''; pdfContainer.appendChild(titleElement); pdfContainer.appendChild(pdfContentClone); const opt = { margin: [0.4, 0.2, 0.4, 0.2], // inches t,l,b,r filename: 'Work_Shift_Roster.pdf', image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true, logging: false, width: pdfContainer.scrollWidth, windowWidth: pdfContainer.scrollWidth }, jsPDF: { unit: 'in', format: 'letter', orientation: 'landscape' } // Landscape often better for rosters }; 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