@php $manifest = json_decode(file_get_contents(public_path('build/manifest.json')), true); @endphp
Facturi de plătit - {{ $heading }}
Data facturii: {{ date('d-m-Y') }}
@php // $sumaRestantaKey = 'suma restanta'; $sumaRestantaKey = 'Total de plată'; $ipaIDKey = 'ipa id'; @endphp @foreach ($bills[0] as $key => $head) @if ($key != '__unique__') {{-- display grouped user id heading --}} {{-- @if (strtolower($key) == strtolower($ipaIDKey)) @endif --}} {{-- display groupeddue amount heading --}} @if (strtolower($key) == strtolower($sumaRestantaKey)) @else {{-- display all other headings --}} @endif @endif @endforeach @php $loopCount = 0; @endphp @foreach ($bills as $key => $billRow) @php $bills['__unique__'] = $loopCount; /* to keep rows unique */ @endphp @foreach ($billRow as $cellKey => $cell) @if ($cellKey == '__unique__') @php continue; @endphp @endif @if (!is_object($cell) && !is_array($cell)) {{-- display grouped user ids --}} @if (strtolower($cellKey) == strtolower($ipaIDKey)) @php $aggregateSum = 0.00; $siblings = collect($bills)->where($ipaIDKey, $billRow[$ipaIDKey]); @endphp @if($billRow == $siblings->first()) @else @endif {{-- also display ungrouped --}} {{-- --}} @elseif (strtolower($cellKey) == strtolower($sumaRestantaKey)) {{-- display goruped due amounts --}} {{-- display non - aggregated sums / telefon --}} @php $aggregateSum = 0.00; $siblings = collect($bills)->where($ipaIDKey, $billRow[$ipaIDKey]); $aggregateSum = $siblings->sum($sumaRestantaKey); $affectedRows = $siblings->count(); @endphp {{-- dispay aggregate on the last row --}} @if($billRow != $siblings->last()) @else @endif @else {{-- display all other cell values --}} @endif @else @endif @endforeach @php $loopCount++ @endphp @endforeach
{{ strtoupper($key) }} / PERSOANĂ {{ strtoupper($key) }} {{ strtoupper($key) }} / TELEFON {{ strtoupper($key) }} / PERSOANĂ {{ strtoupper($key) }}
{{ $cell }} {{ $cell }} {{ $cell }} {{ $aggregateSum }} {{ $cell }} ...