@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $trend = $data['trend']; $byType = $data['by_type']; $perSite = $data['per_site']; $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']; // Monthly bars + objective line. $barW = 320; $barH = 160; $barPadX = 30; $barPadY = 22; $maxV = max(array_merge($trend['counts'], $trend['objective']) ?: [1]); $barCount = count($trend['labels']); $barSlot = $barCount > 0 ? ($barW - 2 * $barPadX) / $barCount : 0; $barWidth = $barSlot * 0.55; // Pie geometry. $pieRadius = 50; $pieCx = 60; $pieCy = 60; $totalPie = array_sum(array_column($byType, 'value')); $pieSlices = []; $accAngle = -90; foreach ($byType as $i => $p) { if ($totalPie <= 0 || $p['value'] === 0) continue; $sweep = ((float) $p['value'] / $totalPie) * 360; $isFull = $sweep >= 359.999; if ($isFull) { $path = null; } else { $rad1 = deg2rad($accAngle); $rad2 = deg2rad($accAngle + $sweep); $x1 = $pieCx + $pieRadius * cos($rad1); $y1 = $pieCy + $pieRadius * sin($rad1); $x2 = $pieCx + $pieRadius * cos($rad2); $y2 = $pieCy + $pieRadius * sin($rad2); $largeArc = $sweep > 180 ? 1 : 0; $path = sprintf('M %s %s L %.2f %.2f A %s %s 0 %d 1 %.2f %.2f Z', $pieCx, $pieCy, $x1, $y1, $pieRadius, $pieRadius, $largeArc, $x2, $y2); } $pieSlices[] = ['path' => $path, 'color' => $p['color'], 'label' => $p['label'], 'value' => $p['value']]; $accAngle += $sweep; } @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

Sinistres ce mois
{{ $kpis['claims_count']['value'] }}
@php $d = $kpis['claims_count']['delta']; @endphp @if ($d !== null && $d !== 0)
{{ $d > 0 ? '+' : '' }}{{ $d }} {{ $kpis['claims_count']['delta_label'] }}
@else
{{ $kpis['claims_count']['delta_label'] }}
@endif
Taux sinistralité
{{ $kpis['claims_rate']['value'] !== null ? number_format($kpis['claims_rate']['value'], 1, ',', ' ') : '—' }}{{ $kpis['claims_rate']['unit'] }}
{{ $kpis['claims_rate']['delta_label'] }}
Coût total
{{ $fmtNum($kpis['total_cost']['value']) }}{{ $kpis['total_cost']['unit'] }}
{{ $kpis['total_cost']['delta_label'] }}
Sinistres responsables
{{ $kpis['responsible_share']['value'] }}{{ $kpis['responsible_share']['unit'] }}
{{ $kpis['responsible_share']['delta_label'] }}

Évolution mensuelle (nb sinistres + objectif)

@if (array_sum($trend['counts']) > 0 || array_sum($trend['objective']) > 0) @foreach ($trend['labels'] as $i => $lbl) @php $h = $maxV > 0 ? (($trend['counts'][$i] / $maxV) * ($barH - 2 * $barPadY)) : 0; $x = $barPadX + $i * $barSlot + ($barSlot - $barWidth) / 2; $y = $barH - $barPadY - $h; @endphp {{ $trend['counts'][$i] }} {{ $lbl }} @endforeach {{-- Objective horizontal dashed line --}} @if (!empty($trend['objective'])) @php $objY = $barH - $barPadY - ($maxV > 0 ? (($trend['objective'][0] / $maxV) * ($barH - 2 * $barPadY)) : 0); @endphp Objectif {{ $trend['objective'][0] }} @endif @else

Pas de données.

@endif

Répartition par type (cumul 6 mois)

@if ($totalPie > 0)
@foreach ($pieSlices as $s) @if ($s['path'] === null) @else @endif @endforeach @foreach ($byType as $b) @if ($b['value'] > 0)
{{ $b['label'] }} — {{ $b['value'] }}
@endif @endforeach
@else

Aucun sinistre sur la période.

@endif

Sinistralité par site (cumul 6 mois)

@if (!empty($perSite)) @foreach ($perSite as $r) @php $tone = $r['status']['tone'] ?? 'neutral'; $bg = $toneBg[$tone]; $fg = $toneColor[$tone]; @endphp @endforeach
Site Nb sinistres Taux pour 100 véh. Statut
{{ $r['site'] }} {{ $r['count'] }} {{ $r['rate'] !== null ? number_format($r['rate'], 1, ',', ' ') . ' %' : '—' }} {{ $r['status']['label'] ?? '' }}
@else

Aucun site avec données.

@endif @endsection