@php
$currentFamille = null;
$familleTotalCA = 0; // To accumulate CA for each famille
$familleTotalQTE = 0; // To accumulate QTE for each famille
$grandTotalCA = 0; // To accumulate grand total CA
$grandTotalQTE = 0; // To accumulate grand total QTE
$productCount = 0; // Counter for product numeration
$familleCount = 0; // Counter for famille numeration
@endphp
@foreach($collection as $row)
@if($row->famille !== $currentFamille)
@if($currentFamille !== null)
|
Total {{ $currentFamille }}: |
{{ number_format($familleTotalCA, 0, ' ', ' ') }} |
{{ $familleTotalQTE }} |
@php
// Accumulate to grand totals
$grandTotalCA += $familleTotalCA;
$grandTotalQTE += $familleTotalQTE;
@endphp
@endif
@php
$currentFamille = $row->famille;
$familleTotalCA = 0; // Reset totals for the new famille
$familleTotalQTE = 0;
$productCount = 0; // Reset product counter
$familleCount++; // Increment famille counter
@endphp
{{ $familleCount }}. {{ $currentFamille }}
|
@endif
{{ ++$productCount }} |
{{ $row->produit }} |
{{ number_format($row->CA, 0, ' ', ' ') }} |
{{ $row->QTE }} |
@php
// Accumulate totals for the famille
$familleTotalCA += $row->CA;
$familleTotalQTE += $row->QTE;
@endphp
@endforeach
@if($currentFamille !== null)
|
Total {{ $currentFamille }}: |
{{ number_format($familleTotalCA, 0, ' ', ' ') }} |
{{ $familleTotalQTE }} |
@php
// Accumulate to grand totals
$grandTotalCA += $familleTotalCA;
$grandTotalQTE += $familleTotalQTE;
@endphp
@endif
|
Total Final : |
{{ number_format($grandTotalCA, 0, ' ', ' ') }} |
{{ $grandTotalQTE }} |