@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $k = $data['kpis']; $drv = $data['drivers']; $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 — top conductors (by total cost). $bars = array_slice($drv, 0, 10); $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_drivers'] }} conducteurs · Généré le {{ $meta['generated_at']->locale('fr')->isoFormat('D MMMM YYYY') }}

Indicateurs clés

Top consommateur
{{ $k['top_consumer']['value'] ?? '—' }}
{{ $k['top_consumer']['delta_label'] }}
Économie potentielle
{{ $fmtNum($k['potential_savings']['value']) }}{{ $k['potential_savings']['unit'] }}
{{ $k['potential_savings']['delta_label'] }}
Top économe
{{ $k['top_economic']['value'] ?? '—' }}
{{ $k['top_economic']['delta_label'] }}
Conso. moy. flotte
{{ $fmtNum($k['fleet_avg']['value']) }}{{ $k['fleet_avg']['unit'] }}
{{ $k['fleet_avg']['delta_label'] }}

Top conducteurs par coût total

@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['driver_name']) > 14 ? mb_substr($b['driver_name'], 0, 13) . '…' : $b['driver_name']; @endphp {{ $label }} {{ number_format($val, 0, ',', ' ') }} € @endforeach @else

Aucune consommation attribuée à un conducteur.

@endif

Détails par conducteur

@if (!empty($drv)) @foreach ($drv as $r) @endforeach
Conducteur Carburant (L) Coût carb. (€) Énergie (kWh) Coût recharge (€) Coût total (€) Km L/100km
{{ $r['driver_name'] }} {{ number_format($r['fuel_l'], 1, ',', ' ') }} {{ number_format($r['fuel_cost'], 2, ',', ' ') }} {{ number_format($r['kwh'], 1, ',', ' ') }} {{ 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 consommation attribuée à un conducteur sur la période.

@endif @endsection