@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $chart = $data['chart']; $rows = $data['table']; $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 '—'; $sign = $v > 0 ? '+' : ''; return $sign . number_format((float) $v, 1, ',', ' ') . ' %'; }; $fmtUnit = function ($v, $unit) { if ($v === null) return '—'; if ($unit === '%') { return number_format((float) $v, 1, ',', ' ') . ' %'; } $s = number_format((float) $v, 0, ',', ' '); return $unit ? ($s . ' ' . $unit) : $s; }; // ── Multi-series line chart ──────────────────────────────────────── $chartW = 540; $chartH = 180; $padX = 36; $padY = 24; $labels = $chart['labels'] ?? []; $series = $chart['series'] ?? []; $count = max(count($labels), 1); $stepX = $count > 1 ? ($chartW - 2 * $padX) / ($count - 1) : 0; // Per-series scaling. $polylines = []; foreach ($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; } $points = []; foreach ($s['data'] as $i => $v) { if ($v === null) continue; $x = $padX + $i * $stepX; $y = $chartH - $padY - (($v - $min) / ($max - $min)) * ($chartH - 2 * $padY); $points[] = ['x' => $x, 'y' => $y, 'v' => $v]; } $polylines[] = [ 'color' => $s['color'], 'label' => $s['label'], 'points' => $points, ]; } // ── Tone palette for impact chips ────────────────────────────────── $toneBg = ['success' => '#D1FAE5', 'warning' => '#FEF3C7', 'danger' => '#FEE2E2', 'neutral' => '#F3F4F6']; $toneColor = ['success' => '#065F46', 'warning' => '#92400E', 'danger' => '#991B1B', 'neutral' => '#374151']; $arrowFor = function ($direction) { return match ($direction) { 'up' => '▲', 'down' => '▼', default => '–', }; }; @endphp @section('content')
DADYCAR FLEET MANAGER

{{ $meta['title'] }}

Synthèse globale {{ $meta['code'] }} Période 1 : {{ $meta['period_1']['label'] }} · Période 2 : {{ $meta['period_2']['label'] }} · {{ $meta['site_label'] }} · {{ $meta['total_vehicles'] }} véhicules · Généré le {{ $meta['generated_at']->locale('fr')->isoFormat('D MMMM YYYY') }}

Synthèse de la comparaison

Indicateurs en hausse
{{ $kpis['indicators_up']['value'] }}
{{ $kpis['indicators_up']['delta_label'] }}
Variation moyenne
{{ $kpis['avg_variation']['value'] === null ? '—' : $fmtPct($kpis['avg_variation']['value']) }}
{{ $kpis['avg_variation']['delta_label'] }}
Gain TCO
{{ $fmtNum($kpis['tco_gain']['value']) }}{{ $kpis['tco_gain']['unit'] }}
{{ $kpis['tco_gain']['delta_label'] }}
Impact financier
{{ $fmtNum($kpis['financial_impact']['value']) }}{{ $kpis['financial_impact']['unit'] }}
{{ $kpis['financial_impact']['delta_label'] }}

Évolution des KPIs clés sur la période

@if (!empty($labels)) @foreach ($polylines as $line) @if (count($line['points']) > 0) @php $polyline = implode(' ', array_map(fn ($p) => "{$p['x']},{$p['y']}", $line['points'])); @endphp @foreach ($line['points'] as $p) @endforeach @endif @endforeach @foreach ($labels as $i => $lbl) @php $x = $padX + $i * $stepX; @endphp {{ $lbl }} @endforeach
@foreach ($polylines as $line) {{ $line['label'] }} @endforeach
@else

Pas de données mensuelles disponibles.

@endif

Tableau comparatif complet — {{ $meta['period_1']['label'] }} vs {{ $meta['period_2']['label'] }}

@if (!empty($rows)) @foreach ($rows as $r) @php $tone = $r['tone'] ?? 'neutral'; $bg = $toneBg[$tone] ?? $toneBg['neutral']; $fg = $toneColor[$tone] ?? $toneColor['neutral']; @endphp @endforeach
Indicateur {{ $meta['period_1']['label'] }} {{ $meta['period_2']['label'] }} Évolution Impact
{{ $r['indicator'] }} {{ $fmtUnit($r['period_1'], $r['unit']) }} {{ $fmtUnit($r['period_2'], $r['unit']) }} {{ $fmtPct($r['delta_pct']) }} {{ $arrowFor($r['direction']) }}
@else

Aucun indicateur calculable.

@endif @endsection