@extends('reports.pdf.layout')
@section('title', $data['meta']['title'])
@php
$meta = $data['meta'];
$kpis = $data['kpis'];
$topZones = $data['top_zones'];
$byHour = $data['by_hour'];
$byDay = $data['by_day'];
$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 = 130; $barPadX = 28; $barPadY = 22;
$maxHour = 0;
foreach ($byHour as $r) { $maxHour = max($maxHour, (int) $r['value']); }
$maxHour = max($maxHour, 1);
$maxDay = 0;
foreach ($byDay as $r) { $maxDay = max($maxDay, (int) $r['value']); }
$maxDay = max($maxDay, 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
Zones à risque
{{ $kpis['zones_at_risk']['value'] }}
{{ $kpis['zones_at_risk']['delta_label'] }}
Pic horaire
{{ $kpis['peak_hour']['value'] }}
{{ $kpis['peak_hour']['delta_label'] }}
Jour le + accidentogène
{{ $kpis['peak_day']['value'] }}
{{ $kpis['peak_day']['delta_label'] }}
Sinistres zone urbaine
{{ $kpis['urban_share']['value'] }}{{ $kpis['urban_share']['unit'] }}
{{ $kpis['urban_share']['delta_label'] }}
Top 5 zones accidentogènes
@if (!empty($topZones))
@foreach ($topZones as $z)
@php $tone = $z['tone']; $bg = $toneBg[$tone]; $fg = $toneColor[$tone]; @endphp
{{ $z['name'] }}
{{ $z['when'] }} · {{ $z['sample'] }}
{{ $z['count'] }} sinistres · {{ $z['level'] }}
@endforeach
@else
Pas de zones identifiées.
@endif
Sinistres par plage horaire
@if ($maxHour > 0)
@php
$barCount = count($byHour);
$barSlot = $barCount > 0 ? ($barW - 2 * $barPadX) / $barCount : 0;
$barWidth = $barSlot * 0.55;
@endphp
@else
Pas de données.
@endif
Sinistres par jour de la semaine
@if ($maxDay > 0)
@php
$barCount2 = count($byDay);
$barSlot2 = $barCount2 > 0 ? ($barW - 2 * $barPadX) / $barCount2 : 0;
$barWidth2 = $barSlot2 * 0.55;
@endphp
@else
Pas de données.
@endif
@endsection