@extends('reports.pdf.layout')
@section('title', $data['meta']['title'])
@php
$meta = $data['meta'];
$kpis = $data['kpis'];
$monthly = $data['monthly'];
$alternatives = $data['alternatives'];
$fmtNum = function ($v, $unit = '') {
if ($v === null) return '—';
$s = is_numeric($v) ? number_format((float) $v, 0, ',', ' ') : (string) $v;
return trim($s . ' ' . $unit);
};
$toneBg = ['danger' => '#FEE2E2', 'warning' => '#FEF3C7', 'success' => '#D1FAE5', 'neutral' => '#F3F4F6'];
$toneColor = ['danger' => '#991B1B', 'warning' => '#92400E', 'success' => '#065F46', 'neutral' => '#374151'];
$barW = 480; $barH = 170; $barPadX = 30; $barPadY = 22;
$maxV = 0;
foreach ($monthly as $m) { $maxV = max($maxV, (int) $m['total']); }
$maxV = max($maxV, 1);
$barCount = count($monthly);
$barSlot = $barCount > 0 ? ($barW - 2 * $barPadX) / $barCount : 0;
$barWidth = $barSlot * 0.55;
$stack = [
['key' => 'leasing', 'color' => '#8B5CF6', 'label' => 'Loyer LLD'],
['key' => 'fuel', 'color' => '#10B981', 'label' => 'Carburant'],
['key' => 'maintenance', 'color' => '#F59E0B', 'label' => 'Maintenance'],
['key' => 'insurance', 'color' => '#3B82F6', 'label' => 'Assurance'],
['key' => 'other', 'color' => '#6B7280', 'label' => 'Autre'],
];
@endphp
@section('content')
DADYCAR FLEET MANAGER
{{ $meta['title'] }}
Autopartage & Pool
{{ $meta['code'] }}
Période : {{ $meta['period']['label'] }} · {{ $meta['site_label'] }} ·
{{ $meta['pool_count'] }} véhicules pool ·
Généré le {{ $meta['generated_at']->locale('fr')->isoFormat('D MMMM YYYY') }}
Indicateurs clés
Coût total pool
{{ $fmtNum($kpis['total_cost_pool']['value']) }}{{ $kpis['total_cost_pool']['unit'] }}
{{ $kpis['total_cost_pool']['delta_label'] }}
Coût par réservation
{{ $fmtNum($kpis['cost_per_reservation']['value']) }}{{ $kpis['cost_per_reservation']['unit'] }}
{{ $kpis['cost_per_reservation']['delta_label'] }}
Coût par km
{{ $kpis['cost_per_km_pool']['value'] !== null ? number_format($kpis['cost_per_km_pool']['value'], 1, ',', ' ') : '—' }}{{ $kpis['cost_per_km_pool']['unit'] }}
{{ $kpis['cost_per_km_pool']['delta_label'] }}
Économie vs alt.
{{ $fmtNum($kpis['savings_vs_alt']['value']) }}{{ $kpis['savings_vs_alt']['unit'] }}
{{ $kpis['savings_vs_alt']['delta_label'] }}
Décomposition des coûts mensuels (€)
@if ($maxV > 0)
@foreach ($stack as $s)
{{ $s['label'] }}@if (! $loop->last) @endif
@endforeach
@else
Pas de données.
@endif
Comparaison avec les alternatives (€/réservation)
@if (!empty($alternatives))
| Alternative |
Coût/rés. |
Évolution |
Verdict |
@foreach ($alternatives as $r)
@php
$tone = $r['tone'] ?? 'neutral';
$bg = $toneBg[$tone]; $fg = $toneColor[$tone];
@endphp
| {{ $r['label'] }} |
{{ $r['amount'] }} |
{{ $r['detail'] }} |
{{ $r['note'] }} |
@endforeach
@else
Pas d'alternatives à comparer.
@endif
@endsection