@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $rows = $data['rows']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, 0, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; // Stacked horizontal bar geometry — one row per driver, segments per // bucket. Width scales to the max driver total. $segments = [ ['key' => 'fuel', 'label' => 'Carburant', 'color' => '#3B82F6'], ['key' => 'maintenance', 'label' => 'Maintenance', 'color' => '#F59E0B'], ['key' => 'fines', 'label' => 'Amendes', 'color' => '#8B5CF6'], ['key' => 'claims_cost', 'label' => 'Sinistres', 'color' => '#EF4444'], ]; $maxTotal = 0; foreach ($rows as $r) { $maxTotal = max($maxTotal, (float) $r['total']); } if ($maxTotal <= 0) { $maxTotal = 1; } $trackW = 280; // pt @endphp @section('content')
DADYCAR FLEET MANAGER

{{ $meta['title'] }}

Dépenses & Coûts {{ $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

Coût moyen / conducteur
{{ $fmtNum($kpis['avg_cost_driver']['value']) }}{{ $kpis['avg_cost_driver']['unit'] }}
{{ $kpis['avg_cost_driver']['delta_label'] }}
Conducteur le + cher
{{ $fmtNum($kpis['most_expensive']['value']) }}{{ $kpis['most_expensive']['unit'] }}
{{ $kpis['most_expensive']['delta_label'] }}
Conducteurs > 100% moy.
{{ $kpis['above_avg_count']['value'] }}
{{ $kpis['above_avg_count']['delta_label'] }}
Coût sinistres
{{ $fmtNum($kpis['claims_cost']['value']) }}{{ $kpis['claims_cost']['unit'] }}
{{ $kpis['claims_cost']['delta_label'] }}

Coût total par conducteur — Décomposition par poste

@if (!empty($rows)) @foreach ($rows as $r) @php $totalLen = $maxTotal > 0 ? ((float) $r['total'] / $maxTotal) * $trackW : 0; @endphp @endforeach
{{ $r['driver'] }}
@php $offset = 0; @endphp @foreach ($segments as $seg) @php $val = (float) ($r[$seg['key']] ?? 0); $segLen = $maxTotal > 0 ? ($val / $maxTotal) * $trackW : 0; @endphp @if ($segLen > 0)
@endif @endforeach
{{ $fmtNum($r['total']) }} €
@foreach ($segments as $seg) {{ $seg['label'] }} @endforeach
@else

Aucun conducteur avec dépense pour la période.

@endif @endsection