@php $coaches = $sgrTrainOperation->coachInspections->sortBy('position')->values(); $removedCount = $coaches->where('availability_status', 'Removed')->count(); $activeCoaches = $coaches->where('availability_status', '!=', 'Removed'); $passedCount = $activeCoaches->where('inspection_status', 'Passed')->count(); $failedCount = $activeCoaches->where('inspection_status', 'Failed')->count(); $pendingCount = $activeCoaches->where('inspection_status', 'Pending')->count(); $inspectedCount = $passedCount + $failedCount; $waterCompleteCount = $activeCoaches->filter(fn ($coach) => $coach->water_arrival_p !== null && $coach->water_arrival_t !== null && $coach->water_departure_p !== null && $coach->water_departure_t !== null)->count(); $withRemarksCount = $activeCoaches->filter(fn ($coach) => filled($coach->remarks))->count(); $withPhotoCount = $activeCoaches->filter(fn ($coach) => filled($coach->photo_path))->count(); @endphp
← Train operations

SGR coach cleaning

{{ $sgrTrainOperation->train_number }}

{{ $sgrTrainOperation->station?->name ?? $branch->name }} {{ $dailyControl->date->format('d M Y') }} Supervisor {{ $sgrTrainOperation->supervisor?->name ?? '—' }}

{{ $sgrTrainOperation->status === 'Submitted' ? 'Submitted · editing locked' : 'Draft · editing allowed' }} @if($sgrTrainOperation->status !== 'Submitted' && ! $sgrTrainOperation->is_composition_confirmed) Confirm coaches @elseif($sgrTrainOperation->status !== 'Submitted') Edit composition @endif
@foreach([ ['label' => 'Actual coaches', 'value' => $coaches->count(), 'tone' => 'text-slate-950'], ['label' => 'Inspected', 'value' => $inspectedCount, 'tone' => 'text-slate-950'], ['label' => 'Passed', 'value' => $passedCount, 'tone' => 'text-emerald-800'], ['label' => 'Failed', 'value' => $failedCount, 'tone' => 'text-red-800'], ['label' => 'Pending', 'value' => $pendingCount, 'tone' => 'text-slate-600'], ['label' => 'Unavailable', 'value' => $removedCount, 'tone' => 'text-slate-500'], ] as $metric)
{{ $metric['label'] }} {{ $metric['value'] }}
@endforeach
@if($coaches->isNotEmpty())
@endif

Actual operation coaches

Coach inspections

{{ $inspectedCount }} of {{ $activeCoaches->count() }} available coaches inspected

@if($coaches->isNotEmpty())
@foreach($coaches as $coach) @php $isRemoved = $coach->availability_status === 'Removed'; $status = $isRemoved ? 'Unavailable' : $coach->inspection_status; $statusTone = match ($status) { 'Passed' => 'text-emerald-900 border-emerald-300 bg-emerald-50', 'Failed' => 'text-red-900 border-red-300 bg-red-50', 'Unavailable' => 'text-slate-600 border-slate-300 bg-slate-100', default => 'text-slate-600 border-slate-300 bg-slate-50', }; $statusSymbol = match ($status) { 'Passed' => '✓', 'Failed' => '!', 'Unavailable' => '—', default => '○', }; @endphp @endforeach
@else

No actual coaches are listed

@if($sgrTrainOperation->status !== 'Submitted') Add coaches to this operation @endif
@endif

Before final submission

Operation review

Train
{{ $sgrTrainOperation->train_number }}
Station
{{ $sgrTrainOperation->station?->name ?? $branch->name }}
Date
{{ $dailyControl->date->format('d M Y') }}
Actual coach count
{{ $coaches->count() }}
Water complete
{{ $waterCompleteCount }} / {{ $activeCoaches->count() }}
Remarks / photos
{{ $withRemarksCount }} / {{ $withPhotoCount }} coaches
@if($failedCount || $pendingCount)

Review needed

@if($failedCount)

{{ $failedCount }} {{ $failedCount === 1 ? 'coach has' : 'coaches have' }} failed checklist items.

@endif @if($pendingCount)

{{ $pendingCount }} {{ $pendingCount === 1 ? 'coach is' : 'coaches are' }} still pending inspection.

@endif @else

All available coaches inspected

@endif @if($removedCount)

{{ $removedCount }} coach{{ $removedCount === 1 ? '' : 'es' }} marked unavailable.

@endif
@if($sgrTrainOperation->status !== 'Submitted')

Final operational commitment

Submit this SGR operation

Submitting confirms that the coach composition and inspection information recorded above are accurate. After submission, editing is locked.

@csrf
@else
Submitted on {{ $sgrTrainOperation->submitted_at?->format('d M Y, H:i') ?? '—' }} · Editing is locked. This report is read-only.
@endif