@extends('layouts.pdf-layout') @section('letter_title')

{{ strtoupper($letter_title) }}


BRANCH: {{ $originBranchName ?? 'UPCOUNTRY' }}
REPORT DATE: {{ $selectedDateRange }}
PRINTED AT: {{ $print_time }}
@endsection @php $branchCodes = [ 'MOROGORO' => 'MORO', 'DAR ES SALAAM' => 'DAR', ]; $originBranchName = key($routes); @endphp @section('content') @foreach($branchServicePoints as $branchName => $servicePoints) @endforeach @foreach($branchServicePoints as $servicePoints) @foreach($servicePoints as $point) @endforeach @endforeach @php $grandTotal = 0; $servicePointTotals = []; foreach($branchServicePoints as $branchPoints) { foreach($branchPoints as $point) { $servicePointTotals[$point] = 0; } } @endphp @foreach ($routes as $originBranch => $destinations) @foreach ($destinations as $destinationBranch => $data) @php $routeTotal = $data['total_rate'] ?? 0; $hasServicePoints = !empty($data['servicePoints']) && array_sum(array_column($data['servicePoints'], 'total_rate')) > 0; if ($routeTotal <= 0 && !$hasServicePoints) { continue; } $grandTotal += $routeTotal; $originBranchCode = $branchCodes[$originBranch] ?? $originBranch; $destinationBranchCode = $branchCodes[$destinationBranch] ?? $destinationBranch; @endphp @foreach($branchServicePoints as $branchPoints) @foreach($branchPoints as $point) @php $servicePointTotal = $data['servicePoints'][$point]['total_rate'] ?? 0; $servicePointTotals[$point] += $servicePointTotal; @endphp @endforeach @endforeach @endforeach @endforeach @foreach($branchServicePoints as $branchPoints) @foreach($branchPoints as $point) @endforeach @endforeach
ROUTE COLLECTION POINTS TOTAL BY ROUTE
{{ strtoupper($branchName) }}
{{ strtoupper($point) }}
{{ $originBranchCode }} - {{ $destinationBranchCode }} @if ($servicePointTotal > 0) {{ floor($servicePointTotal) == $servicePointTotal ? number_format($servicePointTotal, 0) : number_format($servicePointTotal, 2) }} @else - @endif {{ floor($routeTotal) == $routeTotal ? number_format($routeTotal, 0) : number_format($routeTotal, 2) }}
TOTAL AMOUNT @php $total = $servicePointTotals[$point]; @endphp @if ($total > 0) {{ floor($total) == $total ? number_format($total, 0) : number_format($total, 2) }} @else - @endif {{ floor($grandTotal) == $grandTotal ? number_format($grandTotal, 0) : number_format($grandTotal, 2) }}
@endsection