Online
Notifications
html += '
'; html += '
Name
' + esc(w.first_name + ' ' + (w.last_name||'')) + '
'; html += '
Position
' + esc(w.position||'\u2014') + '
'; html += '
Division
' + esc(w.division_name||'\u2014') + '
'; html += '
Hourly Rate
$' + (Number(w.hourly_rate)||0).toFixed(2) + '
'; html += '
Hire Date
' + (w.hire_date ? new Date(w.hire_date).toLocaleDateString() : '\u2014') + '
'; html += '
Pay Type
' + esc(w.pay_type||'hourly') + '
'; html += '
'; // Reports To section if (w.manager_name || w.supervisor_name) { html += '
Reports To
'; html += '
'; html += '
Manager
' + esc(w.manager_name||'\u2014') + '
'; html += '
Supervisor
' + esc(w.supervisor_name||'\u2014') + '
'; html += '
'; } html += '
Certifications
'; html += '
'; if (certs.length === 0) { html += '
No certifications yet
'; } else { html += '
'; for (const cert of certs) { html += ''; html += ''; html += ''; html += ''; html += ''; } html += '
NameIssuerIssue DateExpiryStatus
' + esc(cert.name) + '' + esc(cert.issuer||'—') + '' + (cert.issue_date ? new Date(cert.issue_date).toLocaleDateString() : '—') + '' + (cert.expiry_date ? new Date(cert.expiry_date).toLocaleDateString() : '—') + '' + certBadge(cert.expiry_date) + '
'; } html += '
'; main.innerHTML = html; } let editingCertId = null; function openCertModal(cert) { editingCertId = cert ? cert.id : null; document.getElementById("cert-modal").style.display = "flex"; document.getElementById("cert-modal-title").textContent = cert ? "Edit Certification" : "Add Certification"; document.getElementById("cert-name").value = cert ? cert.name : ""; document.getElementById("cert-issuer").value = cert ? (cert.issuer||"") : ""; document.getElementById("cert-number").value = cert ? (cert.certificate_number||"") : ""; document.getElementById("cert-issue-date").value = cert ? (cert.issue_date ? cert.issue_date.substring(0,10) : "") : ""; document.getElementById("cert-expiry-date").value = cert ? (cert.expiry_date ? cert.expiry_date.substring(0,10) : "") : ""; } function closeCertModal() { document.getElementById("cert-modal").style.display = "none"; editingCertId = null; } async function editCert(id) { const certs = await apiGet("/my-certifications").catch(() => []); const cert = (Array.isArray(certs) ? certs : []).find(c => c.id === id); if (cert) openCertModal(cert); } async function saveCert() { const body = { name: document.getElementById("cert-name").value.trim(), issuer: document.getElementById("cert-issuer").value.trim() || null, certificate_number: document.getElementById("cert-number").value.trim() || null, issue_date: document.getElementById("cert-issue-date").value || null, expiry_date: document.getElementById("cert-expiry-date").value || null }; if (!body.name) { toast("Certification name is required", "danger"); return; } try { if (editingCertId) { await api("/api/my-certifications/" + editingCertId, { method: "PATCH", body: JSON.stringify(body) }); toast("Certification updated"); } else { await api("/api/my-certifications", { method: "POST", body: JSON.stringify(body) }); toast("Certification added"); } closeCertModal(); loadMyProfile(); } catch(e) { toast(e.message, "danger"); } }
Online
Notifications