Smart Employee Task Request Form Generator

Smart Employee Task Request Form

Generate a professional task request ticket for your team.

Your generated task request will appear here.

DUE DATE

${formattedDueDate}

DESCRIPTION

${taskData.description}

`; downloadArea.classList.remove('hidden'); } function toggleModal(show) { if (show) { modal.classList.add('active'); } else { modal.classList.remove('active'); } } function setMinDueDate() { const today = new Date().toISOString().split('T')[0]; dueDateInput.setAttribute('min', today); dueDateInput.value = today; } // --- EVENT HANDLERS --- createRequestBtn.addEventListener('click', () => toggleModal(true)); cancelRequestBtn.addEventListener('click', () => toggleModal(false)); modal.addEventListener('click', (e) => { if (e.target === modal) toggleModal(false); }); requestForm.addEventListener('submit', (e) => { e.preventDefault(); const taskData = { requesterName: document.getElementById('requester-name').value.trim(), requesterDept: document.getElementById('requester-dept').value.trim(), description: document.getElementById('task-description').value.trim(), priority: document.getElementById('task-priority').value, dueDate: document.getElementById('task-due-date').value, requestDate: new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }) }; renderTaskCard(taskData); toggleModal(false); }); downloadPdfBtn.addEventListener('click', () => { const cardToDownload = document.getElementById('generated-task-card'); if (!cardToDownload) return; const originalBtnText = downloadPdfBtn.innerText; downloadPdfBtn.disabled = true; downloadPdfBtn.innerText = 'Generating...'; html2canvas(cardToDownload, { scale: 2, useCORS: true, logging: false }) .then(canvas => { const imgData = canvas.toDataURL('image/png'); const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const pdfWidth = doc.internal.pageSize.getWidth(); const imgProps = doc.getImageProperties(imgData); const imgHeight = (imgProps.height * pdfWidth) / imgProps.width; const margin = 15; const finalWidth = pdfWidth - (margin * 2); const finalHeight = (imgProps.height * finalWidth) / imgProps.width; doc.addImage(imgData, 'PNG', margin, margin, finalWidth, finalHeight); doc.save('task-request.pdf'); }) .catch(err => console.error("PDF generation failed:", err)) .finally(() => { downloadPdfBtn.disabled = false; downloadPdfBtn.innerText = originalBtnText; }); }); // --- INITIALIZATION --- setMinDueDate(); });
Scroll to Top