@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $k = $data['kpis']; $sites = $data['sites']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, ((float) $v) == (int) $v ? 0 : 2, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; // Bar chart geometry — total cost per site. $bars = $sites; $maxBar = !empty($bars) ? max(1, max(array_map(fn ($b) => (float) ($b['total_cost'] ?? 0), $bars))) : 1; $barW = 480; $barH = 160; $barPad = 30; $barWidth = !empty($bars) ? max(8, (int) (($barW - 2 * $barPad) / max(1, count($bars))) - 8) : 0; @endphp @section('content')
DADYCAR FLEET MANAGER

{{ $meta['title'] }}

Carburant & Énergie {{ $meta['code'] }} Période : {{ $meta['period']['label'] }} · {{ $meta['site_label'] }} · {{ $meta['total_sites'] }} sites · Généré le {{ $meta['generated_at']->locale('fr')->isoFormat('D MMMM YYYY') }}

Indicateurs clés

Coût site le + consommateur
{{ $fmtNum($k['top_site_cost']['value']) }}{{ $k['top_site_cost']['unit'] }}
{{ $k['top_site_cost']['delta_label'] }}
Coût total (tous sites)
{{ $fmtNum($k['total_cost_all']['value']) }}{{ $k['total_cost_all']['unit'] }}
{{ $k['total_cost_all']['delta_label'] }}
Classement sites
{{ $fmtNum($k['site_ranking']['value']) }}{{ $k['site_ranking']['unit'] }}
{{ $k['site_ranking']['delta_label'] }}
Écart entre sites
{{ $fmtNum($k['site_gap']['value']) }}{{ $k['site_gap']['unit'] }}
{{ $k['site_gap']['delta_label'] }}

Consommation par site

@if (!empty($bars)) @foreach ($bars as $i => $b) @php $val = (float) ($b['total_cost'] ?? 0); $h = ($val / $maxBar) * ($barH - 60); $x = $barPad + $i * (($barW - 2 * $barPad) / count($bars)) + 4; $y = $barH - 30 - $h; $label = mb_strlen($b['site_name']) > 14 ? mb_substr($b['site_name'], 0, 13) . '…' : $b['site_name']; @endphp {{ $label }} {{ number_format($val, 0, ',', ' ') }} € @endforeach @else

Aucune consommation enregistrée par site sur la période.

@endif

Détails par site

@if (!empty($sites)) @foreach ($sites as $r) @endforeach
Site Véh. Volume (L) Énergie (kWh) Coût carb. (€) Coût recharge (€) Coût total (€) Km L/100km
{{ $r['site_name'] }} {{ $r['vehicles'] }} {{ number_format($r['liters'], 1, ',', ' ') }} {{ number_format($r['kwh'], 1, ',', ' ') }} {{ number_format($r['fuel_cost'], 2, ',', ' ') }} {{ number_format($r['kwh_cost'], 2, ',', ' ') }} {{ number_format($r['total_cost'], 2, ',', ' ') }} {{ $r['km'] !== null ? number_format($r['km'], 0, ',', ' ') : '—' }} {{ $r['l_100km'] !== null ? number_format($r['l_100km'], 2, ',', ' ') : '—' }}
@else

Aucune donnée à afficher pour les sites.

@endif @endsection