@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $rows = $data['rows']; $pie = $data['pie']; $plan = $data['planning']; $fmtDate = function ($d) { if ($d === null) return '—'; try { return \Carbon\Carbon::parse($d)->locale('fr')->isoFormat('D MMM YYYY'); } catch (\Throwable $e) { return (string) $d; } }; $toneBg = ['danger' => '#FEE2E2', 'warning' => '#FEF3C7', 'success' => '#D1FAE5', 'neutral' => '#F3F4F6']; $toneColor = ['danger' => '#991B1B', 'warning' => '#92400E', 'success' => '#065F46', 'neutral' => '#374151']; $statusTone = [ 'expired' => 'danger', 'expiring_30' => 'danger', 'expiring_60' => 'warning', 'valid' => 'success', 'unknown' => 'neutral', ]; // Pie geometry. $pieRadius = 50; $pieCx = 60; $pieCy = 60; $totalPie = array_sum(array_column($pie, 'value')); $pieSlices = []; $accAngle = -90; foreach ($pie as $i => $p) { if ($totalPie <= 0) break; $sweep = ((float) $p['value'] / $totalPie) * 360; $isFull = $sweep >= 359.999; if ($isFull) { $path = null; } else { $rad1 = deg2rad($accAngle); $rad2 = deg2rad($accAngle + $sweep); $x1 = $pieCx + $pieRadius * cos($rad1); $y1 = $pieCy + $pieRadius * sin($rad1); $x2 = $pieCx + $pieRadius * cos($rad2); $y2 = $pieCy + $pieRadius * sin($rad2); $largeArc = $sweep > 180 ? 1 : 0; $path = sprintf('M %s %s L %.2f %.2f A %s %s 0 %d 1 %.2f %.2f Z', $pieCx, $pieCy, $x1, $y1, $pieRadius, $pieRadius, $largeArc, $x2, $y2); } $pieSlices[] = ['path' => $path, 'color' => $p['color'], 'label' => $p['label'], 'value' => $p['value']]; $accAngle += $sweep; } // Planning bars. $pBarW = 480; $pBarH = 130; $pBarPadX = 30; $pBarPadY = 18; $pMax = max($plan['values'] + [1]); $pCount = count($plan['labels']); $pSlot = $pCount > 0 ? ($pBarW - 2 * $pBarPadX) / $pCount : 0; $pWidth = $pSlot * 0.55; @endphp @section('content')
DADYCAR FLEET MANAGER

{{ $meta['title'] }}

Conformité {{ $meta['code'] }} Période : {{ $meta['period']['label'] }} · {{ $meta['site_label'] }} · {{ $meta['total_vehicles'] }} véhicules · Généré le {{ $meta['generated_at']->locale('fr')->isoFormat('D MMMM YYYY') }}

Indicateurs clés

CT valides
{{ $kpis['ct_valid']['value'] }}
{{ $kpis['ct_valid']['delta_label'] }}
CT expirés
{{ $kpis['ct_expired']['value'] }}
{{ $kpis['ct_expired']['delta_label'] }}
CT urgents (≤30j)
{{ $kpis['ct_urgent']['value'] }}
{{ $kpis['ct_urgent']['delta_label'] }}
CT à planifier (≤60j)
{{ $kpis['ct_to_plan']['value'] }}
{{ $kpis['ct_to_plan']['delta_label'] }}

État des contrôles techniques

@if (!empty($rows)) @foreach (array_slice($rows, 0, 8) as $r) @php $tone = $statusTone[$r['status']] ?? 'neutral'; $bg = $toneBg[$tone]; $fg = $toneColor[$tone]; @endphp
{{ $r['vehicle'] }} · {{ $r['model'] }}
Dernier CT : {{ $fmtDate($r['last_ct']) }} · Échéance : {{ $fmtDate($r['expiration_date']) }}
{{ $r['status_label'] }}
@endforeach @else

Aucun contrôle technique pour les filtres choisis.

@endif

Répartition des statuts

@if ($totalPie > 0)
@foreach ($pieSlices as $s) @if ($s['path'] === null) @else @endif @endforeach @foreach ($pieSlices as $s)
{{ $s['label'] }} — {{ $s['value'] }}
@endforeach
@else

Pas de données.

@endif

Planning CT (6 mois)

@if (array_sum($plan['values']) > 0) @foreach ($plan['labels'] as $i => $lbl) @php $h = $pMax > 0 ? (($plan['values'][$i] / $pMax) * ($pBarH - 2 * $pBarPadY)) : 0; $x = $pBarPadX + $i * $pSlot + ($pSlot - $pWidth) / 2; $y = $pBarH - $pBarPadY - $h; @endphp {{ $plan['values'][$i] }} {{ $lbl }} @endforeach @else

Aucun CT à planifier dans les 6 prochains mois.

@endif @endsection