@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $k = $data['kpis']; $top = $data['top_10']; $rows = $data['rows']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, (is_int($v) || ((float) $v) == (int) $v) ? 0 : 1, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; $fmtCostKm = function ($v) { if ($v === null) return '—'; return number_format((float) $v, 3, ',', ' ') . ' €/km'; }; $barW = 480; $barH = 160; $barPad = 30; $maxBar = max(1, max(array_map(fn ($r) => (int) $r['cost'], $top ?: [['cost' => 0]]))); $barCount = max(1, count($top)); $barWidth = (int) (($barW - 2 * $barPad) / $barCount) - 6; @endphp @section('content')
DADYCAR FLEET MANAGER

{{ $meta['title'] }}

Maintenance {{ $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

Coût moyen / véhicule
{{ $fmtNum($k['avg_cost']['value']) }}{{ $k['avg_cost']['unit'] }}
{{ $k['avg_cost']['caption'] }}
Véhicules > 150% moy.
{{ $fmtNum($k['above_avg']['value']) }}
{{ $k['above_avg']['caption'] }}
Coût/km le plus élevé
{{ $k['highest_cost_per_km']['value'] !== null ? number_format((float) $k['highest_cost_per_km']['value'], 3, ',', ' ') : '—' }}{{ $k['highest_cost_per_km']['unit'] }}
{{ $k['highest_cost_per_km']['caption'] }}
Réforme recommandée
{{ $fmtNum($k['reform_recommendation']['value']) }}
{{ $k['reform_recommendation']['caption'] }}

Top {{ count($top) }} véhicules par coût cumulé

@if (!empty($top)) @foreach ($top as $i => $r) @php $h = ($r['cost'] / $maxBar) * ($barH - 60); $x = $barPad + $i * (($barW - 2 * $barPad) / $barCount) + 3; $y = $barH - 30 - $h; $color = $i < 2 ? '#EF4444' : ($i < 5 ? '#F59E0B' : '#3B82F6'); @endphp {{ \Illuminate\Support\Str::limit((string) ($r['plate'] ?? '—'), 9, '') }} {{ number_format($r['cost'], 0, ',', ' ') }} @endforeach @else

Aucune dépense de maintenance sur la période.

@endif

Détail coût / km par véhicule

@if (!empty($rows)) @foreach (array_slice($rows, 0, 25) as $r) @endforeach
Plaque Véhicule Année Coût Km Coût/km
{{ $r['plate'] ?? '—' }} {{ $r['mark_model'] ?? '—' }} {{ $r['year'] ?? '—' }} {{ number_format((float) $r['cost'], 0, ',', ' ') }} € {{ $r['km'] !== null ? number_format($r['km'], 0, ',', ' ') : '—' }} {{ $fmtCostKm($r['cost_per_km']) }}
@if (count($rows) > 25)

{{ count($rows) - 25 }} véhicule(s) supplémentaire(s) — voir l'export Excel pour le détail complet.

@endif @else

Aucune dépense de maintenance sur la période.

@endif @endsection