@extends('reports.pdf.layout')
@section('title', $data['meta']['title'])
@php
$meta = $data['meta'];
$kpis = $data['kpis'];
$rows = $data['rows'];
$horizon = $data['horizon'];
$action = $data['action'];
$fmtNum = function ($v, $unit = '') {
if ($v === null) return '—';
$s = is_numeric($v) ? number_format((float) $v, 0, ',', ' ') : (string) $v;
return trim($s . ' ' . $unit);
};
$statusToneBar = ['success' => '#10B981', 'warning' => '#F59E0B', 'danger' => '#EF4444', 'neutral' => '#6B7280'];
$rowToneBar = function ($r) {
if (($r['penalty'] ?? 0) > 0) return '#EF4444';
if (($r['km_usage_score'] ?? 0) >= 90) return '#F59E0B';
if (($r['km_usage_score'] ?? 0) <= 50) return '#FBBF24';
return '#10B981';
};
// Horizon bars.
$barW = 320; $barH = 160; $barPadX = 30; $barPadY = 22;
$barMax = max($horizon['values'] + [1]);
$barCount = count($horizon['labels']);
$barSlot = $barCount > 0 ? ($barW - 2 * $barPadX) / $barCount : 0;
$barWidth = $barSlot * 0.55;
$bucketColors = ['#EF4444', '#F59E0B', '#FBBF24', '#10B981', '#3B82F6'];
$toneBg = ['danger' => '#FEE2E2', 'warning' => '#FEF3C7', 'success' => '#D1FAE5', 'neutral' => '#F3F4F6'];
$toneColor = ['danger' => '#991B1B', 'warning' => '#92400E', 'success' => '#065F46', 'neutral' => '#374151'];
$aTone = $action['tone'] ?? 'neutral';
@endphp
@section('content')
DADYCAR FLEET MANAGER
{{ $meta['title'] }}
Conformité
{{ $meta['code'] }}
Période : {{ $meta['period']['label'] }} · {{ $meta['site_label'] }} ·
Généré le {{ $meta['generated_at']->locale('fr')->isoFormat('D MMMM YYYY') }}
Indicateurs clés
Contrats actifs
{{ $kpis['active_contracts']['value'] }}
{{ $kpis['active_contracts']['delta_label'] }}
Fin de contrat < 3 mois
{{ $kpis['ending_3_months']['value'] }}
{{ $kpis['ending_3_months']['delta_label'] }}
Km dépassés
{{ $kpis['km_overrun']['value'] }}
{{ $kpis['km_overrun']['delta_label'] }}
Loyer mensuel total
{{ $fmtNum($kpis['total_monthly_rent']['value']) }}{{ $kpis['total_monthly_rent']['unit'] }}
{{ $kpis['total_monthly_rent']['delta_label'] }}
Contrats — état kilométrique et échéances
@if (!empty($rows))
@foreach (array_slice($rows, 0, 8) as $r)
@php
$w = $r['km_usage_score'] !== null ? min(180, ($r['km_usage_score'] / 100) * 180) : 0;
$color = $rowToneBar($r);
@endphp
{{ $r['vehicle'] }} · {{ $r['model'] }}
{{ $r['type'] }} · {{ $r['lessor'] }} · Fin : {{ $r['end_date'] ?? '—' }}
· {{ $fmtNum($r['km_actual'], 'km') }} / {{ $fmtNum($r['km_contract'], 'km') }}
{{ $r['km_usage_score'] !== null ? $r['km_usage_score'] . ' %' : '—' }}
@if ($r['penalty'] > 0)
· {{ $fmtNum($r['penalty'], '€') }}
@endif
@endforeach
@else
Aucun contrat pour les filtres choisis.
@endif
Répartition par horizon de fin
@if (array_sum($horizon['values']) > 0)
@else
Aucun contrat à venir.
@endif
@if (!empty($action['label']))
Action requise : {{ $action['label'] }}
@endif
@endsection