@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $k = $data['kpis']; $top = $data['top_consumers']; $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 10 consumers. $bars = $top; $maxBar = !empty($bars) ? max(1, max(array_map(fn ($b) => (float) ($b['consumption'] ?? 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_vehicles'] }} véhicules · 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'] }}
Conso. moy. flotte
{{ $fmtNum($k['fleet_avg']['value']) }}{{ $k['fleet_avg']['unit'] }}
{{ $k['fleet_avg']['delta_label'] }}
Coût annuel estimé
{{ $fmtNum($k['annual_cost_estimate']['value']) }}{{ $k['annual_cost_estimate']['unit'] }}
{{ $k['annual_cost_estimate']['delta_label'] }}
Cause probable
—
{{ $k['probable_cause']['delta_label'] }}

Top 10 consommateurs

@if (!empty($bars)) @foreach ($bars as $i => $b) @php $val = (float) ($b['consumption'] ?? 0); $h = ($val / $maxBar) * ($barH - 60); $x = $barPad + $i * (($barW - 2 * $barPad) / count($bars)) + 4; $y = $barH - 30 - $h; $color = $b['motor'] === 'Electric' ? '#10B981' : ($b['motor'] === 'Diesel' ? '#6B7280' : '#3B82F6'); @endphp {{ $b['plate'] ?? '—' }} {{ $b['motor'] }} {{ $b['consumption'] !== null ? number_format($b['consumption'], 1, ',', ' ') : '—' }} @endforeach @else

Aucune consommation enregistrée sur la période.

@endif

Détails et écart à la moyenne

@if (!empty($top)) @foreach ($top as $r) @endforeach
Immatriculation Marque / Modèle Énergie Consommation Écart à la moy. Coût (€) Coût annuel (€) Cause probable
{{ $r['plate'] ?? '—' }} {{ $r['model'] }} {{ $r['motor'] }} {{ $r['consumption'] !== null ? number_format($r['consumption'], 2, ',', ' ') . ' ' . $r['unit'] : '—' }} {{ $r['delta_to_avg'] !== null ? (($r['delta_to_avg'] >= 0 ? '+' : '') . number_format($r['delta_to_avg'], 2, ',', ' ')) : '—' }} {{ number_format($r['cost'], 2, ',', ' ') }} {{ $r['annual_cost'] !== null ? number_format($r['annual_cost'], 0, ',', ' ') : '—' }} {{ $r['cause'] ?? '—' }}

Cause probable : analyse comportementale à venir (signal éco-conduite non disponible).

@else

Aucune donnée à afficher.

@endif @endsection