{{-- ══════════════════════════════════════════════════════ PAGE HEADER ══════════════════════════════════════════════════════ --}} {{-- ══════════════════════════════════════════════════════ PROCESS OVERVIEW ══════════════════════════════════════════════════════ --}}
Process Overview
@if(!empty($metadata['submitted_by'])) @endif @if($metadata['completed_at']) @endif @if($metadata['total_duration']) @endif @if($metadata['escalation_time']) @endif @if($metadata['risk_level']) @endif
Workflow{{ $metadata['workflow_name'] }} ({{ $metadata['version'] }})
Process ID#{{ $metadata['process_id'] }}
Status{{ $metadata['status'] }}
Submitted By{{ $metadata['submitted_by']['name'] }}  ·  {{ $metadata['submitted_by']['email'] }}
Initiated At{{ $metadata['initiated_at'] ?? '—' }}
Completed At{{ $metadata['completed_at'] }}
Total Duration{{ $metadata['total_duration'] }}
Escalation Time{{ $metadata['escalation_time'] }}
Risk Level{{ $metadata['risk_level'] }}
Sub-Workflows{{ $metadata['sub_workflows'] }}
Total Levels {{ $metadata['total_levels'] }} @foreach($metadata['task_counts'] as $tc)  ·  Level {{ $tc['level'] }}: {{ $tc['count'] }} task{{ $tc['count'] != 1 ? 's' : '' }} @endforeach
{{-- ══════════════════════════════════════════════════════ INITIAL SUBMISSION ══════════════════════════════════════════════════════ --}}
Initial Submission
@if($submission['form_name'])
Form: {{ $submission['form_name'] }}
@endif @if(!empty($submission['submitted_by'])) @endif
Submitted By {{ $submission['submitted_by']['name'] }}  ·  {{ $submission['submitted_by']['email'] }}
Submitted At{{ $submission['submitted_at'] ?? '—' }}
@if(!empty($submission['fields'])) @foreach($submission['fields'] as $field) @endforeach
FieldValue
{{ $field['label'] }} @if(($field['value'] ?? null) === null || $field['value'] === '') (not filled) @elseif(($field['type'] ?? '') === 'signature') [Signature] @elseif(($field['type'] ?? '') === 'file') [File uploaded] @else {{ \App\Support\FormValueText::forReport($field) }} @endif
@else
No form fields recorded.
@endif
{{-- ══════════════════════════════════════════════════════ CHRONOLOGICAL EVENT STREAM ══════════════════════════════════════════════════════ --}} @php $currentLevel = null; @endphp @foreach($events as $event) {{-- Level Section Header (when level changes) --}} @if(in_array($event['type'], ['task_action', 'pending_task']) && $event['level_number'] !== $currentLevel) @php $currentLevel = $event['level_number']; @endphp
Level {{ $event['level_number'] }}
@endif {{-- ── Task Action ── --}} @if($event['type'] === 'task_action') @php $actionBadge = match($event['action']) { 'approve' => 'action-approved', 'reject' => 'action-reject', 'send_back' => 'action-send_back', default => 'action-pending', }; $actionLabel = match($event['action']) { 'approve' => 'Approved', 'reject' => 'Rejected', 'send_back' => 'Send Back', default => ucfirst($event['action']), }; @endphp
Level {{ $event['level_number'] }}  ·  Task {{ $event['task_number'] }}  ·  {{ $event['task_name'] }}
{{ $actionLabel }}

{{-- Assignees --}}
Assignees
@if(!empty($event['assignees']) && count($event['assignees']) > 0) {{ implode('  ·  ', array_map(fn($u) => ($u->name ?? $u['name'] ?? '') . ' (' . ($u->email ?? $u['email'] ?? '') . ')', (array)$event['assignees'])) }} @else — @endif
{{-- Actioned By --}} @if(!empty($event['actioned_by']))
Actioned By
{{ $event['actioned_by']['name'] }}  ({{ $event['actioned_by']['email'] }})
@endif {{-- Comments --}} @if(!empty($event['comments']))
Comments
"{{ $event['comments'] }}"
@endif {{-- Approver Form --}} @if(!empty($event['form_fields']))
Approver Form{{ $event['form_name'] ? ': ' . $event['form_name'] : '' }}
@foreach($event['form_fields'] as $ff) @endforeach
FieldValue
{{ $ff['label'] }} @if(($ff['value'] ?? null) === null || $ff['value'] === '') (not filled) @elseif(($ff['type'] ?? '') === 'signature') [Signature] @elseif(($ff['type'] ?? '') === 'file') [File uploaded] @else {{ \App\Support\FormValueText::forReport($ff) }} @endif
@endif {{-- Documents --}}
Documents
@if(!empty($event['documents'])) @foreach($event['documents'] as $doc) {{ $doc['name'] ?? 'File' }}@if(!$loop->last), @endif @endforeach @else None @endif
{{-- Timing & SLA --}}
Completed At
{{ $event['completed_at'] ?: '—' }}
@if($event['expected_sla_at'])
Expected SLA
{{ $event['expected_sla_at'] }} @if($event['sla_duration_minutes']) ({{ $event['sla_duration_minutes'] >= 60 ? intdiv($event['sla_duration_minutes'], 60) . 'h' . ($event['sla_duration_minutes'] % 60 > 0 ? ' ' . ($event['sla_duration_minutes'] % 60) . 'm' : '') : $event['sla_duration_minutes'] . ' min' }} from activation) @endif
SLA Status
@if($event['sla_breached'] === true) ⚠ SLA Breached{{ $event['sla_overrun'] ? ' (by ' . $event['sla_overrun'] . ')' : '' }} @elseif($event['sla_breached'] === false) ✓ Within SLA @else — @endif
@endif
@endif {{-- ── Send Back Block ── --}} @if($event['type'] === 'send_back')
↩ Send Back #{{ $event['send_back_number'] }}  ·  {{ $event['created_at'] }}
@if(!empty($event['recipients']))
Recipients
@foreach($event['recipients'] as $r) @endforeach
RecipientReturn Route
{{ $r['label'] }} @if(!empty($r['responsible_user']))  ({{ $r['responsible_user']['name'] ?? $r['responsible_user']['email'] }}) @endif {{ $r['return_route'] ?: '—' }}
@endif
@endif {{-- ── Correction Entry ── --}} @if($event['type'] === 'correction')
🔄 Correction  ·  Send Back #{{ $event['send_back_number'] }}
Recipient
{{ $event['recipient_label'] }}
@if($event['completed_at'])
Completed At
{{ $event['completed_at'] }}
@endif @if(!empty($event['comments']))
Comments
"{{ $event['comments'] }}"
@endif
Documents
@if(!empty($event['documents'])) @foreach($event['documents'] as $doc) {{ $doc['name'] }}@if(!$loop->last), @endif @endforeach @else None @endif
@if(!empty($event['form_fields']))
Updated Form Fields
@foreach($event['form_fields'] as $ff) @endforeach
FieldUpdated Value
{{ $ff['label'] }} {{ \App\Support\FormValueText::forReport($ff) }}
@endif
@endif {{-- ── Pending / Not-Yet-Reached Task ── --}} @if($event['type'] === 'pending_task') @php $isNotReached = in_array($event['level_status'] ?? '', ['', 'not_reached']); $pendingLabel = $isNotReached ? 'Not Yet Reached' : 'Pending'; @endphp
Level {{ $event['level_number'] }}  ·  Task {{ $event['task_number'] }}  ·  {{ $event['task_name'] }}
⏳ {{ $pendingLabel }}

Assignees
@if(!empty($event['assignees']) && count($event['assignees']) > 0) {{ implode('  ·  ', array_map(fn($u) => ($u->name ?? $u['name'] ?? '') . ' (' . ($u->email ?? $u['email'] ?? '') . ')', (array)$event['assignees'])) }} @else — @endif
@if(!empty($event['form_fields']))
Form to Fill{{ $event['form_name'] ? ': ' . $event['form_name'] : '' }}
@foreach($event['form_fields'] as $ff) @endforeach
FieldValue
{{ $ff['label'] }} (awaiting input)
@endif
Expected SLA
@if($event['sla_duration_minutes']) Once activated — @php $m = (int)$event['sla_duration_minutes']; echo $m >= 60 ? intdiv($m, 60) . ' hour' . (intdiv($m, 60) > 1 ? 's' : '') . ($m % 60 > 0 ? ' ' . ($m % 60) . ' min' : '') : $m . ' minutes'; @endphp @else — @endif
@endif @endforeach {{-- ══════════════════════════════════════════════════════ PAGE FOOTER ══════════════════════════════════════════════════════ --}}