@extends('reports.pdf.layout')
@section('title', $data['meta']['title'])
@php
$meta = $data['meta'];
$kpis = $data['kpis'];
$ranking = $data['ranking'];
$distribution = $data['distribution'];
$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'];
// Distribution bar geometry.
$barW = 320; $barH = 160; $barPadX = 30; $barPadY = 22;
$maxV = 0;
foreach ($distribution as $d) { $maxV = max($maxV, (int) $d['value']); }
$maxV = max($maxV, 1);
$barCount = count($distribution);
$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_drivers'] }} conducteurs ·
Généré le {{ $meta['generated_at']->locale('fr')->isoFormat('D MMMM YYYY') }}
Indicateurs clés
Conducteurs avec sinistres
{{ $kpis['drivers_with_claims']['value'] }}
{{ $kpis['drivers_with_claims']['delta_label'] }}
Conducteurs à risque élevé
{{ $kpis['high_risk_drivers']['value'] }}
{{ $kpis['high_risk_drivers']['delta_label'] }}
Coût moyen / conducteur
{{ $fmtNum($kpis['avg_cost_driver']['value']) }}{{ $kpis['avg_cost_driver']['unit'] }}
{{ $kpis['avg_cost_driver']['delta_label'] }}
Sans sinistre
{{ $kpis['drivers_no_claims']['value'] }}
{{ $kpis['drivers_no_claims']['delta_label'] }}
Classement conducteurs par sinistralité
@if (!empty($ranking))
@foreach (array_slice($ranking, 0, 8) as $i => $r)
@php
$tone = $r['level']['tone'];
$bg = $toneBg[$tone]; $fg = $toneColor[$tone];
@endphp
{{ $i + 1 }}. {{ $r['name'] }}
{{ $r['count'] }} sinistres · {{ $r['resp_rate'] }} % resp. · Coût : {{ $fmtNum($r['cost'], '€') }} · Score séc. {{ $r['safety_score'] }}/100
{{ $r['level']['label'] }}
@endforeach
@else
Aucun conducteur impliqué.
@endif
Distribution du nombre de sinistres
@if ($maxV > 0)
Nombre de sinistres par conducteur
@else
Pas de données.
@endif
@if (!empty($action['label']))
@php $aTone = $action['tone'] ?? 'neutral'; @endphp
Action : {{ $action['label'] }}
@endif
@endsection