@extends('layouts.structure') @section('content') Ready To Dispatch

Ready To Dispatch

@if (session('success'))
{{ session('success') }}
@endif @if (session('error'))
{{ session('error') }}
@endif

Ready To Dispatch

@csrf
Please select a client
Please select a CRR No.
Grade is required
Width must be a positive number
Thickness must be a positive number
Net Weight must be a positive number
Status: {{ $plan->status }}
Dispatch Status: {{ $plan->dispatch_status ?? 'Not Dispatched' }}
Coil Balance Weight: {{ number_format(max(0, $plan->balance_weight), 3) }} TON
dispatches->where('type', 'coil')->where('dispatch_option', 'scrap')->isEmpty() ? 'checked' : '' }}> Dispatch dispatches->where('type', 'coil')->where('dispatch_option', 'scrap')->isNotEmpty() ? 'checked' : '' }}> Scrap
Balance weight is added to scrap
@foreach ($plan->processes as $index => $process) @php $totalWeight = $process->process_type === 'crs' ? $process->crsCuts->sum('weight') : $process->ctlCuts->sum('weight'); $currentWeight = $process->process_type === 'crs' ? $process->crsCuts->sum('current_weight') : $process->ctlCuts->sum('current_weight'); $dispatchedWeight = $process->dispatches->sum('gross_weight'); $balanceWeight = max( 0, $totalWeight - $currentWeight - $dispatchedWeight, ); $individualWeights = []; $isDispatched = $process->dispatches->isNotEmpty() && $balanceWeight <= 0; if ($process->process_type === 'crs') { foreach ($process->crsCuts as $cut) { $qty = $cut->quantity ?? 0; $weight = $cut->weight ?? 0; $individualWeight = $qty > 0 ? $weight / $qty : 0; for ($i = 0; $i < $qty; $i++) { $individualWeights[] = number_format($individualWeight, 3); } } } @endphp @endforeach
Dispatch Details
Coil Dispatch
@if ($plan->dispatches->where('type', 'coil')->isNotEmpty()) @foreach ($plan->dispatches->where('type', 'coil') as $dispatch)

Type: {{ ucfirst($dispatch->type ?? 'N/A') }}

Dispatch Option: {{ ucfirst($dispatch->dispatch_option ?? 'N/A') }}

Gross Weight: {{ number_format($dispatch->gross_weight ?? 0, 3) }} TON

Location: {{ $dispatch->location ?? 'Not specified' }}

Packaging Type: {{ ucfirst($dispatch->packaging_type ?? 'N/A') }}

Packaging Quantity: {{ $dispatch->packaging_quantity ?? 'N/A' }}

Scrap: {{ number_format($dispatch->scrap ?? 0, 4) }} TON

Dispatch Remark: {{ $dispatch->remark ?? 'None' }}

Dispatch Notes: {{ $dispatch->notes ?? 'None' }}

Dispatched At: {{ $dispatch->dispatched_at ? $dispatch->dispatched_at->format('Y-m-d H:i:s') : 'N/A' }}


@endforeach @else

No coil dispatch records.

@endif
Scrap Dispatch
@if ($plan->dispatches->where('type', 'scrap')->isNotEmpty()) @foreach ($plan->dispatches->where('type', 'scrap') as $dispatch)

Type: {{ ucfirst($dispatch->type ?? 'N/A') }}

Scrap Weight: {{ number_format($dispatch->gross_weight ?? 0, 3) }} TON

Location: {{ $dispatch->location ?? 'Not specified' }}

Remark: {{ $dispatch->remark ?? 'None' }}

Dispatch Notes: {{ $dispatch->notes ?? 'None' }}

Dispatched At: {{ $dispatch->dispatched_at ? $dispatch->dispatched_at->format('Y-m-d H:i:s') : 'N/A' }}


@endforeach @else

No scrap dispatch records.

@endif
Process Dispatch
@foreach ($plan->processes as $index => $process) @php $totalWeight = $process->process_type === 'crs' ? $process->crsCuts->sum('weight') : $process->ctlCuts->sum('weight'); $currentWeight = $process->process_type === 'crs' ? $process->crsCuts->sum('current_weight') : $process->ctlCuts->sum('current_weight'); $dispatchedWeight = $process->dispatches->sum('gross_weight'); $balanceWeight = max(0, $totalWeight - $currentWeight - $dispatchedWeight); @endphp @if ($process->dispatches->isNotEmpty())
Process {{ $index + 1 }} ({{ strtoupper($process->process_type) }})
@foreach ($process->dispatches as $dispatch)

Type: {{ ucfirst($dispatch->type ?? 'N/A') }}

Gross Weight: {{ number_format($dispatch->gross_weight ?? 0, 3) }} TON

Location: {{ $dispatch->location ?? 'Not specified' }}

Packaging Type: {{ ucfirst($dispatch->packaging_type ?? 'N/A') }}

Packaging Quantity: {{ $dispatch->packaging_quantity ?? 'N/A' }}

Scrap: {{ number_format($dispatch->scrap ?? 0, 4) }} TON

Dispatch Remark: {{ $dispatch->remark ?? 'None' }}

Dispatch Notes: {{ $dispatch->notes ?? 'None' }}

Dispatched At: {{ $dispatch->dispatched_at ? $dispatch->dispatched_at->format('Y-m-d H:i:s') : 'N/A' }}


@endforeach
@endif @endforeach @if ($plan->processes->pluck('dispatches')->flatten()->isEmpty())

No process dispatch records.

@endif
@endsection