@extends('layouts.app') @section('title', 'Statistiche – RoBenz') @push('head') @endpush @section('content') {{-- HEADER --}}

πŸ“Š Statistiche {{ $province }}

Prezzi self service Β· ultimi {{ $days }} giorni Β· dati MIMIT

{{-- STATO DATI --}} @if(empty($summary))
πŸ“Š

Nessun dato statistico disponibile

Esegui questi comandi sul server per generare le statistiche:

php artisan db:seed --class=MonthlyHistorySeeder php artisan stats:compute --days=31

Oppure aspetta domani: il sistema calcola le statistiche automaticamente alle 10:00.

@else @php $fuelMeta = [ 'Benzina' => [ 'icon' => '🟒', 'avgCss' => 'text-brand-700', 'bgCss' => 'bg-brand-50', 'border' => 'border-brand-200', 'barCss' => 'bg-brand-500', 'sparkHex'=> '#16a34a', ], 'Gasolio' => [ 'icon' => 'πŸ”΅', 'avgCss' => 'text-blue-700', 'bgCss' => 'bg-blue-50', 'border' => 'border-blue-200', 'barCss' => 'bg-blue-500', 'sparkHex'=> '#3b82f6', ], 'GPL' => [ 'icon' => '🟣', 'avgCss' => 'text-purple-700', 'bgCss' => 'bg-purple-50', 'border' => 'border-purple-200', 'barCss' => 'bg-purple-500', 'sparkHex'=> '#a855f7', ], 'Metano' => [ 'icon' => '🟠', 'avgCss' => 'text-orange-700', 'bgCss' => 'bg-orange-50', 'border' => 'border-orange-200', 'barCss' => 'bg-orange-500', 'sparkHex'=> '#f97316', ], ]; $sparkIdx = 0; @endphp
@foreach($fuelMeta as $fuel => $m) @php $s = $summary[$fuel] ?? null; $currentSparkIdx = $sparkIdx++; @endphp
{{-- HEADER CARD --}}
{{ $m['icon'] }} {{ $fuel }} @if($s && isset($s['source']) && $s['source'] === 'prices_live') live @endif
{{-- Delta vs ieri --}} @if($s && $s['delta_percent'] !== null) @php $dp = $s['delta_percent']; $down = $dp <= 0; @endphp {{ $dp > 0 ? 'β–²' : ($dp < 0 ? 'β–Ό' : '–') }} {{ abs($dp) > 0.001 ? number_format(abs($dp), 2, ',', '.') . '%' : 'invariato' }} vs ieri @endif
{{-- PREZZO MEDIO --}} @if($s)
{{ number_format($s['avg'], 3, ',', '.') }} €/L media
@else
N/D
@endif
@if($s)
{{-- MIN / MEDIANA / MAX --}}
Min
{{ number_format($s['min'], 3, ',', '.') }} €
Med
{{ number_format($s['med'], 3, ',', '.') }} €
Max
{{ number_format($s['max'], 3, ',', '.') }} €
{{-- BARRA SPREAD --}}
Spread min β†’ max {{ number_format($s['spread'], 3, ',', '.') }} €
@php $range = max($s['max'] - $s['min'], 0.001); $avgPct = min(100, max(0, round((($s['avg'] - $s['min']) / $range) * 100))); @endphp {{-- sfondo colorato --}}
{{-- barra fino alla media --}}
{{-- indicatore media --}}
{{ number_format($s['min'], 3, ',', '.') }} β–² avg {{ number_format($s['max'], 3, ',', '.') }}
{{-- SPARKLINE TREND --}} @if(!empty($s['trend_history']) && count($s['trend_history']) > 2)
Trend {{ $days }}gg
@else
Storico non disponibile Β· Esegui stats:compute
@endif {{-- FOOTER --}}
{{ $s['station_count'] }} impianti @if($s['date']) {{ \Carbon\Carbon::parse($s['date'])->format('d/m/Y') }} @else – @endif
@else
Nessun dato per {{ $fuel }}
@endif
@endforeach
{{-- NOTA FONTE DATI --}} @if(collect($summary)->contains('source', 'prices_live'))
Nota: alcune card mostrano dati live (prezzi attuali) perchΓ© lo storico non Γ¨ ancora stato calcolato. Per attivare i trend storici, esegui: php artisan stats:compute --days=31
@endif @endif @endsection @push('scripts') @endpush