@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')
DADYCAR FLEET MANAGER

{{ $meta['title'] }}

Synthèse globale {{ $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 de performance par site

Meilleur site
{{ $kpis['best_site']['value'] }}
{{ $kpis['best_site']['delta_label'] }}
Site à améliorer
{{ $kpis['worst_site']['value'] }}
{{ $kpis['worst_site']['delta_label'] }}
Écart TCO maximal
{{ $fmtNum($kpis['tco_gap']['value']) }}{{ $kpis['tco_gap']['unit'] }}
{{ $kpis['tco_gap']['delta_label'] }}
Sites dans l'objectif
{{ $kpis['sites_target']['value'] }}
{{ $kpis['sites_target']['delta_label'] }}

Comparaison multi-indicateurs par site

@if (!empty($chart['labels'])) {{-- baseline --}} @foreach ($chart['labels'] as $i => $label) @php $groupX = $barPadX + $i * $groupWidth; $labelX = $groupX + $groupWidth / 2; @endphp @foreach ($chart['series'] as $j => $s) @php $val = $s['data'][$i] ?? null; $scale = $seriesScales[$s['key']]; $h = ($val !== null) ? (($val - $scale['min']) / ($scale['max'] - $scale['min'])) * ($barH - 2 * $barPadY) : 0; if ($h < 0) $h = 0; $x = $groupX + ($j + 0.5) * $barWidth; $y = $barH - $barPadY - $h; @endphp @if ($val !== null) {{ is_numeric($val) ? number_format((float) $val, 0, ',', ' ') : $val }} @endif @endforeach {{ $label }} @endforeach
@foreach ($chart['series'] as $s) {{ $s['label'] }} @endforeach
@else

Aucun site disponible pour la comparaison.

@endif

Tableau de bord détaillé par site

@if (!empty($rows)) @foreach ($rows as $r) @endforeach
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'] }}
@else

Aucune donnée site sur la période.

@endif @endsection