@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $categories = $data['categories']; $trend = $data['trend']; $perSite = $data['per_site']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, 1, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; $toneBar = ['success' => '#10B981', 'warning' => '#F59E0B', 'danger' => '#EF4444', 'neutral' => '#6B7280']; $barTrackW = 220; // Trend line. $chartW = 320; $chartH = 130; $padX = 30; $padY = 18; $values = array_filter($trend['values'] ?? [], fn ($v) => $v !== null); $minV = !empty($values) ? min($values) : 0; $maxV = !empty($values) ? max($values) : 100; if ($minV === $maxV) { $maxV = $minV + 1; } $stepX = count($trend['labels']) > 1 ? ($chartW - 2 * $padX) / (count($trend['labels']) - 1) : 0; $points = []; foreach ($trend['values'] as $i => $v) { if ($v === null) continue; $x = $padX + $i * $stepX; $y = $chartH - $padY - (($v - $minV) / ($maxV - $minV)) * ($chartH - 2 * $padY); $points[] = ['x' => $x, 'y' => $y, 'label' => $trend['labels'][$i] ?? '', 'value' => $v]; } $polyline = implode(' ', array_map(fn ($p) => "{$p['x']},{$p['y']}", $points)); // Per-site bars. $sBarW = 480; $sBarH = 130; $sBarPadX = 30; $sBarPadY = 18; $sLabels = array_column($perSite, 'site'); $sValues = array_map(fn ($r) => (float) ($r['rate'] ?? 0), $perSite); $sMax = 100; $sCount = count($sLabels); $sSlot = $sCount > 0 ? ($sBarW - 2 * $sBarPadX) / $sCount : 0; $sWidth = $sSlot * 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

Conformité globale
{{ $fmtNum($kpis['global_compliance']['value']) }}{{ $kpis['global_compliance']['unit'] }}
{{ $kpis['global_compliance']['delta_label'] }}
Non-conformités actives
{{ $kpis['non_compliant_count']['value'] }}
{{ $kpis['non_compliant_count']['delta_label'] }}
Alertes critiques
{{ $kpis['critical_alerts']['value'] }}
{{ $kpis['critical_alerts']['delta_label'] }}
Objectif mensuel
{{ $fmtNum($kpis['monthly_target']['value']) }}{{ $kpis['monthly_target']['unit'] }}
{{ $kpis['monthly_target']['delta_label'] }}

Taux de conformité par catégorie

@if (!empty($categories)) @foreach ($categories as $c) @php $w = $c['rate'] !== null ? min($barTrackW, ($c['rate'] / 100) * $barTrackW) : 0; $color = $toneBar[$c['tone']] ?? $toneBar['neutral']; @endphp
{{ $c['label'] }}
{{ $c['sublabel'] }}
{{ $fmtNum($c['rate']) }} %
@endforeach @else

Aucune catégorie pour les filtres choisis.

@endif

Évolution du taux global (6 mois)

@if (!empty($points)) @foreach ($points as $p) {{ $p['label'] }} {{ number_format($p['value'], 1, ',', ' ') }} @endforeach @else

Pas de mesure pour la période.

@endif

Conformité par site

@if (!empty($perSite)) @foreach ($sLabels as $i => $lbl) @php $h = $sMax > 0 ? (($sValues[$i] / $sMax) * ($sBarH - 2 * $sBarPadY)) : 0; $x = $sBarPadX + $i * $sSlot + ($sSlot - $sWidth) / 2; $y = $sBarH - $sBarPadY - $h; $col = $sValues[$i] >= 95 ? '#10B981' : ($sValues[$i] >= 80 ? '#F59E0B' : '#EF4444'); @endphp {{ number_format($sValues[$i], 1, ',', ' ') }} {{ $lbl }} @endforeach @else

Aucun site avec données.

@endif @endsection