@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $break = $data['status_breakdown']; $issues = $data['issue_rows']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, is_float($v) && fmod($v, 1) !== 0.0 ? 1 : 0, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; // Pie geometry — 360° fallback to for the single-segment case. $pieCx = 70; $pieCy = 70; $pieR = 60; $pieTotal = array_sum(array_map(fn ($s) => $s['count'], $break)); $pieSlices = []; $acc = -90; foreach ($break as $s) { if ($pieTotal <= 0 || $s['count'] <= 0) continue; $sweep = ($s['count'] / $pieTotal) * 360; $isFull = $sweep >= 359.999; if ($isFull) { $path = null; } else { $r1 = deg2rad($acc); $r2 = deg2rad($acc + $sweep); $x1 = $pieCx + $pieR * cos($r1); $y1 = $pieCy + $pieR * sin($r1); $x2 = $pieCx + $pieR * cos($r2); $y2 = $pieCy + $pieR * sin($r2); $large = $sweep > 180 ? 1 : 0; $path = sprintf('M %s %s L %.2f %.2f A %s %s 0 %d 1 %.2f %.2f Z', $pieCx, $pieCy, $x1, $y1, $pieR, $pieR, $large, $x2, $y2); } $pieSlices[] = [ 'path' => $path, 'color' => $s['color'], 'label' => $s['label'], 'count' => $s['count'], 'percent' => $s['percent'], ]; $acc += $sweep; } $statusBadgeBg = [ 'active' => '#D1FAE5', 'inactive' => '#FEF3C7', 'error' => '#FEE2E2', 'pending' => '#DBEAFE', ]; $statusBadgeFg = [ 'active' => '#065F46', 'inactive' => '#92400E', 'error' => '#991B1B', 'pending' => '#1E3A8A', ]; @endphp @section('content')
DADYCAR FLEET MANAGER

{{ $meta['title'] }}

Télématique {{ $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') }}

État des boîtiers télématiques

Boîtiers actifs
{{ $fmtNum($kpis['active']['value']) }}
{{ $kpis['active']['delta_label'] }}
Boîtiers inactifs
{{ $fmtNum($kpis['inactive']['value']) }}
{{ $kpis['inactive']['delta_label'] }}
Boîtiers en erreur
{{ $fmtNum($kpis['error']['value']) }}
{{ $kpis['error']['delta_label'] }}
Durée moy. déconnexion
{{ $fmtNum($kpis['avg_disconnection']['value']) }}{{ $kpis['avg_disconnection']['unit'] }}
{{ $kpis['avg_disconnection']['delta_label'] }}

Répartition des statuts

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

Aucun véhicule à analyser.

@endif

Boîtiers à traiter (inactifs ou en erreur)

@if (!empty($issues)) @foreach ($issues as $r) @php $bg = $statusBadgeBg[$r['status_key']] ?? '#F3F4F6'; $fg = $statusBadgeFg[$r['status_key']] ?? '#374151'; @endphp @endforeach
Véhicule Modèle Statut Dernière synchro
{{ $r['plate'] }} {{ $r['model'] }} {{ $r['status'] }} {{ $r['last_sync'] }}
@else

Aucun boîtier inactif ou en erreur — parc 100% opérationnel.

@endif

Note : la durée de déconnexion s'appuie sur vehicles.updated_at faute d'horodatage de communication dédié dans la table devices. Une mesure plus précise sera disponible dès l'ajout d'un last_communication_at côté boîtier.

@endsection