@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis_quarter']; $series = $data['monthly_series']; $ranking = $data['site_ranking'] ?? []; $objectives = $data['objectives'] ?? []; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, 0, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; $fmtDelta = function ($v, $unit = '%') { if ($v === null) return null; $sign = $v > 0 ? '+' : ''; return $sign . number_format((float) $v, 1, ',', ' ') . $unit; }; $deltaClass = function ($v, bool $maximize = true) { if ($v === null || $v == 0) return 'delta-flat'; $up = $v > 0; return ($up === $maximize) ? 'delta-up' : 'delta-down'; }; // Multi-axis line chart geometry. Two axes : TCO (left, €) and // dispo + eco (right, %). Single SVG, fixed pixel size — wkhtmltopdf // 0.12.x renders width="100%" SVGs at 0×0. $chartW = 540; $chartH = 200; $padX = 42; $padY = 24; $tcoVals = array_filter(array_map(fn ($r) => $r['tco'], $series), fn ($v) => $v !== null); $rightVals = []; foreach ($series as $r) { if ($r['availability'] !== null) $rightVals[] = $r['availability']; if ($r['eco_score'] !== null) $rightVals[] = $r['eco_score']; } $minL = !empty($tcoVals) ? min($tcoVals) : 0; $maxL = !empty($tcoVals) ? max($tcoVals) : 1; if ($minL === $maxL) { $maxL = $minL + 1; } $minL = max(0, $minL - ($maxL - $minL) * 0.1); $maxL = $maxL + ($maxL - $minL) * 0.1; $minR = 0; $maxR = 100; $count = count($series); $stepX = $count > 1 ? ($chartW - 2 * $padX) / ($count - 1) : 0; $coords = function ($i, $value, $axis) use ($padX, $padY, $stepX, $chartH, $minL, $maxL, $minR, $maxR) { $x = $padX + $i * $stepX; if ($value === null) return null; if ($axis === 'left') { $y = $chartH - $padY - (($value - $minL) / ($maxL - $minL)) * ($chartH - 2 * $padY); } else { $y = $chartH - $padY - (($value - $minR) / ($maxR - $minR)) * ($chartH - 2 * $padY); } return ['x' => $x, 'y' => $y]; }; $seriesDefs = [ ['key' => 'tco', 'label' => 'TCO (€)', 'color' => '#3B82F6', 'axis' => 'left', 'unit' => '€'], ['key' => 'availability', 'label' => 'Disponibilité (%)', 'color' => '#10B981', 'axis' => 'right', 'unit' => '%'], ['key' => 'eco_score', 'label' => 'Score conduite', 'color' => '#8B5CF6', 'axis' => 'right', 'unit' => '/100'], ]; $renderedSeries = []; foreach ($seriesDefs as $def) { $points = []; foreach ($series as $i => $r) { $v = $r[$def['key']] ?? null; $c = $coords($i, $v, $def['axis']); if ($c !== null) { $points[] = $c + ['value' => $v]; } } $renderedSeries[] = $def + ['points' => $points]; } $toneBg = ['success' => '#D1FAE5', 'warning' => '#FEF3C7', 'danger' => '#FEE2E2', 'neutral' => '#F3F4F6']; $toneColor = ['success' => '#065F46', 'warning' => '#92400E', 'danger' => '#991B1B', 'neutral' => '#374151']; @endphp @section('content')
Pas de données mensuelles pour la période.
@endif| # | Site | Score |
|---|---|---|
| #{{ $r['rank'] }} |
{{ $r['label'] }} {{ $r['sublabel'] }} |
{{ number_format($r['score'], 0, ',', ' ') }}/100 |
Aucun site avec véhicules sur la période.
@endif| KPI | Objectif | Réalisé | Écart | Statut |
|---|---|---|---|---|
| {{ $o['kpi'] }} | {{ $o['objective'] }} | {{ $o['actual'] }} | {{ $o['gap'] }} | {{ $o['status']['label'] }} |
Pas d'objectifs définis.
@endif