@section('page-title', 'Edit Data Evaluation') @php $asianPorts = $asianPorts ?? \App\Models\Evaluation::getAsianPorts(); $allPorts = collect($asianPorts)->flatten()->toArray(); $oldOrigin = old('port_origin', $planning->port_origin ?? ''); $oldDestination = old('port_destination', $planning->port_destination ?? ''); $selectedOrigin = in_array($oldOrigin, $allPorts) ? $oldOrigin : ($oldOrigin ? 'OTHER' : ''); $customOrigin = !in_array($oldOrigin, $allPorts) && $oldOrigin ? $oldOrigin : old('port_origin_custom', ''); $selectedDestination = in_array($oldDestination, $allPorts) ? $oldDestination : ($oldDestination ? 'OTHER' : ''); $customDestination = !in_array($oldDestination, $allPorts) && $oldDestination ? $oldDestination : old('port_destination_custom', ''); $existingCargoList = []; $rawCargoInput = old('cargo_data'); if (is_array($rawCargoInput)) { foreach ($rawCargoInput as $r) { $existingCargoList[] = [ 'cargo' => $r['cargo'] ?? ($r['cargo_name'] ?? ($r['name'] ?? '')), 'cargo_type' => $r['cargo_type'] ?? ($r['type'] ?? ''), 'discharging' => $r['discharging'] ?? 0, 'unit' => $r['unit'] ?? 'UNITS', 'stevedoring' => $r['stevedoring'] ?? '', 'cargodoring' => $r['cargodoring'] ?? '', 'consignee' => $r['consignee'] ?? ($r['nominative_owner'] ?? ''), ]; } } elseif ($planning->consignees && $planning->consignees->isNotEmpty()) { foreach ($planning->consignees as $c) { if ($c->items && $c->items->isNotEmpty()) { foreach ($c->items as $cItem) { $dVal = (int)($cItem->discharging ?? 0); $lVal = (int)($cItem->loading ?? 0); $cName = trim((string)($cItem->cargo ?? '')); if ($dVal > 0 || ($lVal === 0 && $dVal === 0 && $cName !== '' && $cName !== 'General Cargo' && $c->consignee !== '-')) { $existingCargoList[] = [ 'cargo' => $cItem->cargo ?: '', 'cargo_type' => $cItem->cargo_type ?: '', 'discharging' => $dVal, 'unit' => $cItem->unit ?: 'UNITS', 'stevedoring' => ($cItem->stevedoring !== '-' && $cItem->stevedoring !== '0') ? $cItem->stevedoring : '', 'cargodoring' => ($cItem->cargodoring !== '-' && $cItem->cargodoring !== '0') ? $cItem->cargodoring : '', 'consignee' => ($c->consignee !== '-') ? $c->consignee : '', ]; } } } else { $existingCargoList[] = [ 'cargo' => '', 'cargo_type' => '', 'discharging' => 0, 'unit' => 'UNITS', 'stevedoring' => '', 'cargodoring' => '', 'consignee' => ($c->consignee !== '-') ? $c->consignee : '', ]; } } } elseif (!empty($planning->cargo_estimasi) || !empty($planning->estimasi_unit)) { $existingCargoList[] = [ 'cargo' => $planning->cargo_estimasi ?: 'General Cargo', 'cargo_type' => '', 'discharging' => (int) ($planning->estimasi_unit ?: 0), 'unit' => 'UNITS', 'stevedoring' => 'APS', 'cargodoring' => 'APS', 'consignee' => '', ]; } $existingLoadingCargoList = []; $rawLoadingCargoInput = old('cargo_loading_data'); if (is_array($rawLoadingCargoInput)) { foreach ($rawLoadingCargoInput as $r) { $existingLoadingCargoList[] = [ 'cargo' => $r['cargo'] ?? ($r['cargo_name'] ?? ($r['name'] ?? '')), 'cargo_type' => $r['cargo_type'] ?? ($r['type'] ?? ''), 'loading' => $r['loading'] ?? ($r['discharging'] ?? 0), 'unit' => $r['unit'] ?? 'UNITS', 'stevedoring' => $r['stevedoring'] ?? '', 'cargodoring' => $r['cargodoring'] ?? '', 'consignee' => $r['consignee'] ?? ($r['nominative_owner'] ?? ''), ]; } } elseif ($planning->consignees && $planning->consignees->isNotEmpty()) { foreach ($planning->consignees as $c) { if ($c->items && $c->items->isNotEmpty()) { foreach ($c->items as $cItem) { if ((int)($cItem->loading ?? 0) > 0) { $existingLoadingCargoList[] = [ 'cargo' => $cItem->cargo ?: '', 'cargo_type' => $cItem->cargo_type ?: '', 'loading' => (int) $cItem->loading, 'unit' => $cItem->unit ?: 'UNITS', 'stevedoring' => ($cItem->stevedoring !== '-' && $cItem->stevedoring !== '0') ? $cItem->stevedoring : '', 'cargodoring' => ($cItem->cargodoring !== '-' && $cItem->cargodoring !== '0') ? $cItem->cargodoring : '', 'consignee' => ($c->consignee !== '-') ? $c->consignee : '', ]; } } } } } $existingSpecialCargos = old('special_cargos'); if ($existingSpecialCargos === null && $planning->specialHandlings && $planning->specialHandlings->isNotEmpty()) { $existingSpecialCargos = $planning->specialHandlings->map(function($sh) { return [ 'cargo_type' => $sh->cargo_type, 'nominative_owner' => $sh->nominative_owner, 'issue' => $sh->issue, 'handling_plan' => $sh->handling_plan, 'note' => $sh->note, ]; })->toArray(); } @endphp
{{-- Top Page Header (Same as Time Sheet & Statement of Fact) --}}

Edit Evaluation: {{ $planning->vessel ?: ($planning->nama_kapal ?: 'MV. -') }}

Perbarui lembar dokumen evaluasi operasional kapal ({{ $planning->no_planning }})

Lihat Detail @if(auth()->user()?->canModule('evaluation', 'delete'))
@csrf @method('DELETE')
@endif
@if ($errors->any())

Periksa kembali isian formulir:

    @foreach ($errors->all() as $err)
  • {{ $err }}
  • @endforeach
@endif
@csrf @method('PUT') @include('partials.vessel-berthing-pull-bar') {{-- Top Card: No. Evaluation & Status Dokumen (Same as Time Sheet & Statement of Fact) --}}
@error('no_planning')

{{ $message }}

@enderror
@php $currentStatus = old('status', $planning->status ?: 'scheduled'); @endphp
{{-- ========================================================================= --}} {{-- MAIN DOCUMENT CARD (Formatted like the Paper Sheet in Time Sheet / SOF) --}} {{-- ========================================================================= --}}
{{-- Document Header --}}

EVALUATION

{{ old('no_planning', $planning->no_planning) }}
{{-- Section 1: Vessel & Voyage Header Info (Unified 2-Column Grid) --}}
{{-- Left Column --}}
NAME OF VESSEL :
VOY. NO :
PRINCIPAL :
SHIPPING AGENT :
{{-- Right Column --}}
BERTH :
OPERATION : @php $defaultKegiatan = old('kegiatan', $planning->kegiatan ?: 'Stevedoring'); @endphp
PORT OF ORIGIN :
NEXT PORT :
{{-- ========================================================================= --}} {{-- SECTION 2: DATA CARGO (DISCHARGING / LOADING) --}} {{-- ========================================================================= --}}

DATA CARGO - DISCHARGING

(0 Item)
{{-- Diisi oleh JavaScript --}} {{-- Diisi oleh JavaScript --}}
NO CARGO NAME TYPE DISCHARGING STEVEDORING CARGODORING NOMINATIVE OWNER
TOTAL DISCHARGING 0
{{-- ========================================================================= --}} {{-- SECTION 3: TOTAL KATEGORI CARGO & SPECIAL HANDLING CARGO --}} {{-- ========================================================================= --}} @php $rawTotalCargoSummary = old('total_cargo_summary', $planning->getCalculatedTotalCargoSummary()); @endphp

TOTAL KATEGORI CARGO

@foreach([ 'mobil_cbu' => 'CBU', 'truck' => 'TRUCK', 'bus' => 'BUS', 'hh' => 'HEAVY HIGH (HH)', 'part' => 'PART', 'mafi' => 'MAFI', ] as $catKey => $catLabel) @endforeach
TYPE CARGO DISCHARGING LOADING TOTAL
{{ $catLabel }}
TOTAL 0 0 0
{{-- ========================================================================= --}} {{-- SECTION 3B: SPECIAL HANDLING CARGO --}} {{-- ========================================================================= --}}

SPECIAL HANDLING CARGO

{{-- Dynamic Special Cargo cards rendered here --}}

TIDAK ADA SPECIAL HANDLING CARGO

Klik "+ Tambah Special Cargo" di kanan atas apabila ada muatan dengan penanganan khusus.

{{-- ========================================================================= --}} {{-- SECTION 4: DATA OPERATING VESSEL --}} {{-- ========================================================================= --}} @php $defaultOpRows = \App\Models\Evaluation::getDefaultOperatingVesselRows(); $rawOpData = old('operating_vessel_data', $planning->operating_vessel_data ?? []); $opRows = []; foreach ($defaultOpRows as $idx => $defRow) { $existing = null; if (!empty($rawOpData) && is_array($rawOpData)) { foreach ($rawOpData as $rItem) { $rName = strtolower(trim($rItem['name'] ?? '')); $dName = strtolower(trim($defRow['name'])); if ($rName === $dName || ($dName === 'open ramp' && str_contains($rName, 'open') && str_contains($rName, 'ramp')) || ($dName === 'close ramp' && str_contains($rName, 'close') && str_contains($rName, 'ramp')) || ($dName === 'commenced of discharging' && str_contains($rName, 'commence') && (str_contains($rName, 'discharg') || !str_contains($rName, 'load'))) || ($dName === 'completed of discharging' && str_contains($rName, 'complete') && (str_contains($rName, 'discharg') || !str_contains($rName, 'load'))) || ($dName === 'commenced of loading' && str_contains($rName, 'commence') && str_contains($rName, 'load')) || ($dName === 'completed of loading' && str_contains($rName, 'complete') && str_contains($rName, 'load')) || ($dName === 'vessel arrived' && $rName === 'eta') || ($dName === 'berthed at ikt car terminal 2 port' && $rName === 'etb') || ($dName === 'vessel sailed from wharf' && $rName === 'etd') ) { $existing = $rItem; break; } } if ($existing === null && isset($rawOpData[$idx])) { $candName = strtolower(trim($rawOpData[$idx]['name'] ?? '')); if ($candName === '' || $candName === $dName) { $existing = $rawOpData[$idx]; } } } $actDate = $existing['actual_date'] ?? ''; $actTime = $existing['actual_time'] ?? ''; if (!empty($linkedSof) && empty($actTime)) { $dName = strtolower(trim($defRow['name'])); if ($dName === 'open ramp') { $actTime = $linkedSof->getMilestoneValue('open_ramp', 'hrs'); $actDate = $actDate ?: $linkedSof->getMilestoneValue('open_ramp', 'date'); } elseif ($dName === 'close ramp') { $actTime = $linkedSof->getMilestoneValue('close_ramp', 'hrs'); $actDate = $actDate ?: $linkedSof->getMilestoneValue('close_ramp', 'date'); } } $opRows[] = [ 'name' => $defRow['name'], 'is_red' => $defRow['is_red'], 'has_date' => $defRow['has_date'], 'plan_date' => $existing['plan_date'] ?? '', 'plan_time' => \App\Models\Evaluation::formatTimeColon($existing['plan_time'] ?? '', ''), 'actual_date' => $actDate, 'actual_time' => \App\Models\Evaluation::formatTimeColon($actTime, ''), 'time_diff' => \App\Models\Evaluation::formatTimeColon($existing['time_diff'] ?? '', ''), ]; } @endphp

DATA OPERATING VESSEL

PLAN VS ACTUAL SCHEDULE
@foreach($opRows as $idx => $r) {{-- Plan Date --}} @if($r['has_date']) @else @endif {{-- Plan Time --}} {{-- Actual Date --}} @if($r['has_date']) @else @endif {{-- Actual Time --}} {{-- Time Difference --}} @endforeach
DATA OPERATING VESSEL PLAN DATE PLAN TIME ACTUAL DATE ACTUAL TIME TIME DIFFERENCE
{{ $r['name'] }} -
-
{{-- ========================================================================= --}} {{-- SECTION 5: SEQUENCING CARGO OPERATION --}} {{-- ========================================================================= --}} @php $rawSeq = old('sequencing_cargo_data', $planning->sequencing_cargo_data ?? []); $dischargingData = $rawSeq['discharging'] ?? (isset($rawSeq['rows']) ? $rawSeq : []); $loadingData = $rawSeq['loading'] ?? []; $shiftingData = $rawSeq['shifting'] ?? []; $defaultDischargingRows = \App\Models\Evaluation::getDefaultSequencingCargoRows('discharging'); $defaultLoadingRows = \App\Models\Evaluation::getDefaultSequencingCargoRows('loading'); $defaultShiftingRows = \App\Models\Evaluation::getDefaultSequencingCargoRows('shifting'); $seqDischargingRows = $dischargingData['rows'] ?? $defaultDischargingRows; $seqDischargingTotals = $dischargingData['totals'] ?? []; $seqLoadingRows = $loadingData['rows'] ?? $defaultLoadingRows; $seqLoadingTotals = $loadingData['totals'] ?? []; $seqShiftingRows = $shiftingData['rows'] ?? $defaultShiftingRows; $seqShiftingTotals = $shiftingData['totals'] ?? []; $shiftActPerfMinutes = 0; foreach ($seqShiftingRows as $r) { $durVal = trim((string)($r['actual_duration'] ?? '')); $val = ($durVal !== '' && $durVal !== '-' && $durVal !== '00:00' && $durVal !== '0:00') ? $durVal : trim((string)($r['actual_performance'] ?? '')); if ($val !== '' && $val !== '-' && $val !== '00:00' && $val !== '0:00') { if (preg_match('/(\d{1,2}[:.]\d{2})\s*[-–—]\s*(\d{1,2}[:.]\d{2})/', $val, $rangeM)) { $sM = \App\Models\StatementOfFact::parseDurationToMinutes($rangeM[1]); $eM = \App\Models\StatementOfFact::parseDurationToMinutes($rangeM[2]); if ($eM < $sM) $eM += 1440; $shiftActPerfMinutes += max(0, $eM - $sM); } elseif (str_contains($val, ':')) { $PART = explode(':', $val); $shiftActPerfMinutes += (intval($PART[0]) * 60) + intval($PART[1] ?? 0); } elseif (str_contains($val, '.')) { $PART = explode('.', $val); $shiftActPerfMinutes += (intval($PART[0]) * 60) + intval($PART[1] ?? 0); } else { $shiftActPerfMinutes += intval(floatval($val) * 60); } } } $shiftActPerfH = floor($shiftActPerfMinutes / 60); $shiftActPerfM = $shiftActPerfMinutes % 60; $defaultShiftActPerfTime = sprintf('%d:%02d', $shiftActPerfH, $shiftActPerfM); $defaultShiftActPerfFormatted = sprintf('%dhr%02dmin', $shiftActPerfH, $shiftActPerfM); $shiftActPerfTotal = !empty($seqShiftingTotals['actual_performance_time']) && $seqShiftingTotals['actual_performance_time'] !== '0:00' ? $seqShiftingTotals['actual_performance_time'] : ($shiftActPerfMinutes > 0 ? $defaultShiftActPerfTime : ($seqShiftingTotals['actual_performance'] ?? '0:00')); $shiftActPerfFormatted = !empty($seqShiftingTotals['actual_performance_formatted']) && $seqShiftingTotals['actual_performance_formatted'] !== '0hr00min' ? $seqShiftingTotals['actual_performance_formatted'] : ($shiftActPerfMinutes > 0 ? $defaultShiftActPerfFormatted : '0hr00min'); @endphp

SEQUENCING CARGO OPERATION

@include('partials.seq-shifting-sof-bar')
{{-- 1. DISCHARGING --}} @foreach($seqDischargingRows as $idx => $row) @php $dischargingRateDefaults = ['CBU' => '150', 'Truck' => '20', 'Bus' => '10', 'HH' => '10']; $cat = $row['category'] ?? ''; if (isset($dischargingRateDefaults[$cat]) && (empty($row['std_performance']) || in_array($row['std_performance'], ['100', '12', '7', '5']))) { $row['std_performance'] = $dischargingRateDefaults[$cat]; } $stdRateDisplay = !empty($row['std_performance']) ? ($row['std_performance'] . ' ' . ($row['std_unit'] ?? 'Unit/hrs')) : ''; $rawActDur = trim((string)($row['actual_duration'] ?? '')); $sofDurVal = trim((string)($sofCargoDurations['discharging'][$cat] ?? '')); $useSofActDur = ($rawActDur === '' || $rawActDur === '-' || $rawActDur === '00:00' || $rawActDur === '0:00') && $sofDurVal !== ''; $displayActDur = $useSofActDur ? $sofDurVal : (($rawActDur !== '' && $rawActDur !== '-') ? $rawActDur : '00:00'); $isSofDurSynced = !empty($row['sof_synced']) || $useSofActDur; $hasManualActualDur = $displayActDur !== '00:00' && !$isSofDurSynced; $rawActPerf = trim((string)($row['actual_performance'] ?? '')); $tsActPerfVal = trim((string)($timeSheetPerfSummary['discharging'][$cat] ?? '')); $useTsActPerf = ($rawActPerf === '' || $rawActPerf === '-') && $tsActPerfVal !== ''; $displayActPerf = $useTsActPerf ? $tsActPerfVal : ($row['actual_performance'] ?? ''); $isTsSyncedRow = !empty($row['timesheet_synced']) || $useTsActPerf; @endphp @endforeach {{-- 2. LOADING --}} @foreach($seqLoadingRows as $idx => $row) @php $loadingRateDefaults = ['CBU' => '100', 'Truck' => '12', 'Bus' => '7', 'HH' => '5']; $cat = $row['category'] ?? ''; if (isset($loadingRateDefaults[$cat]) && (empty($row['std_performance']) || in_array($row['std_performance'], ['150', '20', '10']))) { $row['std_performance'] = $loadingRateDefaults[$cat]; } $stdRateDisplay = !empty($row['std_performance']) ? ($row['std_performance'] . ' ' . ($row['std_unit'] ?? 'Unit/hrs')) : ''; $rawActDur = trim((string)($row['actual_duration'] ?? '')); $sofDurVal = trim((string)($sofCargoDurations['loading'][$cat] ?? '')); $useSofActDur = ($rawActDur === '' || $rawActDur === '-' || $rawActDur === '00:00' || $rawActDur === '0:00') && $sofDurVal !== ''; $displayActDur = $useSofActDur ? $sofDurVal : (($rawActDur !== '' && $rawActDur !== '-') ? $rawActDur : '00:00'); $isSofDurSynced = !empty($row['sof_synced']) || $useSofActDur; $hasManualActualDur = $displayActDur !== '00:00' && !$isSofDurSynced; $rawActPerf = trim((string)($row['actual_performance'] ?? '')); $tsActPerfVal = trim((string)($timeSheetPerfSummary['loading'][$cat] ?? '')); $useTsActPerf = ($rawActPerf === '' || $rawActPerf === '-') && $tsActPerfVal !== ''; $displayActPerf = $useTsActPerf ? $tsActPerfVal : ($row['actual_performance'] ?? ''); $isTsSyncedRow = !empty($row['timesheet_synced']) || $useTsActPerf; @endphp @endforeach {{-- 3. SHIFTING --}} @foreach($seqShiftingRows as $idx => $row) @php $shiftCat = $row['category'] ?? ''; $rawShiftQty = trim((string)($row['qty'] ?? '')); $sofShiftQty = trim((string)($sofShiftingSummary['qty_by_category'][$shiftCat] ?? '')); $useSofShiftQty = ($rawShiftQty === '' || $rawShiftQty === '-') && $sofShiftQty !== ''; $displayShiftQty = $useSofShiftQty ? $sofShiftQty : ($row['qty'] ?? ''); $isSofShiftQtySynced = !empty($row['sof_qty_synced']) || $useSofShiftQty; @endphp @endforeach
Discharging STD Proformance Discharging qty (Unit/pkgs)
Approximately STD Duration Time
(hrs:min)
Discharging Actual Performance
Rate & Unit
Actual Duration Time
(hrs:min)
{{ $row['category'] }} @if($stdRateDisplay) ({{ $stdRateDisplay }}) @endif
{{ $row['std_duration_time'] ?? '00:00' }} Hrs {{ $row['actual_unit'] ?? ($row['std_unit'] ?? 'Unit/hrs') }}
TOTAL {{ $seqDischargingTotals['std_duration_time'] ?? '0:00' }} {{ $seqDischargingTotals['std_duration_formatted'] ?? '0hr00min' }} TOTAL {{ $seqDischargingTotals['actual_duration_time'] ?? '0:00' }} ({{ $seqDischargingTotals['actual_duration_formatted'] ?? '0hr00min' }})
{{-- ========================================================================= --}} {{-- SECTION 6: OPERATION STRATEGIC --}} {{-- ========================================================================= --}} @php $rawOpStrat = old('ops_strategic_data', $planning->ops_strategic_data ?? []); $opStrat = \App\Models\Evaluation::normalizeOperationStrategicTimesToColon(is_array($rawOpStrat) ? $rawOpStrat : []); if (!empty($linkedSof)) { $curActAvail = trim((string)($opStrat['actual_available_time'] ?? '')); $rawActAvailDot = trim((string)(is_array($rawOpStrat) ? ($rawOpStrat['actual_available_time'] ?? '') : '')); if (in_array($curActAvail, ['', '0.00', '00.00', '0:00', '00:00', '-'], true) || str_contains($rawActAvailDot, '.')) { $rampAvail = $linkedSof->extractActualAvailableTimeFromRamp(); if ($rampAvail['has_data']) { $opStrat['actual_available_time'] = $rampAvail['available_time']; } } } \App\Models\Evaluation::syncRealtimeOperationInOpsStrategic( $opStrat, is_array($rawOpStrat) ? $rawOpStrat : null ); @endphp

OPERATION STRATEGIC

PLAN VS ACTUAL DURATION
{{-- Row 1 --}} {{-- Row 2 --}} {{-- Row 3 --}} {{-- Row 4 --}} {{-- Row 5 --}} {{-- Row 6: Available Time --}}
OPERATION STRATEGIC (PLAN) PLAN DURATION TIME OPERATION STRATEGIC (ACTUAL) ACTUAL DURATION TIME
Total Approximately Duration Time Hrs Actual Duration Time Hrs
Waiting Cargo / Document Hrs Waiting Cargo / Document Hrs
Idle Time / Stop Operation Hrs Idle Time / Stop Operation Hrs
Shifting Hrs Shifting Hrs
MEAL BREAK Hrs MEAL BREAK Hrs
AVAILABLE TIME Hrs ACTUAL AVAILABLE TIME Hrs
{{-- ========================================================================= --}} {{-- REALTIME OPERATION (SEPARATE 1-ROW TABLE ABOVE DEPLOYMENT / MAN POWER) --}} {{-- ========================================================================= --}}
REALTIME OPERATION Hrs
{{-- ========================================================================= --}} {{-- SECTION 7, 8 & 9: DEPLOYMENT, ESTIMATE BUDGET & MECHANICAL EQUIPMENT --}} {{-- ========================================================================= --}} @include('evaluation._deployment-sheet-tables') {{-- Submit Action Bar inside Sheet Footer --}}
Batal