@extends('layouts.app') @section('title', 'Edit Arrival & Item Intake') @push('styles') @include('wuser.shipments.partials.intake-layout-styles') @include('wuser.partials.delivery-badge-styles') @endpush @section('content') @php $selectedSuite = old('suite_number', $shipment->suite_number); $weightUnit = old('weight_unit', $parsedMeasurements['weight_unit'] ?? 'kg'); $dimensionUnit = old('dimension_unit', $parsedMeasurements['dimension_unit'] ?? 'cm'); $stream = old('customs_shipment_stream', $shipment->customs_shipment_stream ?: 'csb_iv'); $port = old('port_of_destination', $shipment->port_of_destination ?: 'male'); $cargo = old('cargo_type', $shipment->cargo_type ?: 'ecommerce'); $weightValue = old('weight', $parsedMeasurements['weight'] ?? ''); $lengthValue = old('length', $parsedMeasurements['length'] ?? ''); $widthValue = old('width', $parsedMeasurements['width'] ?? ''); $heightValue = old('height', $parsedMeasurements['height'] ?? ''); $oldItems = old('items'); if (!is_array($oldItems) || count($oldItems) === 0) { $oldItems = []; if ($shipment->items && $shipment->items->count() > 0) { foreach ($shipment->items as $savedItem) { $oldItems[] = [ 'item_name' => $savedItem->item_name, 'item_description' => $savedItem->item_description, 'hscode' => $savedItem->hscode, 'uom_id' => $savedItem->uom_id, 'unit_quantity' => $savedItem->unit_quantity, 'unit_price' => $savedItem->unit_price, 'declared_value_inr' => $savedItem->declared_value_inr, 'declared_value_usd' => $savedItem->declared_value_usd, ]; } } if (count($oldItems) === 0) { $oldItems = [[ 'item_name' => $shipment->item_name, 'item_description' => $shipment->item_description, ]]; } } $storedFigures = $shipment->shippingFigures(); $savedNotax = old('notax_shipping_amount', $storedFigures['notax']); $savedGst = old('gst_amount', $storedFigures['gst']); $savedShippingTotal = old('shipping_amount', $storedFigures['shipping']); $savedNotaxValue = ($savedNotax === null || $savedNotax === '') ? null : (float) $savedNotax; $savedGstValue = ($savedGst === null || $savedGst === '') ? null : (float) $savedGst; $savedShippingValue = ($savedShippingTotal === null || $savedShippingTotal === '') ? null : (float) $savedShippingTotal; $showSavedRate = $savedNotaxValue !== null || $savedShippingValue !== null; $openPhotos = false; if ($errors->any()) { foreach ($errors->keys() as $errorKey) { if (strpos((string) $errorKey, 'photos') === 0) { $openPhotos = true; break; } } } $photoCount = $shipment->photos ? $shipment->photos->count() : 0; $summaryWeight = ($weightValue !== '' && $weightValue !== null) ? $weightValue.' '.$weightUnit : '—'; $summaryDims = ($lengthValue !== '' && $widthValue !== '' && $heightValue !== '') ? $lengthValue.' × '.$widthValue.' × '.$heightValue.' '.$dimensionUnit : '—'; $backUrl = route('wuser.shipments.show', \Illuminate\Support\Facades\Crypt::encrypt($shipment->id)); @endphp