@php // No brand colours are read here on purpose. The certificate is set in one // ink, like the invoice and the quote, and the logo is what places it. A // workspace whose primary colour happens to be a strong blue or red should // not end up with a louder certificate than one whose colour is navy. $companyName = $setting?->company_name ?: $job->team?->name; $logoData = null; if ($setting?->logo_path) { try { $logoFull = \Illuminate\Support\Facades\Storage::disk('public')->path($setting->logo_path); if (is_file($logoFull)) { $logoData = 'data:' . (mime_content_type($logoFull) ?: 'image/png') . ';base64,' . base64_encode(file_get_contents($logoFull)); } } catch (\Throwable $e) { $logoData = null; } } // ---- Score ------------------------------------------------------------ $allItems = $grouped->flatten(); $totalChecks = $allItems->count(); $doneChecks = $allItems->where('is_done', true)->count(); $requiredChecks = $allItems->where('is_required', true); $requiredTotal = $requiredChecks->count(); $requiredDone = $requiredChecks->where('is_done', true)->count(); $evidenceCount = $allItems->whereNotNull('evidence_path')->count(); $lastCheckedAt = $allItems->where('is_done', true)->max('checked_at'); // ---- Verdict ---------------------------------------------------------- // A certificate is a document, not a dashboard. The verdict carries the only // colour on the page, and even that is a restrained ink rather than a tint: // a wash of green or amber behind the whole panel reads as a status banner // and cheapens the thing people are meant to file. $verdict = $passed ? [ 'label' => __('PASSED'), 'colour' => '#166534', 'glyph' => '✓', 'statement' => __('Every required quality check on this job was carried out, verified and signed off.'), ] : [ 'label' => __('PROVISIONAL'), 'colour' => '#8a5a1b', 'glyph' => '!', 'statement' => $requiredTotal === 0 ? __('This job carried no mandatory quality checks. The record below is issued for information.') : __('Issued before every required check was signed off. The outstanding items are marked below.'), ]; $issuedAt = now()->timezone(config('app.display_timezone')); $certificateNo = 'QC-' . $job->job_number; @endphp {{ $certificateNo }} {{-- ============ MASTHEAD ============ --}}
@if ($logoData)
@endif
{{ $companyName }}
@php $contact = array_filter([$setting?->address, $setting?->phone, $setting?->email, $setting?->website]); @endphp @if ($contact)
{{ implode(' · ', $contact) }}
@endif
{{ __('Certificate of') }}
{{ __('Quality Assurance') }}
{{ $certificateNo }}  ·  {{ $issuedAt->format('d M Y') }}
{{-- ============ VERDICT ============ --}}
{!! $verdict['glyph'] !!}
{{ $verdict['label'] }}
{{ $verdict['statement'] }}
{{ __('Required') }}
{{ $requiredDone }}/{{ $requiredTotal }}
{{ __('All checks') }}
{{ $doneChecks }}/{{ $totalChecks }}
{{-- ============ JOB DETAILS ============ --}}
{{ __('Job number') }}
{{ $job->job_number }}
{{ __('Customer') }}
{{ $job->customer?->name ?: '—' }}
{{ __('Category') }}
{{ $job->category?->name ?: __('General') }}
{{ __('Started') }}
{{ optional($job->started_at)->format('d M Y') ?: '—' }}
{{ __('Job title') }}
{{ $job->title ?: '—' }}
{{ __('Completed') }}
{{ optional($job->completed_at)->format('d M Y') ?: '—' }}
{{ __('Evidence on file') }}
{{ trans_choice('{0}None|{1}:count file|[2,*]:count files', $evidenceCount, ['count' => $evidenceCount]) }}
{{-- ============ CHECKS BY STAGE ============ --}} @foreach ($stageOrder as $stage) @php $items = $grouped[$stage] ?? collect(); $stageTotal = $items->count(); $stageDone = $items->where('is_done', true)->count(); @endphp @if ($items->isNotEmpty())
{{ $stageLabels[$stage] ?? $stage }} {{ __(':done of :total verified', ['done' => $stageDone, 'total' => $stageTotal]) }}
@foreach ($items as $item) @endforeach
{{ __('Quality check') }} {{ __('Verified by') }} {{ __('Approved by') }} {{ __('Date') }}
{!! $item->is_done ? '✓' : '□' !!} {{ $item->label }} @if ($item->is_required) {{ __('REQUIRED') }}@endif @if ($item->description)
{{ $item->description }}
@endif @if ($item->evidence_path)
{{ __('Evidence attached and retained on file.') }}
@endif @if ($item->note)
“{{ $item->note }}”
@endif
{!! $item->is_done ? e($item->checker?->name ?: '—') : '' . e(__('Not verified')) . '' !!} {{ $item->approved_by_name ?: '—' }} @if ($item->approved_by_name && $item->approved_on)
{{ $item->approved_on->format('d M Y') }}
@endif
{{ $item->is_done ? optional($item->checked_at)->format('d M Y') : '—' }}
@endif @endforeach @if ($grouped->isEmpty())
{{ __('No quality checks were recorded against this job.') }}
@endif {{-- ============ SIGN-OFF ============ --}}
{{ __('Checked by — Production') }}
{{ __('Name · Signature · Date') }}
{{ __('Authorised by — Management') }}
{{ __('Name · Signature · Date') }}
{{ __('Accepted by — Customer') }}
{{ __('Name · Signature · Date') }}
{{-- ============ FOOTER (repeats at the foot of every page) ============ --}}