1
0
forked from poc/pds

Removed production plan logic in sticker reprint page

This commit is contained in:
dhanabalan
2025-12-27 16:26:43 +05:30
parent ea16763f33
commit 3bcc351fa6

View File

@@ -712,251 +712,251 @@ class StickerReprint extends Page implements HasForms
]); ]);
} }
} }
else // else
{ // {
$existShifts = \App\Models\ProductionPlan::where('plant_id', $this->pId) // $existShifts = \App\Models\ProductionPlan::where('plant_id', $this->pId)
->where('shift_id', $this->sId) // ->where('shift_id', $this->sId)
->where('line_id', $this->lId) // ->where('line_id', $this->lId)
->whereDate('created_at', Carbon::yesterday()) // ->whereDate('created_at', Carbon::yesterday())
->latest() // ->latest()
->exists(); // ->exists();
if ($existShifts) //if ($existShifts->count() > 0) // if ($existShifts) //if ($existShifts->count() > 0)
{ // record exist on yesterday // { // record exist on yesterday
//$currentDate = date('Y-m-d'); // //$currentDate = date('Y-m-d');
$yesterday = date('Y-m-d', strtotime('-1 days')); // $yesterday = date('Y-m-d', strtotime('-1 days'));
$shiftId = Shift::where('id', $this->sId) // $shiftId = Shift::where('id', $this->sId)
->first(); // ->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0]; // [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs; // $hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/ // // $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs; // $totalMinutes = $hRs * 60 + $miNs;
$from_dt = $yesterday . ' ' . $shiftId->start_time; // $from_dt = $yesterday . ' ' . $shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes")); // $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s'); // $currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range // // Check if current date time is within the range
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) { // if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
$this->form->fill([ // $this->form->fill([
'plant_id'=> $this->pId, // 'plant_id'=> $this->pId,
'block_name'=> $this->bId, // 'block_name'=> $this->bId,
'shift_id'=> $this->sId, // 'shift_id'=> $this->sId,
'line_id'=> $this->lId, // 'line_id'=> $this->lId,
'item_id'=> null, // 'item_id'=> null,
'serial_number'=> null, // 'serial_number'=> null,
'success_msg'=> null, // 'success_msg'=> null,
'production_order'=> $this->prodOrder, // 'production_order'=> $this->prodOrder,
'sap_msg_status' => null, // 'sap_msg_status' => null,
'sap_msg_description' => null, // 'sap_msg_description' => null,
'operator_id'=> $operatorName, // 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr, // 'recent_qr' => $this->recQr,
]); // ]);
} // }
else // else
{ // {
$currentDate = date('Y-m-d'); // $currentDate = date('Y-m-d');
$shiftId = Shift::where('id', $this->sId) // $shiftId = Shift::where('id', $this->sId)
->first(); // ->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0]; // [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs; // $hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/ // // $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs; // $totalMinutes = $hRs * 60 + $miNs;
$from_dt = $currentDate . ' ' . $shiftId->start_time; // $from_dt = $currentDate . ' ' . $shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes")); // $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s'); // $currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range // // Check if current date time is within the range
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) { // if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
//echo "Choosed a valid shift..."; // //echo "Choosed a valid shift...";
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')'); // // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
$this->form->fill([ // $this->form->fill([
'plant_id'=> $this->pId, // 'plant_id'=> $this->pId,
'block_name'=> $this->bId, // 'block_name'=> $this->bId,
'shift_id'=> $this->sId, // 'shift_id'=> $this->sId,
'line_id'=> $this->lId, // 'line_id'=> $this->lId,
'item_id'=> null, // 'item_id'=> null,
'serial_number'=> null, // 'serial_number'=> null,
'success_msg'=> null, // 'success_msg'=> null,
'production_order'=> $this->prodOrder, // 'production_order'=> $this->prodOrder,
'sap_msg_status' => null, // 'sap_msg_status' => null,
'sap_msg_description' => null, // 'sap_msg_description' => null,
'operator_id'=> $operatorName, // 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr, // 'recent_qr' => $this->recQr,
]); // ]);
Notification::make() // Notification::make()
->title('Plan Not Found') // ->title('Plan Not Found')
->body("Please set production plan first.") // ->body("Please set production plan first.")
->danger() // ->danger()
->send(); // ->send();
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')'); // //$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
return; // return;
} // }
else // else
{ // {
//echo "Choosed a valid shift..."; // //echo "Choosed a valid shift...";
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')'); // // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
$this->form->fill([ // $this->form->fill([
'plant_id'=> $this->pId, // 'plant_id'=> $this->pId,
'block_name'=> $this->bId, // 'block_name'=> $this->bId,
'shift_id'=> $this->sId, // 'shift_id'=> $this->sId,
'line_id'=> $this->lId, // 'line_id'=> $this->lId,
'item_id'=> null, // 'item_id'=> null,
'serial_number'=> null, // 'serial_number'=> null,
'success_msg'=> null, // 'success_msg'=> null,
'production_order'=> $this->prodOrder, // 'production_order'=> $this->prodOrder,
'sap_msg_status' => null, // 'sap_msg_status' => null,
'sap_msg_description' => null, // 'sap_msg_description' => null,
'operator_id'=> $operatorName, // 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr, // 'recent_qr' => $this->recQr,
]); // ]);
Notification::make() // Notification::make()
->title('Invalid Shift') // ->title('Invalid Shift')
->body("Please select a valid shift.") // ->body("Please select a valid shift.")
->danger() // ->danger()
->send(); // ->send();
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')'); // //$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
return; // return;
} // }
} // }
} // }
else // else
{ // record not exist on yesterday // { // record not exist on yesterday
//$currentDate = date('Y-m-d'); // //$currentDate = date('Y-m-d');
$yesterday = date('Y-m-d', strtotime('-1 days')); // $yesterday = date('Y-m-d', strtotime('-1 days'));
$shiftId = Shift::where('id', $this->sId) // $shiftId = Shift::where('id', $this->sId)
->first(); // ->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0]; // [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs; // $hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/ // // $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs; // $totalMinutes = $hRs * 60 + $miNs;
$from_dt = $yesterday . ' ' . $shiftId->start_time; // $from_dt = $yesterday . ' ' . $shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes")); // $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s'); // $currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range // // Check if current date time is within the range
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) { // if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
//echo "Choosed a valid shift..."; // //echo "Choosed a valid shift...";
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')'); // // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
$this->form->fill([ // $this->form->fill([
'plant_id'=> $this->pId, // 'plant_id'=> $this->pId,
'block_name'=> $this->bId, // 'block_name'=> $this->bId,
'shift_id'=> $this->sId, // 'shift_id'=> $this->sId,
'line_id'=> $this->lId, // 'line_id'=> $this->lId,
'item_id'=> null, // 'item_id'=> null,
'serial_number'=> null, // 'serial_number'=> null,
'success_msg'=> null, // 'success_msg'=> null,
'production_order'=> $this->prodOrder, // 'production_order'=> $this->prodOrder,
'sap_msg_status' => null, // 'sap_msg_status' => null,
'sap_msg_description' => null, // 'sap_msg_description' => null,
'operator_id'=> $operatorName, // 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr, // 'recent_qr' => $this->recQr,
]); // ]);
Notification::make() // Notification::make()
->title('Plan Not Found') // ->title('Plan Not Found')
->body("Please set production plan first.") // ->body("Please set production plan first.")
->danger() // ->danger()
->send(); // ->send();
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')'); // //$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
return; // return;
} // }
else // else
{ // {
$currentDate = date('Y-m-d'); // $currentDate = date('Y-m-d');
$shiftId = Shift::where('id', $this->sId) // $shiftId = Shift::where('id', $this->sId)
->first(); // ->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0]; // [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs; // $hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/ // // $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs; // $totalMinutes = $hRs * 60 + $miNs;
$from_dt = $currentDate . ' ' . $shiftId->start_time; // $from_dt = $currentDate . ' ' . $shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes")); // $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s'); // $currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range // // Check if current date time is within the range
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) { // if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
//echo "Choosed a valid shift..."; // //echo "Choosed a valid shift...";
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')'); // // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
$this->form->fill([ // $this->form->fill([
'plant_id'=> $this->pId, // 'plant_id'=> $this->pId,
'block_name'=> $this->bId, // 'block_name'=> $this->bId,
'shift_id'=> $this->sId, // 'shift_id'=> $this->sId,
'line_id'=> $this->lId, // 'line_id'=> $this->lId,
'item_id'=> null, // 'item_id'=> null,
'serial_number'=> null, // 'serial_number'=> null,
'success_msg'=> null, // 'success_msg'=> null,
'production_order'=> $this->prodOrder, // 'production_order'=> $this->prodOrder,
'sap_msg_status' => null, // 'sap_msg_status' => null,
'sap_msg_description' => null, // 'sap_msg_description' => null,
'operator_id'=> $operatorName, // 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr, // 'recent_qr' => $this->recQr,
]); // ]);
Notification::make() // Notification::make()
->title('Plan Not Found') // ->title('Plan Not Found')
->body("Please set production plan first.") // ->body("Please set production plan first.")
->danger() // ->danger()
->send(); // ->send();
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')'); // //$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
return; // return;
} // }
else // else
{ // {
//echo "Choosed a valid shift..."; // //echo "Choosed a valid shift...";
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')'); // // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
$this->form->fill([ // $this->form->fill([
'plant_id'=> $this->pId, // 'plant_id'=> $this->pId,
'block_name'=> $this->bId, // 'block_name'=> $this->bId,
'shift_id'=> $this->sId, // 'shift_id'=> $this->sId,
'line_id'=> $this->lId, // 'line_id'=> $this->lId,
'item_id'=> null, // 'item_id'=> null,
'serial_number'=> null, // 'serial_number'=> null,
'success_msg'=> null, // 'success_msg'=> null,
'production_order'=> $this->prodOrder, // 'production_order'=> $this->prodOrder,
'sap_msg_status' => null, // 'sap_msg_status' => null,
'sap_msg_description' => null, // 'sap_msg_description' => null,
'operator_id'=> $operatorName, // 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr, // 'recent_qr' => $this->recQr,
]); // ]);
Notification::make() // Notification::make()
->title('Invalid Shift') // ->title('Invalid Shift')
->body("Please select a valid shift.") // ->body("Please select a valid shift.")
->danger() // ->danger()
->send(); // ->send();
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')'); // //$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
return; // return;
} // }
} // }
} // }
} // }
// ******************************** // ********************************