@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $energy = $data['energy_breakdown']; $status = $data['status_breakdown']; $marks = $data['top_marks']; $inv = $data['inventory']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, is_float($v) && fmod($v, 1) !== 0.0 ? 1 : 0, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; // Donut geometry (re-used for both pies). Single 360° segment falls // back to a full — wkhtmltopdf 0.12 won't render a degenerate // arc. $donutBuilder = function (array $slices, array $palette) { $cx = 70; $cy = 70; $r = 60; $total = array_sum(array_map(fn ($s) => $s['count'], $slices)); $out = []; $acc = -90; foreach ($slices as $i => $s) { if ($total <= 0 || $s['count'] <= 0) continue; $sweep = ($s['count'] / $total) * 360; $isFull = $sweep >= 359.999; if ($isFull) { $path = null; } else { $r1 = deg2rad($acc); $r2 = deg2rad($acc + $sweep); $x1 = $cx + $r * cos($r1); $y1 = $cy + $r * sin($r1); $x2 = $cx + $r * cos($r2); $y2 = $cy + $r * sin($r2); $large = $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, $large, $x2, $y2); } $out[] = [ 'path' => $path, 'color' => $palette[$i % count($palette)], 'label' => $s['label'], 'count' => $s['count'], 'percent' => $s['percent'], ]; $acc += $sweep; } return ['cx' => $cx, 'cy' => $cy, 'r' => $r, 'slices' => $out]; }; $palette1 = ['#3B82F6', '#10B981', '#F59E0B', '#EF4444', '#8B5CF6', '#06B6D4', '#EC4899', '#6B7280']; $palette2 = ['#10B981', '#F59E0B', '#EF4444', '#3B82F6', '#8B5CF6', '#6B7280']; $energyPie = $donutBuilder($energy, $palette1); $statusPie = $donutBuilder($status, $palette2); @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 du parc

Total véhicules
{{ $fmtNum($kpis['total_vehicles']['value']) }}
{{ $kpis['total_vehicles']['delta_label'] }}
Âge moyen
{{ $fmtNum($kpis['avg_age']['value']) }}{{ $kpis['avg_age']['unit'] }}
{{ $kpis['avg_age']['delta_label'] }}
Kilométrage moyen
{{ $fmtNum($kpis['avg_mileage']['value']) }}{{ $kpis['avg_mileage']['unit'] }}
{{ $kpis['avg_mileage']['delta_label'] }}
Valeur du parc
{{ $fmtNum($kpis['fleet_value']['value']) }}{{ $kpis['fleet_value']['unit'] }}
{{ $kpis['fleet_value']['delta_label'] }}

Répartition par énergie

@if (!empty($energyPie['slices']))
@foreach ($energyPie['slices'] as $s) @if ($s['path'] === null) @else @endif @endforeach @foreach ($energyPie['slices'] as $s)
{{ $s['label'] }} — {{ $s['count'] }} ({{ number_format($s['percent'], 1, ',', ' ') }} %)
@endforeach
@else

Aucun véhicule à analyser.

@endif

Répartition par statut

@if (!empty($statusPie['slices']))
@foreach ($statusPie['slices'] as $s) @if ($s['path'] === null) @else @endif @endforeach @foreach ($statusPie['slices'] as $s)
{{ $s['label'] }} — {{ $s['count'] }} ({{ number_format($s['percent'], 1, ',', ' ') }} %)
@endforeach
@else

—

@endif

Top marques

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

Aucune marque enregistrée.

@endif

Extrait de l'inventaire (10 premiers)

@if (!empty($inv)) @foreach ($inv as $r) @endforeach
Immatriculation Marque / Modèle Énergie Statut Site Km
{{ $r['plate'] }} {{ $r['model'] }} {{ $r['energy'] }} {{ $r['status'] }} {{ $r['site'] }} {{ $r['km'] !== null ? number_format($r['km'], 0, ',', ' ') : '—' }}
@else

Aucun véhicule.

@endif @endsection