@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); }; // Per-site bar geometry — vertical bars of cost per vehicle. $barW = 480; $barH = 150; $barPadX = 30; $barPadY = 22; $barLabels = array_column($rows, 'site'); $barValues = array_map(fn ($r) => (float) ($r['cost_per_vehicle'] ?? 0), $rows); $barMax = !empty($barValues) ? max($barValues + [1]) : 1; $barCount = count($barLabels); $barSlot = $barCount > 0 ? ($barW - 2 * $barPadX) / $barCount : 0; $barWidth = $barSlot * 0.55; $barColor = '#F59E0B'; @endphp @section('content')
DADYCAR FLEET MANAGER

{{ $meta['title'] }}

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

Site le plus coûteux
{{ $kpis['most_expensive_site']['value'] }}
@if (!empty($kpis['most_expensive_site']['unit']))
{{ $kpis['most_expensive_site']['unit'] }}
@endif
{{ $kpis['most_expensive_site']['delta_label'] ?? '' }}
Site le plus économique
{{ $kpis['cheapest_site']['value'] }}
@if (!empty($kpis['cheapest_site']['unit']))
{{ $kpis['cheapest_site']['unit'] }}
@endif
{{ $kpis['cheapest_site']['delta_label'] ?? '' }}
Écart maximum
{{ $fmtNum($kpis['site_gap']['value']) }}{{ $kpis['site_gap']['unit'] }}
{{ $kpis['site_gap']['delta_label'] ?? '' }}
Coût total flotte
{{ $fmtNum($kpis['total_cost_fleet']['value']) }}{{ $kpis['total_cost_fleet']['unit'] }}
{{ $kpis['total_cost_fleet']['delta_label'] ?? '' }}

Détail des coûts par site

@if (!empty($rows)) @foreach ($rows as $r) @endforeach
Site Véh. Leasing Maint. Carb. Assur. Total
{{ $r['site'] }} {{ $r['vehicles'] }} {{ $fmtNum($r['leasing'], '€') }} {{ $fmtNum($r['maintenance'], '€') }} {{ $fmtNum($r['fuel'], '€') }} {{ $fmtNum($r['insurance'], '€') }} {{ $fmtNum($r['total'], '€') }}
@else

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

@endif @if ($meta['compare_sites'])

Coût moyen par véhicule (par site)

@if (array_sum($barValues) > 0) @foreach ($barLabels as $i => $lbl) @php $h = $barMax > 0 ? (($barValues[$i] / $barMax) * ($barH - 2 * $barPadY)) : 0; $x = $barPadX + $i * $barSlot + ($barSlot - $barWidth) / 2; $y = $barH - $barPadY - $h; @endphp {{ number_format($barValues[$i], 0, ',', ' ') }} € {{ $lbl }} @endforeach @else

Pas de données par site.

@endif @endif @endsection