@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $k = $data['kpis']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, (is_int($v) || ((float) $v) == (int) $v) ? 0 : 1, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; // Pie geometry helper (single SVG slice path per segment). $renderPie = function (array $segments) { $cx = 70; $cy = 70; $r = 60; $total = array_sum(array_map(fn ($s) => $s['count'] ?? $s['percent'], $segments)); $slices = []; $acc = -90; foreach ($segments as $s) { $val = $s['count'] ?? $s['percent']; if ($total <= 0) break; $sweep = ($val / $total) * 360; $isFull = $sweep >= 359.999; if ($isFull) { $path = null; } else { $rad1 = deg2rad($acc); $rad2 = deg2rad($acc + $sweep); $x1 = $cx + $r * cos($rad1); $y1 = $cy + $r * sin($rad1); $x2 = $cx + $r * cos($rad2); $y2 = $cy + $r * sin($rad2); $largeArc = $sweep > 180 ? 1 : 0; $path = sprintf('M %s %s L %.2f %.2f A %s %s 0 %d 1 %.2f %.2f Z', $cx, $cy, $x1, $y1, $r, $r, $largeArc, $x2, $y2); } $slices[] = ['path' => $path, 'color' => $s['color']]; $acc += $sweep; } return ['slices' => $slices, 'cx' => $cx, 'cy' => $cy, 'r' => $r]; }; $energyPie = $renderPie($data['energy_segments']); $bodyPie = $renderPie($data['body_segments']); // Bar chart for age buckets. $bars = $data['age_buckets']; $maxBar = max(1, max(array_map(fn ($b) => $b['count'], $bars))); $barW = 480; $barH = 140; $barPad = 30; $barWidth = (int) (($barW - 2 * $barPad) / max(1, count($bars))) - 8; @endphp @section('content')
DADYCAR FLEET MANAGER

{{ $meta['title'] }}

Parc & Véhicules {{ $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

Total véhicules
{{ $fmtNum($k['total']['value']) }}
{{ $k['total']['caption'] }}
Ancienneté moyenne
{{ $fmtNum($k['avg_age']['value']) }}{{ $k['avg_age']['unit'] }}
{{ $k['avg_age']['caption'] }}
Part électrique
{{ $fmtNum($k['electric_pct']['value']) }}%
{{ $k['electric_pct']['caption'] }}
Part thermique
{{ $fmtNum($k['thermal_pct']['value']) }}%
{{ $k['thermal_pct']['caption'] }}

Répartition par énergie

@if (!empty($data['energy_segments']))
@foreach ($energyPie['slices'] as $idx => $sl) @if ($sl['path'] === null) @else @endif @endforeach @foreach ($data['energy_segments'] as $s)
{{ $s['label'] }} — {{ $s['count'] }} véh. ({{ number_format($s['percent'], 1, ',', ' ') }} %)
@endforeach
@else

Aucun véhicule.

@endif

Répartition par carrosserie

@if (!empty($data['body_segments']))
@foreach ($bodyPie['slices'] as $sl) @if ($sl['path'] === null) @else @endif @endforeach @foreach ($data['body_segments'] as $s)
{{ $s['label'] }} — {{ $s['count'] }} véh. ({{ number_format($s['percent'], 1, ',', ' ') }} %)
@endforeach
@else

Donnée carrosserie non renseignée.

@endif

Pyramide des âges du parc

@foreach ($bars as $i => $b) @php $h = ($b['count'] / $maxBar) * ($barH - 50); $x = $barPad + $i * (($barW - 2 * $barPad) / count($bars)) + 4; $y = $barH - 24 - $h; @endphp {{ $b['label'] }} {{ $b['count'] }} @endforeach

Top {{ count($data['brand_segments']) }} marques du parc ({{ $data['brand_count'] }} marques au total)

@if (!empty($data['brand_segments'])) @foreach ($data['brand_segments'] as $b) @endforeach
Marque Véhicules % du parc
{{ $b['label'] }} {{ $b['count'] }} {{ number_format($b['percent'], 1, ',', ' ') }} %
@else

Aucune marque.

@endif @endsection