@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $chart = $data['chart']; $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); }; $fmtPct = function ($v) { if ($v === null) return '—'; return number_format((float) $v, 1, ',', ' ') . ' %'; }; $fmtDelta = function ($v) { if ($v === null) return null; $sign = $v > 0 ? '+' : ''; return $sign . number_format((float) $v, 1, ',', ' ') . ' %'; }; $deltaClass = function ($v, bool $maximize = true) { if ($v === null || $v == 0) return 'delta-flat'; $up = $v > 0; return ($up === $maximize) ? 'delta-up' : 'delta-down'; }; // ── Grouped bar chart geometry ───────────────────────────────────── // We render the bar chart as a fixed-size SVG (wkhtmltopdf 0.12.x). // Each site gets one group of N bars, one bar per series. $barW = 540; $barH = 200; $barPadX = 36; $barPadY = 28; $siteCount = max(count($chart['labels']), 1); $seriesCount = max(count($chart['series']), 1); $groupWidth = ($barW - 2 * $barPadX) / $siteCount; $barWidth = $groupWidth / ($seriesCount + 1); // Each series gets its own scale so different units coexist. $seriesScales = []; foreach ($chart['series'] as $s) { $vals = array_filter($s['data'], fn ($v) => $v !== null); $min = !empty($vals) ? min($vals) : 0; $max = !empty($vals) ? max($vals) : 1; if ($max == $min) { $max = $min + 1; } $seriesScales[$s['key']] = ['min' => 0, 'max' => $max * 1.1]; } @endphp @section('content')
Aucun site disponible pour la comparaison.
@endif| Site | Véhicules | TCO moy. | Δ TCO | Disponibilité | Sinistres | Conformité | Score conduite |
|---|---|---|---|---|---|---|---|
| {{ $r['site'] }} | {{ $r['vehicles'] }} | {{ $fmtNum($r['tco'], '€') }} | @if ($r['tco_delta'] !== null) {{ $fmtDelta($r['tco_delta']) }} @else — @endif | {{ $fmtPct($r['availability']) }} | {{ $r['claims'] }} | {{ $fmtPct($r['compliance']) }} | {{ $r['eco_score'] === null ? 'À venir' : $r['eco_score'] }} |
Aucune donnée site sur la période.
@endif @endsection