@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $items = $data['items']; $byType = $data['by_type']; $byTier = $data['by_tier']; $fmtDate = function ($d) { if ($d === null) return '—'; try { return \Carbon\Carbon::parse($d)->locale('fr')->isoFormat('D MMM YYYY'); } catch (\Throwable $e) { return (string) $d; } }; $toneBg = ['danger' => '#FEE2E2', 'warning' => '#FEF3C7', 'info' => '#DBEAFE', 'success' => '#D1FAE5', 'neutral' => '#F3F4F6']; $toneColor = ['danger' => '#991B1B', 'warning' => '#92400E', 'info' => '#1E3A8A', 'success' => '#065F46', 'neutral' => '#374151']; $tierTone = ['expired' => 'danger', 'within_30' => 'danger', 'within_60' => 'warning', 'within_90' => 'info']; $typeColors = ['CT' => '#3B82F6', 'Assurance' => '#10B981', 'Contrat' => '#F59E0B', "Vignette Crit'Air" => '#8B5CF6']; // Per-type horizontal bars. $typeBarMax = max($byType['values'] + [1]); $typeBarTrackW = 200; // Per-tier vertical bars. $tBarW = 320; $tBarH = 130; $tBarPadX = 30; $tBarPadY = 18; $tBarMax = max($byTier['values'] + [1]); $tCount = count($byTier['labels']); $tSlot = $tCount > 0 ? ($tBarW - 2 * $tBarPadX) / $tCount : 0; $tWidth = $tSlot * 0.55; @endphp @section('content')
DADYCAR FLEET MANAGER

{{ $meta['title'] }}

Conformité {{ $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

Échéances expirées
{{ $kpis['expired']['value'] }}
{{ $kpis['expired']['delta_label'] }}
Échéances < 30 jours
{{ $kpis['within_30']['value'] }}
{{ $kpis['within_30']['delta_label'] }}
Échéances 30-60 jours
{{ $kpis['within_60']['value'] }}
{{ $kpis['within_60']['delta_label'] }}
Échéances 60-90 jours
{{ $kpis['within_90']['value'] }}
{{ $kpis['within_90']['delta_label'] }}

Calendrier des échéances critiques (90 jours)

@if (!empty($items)) @foreach (array_slice($items, 0, 12) as $i) @php $tone = $tierTone[$i['tier']] ?? 'neutral'; $bg = $toneBg[$tone]; $fg = $toneColor[$tone]; @endphp
{{ $i['vehicle'] }}
{{ $i['type_label'] }}
{{ $i['action'] }}
{{ $fmtDate($i['expiration']) }}{{ $i['days_until'] < 0 ? ' · expiré' : ' · dans ' . $i['days_until'] . ' jours' }}
{{ $i['tier_label'] }}
@endforeach @else

Aucune échéance critique dans les 90 prochains jours.

@endif

Par type d'échéance

@if (array_sum($byType['values']) > 0) @foreach ($byType['labels'] as $i => $label) @php $w = $typeBarMax > 0 ? min($typeBarTrackW, ($byType['values'][$i] / $typeBarMax) * $typeBarTrackW) : 0; $color = $typeColors[$label] ?? '#3B82F6'; @endphp
{{ $label }}
{{ $byType['values'][$i] }}
@endforeach @else

Aucune échéance par type.

@endif

Par tranche de délai

@if (array_sum($byTier['values']) > 0) @foreach ($byTier['labels'] as $i => $lbl) @php $h = $tBarMax > 0 ? (($byTier['values'][$i] / $tBarMax) * ($tBarH - 2 * $tBarPadY)) : 0; $x = $tBarPadX + $i * $tSlot + ($tSlot - $tWidth) / 2; $y = $tBarH - $tBarPadY - $h; $col = $i === 0 ? '#EF4444' : ($i === 1 ? '#F59E0B' : '#3B82F6'); @endphp {{ $byTier['values'][$i] }} {{ $lbl }} @endforeach @else

Aucune répartition par délai.

@endif
@endsection