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

{{ strtoupper($letter_title) }}


BRANCH: {{ $originBranchName ?? 'N/A' }}
REPORT DATE: {{ $selectedDateRange }}
PRINTED AT: {{ $print_time }}
@endsection @php $branchCodes = [ 'MOROGORO' => 'MORO', 'DAR ES SALAAM' => 'DAR', ]; $originBranchName = key($routes); @endphp @section('content') @foreach ($servicePoints as $point) @endforeach @php $grandTotal = 0; $servicePointTotals = array_fill_keys($servicePoints, 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 ($servicePoints as $servicePoint) @php $servicePointTotal = $data['servicePoints'][$servicePoint]['total_rate'] ?? 0; $servicePointTotals[$servicePoint] += $servicePointTotal; @endphp @endforeach @endforeach @endforeach @foreach ($servicePoints as $servicePoint) @endforeach
ROUTE COLLECTION POINTS TOTAL BY ROUTE
{{ 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[$servicePoint]; @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