Online Remote Employee Onboarding System

Remote Employee Onboarding System

Session ID: Loading... (Share with your team)

Add a new employee in the Data Configuration tab to begin.

`; return; } for (const [empId, emp] of Object.entries(employees)) { const { total, completed } = calculateProgress(emp.onboardingPlan); const progressPercent = total > 0 ? (completed / total) * 100 : 0; const card = document.createElement('div'); card.className = 'bg-white p-4 rounded-lg shadow-md'; card.innerHTML = `

${emp.name}

Onboarding Progress

${completed} / ${total} Tasks
`; container.appendChild(card); } document.querySelectorAll('.view-details-btn').forEach(btn => { btn.addEventListener('click', e => openDetailsModal(e.currentTarget.dataset.empId)); }); } function calculateProgress(plan) { let total = 0; let completed = 0; if (!plan) return { total, completed }; for (const stage of Object.values(plan)) { for (const item of Object.values(stage.items)) { total++; if (item.completed) completed++; } } return { total, completed }; } // --- DATABASE OPERATIONS --- document.getElementById('addEmployeeBtn').addEventListener('click', async () => { const name = document.getElementById('employeeNameInput').value.trim(); if (!name) return showMessage("Employee name is required.", true); const empId = 'emp_' + Date.now(); const newEmployee = { name, onboardingPlan: createDefaultPlan() }; await updateDoc(sessionDocRef, { [`employees.${empId}`]: newEmployee }); document.getElementById('employeeNameInput').value = ''; showMessage("Employee added and onboarding plan created."); }); async function updateChecklistItem(empId, stageKey, itemKey, completed) { const path = `employees.${empId}.onboardingPlan.${stageKey}.items.${itemKey}.completed`; await updateDoc(sessionDocRef, { [path]: completed }); } function createDefaultPlan() { return { welcome: { title: 'Welcome Aboard!', items: { item1: { text: 'Sign and return offer letter', completed: false }, item2: { text: 'Complete new hire profile in HR system', completed: false }, item3: { text: 'Review company handbook and policies', completed: false }, }}, paperwork: { title: 'Paperwork & Logistics', items: { item1: { text: 'Submit I-9 and W-4 forms', completed: false }, item2: { text: 'Set up direct deposit', completed: false }, item3: { text: 'Confirm equipment shipment and setup (laptop, monitor, etc.)', completed: false }, }}, training: { title: 'Training & Tools', items: { item1: { text: 'Complete security awareness training', completed: false }, item2: { text: 'Get access to essential software (Slack, Jira, etc.)', completed: false }, item3: { text: 'Review role-specific training materials', completed: false }, }}, team: { title: 'Team Introduction', items: { item1: { text: '1-on-1 meeting with manager', completed: false }, item2: { text: 'Attend team introduction meeting', completed: false }, item3: { text: 'Schedule introductory chats with key team members', completed: false }, }}, }; } // --- MODAL LOGIC --- const modal = document.getElementById('detailsModal'); const modalHeader = document.getElementById('modalHeader'); const modalBody = document.getElementById('modalBody'); function openDetailsModal(empId) { const employee = sessionData.employees[empId]; if (!employee) return; modalHeader.textContent = `Onboarding for ${employee.name}`; modalBody.innerHTML = ''; for (const [stageKey, stage] of Object.entries(employee.onboardingPlan)) { let itemsHtml = ''; for (const [itemKey, item] of Object.entries(stage.items)) { itemsHtml += ` `; } modalBody.innerHTML += `

${stage.title}

${itemsHtml}
`; } modal.classList.remove('hidden'); setTimeout(() => { modal.classList.remove('opacity-0'); modal.querySelector('.modal-content').classList.remove('scale-95'); }, 10); // Add event listeners to checkboxes modalBody.querySelectorAll('input[type="checkbox"]').forEach(checkbox => { checkbox.addEventListener('change', e => { const { empId, stageKey, itemKey } = e.target.dataset; updateChecklistItem(empId, stageKey, itemKey, e.target.checked); }); }); } function closeModal() { modal.classList.add('opacity-0'); modal.querySelector('.modal-content').classList.add('scale-95'); setTimeout(() => modal.classList.add('hidden'), 300); } document.getElementById('closeModalBtn').addEventListener('click', closeModal); modal.addEventListener('click', e => { if (e.target === modal) closeModal(); }); // --- UI & PDF --- const tabs = document.querySelectorAll('.tab-content'); const tabLinks = document.querySelectorAll('.tab-link'); function showTab(tabIndex) { tabs.forEach((tab, index) => { tab.style.display = (index === tabIndex) ? 'block' : 'none'; }); tabLinks.forEach((link, index) => { link.classList.toggle('active', index === tabIndex); link.classList.toggle('inactive', index !== tabIndex); }); }; tabLinks.forEach((link, index) => { link.addEventListener('click', () => showTab(index)); }); document.getElementById('downloadPdfBtn').addEventListener('click', () => { const { jsPDF } = window.jspdf; const doc = new jsPDF(); const { employees } = sessionData; const pageHeight = doc.internal.pageSize.height; const margin = 15; let y = margin; doc.setFontSize(22); doc.setFont("helvetica", "bold"); doc.text("Employee Onboarding Report", doc.internal.pageSize.width / 2, y, { align: 'center' }); y += 10; doc.setFontSize(12); doc.setFont("helvetica", "normal"); doc.text(`Session ID: ${currentSessionId}`, doc.internal.pageSize.width / 2, y, { align: 'center' }); y += 15; for (const emp of Object.values(employees)) { const { total, completed } = calculateProgress(emp.onboardingPlan); if (y + 30 > pageHeight - margin) { doc.addPage(); y = margin; } doc.setFontSize(16); doc.setFont("helvetica", "bold"); doc.text(`${emp.name} - Progress: ${completed}/${total}`, margin, y); y += 10; doc.setFontSize(12); doc.setFont("helvetica", "normal"); for (const stage of Object.values(emp.onboardingPlan)) { for (const item of Object.values(stage.items)) { const itemText = `[${item.completed ? 'x' : ' '}] ${item.text}`; const lines = doc.splitTextToSize(itemText, doc.internal.pageSize.width - margin * 2 - 5); if (y + (lines.length * 7) > pageHeight - margin) { doc.addPage(); y = margin; } doc.text(lines, margin + 5, y); y += lines.length * 7; } } y += 5; } doc.save(`onboarding-report-${currentSessionId}.pdf`); }); function showMessage(message, isError = false) { const box = document.getElementById('messageBox'); box.textContent = message; box.className = `fixed top-5 right-5 text-white py-2 px-4 rounded-lg shadow-lg ${isError ? 'bg-red-500' : 'bg-green-500'}`; setTimeout(() => { box.className += ' hidden'; }, 3000); } // Initialize with the first tab visible showTab(0); });
Scroll to Top