From 3977c3652f72a6946155b2be1ec9c045ab5d8f10 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 6 Mar 2026 23:34:45 -0600 Subject: [PATCH] feat: redesign PDF template - clean modern layout with inline logo --- pdf/template.js | 627 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 504 insertions(+), 123 deletions(-) diff --git a/pdf/template.js b/pdf/template.js index 67fc5cc..c66fb6d 100755 --- a/pdf/template.js +++ b/pdf/template.js @@ -1,39 +1,49 @@ +// Inline base64 logo — avoids Puppeteer needing a live HTTP request to /static/ +const LOGO_B64 = 'iVBORw0KGgoAAAANSUhEUgAAAGsAAACbCAYAAABlLWUVAAAQAElEQVR4AexdC3AW1RW+f8CgQqsiCLUVLBjEKuADRFBQsCDgY6zAWAq2FijtjFL7tFUcRtvRqeNYW6Y+Z2oVHOigtCKPFDCgSAsICAFJEBTRVEDegYRHXtdz/nCT/Tf7uOfc/fffTXZnD3cf53zn3O/ec/fs/4ckTyRbbBggDZbcsbhN5YaOMpFgOKDOEq3BqtxY8FnF+gtkZfm9J6VMiUSC4QA5RTn58fipOgPnOVgHi0d+C8FkbXkXHbBEh8dAzZFlM5BnP2vXwTq27gKZX7WhTEoBmZRIGDwg58c2XvGu26A5DtZRGCgYI5EITFJgLlQeavYNRv7BbZO9yWCVv99JCnguJZKCkcqdHN3Q7ZB9tDIGKz1QoBHqTEr8CUe+ayvP27/twa8BPQ17xmCFsS4nPiBhYXR0eDij/NWjDSMFBw2DdWRtZ4CAtBfNVeLZr/pxgZGCPT1Ycu/MtjBSzukISsk9yIYc8gCu03t6sI7serAiGSngI6Kz8vAaXPWESA9WUDGed93eVCKNHLTp8XrXoLiFqSTyTh1Y0VNCqc6VVmdf8157GCQUBEykkYGz2w/6HHlB4fKr7BA1r2LHD0rxgCPnD9iTOqf3osEc25Zmg1y1anfl09x+y4otnfIk5ClHTnVd0JbruKXandur8DccrtHm0NbRJfDMSgF3dLnwwr7HwTDZiQx0GLgHyIad+IokayvaszKrw8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hKeNWHLRQU3PZKX36ZtqD+i3NIyIqj+DrnjD4/njZu6eADnYZfYwLspjERYPICr+k8wspXSCW5wj4yGwep66dD7RFhTJPFDTskf//YdeBkW9Zk19I7pzyUckjkMbX5jVqE0lO4Xdes3SRj9PEJKiMReiIA5mPhgfVYJ2BoGa9iYp16WkF6JQIZFiAcYo4a9YbDwyqTfrcD0wMNEIsCAfTwyBgvjQwWZg5e+xGdm5YjjgONhlSaDhTcn/355kmFIRI7EjX/HwcIY0UBGaO1uCbF0/mafucg78u8kroOFyj95aHkKBcYstDI1pr6M+UGeb7vnmbuRdzfxHCxlNAUGDUWcLktl8kwj/80xO2fIZX5+28PIK4rQ2LQGS+FMeagohfLTh4tSKHD97UQEiQPkDQV5vPfXC0g/Dv4V3Z9eXgAAAAVJREFUAAAA///yqks2AAAABklEQVQDAL3XqznDSjO2AAAAAElFTkSuQmCC'; + const TIERS = [ - { min: 0, max: 4, label: 'Tier 0-1 — Elite Standing', color: '#28a745' }, - { min: 5, max: 9, label: 'Tier 1 — Realignment', color: '#856404' }, - { min: 10, max: 14, label: 'Tier 2 — Administrative Lockdown', color: '#d9534f' }, - { min: 15, max: 19, label: 'Tier 3 — Verification', color: '#d9534f' }, - { min: 20, max: 24, label: 'Tier 4 — Risk Mitigation', color: '#c0392b' }, - { min: 25, max: 29, label: 'Tier 5 — Final Decision', color: '#c0392b' }, - { min: 30, max: 999,label: 'Tier 6 — Separation', color: '#721c24' }, + { min: 0, max: 4, label: 'Tier 0–1 — Elite Standing', color: '#16a34a', bg: '#f0fdf4' }, + { min: 5, max: 9, label: 'Tier 1 — Realignment', color: '#854d0e', bg: '#fefce8' }, + { min: 10, max: 14, label: 'Tier 2 — Administrative Lockdown', color: '#b45309', bg: '#fff7ed' }, + { min: 15, max: 19, label: 'Tier 3 — Verification', color: '#c2410c', bg: '#fff7ed' }, + { min: 20, max: 24, label: 'Tier 4 — Risk Mitigation', color: '#b91c1c', bg: '#fef2f2' }, + { min: 25, max: 29, label: 'Tier 5 — Final Decision', color: '#991b1b', bg: '#fef2f2' }, + { min: 30, max: 999, label: 'Tier 6 — Separation', color: '#ffffff', bg: '#7f1d1d' }, ]; -function getTier(points) { return TIERS.find(t => points >= t.min && points <= t.max) || TIERS[0]; } - -function formatDate(d) { - if (!d) return '—'; - const dt = new Date(d + 'T12:00:00'); - return dt.toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', timeZone: 'America/Chicago' }); +function getTier(pts) { + return TIERS.find(t => pts >= t.min && pts <= t.max) || TIERS[0]; } -function formatDateTime(d, t) { const date = formatDate(d); return t ? `${date} at ${t}` : date; } +function fmt(d) { + if (!d) return '—'; + return new Date(d + 'T12:00:00').toLocaleDateString('en-US', { + weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', + timeZone: 'America/Chicago', + }); +} -function row(label, value) { +function fmtDT(d, t) { return t ? `${fmt(d)} at ${t}` : fmt(d); } + +function field(label, value) { + if (!value) return ''; return ` - - ${label} - ${value || '—'} - `; +
+
${label}
+
${value}
+
`; } function buildHtml(v, score) { - const priorPts = score.active_points || 0; // snapshot at time of logging - const priorTier= getTier(priorPts); - const newTotal = priorPts + v.points; // math always based on stored snapshot - const newTier = getTier(newTotal); - const tierChange = priorTier.label !== newTier.label; - - const generatedAt = new Date().toLocaleString('en-US', { timeZone: 'America/Chicago', dateStyle: 'full', timeStyle: 'short' }); + const priorPts = score.active_points || 0; + const priorTier = getTier(priorPts); + const newTotal = priorPts + v.points; + const newTier = getTier(newTotal); + const escalated = priorTier.label !== newTier.label; + const genAt = new Date().toLocaleString('en-US', { + timeZone: 'America/Chicago', dateStyle: 'full', timeStyle: 'short', + }); + const docId = `CPAS-${v.id.toString().padStart(5, '0')}`; return ` @@ -41,128 +51,499 @@ function buildHtml(v, score) {
- +
-

CPAS Individual Violation Record

-

Message Point Media — Comprehensive Professional Accountability System

+
CPAS Violation Record
+
Comprehensive Professional Accountability System
-
Document ID: CPAS-${v.id.toString().padStart(5,'0')}
Generated: ${generatedAt}
+
+
${docId}
+
Generated ${genAt}
+
-
+
⚑ Confidential — Authorized HR & Management Use Only
-
⚠ CONFIDENTIAL — For authorized HR and management use only
+
-
-
Employee Information
- - ${row('Employee Name', `${v.employee_name}`)} - ${row('Department', v.department)} - ${row('Supervisor', v.supervisor)} - ${row('Witness / Documenting Officer', v.witness_name)} -
-
- -
-
Violation Details
- - ${row('Violation Type', `${v.violation_name}`)} - ${row('Category', v.category)} - ${row('Policy Reference', 'Chapter 4, Section 5 — Comprehensive Professional Accountability System (CPAS)')} - ${row('Incident Date / Time', formatDateTime(v.incident_date, v.incident_time))} - ${v.location ? row('Location / Context', v.location) : ''} - ${row('Submitted By', v.submitted_by || 'System')} -
- ${v.details ? `
Incident Details:
${v.details}
` : ''} -
- -
-
CPAS Point Assessment
-
${v.points}
Points Assessed — This Violation
-
-
-
${priorPts}
-
Active Points (Prior)
-
${priorTier.label}
+ +
+
+
Employee Information
+
-
+
-
-
${v.points}
-
Points — This Violation
-
-
=
-
-
${newTotal}
-
New Active Total
-
${newTier.label}
+
+
+
Employee Name
+
${v.employee_name}
+
+
+
Department
+
${v.department || '—'}
+
+
+
Supervisor
+
${v.supervisor || '—'}
+
+
+
Witness / Documenting Officer
+
${v.witness_name || '—'}
+
- ${tierChange ? `
⚠ Tier Escalation: This violation advances the employee from ${priorTier.label} to ${newTier.label}.
` : ''} -
-
-
CPAS Tier Reference
- - - ${TIERS.map(t => ``).join('')} -
PointsTier
${t.min === 30 ? '30+' : t.min + '–' + t.max}${t.label}
-
+ +
+
+
Violation Details
+
+
+
+
+
Violation
+
${v.violation_name}
+
+
+
Category
+
${v.category}
+
+
+
Incident Date / Time
+
${fmtDT(v.incident_date, v.incident_time)}
+
+
+
Submitted By
+
${v.submitted_by || 'System'}
+
+ ${v.location ? ` +
+
Location / Context
+
${v.location}
+
` : ''} +
+ ${v.details ? ` +
+
Incident Notes
+ ${v.details} +
` : ''} +
-
Employee Notice: CPAS points remain active for a rolling 90-day period from the date of each incident. Accumulation of points may result in tier escalation and associated consequences as outlined in the Employee Handbook.
+ +
+
+
CPAS Point Assessment
+
+
-
-
Acknowledgement & Signatures
-
-

By signing below, the employee acknowledges receipt of this violation record. Acknowledgement does not imply agreement. The employee may submit a written response within 5 business days.

+
+
${v.points}
+
+ Points Assessed + This violation +
+
+ +
+
+
${priorPts}
+
Prior Active Points
+ + ${priorTier.label} + +
+
+
+
+
${v.points}
+
This Violation
+
+
=
+
+
${newTotal}
+
New Active Total
+ + ${newTier.label} + +
+
+ + ${escalated ? ` +
+ +
+ Tier Escalation: + This violation advances the employee from ${priorTier.label} + to ${newTier.label}. +
+
` : ''} +
+ + +
+
+
CPAS Tier Reference
+
+
+ + + + + + + + + ${TIERS.map(t => { + const active = newTotal >= t.min && newTotal <= t.max; + const range = t.min === 30 ? '30+' : `${t.min}–${t.max}`; + return ` + + + `; + }).join('')} + +
PointsTier & Standing
${active ? '▶ ' : ''}${range} + + ${t.label} + ${active ? ' ← Current' : ''} +
+
+ + +
+ Employee Notice: CPAS points remain active for a rolling 90-day period from the date of each incident. + Accumulation of points may result in tier escalation and associated consequences as outlined in the Employee Handbook. + The employee may submit a written response within 5 business days of receiving this document. +
+ + +
+
+
Acknowledgement & Signatures
+
+
+

+ By signing below, the employee acknowledges receipt of this violation record. + Acknowledgement does not imply agreement with the violation as documented. +

-
-
Employee Signature
-
Date
+
+
+
Employee Signature
+ +
Date
-
-
Supervisor / Documenting Officer Signature
-
Date
+
+
+
Supervisor / Documenting Officer Signature
+ +
Date
-
- +