@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, 0, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; // Pie geometry. $cx = 70; $cy = 70; $r = 60; $segs = $data['pie_segments']; $totalSeg = array_sum(array_map(fn ($s) => $s['count'], $segs)); $slices = []; $acc = -90; foreach ($segs as $s) { if ($totalSeg <= 0) break; $sweep = ($s['count'] / $totalSeg) * 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; } // Bar chart for monthly distribution. $bars = $data['monthly']; $maxBar = max(1, !empty($bars) ? max(array_map(fn ($b) => $b['count'], $bars)) : 1); $barW = 480; $barH = 140; $barPad = 30; $barWidth = !empty($bars) ? max(8, (int) (($barW - 2 * $barPad) / max(1, count($bars))) - 6) : 0; $toneBg = ['success' => '#D1FAE5', 'warning' => '#FEF3C7', 'danger' => '#FEE2E2', 'neutral' => '#F3F4F6']; $toneFg = ['success' => '#065F46', 'warning' => '#92400E', 'danger' => '#991B1B', 'neutral' => '#374151']; $toneIcon = ['success' => '✓', 'warning' => '!', 'danger' => '✕', 'neutral' => '·']; @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 de fin de contrat

Contrats < 30 jours
{{ $fmtNum($k['count_30d']['value']) }}
{{ $k['count_30d']['caption'] }}
Contrats 30-60 jours
{{ $fmtNum($k['count_60d']['value']) }}
{{ $k['count_60d']['caption'] }}
Pénalités potentielles
{{ $fmtNum($k['penalty_total']['value']) }}{{ $k['penalty_total']['unit'] ?? '' }}
{{ $k['penalty_total']['caption'] }}
Contrats à renouveler
{{ $fmtNum($k['count_renew']['value']) }}
{{ $k['count_renew']['caption'] }}

Échéances sur les 12 prochains mois

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

Pas de contrat à venir.

@endif

Répartition par horizon d'échéance

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

Aucun contrat actif.

@endif

Alertes kilométriques

@foreach ($data['km_alerts'] as $p) @php $tone = $p['tone'] ?? 'neutral'; $bg = $toneBg[$tone] ?? $toneBg['neutral']; $fg = $toneFg[$tone] ?? $toneFg['neutral']; @endphp
{{ $toneIcon[$tone] ?? '·' }} {{ $p['title'] }}@if (!empty($p['reference'])) · {{ $p['reference'] }}@endif @if (!empty($p['meta']))
{{ $p['meta'] }}@endif
@endforeach

Détail des contrats arrivant à échéance (90 jours)

@if (!empty($data['detail'])) @foreach ($data['detail'] as $r) @endforeach
Immat. Modèle Type Échéance Restant Km contrat Km réel Écart Pénalité
{{ $r['plate'] }} {{ $r['label'] }} {{ $r['type'] }} {{ $r['end_label'] }} {{ $r['days_remaining'] }} j @if ($r['km_contract'] !== null){{ number_format($r['km_contract'], 0, ',', ' ') }}@else À venir@endif @if ($r['km_real'] !== null){{ number_format($r['km_real'], 0, ',', ' ') }}@else À venir@endif @if ($r['gap'] !== null){{ ($r['gap'] > 0 ? '+' : '') . number_format($r['gap'], 0, ',', ' ') }}@else —@endif @if (($r['penalty'] ?? 0) > 0){{ number_format($r['penalty'], 0, ',', ' ') }} €@else 0 €@endif

Pénalité estimée à 0,50 € / km (taux moyen — les avenants au contrat peuvent prévoir un taux différent).

@else

Aucun contrat arrivant à échéance dans les 90 jours.

@endif @endsection