@extends('layouts.master') @section('content')

Rapport des approvisionnements et consommation par filiale

Filtrer les données

Stock Initial {{ number_format($stockInitialValue, 2, ',', ' ') }} L
Total Approvisionnements {{ number_format($totalAppro, 2, ',', ' ') }} L
Total Consommations {{ number_format($totalConsommation, 2, ',', ' ') }} L
Stock Final {{ number_format($stockFinal, 2, ',', ' ') }} L

Rapport pour la période du {{ \Carbon\Carbon::parse($date_debut)->format('d/m/Y') }} au {{ \Carbon\Carbon::parse($date_fin)->format('d/m/Y') }}

@if(request('type_carburant') > 0) Type de carburant: {{ $types_carburant->where('id_carburant', request('type_carburant'))->first()->type_carburant ?? '' }} @else Tous les types de carburant @endif

@foreach($filiales as $filiale) @php $filialeName = strlen($filiale->nom_filiale) > 12 ? substr($filiale->nom_filiale, 0, 12) . '...' : $filiale->nom_filiale; @endphp @endforeach @foreach($rapport as $jour) @foreach($filiales as $filiale) @php // CHANGEMENT ICI : Accès à la quantité via le tableau associatif $consommation = $jour['consommations_par_filiale'][$filiale->id_filiale]['quantite'] ?? 0; $hasConsommation = $consommation > 0; $totalFiliale = $totauxParFiliale[$filiale->id_filiale]['quantite'] ?? 0; $isImportant = $totalFiliale > 0 && $consommation > ($totalFiliale * 0.1); // Plus de 10% du total $isVeryImportant = $totalFiliale > 0 && $consommation > ($totalFiliale * 0.2); // Plus de 20% du total $cellClass = $isVeryImportant ? 'bg-warning' : ($isImportant ? 'bg-light-warning' : ''); $textClass = $hasConsommation ? 'font-weight-bold' : ''; $textColor = $hasConsommation ? 'text-primary' : ''; $displayValue = $hasConsommation ? number_format($consommation, 2, ',', ' ') . ' L' : '-'; $title = $hasConsommation ? "{$filiale->nom_filiale}: {$displayValue}" : ''; @endphp @endforeach @endforeach @foreach($filiales as $filiale) @php // CHANGEMENT ICI : Accès à la quantité via le tableau associatif $totalFiliale = $totauxParFiliale[$filiale->id_filiale]['quantite'] ?? 0; $hasTotal = $totalFiliale > 0; $cellClass = $hasTotal ? 'bg-light-success' : ''; $textClass = $hasTotal ? 'text-success' : ''; $displayValue = $hasTotal ? number_format($totalFiliale, 2, ',', ' ') . ' L' : '-'; $title = $hasTotal ? "Total {$filiale->nom_filiale}: {$displayValue}" : ''; @endphp @endforeach
DATE APPRO STOCK INITIAL CONSOMMATION PAR FILIALE STOCK FINAL CONSOMMATION TOTALE
{{ $filialeName }}
{{ \Carbon\Carbon::parse($jour['date'])->format('d/m/Y') }} @if($jour['approvisionnement'] > 0) {{ number_format($jour['approvisionnement'], 2, ',', ' ') }} L @else - @endif {{ number_format($jour['stock_initial'], 2, ',', ' ') }} L {{ $displayValue }} {{ number_format($jour['stock_final'], 2, ',', ' ') }} L @if($jour['consommation_totale'] > 0) {{ number_format($jour['consommation_totale'], 2, ',', ' ') }} L @else - @endif
TOTAUX {{ number_format($totalAppro, 2, ',', ' ') }} L {{ number_format($stockInitialValue, 2, ',', ' ') }} L {{ $displayValue }} {{ number_format($stockFinal, 2, ',', ' ') }} L {{ number_format($totalConsommation, 2, ',', ' ') }} L
@if($totalConsommation > 0)

Graphique de consommation par filiale

@endif

Résumé de la période

Filiales avec consommation :
    @php $filialesAvecConsommation = []; foreach ($filiales as $filiale) { $totalFiliale = $totauxParFiliale[$filiale->id_filiale]['quantite'] ?? 0; if ($totalFiliale > 0) { $filialesAvecConsommation[] = [ 'nom' => $filiale->nom_filiale, 'total' => $totalFiliale, 'pourcentage' => $totalConsommation > 0 ? round(($totalFiliale / $totalConsommation) * 100, 2) : 0 ]; } } // Trier par consommation décroissante usort($filialesAvecConsommation, function($a, $b) { return $b['total'] <=> $a['total']; }); @endphp @foreach($filialesAvecConsommation as $filiale)
  • {{ $filiale['nom'] }} {{ number_format($filiale['total'], 2, ',', ' ') }} L ({{ $filiale['pourcentage'] }}%)
  • @endforeach @if(count($filialesAvecConsommation) == 0)
  • Aucune consommation enregistrée pour cette période
  • @endif
Équilibre stock :
@php $stockMax = max($stockInitialValue + $totalAppro, $totalConsommation, $stockFinal); $pourcentageInitial = $stockMax > 0 ? ($stockInitialValue / $stockMax) * 100 : 0; $pourcentageAppro = $stockMax > 0 ? ($totalAppro / $stockMax) * 100 : 0; $pourcentageConsommation = $stockMax > 0 ? ($totalConsommation / $stockMax) * 100 : 0; $pourcentageFinal = $stockMax > 0 ? ($stockFinal / $stockMax) * 100 : 0; @endphp
Initial
Appro
Conso
Final
Détails :
Stock Initial + Approvisionnements {{ number_format($stockInitialValue + $totalAppro, 2, ',', ' ') }} L
Consommations Total {{ number_format($totalConsommation, 2, ',', ' ') }} L
Stock Final (calculé) {{ number_format(($stockInitialValue + $totalAppro) - $totalConsommation, 2, ',', ' ') }} L
Stock Final (réel) {{ number_format($stockFinal, 2, ',', ' ') }} L
Écart @php $ecart = (($stockInitialValue + $totalAppro) - $totalConsommation) - $stockFinal; $ecartClass = abs($ecart) < 0.01 ? 'text-success' : 'text-danger'; @endphp {{ number_format($ecart, 2, ',', ' ') }} L
@endsection