@extends('reports.pdf.layout')
@section('title', $data['meta']['title'])
@php
$meta = $data['meta'];
$kpis = $data['kpis'];
$reasons = $data['top_reasons'];
$rec = $data['recurrent_vehicles'];
$fmtNum = function ($v, $unit = '') {
if ($v === null) return '—';
$s = is_numeric($v) ? number_format((float) $v, is_float($v) && fmod((float) $v, 1) !== 0.0 ? 1 : 0, ',', ' ') : (string) $v;
return trim($s . ' ' . $unit);
};
// Bar chart geometry — top 5 reasons (count).
$chartW = 480; $chartH = 180; $padX = 30; $padY = 30;
$vals = array_map(fn ($r) => (int) $r['count'], $reasons);
$maxV = !empty($vals) ? max($vals) : 0;
if ($maxV <= 0) { $maxV = 1; }
$barCount = count($reasons);
$availW = $chartW - 2 * $padX;
$barW = $barCount > 0 ? ($availW / $barCount) * 0.55 : 0;
$stepX = $barCount > 0 ? $availW / max($barCount, 1) : 0;
$barColors = ['#EF4444', '#F59E0B', '#3B82F6', '#8B5CF6', '#10B981'];
@endphp
@section('content')
DADYCAR FLEET MANAGER
{{ $meta['title'] }}
Maintenance
{{ $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 pannes
Top motif panne
{{ $kpis['top_reason']['value'] ?? '—' }}
{{ $kpis['top_reason']['delta_label'] }}
Véhicules les plus touchés
{{ $fmtNum($kpis['vehicles_affected']['value']) }}
{{ $kpis['vehicles_affected']['delta_label'] }}
Fréquence
{{ $fmtNum($kpis['frequency']['value']) }}{{ $kpis['frequency']['unit'] }}
{{ $kpis['frequency']['delta_label'] }}
Coût cumulé
{{ $fmtNum($kpis['cumulative_cost']['value']) }}{{ $kpis['cumulative_cost']['unit'] }}
{{ $kpis['cumulative_cost']['delta_label'] }}
Top motifs de panne
@if (!empty($reasons) && $maxV > 0)
Motif dérivé du label de l'issue (à défaut du titre). Classification dédiée à venir.
@else
Aucune panne enregistrée sur la période.
@endif
Véhicules récurrents
@if (!empty($rec))
| Immat. |
Véhicule |
Pannes |
Coût maintenance (€) |
@foreach ($rec as $r)
| {{ $r['plate'] }} |
{{ $r['vehicle'] }} |
{{ $r['breakdown_count'] }} |
{{ $r['cost'] !== null ? number_format($r['cost'], 0, ',', ' ') : '—' }} |
@endforeach
@else
Aucun véhicule avec pannes récurrentes (≥ 2) sur la période.
@endif
@endsection