@extends('reports.pdf.layout')
@section('title', $data['meta']['title'])
@php
$meta = $data['meta'];
$kpis = $data['kpis'];
$top = $data['top'];
$byCategory = $data['by_category'];
$action = $data['action'];
$fmtNum = function ($v, $unit = '') {
if ($v === null) return '—';
$s = is_numeric($v) ? number_format((float) $v, 0, ',', ' ') : (string) $v;
return trim($s . ' ' . $unit);
};
$toneBg = ['danger' => '#FEE2E2', 'warning' => '#FEF3C7', 'success' => '#D1FAE5', 'neutral' => '#F3F4F6'];
$toneColor = ['danger' => '#991B1B', 'warning' => '#92400E', 'success' => '#065F46', 'neutral' => '#374151'];
$barW = 320; $barH = 160; $barPadX = 30; $barPadY = 22;
$maxV = 0;
foreach ($byCategory as $c) { $maxV = max($maxV, (int) $c['count']); }
$maxV = max($maxV, 1);
$barCount = count($byCategory);
$barSlot = $barCount > 0 ? ($barW - 2 * $barPadX) / $barCount : 0;
$barWidth = $barSlot * 0.55;
@endphp
@section('content')
DADYCAR FLEET MANAGER
{{ $meta['title'] }}
Sinistres
{{ $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
Véhicules accidentés
{{ $kpis['vehicles_with_claims']['value'] }}
{{ $kpis['vehicles_with_claims']['delta_label'] }}
Véhicule le + accidenté
{{ $kpis['top_vehicle']['value'] }}
{{ $kpis['top_vehicle']['delta_label'] }}
Coût moyen / véh.
{{ $fmtNum($kpis['avg_cost_vehicle']['value']) }}{{ $kpis['avg_cost_vehicle']['unit'] }}
{{ $kpis['avg_cost_vehicle']['delta_label'] }}
Utilitaires - exposés
{{ $kpis['utility_exposure']['value'] }}{{ $kpis['utility_exposure']['unit'] }}
{{ $kpis['utility_exposure']['delta_label'] }}
Top 5 véhicules les plus accidentés
@if (!empty($top))
@foreach ($top as $r)
@php $tone = $r['tone']; $bg = $toneBg[$tone]; $fg = $toneColor[$tone]; @endphp
{{ $r['plate'] }} {{ $r['brand'] }}
{{ $r['meta'] }}
{{ $r['count'] }} sinistres · {{ $fmtNum($r['cost'], '€') }}
@endforeach
@else
Aucun véhicule accidenté.
@endif
Sinistres par catégorie de véhicule
@if ($maxV > 0)
@else
Pas de données.
@endif
@if (!empty($action['label']))
@php $aTone = $action['tone'] ?? 'neutral'; @endphp
Analyse : {{ $action['label'] }}
@endif
@endsection