Added sticker reprint updated logic and added blade file

This commit is contained in:
dhanabalan
2025-08-07 09:25:25 +05:30
parent 15af1edb8f
commit e58dbfbebd
3 changed files with 421 additions and 197 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Filament\Pages;
use App\Models\Item;
use App\Models\Line;
use App\Models\Plant;
use App\Models\ProductionQuantity;
use App\Models\Shift;
@@ -20,7 +21,7 @@ use Filament\Facades\Filament;
use Livewire\Attributes\On;
use Carbon\Carbon;
use Illuminate\Support\Facades\Request;
use Str;
class StickerReprint extends Page implements HasForms
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
@@ -1145,6 +1146,20 @@ class StickerReprint extends Page implements HasForms
if (!$item) {
// Handle unknown item code
$this->form->fill([
'plant_id'=> $this->pId,
'block_name'=> $this->bId,
'shift_id'=> $this->sId,
'line_id'=> $this->lId,
'item_id'=> null,
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Invalid Item Code')
->body("Item code '{$itemCode}' does not exist in Item master.")
@@ -1152,37 +1167,9 @@ class StickerReprint extends Page implements HasForms
->send();
return;
}
$sticker = StickerMaster::where('item_id', $item->id)->first();
if (!$sticker) {
// If no sticker or item_id is found, it's an unknown item
$this->form->fill([
'plant_id'=> $this->pId,
'block_name'=> $this->bId,
'shift_id'=> $this->sId,
'line_id'=> $this->lId,
'item_id'=> null,
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Unknown Item Code')
->body("Item code does not exist in the Sticker Master.")
->danger()
->send();
return;
}
// Now fetch the Item using item_id from sticker and plant_id check
$item = Item::where('id', $sticker->item_id)
->where('plant_id', $this->pId)
->first();
$item = Item::where('code', $itemCode)
->where('plant_id', $this->pId)
->first();
if ($item)
{
@@ -1233,8 +1220,114 @@ class StickerReprint extends Page implements HasForms
return;
}
}
else
{
$this->form->fill([
'plant_id'=> $this->pId,
'block_name'=> $this->bId,
'shift_id'=> $this->sId,
'line_id'=> $this->lId,
'item_id'=> null,
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
if ($this->succId === null) {
Notification::make()
->title('Unknown Item Code')
->body("Item code does not exist in master data for choosed plant.")
->danger()
->seconds(2)
->send();
return;
}
$line = Line::find($this->lId);
$lineName = $line ? $line->name : null;
$categoryName = (Str::length($item->category) > 0) ? $item->category : "";
if ($categoryName == 'Submersible Motor')
{
if ($lineName != '6 inch motor line')
{
$this->form->fill([
'plant_id'=> $this->pId,
'block_name'=> $this->bId,
'shift_id'=> $this->sId,
'line_id'=> $this->lId,
'item_id'=> null,
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Invalid Line Found')
->body("Choose '6 inch motor line' to proceed..!")
->danger()
->send();
return;
}
}
else if ($categoryName == 'Submersible Pump')
{
if ($lineName != '6 inch pump line')
{
$this->form->fill([
'plant_id'=> $this->pId,
'block_name'=> $this->bId,
'shift_id'=> $this->sId,
'line_id'=> $this->lId,
'item_id'=> null,
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Invalid Line Found')
->body("Choose '6 inch pump line' to proceed..!")
->danger()
->send();
return;
}
}
else
{
$this->form->fill([
'plant_id'=> $this->pId,
'block_name'=> $this->bId,
'shift_id'=> $this->sId,
'line_id'=> $this->lId,
'item_id'=> null,
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Invalid Category Found')
->body("Set proper category to proceed..!")
->danger()
->send();
return;
}
if ($this->succId == null) {
$this->form->fill([
'plant_id'=> $this->pId,
'block_name'=> $this->bId,