@php $items = collect($calls ?? []); $groupedBySector = $items ->groupBy(function ($call) { return $call->mysteryAssignment->sector_id ?? 'no-sector'; }) ->sortBy(function ($callsOfSector) { $sectorName = $callsOfSector->first()?->mysteryAssignment?->sector?->name; return $sectorName ? mb_strtolower($sectorName) : 'zzz'; }); @endphp
@forelse($groupedBySector as $callsOfSector) @php $sector = $callsOfSector->first()?->mysteryAssignment?->sector; $groupedByBusiness = $callsOfSector ->groupBy(function ($call) { return $call->mysteryAssignment->business_id ?? 'no-business'; }) ->sortBy(function ($sectorBusinessCalls) { $businessName = $sectorBusinessCalls->first()?->mysteryAssignment?->business?->name; return $businessName ? mb_strtolower($businessName) : 'zzz'; }); @endphp
Sector: {{ $sector->name ?? 'Unknown Sector' }}
Pending assignments grouped by business in this sector.
{{ $callsOfSector->count() }} pending
@foreach($groupedByBusiness as $callsOfBusiness) @php $first = $callsOfBusiness->first(); $business = $first?->mysteryAssignment?->business; $month = $first?->mysteryAssignment?->month; $sortedCalls = $callsOfBusiness->sortBy(function ($call) { return sprintf('%010d-%010d', $call->call_number ?? 9999999999, $call->id ?? 9999999999); })->values(); @endphp
{{ $business->name ?? 'Unknown Business' }}
{{ $business->phone ?? 'N/A' }}
{{ $sector->name ?? 'N/A' }} | {{ $month ?? 'N/A' }}
{{ $callsOfBusiness->count() }} pending
@foreach($sortedCalls as $index => $call) @php $scenarioDoc = $call->mysteryAssignment->sector?->getScenarioDocumentPath($call->scenario_number); $displayCallNumber = $call->call_number ?? ($index + 1); @endphp @endforeach
Call Details Phone Scenario PDF Action
{{ $displayCallNumber }} {{ $call->mysteryAssignment->business->name ?? '-' }} | {{ $call->mysteryAssignment->sector->name ?? '-' }} | {{ $call->mysteryAssignment->month ?? '-' }} {{ $call->mysteryAssignment->business->phone ?? 'N/A' }} @if($scenarioDoc) Scenario {{ $call->scenario_number ?? 'N/A' }} @else N/A @endif Edit
@endforeach
@empty
No pending assignments found.
@endforelse @if(isset($businessesPage) && $businessesPage)
{{ $businessesPage->appends(request()->query())->links('pagination::bootstrap-4') }}
@endif