Contract Management Workflow Automation
Design a custom, step-by-step workflow for your contract management process.
General Workflow Information
Build Your Workflow Stages
Your Generated Workflow
Total Estimated Duration: ${totalDuration} Day(s)
`; }; const handleDownloadPdf = async () => { const { jsPDF } = window.jspdf; const content = document.getElementById('workflow-output-content'); if (!content) return; const originalButtonText = downloadPdfBtn.innerHTML; downloadPdfBtn.innerHTML = 'Generating...'; downloadPdfBtn.disabled = true; try { const canvas = await html2canvas(content, { scale: 2, backgroundColor: '#ffffff' }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF('p', 'mm', 'a4'); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgProps = pdf.getImageProperties(imgData); const imgHeight = (imgProps.height * pdfWidth) / imgProps.width; let position = 10; pdf.addImage(imgData, 'PNG', 10, position, pdfWidth - 20, imgHeight); pdf.save(`${(document.getElementById('workflow-title').value || 'contract_workflow').replace(/\s+/g, '_')}.pdf`); } catch (error) { console.error("PDF generation failed:", error); } finally { downloadPdfBtn.innerHTML = originalButtonText; downloadPdfBtn.disabled = false; } }; // Event Listeners tabButtons.forEach((btn, i) => btn.addEventListener('click', () => switchTab(i + 1))); prevBtn.addEventListener('click', () => switchTab(currentTab - 1)); nextBtn.addEventListener('click', () => switchTab(currentTab + 1)); addStageBtn.addEventListener('click', () => addStage()); downloadPdfBtn.addEventListener('click', handleDownloadPdf); // Initial setup addStage('Contract Drafting', 'Sales Team', '2'); addStage('Internal Review', 'Sales Manager', '1'); addStage('Legal Review', 'Legal Department', '3'); addStage('Client Negotiation', 'Sales Team', '5'); addStage('Final Approval', 'Department Head', '1'); addStage('Signature & Execution', 'All Parties', '2'); updateNavButtons(); });