@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $rows = $data['rows']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, 0, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; // Stacked horizontal bar geometry — one row per driver, segments per // bucket. Width scales to the max driver total. $segments = [ ['key' => 'fuel', 'label' => 'Carburant', 'color' => '#3B82F6'], ['key' => 'maintenance', 'label' => 'Maintenance', 'color' => '#F59E0B'], ['key' => 'fines', 'label' => 'Amendes', 'color' => '#8B5CF6'], ['key' => 'claims_cost', 'label' => 'Sinistres', 'color' => '#EF4444'], ]; $maxTotal = 0; foreach ($rows as $r) { $maxTotal = max($maxTotal, (float) $r['total']); } if ($maxTotal <= 0) { $maxTotal = 1; } $trackW = 280; // pt @endphp @section('content')
|
{{ $r['driver'] }}
|
@php $offset = 0; @endphp
@foreach ($segments as $seg)
@php
$val = (float) ($r[$seg['key']] ?? 0);
$segLen = $maxTotal > 0 ? ($val / $maxTotal) * $trackW : 0;
@endphp
@if ($segLen > 0)
@endif
@endforeach
|
{{ $fmtNum($r['total']) }} € |
Aucun conducteur avec dépense pour la période.
@endif @endsection