@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $rows = $data['rows']; $pie = $data['pie']; $trend = $data['trend']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, 0, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; $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' => 'warning', '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; } // Premium trend line. $chartW = 480; $chartH = 140; $padX = 30; $padY = 18; $values = array_filter($trend['values'] ?? [], fn ($v) => $v !== null); $minV = !empty($values) ? min($values) : 0; $maxV = !empty($values) ? max($values) : 1; if ($minV === $maxV) { $maxV = $minV + 1; } $stepX = count($trend['labels']) > 1 ? ($chartW - 2 * $padX) / (count($trend['labels']) - 1) : 0; $points = []; foreach ($trend['values'] as $i => $v) { if ($v === null) continue; $x = $padX + $i * $stepX; $y = $chartH - $padY - (($v - $minV) / ($maxV - $minV)) * ($chartH - 2 * $padY); $points[] = ['x' => $x, 'y' => $y, 'label' => $trend['labels'][$i] ?? '', 'value' => $v]; } $polyline = implode(' ', array_map(fn ($p) => "{$p['x']},{$p['y']}", $points)); @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

Polices actives
{{ $kpis['active_policies']['value'] }}
{{ $kpis['active_policies']['delta_label'] }}
Prime mensuelle totale
{{ $fmtNum($kpis['total_premium']['value']) }}{{ $kpis['total_premium']['unit'] }}
{{ $kpis['total_premium']['delta_label'] }}
Renouvellements < 60j
{{ $kpis['renewals_60j']['value'] }}
{{ $kpis['renewals_60j']['delta_label'] }}
Couverture tous risques
{{ $kpis['all_risks_coverage']['value'] !== null ? number_format($kpis['all_risks_coverage']['value'], 1, ',', ' ') : '—' }}{{ $kpis['all_risks_coverage']['unit'] }}
{{ $kpis['all_risks_coverage']['delta_label'] }}

Détail des polices d'assurance

@if (!empty($rows)) @foreach (array_slice($rows, 0, 12) as $r) @php $tone = $statusTone[$r['status']] ?? 'neutral'; $bg = $toneBg[$tone]; $fg = $toneColor[$tone]; @endphp @endforeach
Véhicule Assureur Couverture Échéance Prime/mois Franchise Statut
{{ $r['vehicle'] }} {{ $r['insurer'] }} {{ $r['coverage'] }} {{ $fmtDate($r['expiration']) }} {{ $fmtNum($r['premium'], '€') }} {{ $fmtNum($r['franchise'], '€') }} {{ $r['status_label'] }}
@else

Aucune police pour les filtres choisis.

@endif

Répartition par assureur

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

Aucune donnée par assureur.

@endif

Évolution des primes (6 mois)

@if (!empty($points)) @foreach ($points as $p) {{ $p['label'] }} {{ number_format($p['value'], 0, ',', ' ') }} @endforeach @else

Pas de données de prime sur 6 mois.

@endif
@endsection