@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $rows = $data['rows']; $segments = $data['segments']; $alerts = $data['alerts']; $fmt = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, 0, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; $fmtDelta = function ($v, $unit = '%') { if ($v === null) return null; $sign = $v > 0 ? '+' : ''; return $sign . number_format((float) $v, 1, ',', ' ') . $unit; }; // Pie chart geometry — single SVG per slice. 360° collapses to . $pieRadius = 60; $pieCx = 70; $pieCy = 70; $totalPie = array_sum(array_map(fn ($s) => $s['value'], $segments)); $pieSlices = []; $accAngle = -90; foreach ($segments as $s) { if ($totalPie <= 0) break; $sweep = ($s['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' => $s['color'], 'label' => $s['label'], 'value' => $s['value'], 'percent' => $s['percent'], ]; $accAngle += $sweep; } $statusLabels = [ 'designated' => ['label' => 'Désignée', 'bg' => '#D1FAE5', 'fg' => '#065F46'], 'to_designate' => ['label' => 'À désigner', 'bg' => '#FEF3C7', 'fg' => '#92400E'], 'urgent' => ['label' => 'Urgente', 'bg' => '#FED7AA', 'fg' => '#9A3412'], 'majored' => ['label' => 'Majorée', 'bg' => '#FEE2E2', 'fg' => '#991B1B'], ]; @endphp @section('content')
DADYCAR FLEET MANAGER

{{ $meta['title'] }}

Conducteurs {{ $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 de désignation

Infractions reçues
{{ $fmt($kpis['received']['value']) }}
{{ $kpis['received']['delta_label'] }}
Infractions désignées
{{ $fmt($kpis['designated']['value']) }}
{{ $kpis['designated']['delta_label'] }}
Délai légal restant
{{ $fmt($kpis['remaining_min']['value']) }}{{ $kpis['remaining_min']['unit'] }}
{{ $kpis['remaining_min']['delta_label'] }}
Amendes majorées
{{ $fmt($kpis['majored']['value']) }}
{{ $kpis['majored']['delta_label'] }}
@if ($kpis['designation_rate']['value'] !== null)
Taux de désignation : {{ number_format((float) $kpis['designation_rate']['value'], 1, ',', ' ') }}% @if ($kpis['designation_rate']['delta'] !== null) ({{ $fmtDelta($kpis['designation_rate']['delta'], ' pts') }} {{ $kpis['designation_rate']['delta_label'] }}) @endif
@endif

Infractions en cours — Suivi des désignations

@if (!empty($rows)) @foreach ($rows as $r) @php $sty = $statusLabels[$r['status']] ?? ['label' => $r['status'], 'bg' => '#F3F4F6', 'fg' => '#374151']; @endphp @endforeach
Référence Véhicule Date Type Conducteur Délai restant Statut
{{ $r['reference'] ?? '—' }} {{ $r['plate'] ?? '—' }} {{ $r['date'] ?? '—' }} {{ $r['natinf'] ?? '—' }} {{ $r['driver'] ?? '—' }} @if ($r['status'] === 'majored') expirée @elseif ($r['status'] === 'designated') — @elseif ($r['remaining_days'] !== null) {{ $r['remaining_days'] }} j @else — @endif {{ $sty['label'] }}
@else

Aucune infraction sur la période.

@endif

Répartition par statut

@if (!empty($pieSlices))
@foreach ($pieSlices as $s) @if ($s['path'] === null) @else @endif @endforeach @foreach ($pieSlices as $s)
{{ $s['label'] }} — {{ $s['value'] }} ({{ number_format($s['percent'], 1, ',', ' ') }} %)
@endforeach
@else

Pas de désignations à répartir.

@endif

Alertes — Désignations critiques

@if (!empty($alerts)) @foreach ($alerts as $a) @php $bg = $a['tone'] === 'danger' ? '#FEE2E2' : ($a['tone'] === 'warning' ? '#FEF3C7' : '#F3F4F6'); $fg = $a['tone'] === 'danger' ? '#991B1B' : ($a['tone'] === 'warning' ? '#92400E' : '#374151'); @endphp
{{ $a['title'] }}
{{ $a['reference'] }}
{{ $a['meta'] }}
@endforeach @else

Aucune alerte critique sur la période.

@endif
@endsection