@extends('reports.pdf.layout')
@section('title', $data['meta']['title'])
@php
$meta = $data['meta'];
$kpis = $data['kpis'];
$open = $data['open_dossiers'];
$distribution = $data['distribution'];
$steps = $data['steps'];
$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 ($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;
$maxStep = 0;
foreach ($steps as $s) { $maxStep = max($maxStep, (float) $s['days']); }
$maxStep = max($maxStep, 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
Délai moyen clôture
{{ $fmtNum($kpis['avg_close_delay']['value']) }}{{ $kpis['avg_close_delay']['unit'] }}
{{ $kpis['avg_close_delay']['delta_label'] }}
Dossiers en retard
{{ $kpis['overdue_30']['value'] }}
{{ $kpis['overdue_30']['delta_label'] }}
Taux clôture dans les délais
{{ $fmtNum($kpis['on_time_rate']['value']) }}{{ $kpis['on_time_rate']['unit'] }}
{{ $kpis['on_time_rate']['delta_label'] }}
Dossier le plus ancien
{{ $fmtNum($kpis['oldest_open']['value']) }}{{ $kpis['oldest_open']['unit'] }}
{{ $kpis['oldest_open']['delta_label'] }}
Dossiers ouverts — délai vs cible
@if (!empty($open))
@foreach ($open as $r)
@php
$tone = $r['pct_target'] >= 100 ? 'danger' : ($r['pct_target'] >= 67 ? 'warning' : 'success');
$bg = $toneBg[$tone]; $fg = $toneColor[$tone];
@endphp
{{ $r['reference'] }} · {{ $r['type_label'] }}
Étape : {{ $r['stage'] }} · {{ $r['delay'] }}j · Cible 30j
{{ $r['pct_target'] }} %
@endforeach
@else
Aucun dossier ouvert.
@endif
Distribution des délais de clôture
@if ($maxV > 0)
@else
Pas de données.
@endif
Durée moyenne par étape (jours)
@if (!empty($steps))
@foreach ($steps as $s)
@php $pct = $maxStep > 0 ? ($s['days'] / $maxStep) * 100 : 0; @endphp
{{ $s['label'] }} — {{ number_format($s['days'], 1, ',', ' ') }} j
@endforeach
@else
Pas de données.
@endif
@endsection