@section('page-title', 'Tally Sheet: MV. ' . ($tallySheet->vessel_name ?: '-')) @php $isLoading = $tallySheet->isLoading(); $opTypeLabel = $isLoading ? 'Untuk Loading' : 'Untuk Discharging'; $opTypeBadgeClass = $isLoading ? 'bg-amber-100 text-amber-800 border-amber-200' : 'bg-blue-100 text-blue-800 border-blue-200'; $sheets = $tallySheet->resolved_sheets; $docTitle = $tallySheet->title ?: \App\Models\TallySheet::getTitleForType($tallySheet->operation_type); @endphp
Kembali ke daftar Tally Sheet

Tally Sheet: MV. {{ $tallySheet->vessel_name ?: '-' }}

{{ $opTypeLabel }} @if($tallySheet->status === 'completed') Completed @else Draft @endif

Voyage: {{ $tallySheet->voyage ?: '-' }} • Dermaga: {{ $tallySheet->berth ?: '-' }} • Pelabuhan: {{ $tallySheet->loading_port ?: '-' }} → {{ $tallySheet->discharging_port ?: '-' }}

@if(auth()->user()?->canModule('checker', 'edit')) Edit @endif Cetak / Print
@if(session('success'))
{{ session('success') }}
@endif {{-- Main Document Card (Matches Official Tally Sheet Paper Sheet) --}}
{{-- Document Header --}}

{{ $docTitle }}

{{-- Vessel & Voyage Header Info --}}
{{-- Left column --}}
VESSEL : MV. {{ $tallySheet->vessel_name ?: '-' }}
BERTH : {{ $tallySheet->berth ?: '-' }}
LOADING PORT : {{ $tallySheet->loading_port ?: '-' }}
DISCHARGING PORT : {{ $tallySheet->discharging_port ?: '-' }}
{{-- Right column --}}
VOY. : {{ $tallySheet->voyage ?: '-' }}
BERTHED TIME : {{ $tallySheet->berthed_time ?: '-' }} HRS DATE : {{ $tallySheet->berthed_date ?: '-' }}
COMMENCED TIME : {{ $tallySheet->commenced_time ?: '-' }} HRS DATE : {{ $tallySheet->commenced_date ?: '-' }}
COMPLETED TIME : {{ $tallySheet->completed_time ?: '-' }} HRS DATE : {{ $tallySheet->completed_date ?: '-' }}
{{-- Main Tally Tables (Multi-Sheet Supported) --}}
@if(count($sheets) > 1)
@foreach($sheets as $sIdx => $sh) @endforeach
@endif @foreach($sheets as $sIdx => $sh) @php $rawItems = $sh['tally_items'] ?? []; $sItems = array_values(array_filter($rawItems, function ($r) { $bl = trim((string)($r['bl_no'] ?? '')); $desc = trim((string)($r['description'] ?? '')); $u = trim((string)($r['units'] ?? '')); $p = trim((string)($r['pkgs'] ?? '')); $tally = $r['tally'] ?? []; $hasTally = false; if (is_array($tally)) { foreach ($tally as $t) { if (trim((string)$t) !== '') { $hasTally = true; break; } } } return ($bl !== '' || $desc !== '' || $u !== '' || $p !== '' || $hasTally); })); $sTotals = $sh['totals'] ?? []; $sUnits = $sTotals['total_units'] ?? 0; $sPkgs = $sTotals['total_pkgs'] ?? 0; $sNo = $sh['sheet_no'] ?? ($sIdx + 1); @endphp

Sheet {{ $sNo }} @if(!empty($sh['date'])) Tanggal: {{ $sh['date'] }} @endif

Lembar ke-{{ $sIdx + 1 }} dari {{ count($sheets) }}
@for($col = 1; $col <= 10; $col++) @endfor @forelse($sItems as $row) @php $rowTally = $row['tally'] ?? array_fill(0, 10, ''); @endphp @for($c = 0; $c < 10; $c++) @endfor @empty @endforelse {{-- TOTAL ROW --}}
B/L NO. DESCRIPTION OF CARGO TALLY TOTAL
{{ $col }}UNITS PKGS
{{ $row['bl_no'] ?? '-' }} {{ $row['description'] ?? '-' }} {{ !empty($rowTally[$c]) ? $rowTally[$c] : '' }} {{ !empty($row['units']) ? number_format((float)$row['units']) : '' }} {{ !empty($row['pkgs']) ? number_format((float)$row['pkgs']) : '' }}
Tidak ada rincian tally item pada sheet ini
TOTAL SHEET {{ $sNo }} {{ number_format((float)$sUnits) }} {{ number_format((float)$sPkgs) }}
@endforeach