@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $rows = $data['rows']; $pie = $data['pie']; $trend = $data['trend']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, 0, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; $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', 'success' => '#D1FAE5', 'neutral' => '#F3F4F6']; $toneColor = ['danger' => '#991B1B', 'warning' => '#92400E', 'success' => '#065F46', 'neutral' => '#374151']; $statusTone = ['expired' => 'danger', 'expiring_30' => 'warning', 'expiring_60' => 'warning', 'valid' => 'success', 'unknown' => 'neutral']; // Pie geometry. $pieRadius = 50; $pieCx = 60; $pieCy = 60; $totalPie = array_sum(array_column($pie, 'value')); $pieSlices = []; $accAngle = -90; foreach ($pie as $i => $p) { if ($totalPie <= 0) break; $sweep = ((float) $p['value'] / $totalPie) * 360; $isFull = $sweep >= 359.999; if ($isFull) { $path = null; } else { $rad1 = deg2rad($accAngle); $rad2 = deg2rad($accAngle + $sweep); $x1 = $pieCx + $pieRadius * cos($rad1); $y1 = $pieCy + $pieRadius * sin($rad1); $x2 = $pieCx + $pieRadius * cos($rad2); $y2 = $pieCy + $pieRadius * sin($rad2); $largeArc = $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, $pieRadius, $pieRadius, $largeArc, $x2, $y2); } $pieSlices[] = ['path' => $path, 'color' => $p['color'], 'label' => $p['label'], 'value' => $p['value']]; $accAngle += $sweep; } // Premium trend line. $chartW = 480; $chartH = 140; $padX = 30; $padY = 18; $values = array_filter($trend['values'] ?? [], fn ($v) => $v !== null); $minV = !empty($values) ? min($values) : 0; $maxV = !empty($values) ? max($values) : 1; 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)); @endphp @section('content')
| Véhicule | Assureur | Couverture | Échéance | Prime/mois | Franchise | Statut |
|---|---|---|---|---|---|---|
| {{ $r['vehicle'] }} | {{ $r['insurer'] }} | {{ $r['coverage'] }} | {{ $fmtDate($r['expiration']) }} | {{ $fmtNum($r['premium'], '€') }} | {{ $fmtNum($r['franchise'], '€') }} | {{ $r['status_label'] }} |
Aucune police pour les filtres choisis.
@endif|
@foreach ($pieSlices as $s)
{{ $s['label'] }} — {{ $s['value'] }}
@endforeach
|
Aucune donnée par assureur.
@endifPas de données de prime sur 6 mois.
@endif