@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $pie = $data['pie']; $evolution = $data['evolution']; $rows = $data['rows']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, 1, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; // Pie geometry. $pieRadius = 50; $pieCx = 60; $pieCy = 60; $totalPie = array_sum(array_column($pie, 'value')); $pieSlices = []; $accAngle = -90; foreach ($pie as $p) { if ($totalPie <= 0) break; $sweep = ($p['value'] / $totalPie) * 360; if ($sweep <= 0) continue; $isFull = $sweep >= 359.999; if ($isFull) { $path = null; } else { $rad1 = deg2rad($accAngle); $rad2 = deg2rad($accAngle + $sweep); $x1 = $pieCx + $pieRadius * cos($rad1); $y1 = $pieCy + $pieRadius * sin($rad1); $x2 = $pieCx + $pieRadius * cos($rad2); $y2 = $pieCy + $pieRadius * sin($rad2); $largeArc = $sweep > 180 ? 1 : 0; $path = sprintf('M %s %s L %.2f %.2f A %s %s 0 %d 1 %.2f %.2f Z', $pieCx, $pieCy, $x1, $y1, $pieRadius, $pieRadius, $largeArc, $x2, $y2); } $pieSlices[] = ['path' => $path, 'color' => $p['color'], 'label' => $p['label'], 'value' => $p['value']]; $accAngle += $sweep; } // Line geometry. $lineW = 320; $lineH = 140; $linePadX = 30; $linePadY = 22; $lineSlot = count($evolution) > 1 ? ($lineW - 2 * $linePadX) / (count($evolution) - 1) : 0; @endphp @section('content')
DADYCAR FLEET MANAGER

{{ $meta['title'] }}

Durabilité ESG {{ $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

Part thermique
{{ number_format($kpis['thermal_share']['value'], 1, ',', ' ') }}{{ $kpis['thermal_share']['unit'] }}
{{ $kpis['thermal_share']['delta_label'] }}
Part propre
{{ number_format($kpis['clean_share']['value'], 1, ',', ' ') }}{{ $kpis['clean_share']['unit'] }}
{{ $kpis['clean_share']['delta_label'] }}
Émissions moyennes
{{ $kpis['avg_emissions_mix']['value'] !== null ? number_format($kpis['avg_emissions_mix']['value'], 0, ',', ' ') : '—' }}{{ $kpis['avg_emissions_mix']['unit'] }}
{{ $kpis['avg_emissions_mix']['delta_label'] }}
CO₂ total
{{ $fmtNum($kpis['total_co2_mix']['value']) }}{{ $kpis['total_co2_mix']['unit'] }}
{{ $kpis['total_co2_mix']['delta_label'] }}

Mix énergétique actuel

@if ($totalPie > 0)
@foreach ($pieSlices as $s) @if ($s['path'] === null) @else @endif @endforeach @foreach ($pieSlices as $s)
{{ $s['label'] }} — {{ $s['value'] }}
@endforeach
@else

Pas de données.

@endif

Évolution du mix sur 12 mois (%)

@php $px1=null;$py1=null;$px2=null;$py2=null;$px3=null;$py3=null; @endphp @foreach ($evolution as $i => $e) @php $x = $linePadX + $i * $lineSlot; $y1 = $lineH - $linePadY - (($e['thermique'] / 100) * ($lineH - 2 * $linePadY)); $y2 = $lineH - $linePadY - (($e['hybride'] / 100) * ($lineH - 2 * $linePadY)); $y3 = $lineH - $linePadY - (($e['electrique'] / 100) * ($lineH - 2 * $linePadY)); @endphp @if ($px1 !== null) @endif {{ $e['label'] }} @php $px1=$x;$py1=$y1;$px2=$x;$py2=$y2;$px3=$x;$py3=$y3; @endphp @endforeach

Émissions CO₂ par énergie

@foreach ($rows as $r) @endforeach
Énergie Véhicules % du parc CO₂ total (T) g/km moyen
{{ $r['energy'] }} {{ $r['count'] }} {{ number_format($r['pct'], 1, ',', ' ') }}% {{ number_format($r['co2_t'], 1, ',', ' ') }} {{ $r['avg'] }}
@endsection