@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'))
: '';
// Calculate sheets per packet for CTL
$thickness = $plan->coil->thickness ?? 0.5;
$maxHeightPerPacket = 400;
$sheetsPerPacket = $thickness > 0 ? floor($maxHeightPerPacket / $thickness) : 1;
// 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,
'crs_bal_weight' => $plan->crs_bal_weight ?? 0,
'ctl_bal_weight' => $plan->ctl_bal_weight ?? 0,
'under_production_cuts_count' => $plan->underProductionCuts->count(),
]);
// width for recreated plans
$displayWidth = $plan->coil->width ?? 0;
foreach ($plan->processes as $process) {
if ($process->process_type === 'crs' && $process->crsCuts->isNotEmpty()) {
$displayWidth = $process->crsCuts->first()->cut_width ?? $displayWidth;
break;
} elseif ($process->process_type === 'ctl' && $process->ctlCuts->isNotEmpty()) {
$displayWidth = $process->ctlCuts->first()->cut_width ?? $displayWidth;
break;
}
}
@endphp
Metal Coil Processing - Under Production
Metal Coil Processing - Under Production
@if ($sessionError)
{{ htmlspecialchars($sessionError) }}
@endif
@if ($sessionSuccess)
{{ htmlspecialchars($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
@if($status==="Approved")
Download Excel
@endif
Back to Plans
@endsection