@extends('layouts.structure') @section('title', 'Classic Roof Pvt Ltd') @section('content') @php // Map plan status to display-friendly text $status = match (strtolower($plan->status ?? 'N/A')) { 'pending' => 'Pending', 'approved' => 'Approved', 'under production' => 'Under Production', 'completed' => 'Completed', 'ready to dispatch' => 'Ready to Dispatch', 'partially dispatched' => 'Partially Dispatched', 'dispatched' => 'Dispatched', default => 'N/A', }; // Convert session error to string $sessionError = session('error') ? (is_array(session('error')) ? implode(', ', array_map('strval', session('error'))) : session('error')) : ''; // Convert session success to string $sessionSuccess = session('success') ? (is_array(session('success')) ? implode(', ', array_map('strval', session('success'))) : session('success')) : ''; // Log plan details for debugging \Log::info('Plan variables for rendering', [ 'plan_id' => $plan->id ?? 'N/A', 'status' => $status, 'client_name' => $plan->client->client_name ?? 'N/A', 'crr_no' => $plan->coil->crr_no ?? 'N/A', 'grade_name' => $plan->grade->grade_name ?? 'N/A', 'inward_code' => $plan->inward->inward_code ?? 'N/A', 'thickness' => $plan->coil->thickness ?? 'N/A', 'coil_width' => $plan->coil->width ?? 'N/A', 'coil_net_weight' => $plan->coil->net_weight ?? 0, ]); @endphp

Plan Details

@if ($sessionError) @endif @if ($sessionSuccess) @endif
@if ($status === 'Pending') Approve Plan @elseif ($status === 'Approved') Start Production @elseif ($status === 'Under Production') Mark as Completed @elseif ($status === 'Completed') Ready to Dispatch @elseif ($status === 'Ready to Dispatch') Mark as Partially Dispatched @elseif ($status === 'Partially Dispatched') Mark as Dispatched @endif Download Excel Back to Plans
(Status: {{ $status }} )
@csrf @method('POST')
Client Name CRR No. Grade Inward Code Thickness Total Width of Coil Coil Total Net Weight (TON)
{{ htmlspecialchars($plan->client->client_name ?? 'N/A') }} {{ htmlspecialchars($plan->coil->crr_no ?? 'N/A') }} {{ htmlspecialchars($plan->grade->grade_name ?? 'N/A') }} {{ htmlspecialchars($plan->inward->inward_code ?? 'N/A') }} {{ htmlspecialchars($plan->coil->thickness ?? 'N/A') }} {{ number_format($plan->coil->width ?? 0, 2) }} {{ number_format($plan->coil->net_weight ?? 0, 3) }}
@if ($plan->processes->isEmpty()) @else
Processes
@foreach ($plan->processes as $index => $process)
Process {{ $index + 1 }} (Type: {{ strtoupper(htmlspecialchars($process->process_type ?? 'N/A')) }} @if ($process->is_dependent == 1) Dependent @endif {{ isset($processDispatches[$process->process_id]) && $processDispatches[$process->process_id]->isNotEmpty() ? 'Dispatched' : 'Not Dispatched' }} )

Selected Line: {{ htmlspecialchars($process->process_type ?? 'N/A') }}

@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'); $balanceWeight = $totalWeight - $currentWeight; $individualWeights = []; if ($process->process_type === 'crs') { foreach ($process->crsCuts as $cut) { $qty = $cut->quantity ?? 0; $weight = $cut->weight ?? 0; $cutWidth = $cut->width ?? 0; $individualWeight = $qty > 0 ? $weight / $qty : 0; for ($i = 0; $i < $qty; $i++) { $individualWeights[] = [ 'dimension' => number_format($cutWidth, 2), 'weight' => number_format($individualWeight, 3), ]; } } } elseif ($process->process_type === 'ctl') { foreach ($process->ctlCuts as $cut) { $qty = $cut->quantity ?? 0; $weight = $cut->weight ?? 0; $cutWidth = $cut->cut_width ?? 0; $cutLength = $cut->cut_length ?? 0; $individualWeight = $qty > 0 ? $weight / $qty : 0; for ($i = 0; $i < $qty; $i++) { $dimension = $cutLength > 0 ? number_format($cutWidth, 2) . 'x' . number_format($cutLength, 2) : number_format($cutWidth, 2); $individualWeights[] = [ 'dimension' => $dimension, 'weight' => number_format($individualWeight, 3), ]; } } } @endphp @if ($process->process_type === 'crs' && !empty($individualWeights)) @foreach ($individualWeights as $i => $iw) @endforeach @elseif ($process->process_type === 'crs') @endif @if ($process->process_type === 'crs' && !empty($individualWeights)) @foreach ($individualWeights as $iw) @endforeach @elseif ($process->process_type === 'crs') @endif
Balance Weight (TON)Dimension {{ $i + 1 }} [{{ $iw['dimension'] }}]Individual Weights
{{ number_format($balanceWeight, 3) }} @if ($process->is_dependent) (Dependent on Process {{ htmlspecialchars($process->dependent_index ?? 'N/A') }}) @endif {{ number_format($iw['weight'], 3) }}N/A
@if ($process->process_type === 'crs') @if ($process->crsCuts->isEmpty()) @else
@foreach ($process->crsCuts as $cutIndex => $cut) @endforeach
Width Quantity Weight (TON) Current Qty Current Weight Balance Weight
@error('cuts.' . $index . '.crs.' . $cutIndex . '.width')
{{ $message }}
@enderror
@error('cuts.' . $index . '.crs.' . $cutIndex . '.quantity')
{{ $message }}
@enderror
{{ number_format($cut->weight, 3) }} @error('cuts.' . $index . '.crs.' . $cutIndex . '.prod_qty')
{{ $message }}
@enderror
@error('cuts.' . $index . '.crs.' . $cutIndex . '.current_weight')
{{ $message }}
@enderror
@error('cuts.' . $index . '.crs.' . $cutIndex . '.bal_weight')
{{ $message }}
@enderror
@endif @elseif ($process->process_type === 'ctl') @if ($process->ctlCuts->isEmpty()) @else
@foreach ($process->ctlCuts as $cutIndex => $cut) @endforeach
Width Length Quantity Weight (TON) Current Qty Current Weight Balance Weight
{{ number_format($cut->cut_width, 2) }} {{ $cut->cut_length > 0 ? number_format($cut->cut_length, 2) : 'N/A' }} {{ $cut->quantity }} {{ number_format($cut->weight, 3) }} @error('cuts.' . $index . '.ctl.' . $cutIndex . '.prod_qty')
{{ $message }}
@enderror
@error('cuts.' . $index . '.ctl.' . $cutIndex . '.current_weight')
{{ $message }}
@enderror
@error('cuts.' . $index . '.ctl.' . $cutIndex . '.bal_weight')
{{ $message }}
@enderror
@endif @else @endif
@endforeach @if ($status === 'Under Production')
@endif @endif
@endsection