@extends('reports.pdf.layout')
@section('title', $data['meta']['title'])
@php
$meta = $data['meta'];
$kpis = $data['kpis'];
$quarterly = $data['quarterly'];
$drivers = $data['drivers'];
$byType = $data['by_type'];
$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'];
// Stacked bar geometry.
$barW = 320; $barH = 160; $barPadX = 30; $barPadY = 22;
$maxV = 0;
foreach ($quarterly as $q) { $maxV = max($maxV, ($q['responsible'] + $q['non_responsible'])); }
$maxV = max($maxV, 1);
$barCount = count($quarterly);
$barSlot = $barCount > 0 ? ($barW - 2 * $barPadX) / $barCount : 0;
$barWidth = $barSlot * 0.55;
$maxByType = 0;
foreach ($byType as $t) { $maxByType = max($maxByType, $t['responsible'] + $t['non_responsible']); }
$maxByType = max($maxByType, 1);
@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
Taux de responsabilité
{{ $kpis['responsibility_rate']['value'] !== null ? $kpis['responsibility_rate']['value'] : '—' }}{{ $kpis['responsibility_rate']['unit'] }}
{{ $kpis['responsibility_rate']['delta_label'] }}
Sinistres responsables
{{ $kpis['responsible_count']['value'] }}
{{ $kpis['responsible_count']['delta_label'] }}
Récidivistes
{{ $kpis['repeat_offenders']['value'] }}
{{ $kpis['repeat_offenders']['delta_label'] }}
Coût responsables
{{ $fmtNum($kpis['responsible_cost']['value']) }}{{ $kpis['responsible_cost']['unit'] }}
{{ $kpis['responsible_cost']['delta_label'] }}
Évolution taux de responsabilité (trimestriel)
@if ($maxV > 0)
Responsable
Non responsable
@else
Pas de données.
@endif
Conducteurs impliqués
@if (!empty($drivers))
@foreach ($drivers as $d)
@php
$tone = $d['resp_rate'] >= 67 ? 'danger' : ($d['resp_rate'] >= 33 ? 'warning' : 'success');
$bg = $toneBg[$tone]; $fg = $toneColor[$tone];
@endphp
{{ $d['name'] }}
{{ $d['count'] }} sinistres · {{ $d['responsible'] }} responsables · Coût : {{ $fmtNum($d['cost'], '€') }} · Score séc. {{ $d['safety_score'] }}/100
{{ $d['resp_rate'] }} % resp.
@endforeach
@else
Aucun conducteur impliqué.
@endif
Responsabilité par type de sinistre
@if ($maxByType > 0)
@foreach ($byType as $t)
@php
$total = $t['responsible'] + $t['non_responsible'];
$pctResp = $total > 0 ? ($t['responsible'] / $total) * 100 : 0;
$pctNon = $total > 0 ? ($t['non_responsible'] / $total) * 100 : 0;
$rowW = $maxByType > 0 ? ($total / $maxByType) * 100 : 0;
@endphp
{{ $t['label'] }} ({{ $t['responsible'] }} resp. / {{ $t['non_responsible'] }} non resp.)
@endforeach
@else
Pas de données.
@endif
@if (!empty($action['label']))
@php $aTone = $action['tone'] ?? 'neutral'; @endphp
Plan d'action : {{ $action['label'] }}
@endif
@endsection