ranjith-dev #1323
@@ -94,157 +94,167 @@ class BulkStickerPrinting extends Page implements HasForms
|
|||||||
TextInput::make('production_order')
|
TextInput::make('production_order')
|
||||||
->label('Production Order')
|
->label('Production Order')
|
||||||
->reactive()
|
->reactive()
|
||||||
->readOnly(),
|
->afterStateUpdated(function ($state, callable $set, $get) {
|
||||||
// ->afterStateUpdated(function ($state, callable $set, $get) {
|
|
||||||
|
|
||||||
// for ($i = 1; $i <= 8; $i++) {
|
for ($i = 1; $i <= 8; $i++) {
|
||||||
// $set("sticker_structure{$i}_id", null);
|
$set("sticker_structure{$i}_id", null);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (blank($state)) {
|
if (blank($state)) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $plantid = $get('plant_id');
|
$plantid = $get('plant_id');
|
||||||
// $machineId = $get('machine_id');
|
$machineId = $get('machine_id');
|
||||||
|
|
||||||
// $plantName = Plant::where('id', $plantid)->value('name');
|
$plantName = Plant::where('id', $plantid)->value('name');
|
||||||
|
|
||||||
// $workCenter = Machine::where('id', $machineId)->value('work_center');
|
$workCenter = Machine::where('id', $machineId)->value('work_center');
|
||||||
|
|
||||||
// if (empty($machineId)) {
|
if (empty($machineId)) {
|
||||||
// Notification::make()
|
Notification::make()
|
||||||
// ->title('Work Center not selected')
|
->title('Work Center not selected')
|
||||||
// ->body('Please select a Work Center first.')
|
->body('Please select a Work Center first.')
|
||||||
// ->warning()
|
->warning()
|
||||||
// ->send();
|
->send();
|
||||||
|
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $productionOrder = ClassCharacteristic::where('plant_id', $plantid)->where('machine_id', $machineId)->where('aufnr', $state)->first();
|
$productionOrder = ClassCharacteristic::where('plant_id', $plantid)->where('machine_id', $machineId)->where('aufnr', $state)->first();
|
||||||
|
|
||||||
// if (! $productionOrder) {
|
if (! $productionOrder) {
|
||||||
// Notification::make()
|
Notification::make()
|
||||||
// ->title('Production Order not found')
|
->title('Production Order not found')
|
||||||
// ->body("Production Order '{$state}' was not found against machine '$workCenter' and plant '$plantName'.")
|
->body("Production Order '{$state}' was not found against machine '$workCenter' and plant '$plantName'.")
|
||||||
// ->danger()
|
->danger()
|
||||||
// ->send();
|
->send();
|
||||||
|
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $plantId = $productionOrder->plant_id;
|
$plantId = $productionOrder->plant_id;
|
||||||
// $itemId = $productionOrder->item_id;
|
$itemId = $productionOrder->item_id;
|
||||||
|
|
||||||
// $item = Item::find($itemId);
|
$item = Item::find($itemId);
|
||||||
|
|
||||||
// if (! $item) {
|
if (! $item) {
|
||||||
// Notification::make()
|
Notification::make()
|
||||||
// ->title('Item not found')
|
->title('Item not found')
|
||||||
// ->body("Item code '{$itemId}' was not found in item master.")
|
->body("Item code '{$itemId}' was not found in item master.")
|
||||||
// ->danger()
|
->danger()
|
||||||
// ->send();
|
->send();
|
||||||
|
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $itemCode = $item->code;
|
$itemCode = $item->code;
|
||||||
|
|
||||||
// $item = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
$item = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
// if (! $item) {
|
if (! $item) {
|
||||||
// Notification::make()
|
Notification::make()
|
||||||
// ->title('Item not found')
|
->title('Item not found')
|
||||||
// ->body("Item '{$itemCode}' was not found for the selected plant.")
|
->body("Item '{$itemCode}' was not found for the selected plant.")
|
||||||
// ->danger()
|
->danger()
|
||||||
// ->send();
|
->send();
|
||||||
|
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $itemCharacteristic = ClassCharacteristic::where('plant_id', $plantId)->where('item_id', $item->id)->first();
|
$itemCharacteristic = ClassCharacteristic::where('plant_id', $plantId)->where('item_id', $item->id)->first();
|
||||||
|
|
||||||
// if (! $itemCharacteristic) {
|
if (! $itemCharacteristic) {
|
||||||
// Notification::make()
|
Notification::make()
|
||||||
// ->title('Class characteristic not found')
|
->title('Class characteristic not found')
|
||||||
// ->body("No class characteristic found for item '{$itemCode}'.")
|
->body("No class characteristic found for item '{$itemCode}'.")
|
||||||
// ->danger()
|
->danger()
|
||||||
// ->send();
|
->send();
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $itemCharacteristicId = $itemCharacteristic->id;
|
$itemCharacteristicId = $itemCharacteristic->id;
|
||||||
|
|
||||||
// $stickerMappings = StickerMappingMaster::where('plant_id', $plantId)
|
$stickerMappings = StickerMappingMaster::where('plant_id', $plantId)
|
||||||
// ->where('item_id', $item->id)
|
->where('item_id', $item->id)
|
||||||
// ->get();
|
->get();
|
||||||
|
|
||||||
// if ($stickerMappings->isEmpty()) {
|
if ($stickerMappings->isEmpty()) {
|
||||||
// Notification::make()
|
Notification::make()
|
||||||
// ->title('Sticker mapping not found')
|
->title('Sticker mapping not found')
|
||||||
// ->body("No sticker mapping found for item '$itemCode' and plant '$plantName'.")
|
->body("No sticker mapping found for item '$itemCode' and plant '$plantName'.")
|
||||||
// ->danger()
|
->danger()
|
||||||
// ->send();
|
->send();
|
||||||
|
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $stickerOptions = [];
|
$stickerOptions = [];
|
||||||
|
|
||||||
// // foreach ($stickerMappings as $stickerMapping) {
|
// foreach ($stickerMappings as $stickerMapping) {
|
||||||
|
|
||||||
// // for ($i = 1; $i <= 8; $i++) {
|
// for ($i = 1; $i <= 8; $i++) {
|
||||||
|
|
||||||
// // $stickerStructureId = $stickerMapping->{"sticker_structure{$i}_id"};
|
// $stickerStructureId = $stickerMapping->{"sticker_structure{$i}_id"};
|
||||||
|
|
||||||
// // if ($stickerStructureId) {
|
// if ($stickerStructureId) {
|
||||||
|
|
||||||
// // $detail = StickerStructureDetail::where('id', $stickerStructureId)
|
// $detail = StickerStructureDetail::where('id', $stickerStructureId)
|
||||||
// // ->first();
|
// ->first();
|
||||||
|
|
||||||
// // if ($detail && $detail->sticker_id) {
|
// if ($detail && $detail->sticker_id) {
|
||||||
// // $stickerOptions[$detail->sticker_id] = $detail->sticker_id;
|
// $stickerOptions[$detail->sticker_id] = $detail->sticker_id;
|
||||||
// // }
|
// }
|
||||||
// // }
|
// }
|
||||||
// // }
|
// }
|
||||||
// // }
|
// }
|
||||||
|
|
||||||
// foreach ($stickerMappings as $stickerMapping) {
|
foreach ($stickerMappings as $stickerMapping) {
|
||||||
|
|
||||||
// for ($i = 1; $i <= 8; $i++) {
|
for ($i = 1; $i <= 8; $i++) {
|
||||||
|
|
||||||
// $machineColumn = "sticker{$i}_machine_id";
|
$machineColumn = "sticker{$i}_machine_id";
|
||||||
|
|
||||||
// $stickerMachineId = $stickerMapping->$machineColumn;
|
$stickerMachineId = $stickerMapping->$machineColumn;
|
||||||
|
|
||||||
// if ((string) $stickerMachineId != (string) $machineId) {
|
if ((string) $stickerMachineId != (string) $machineId) {
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $structureColumn = "sticker_structure{$i}_id";
|
$structureColumn = "sticker_structure{$i}_id";
|
||||||
|
|
||||||
// $stickerStructureId = $stickerMapping->$structureColumn;
|
$stickerStructureId = $stickerMapping->$structureColumn;
|
||||||
|
|
||||||
// if (empty($stickerStructureId)) {
|
if (empty($stickerStructureId)) {
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $detail = StickerStructureDetail::find($stickerStructureId);
|
$detail = StickerStructureDetail::find($stickerStructureId);
|
||||||
|
|
||||||
// if ($detail && $detail->sticker_id) {
|
if ($detail && $detail->sticker_id) {
|
||||||
|
|
||||||
// $stickerOptions[$detail->sticker_id] =
|
$stickerOptions[$detail->sticker_id] =
|
||||||
// $detail->sticker_id;
|
$detail->sticker_id;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $set("sticker_structure{$i}_id", $stickerStructureId);
|
$set("sticker_structure{$i}_id", $stickerStructureId);
|
||||||
|
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $set('sticker_options', $stickerOptions);
|
$set('sticker_options', $stickerOptions);
|
||||||
// }),
|
|
||||||
|
$serialNumbers = ClassCharacteristic::query()
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->where('aufnr', $state)
|
||||||
|
->pluck('gernr')
|
||||||
|
->filter()
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
|
|
||||||
|
$this->dispatch('load-serial-numbers',serialNumbers: $serialNumbers);
|
||||||
|
|
||||||
|
}),
|
||||||
|
|
||||||
Select::make('sticker_id')
|
Select::make('sticker_id')
|
||||||
->label('Sticker ID')
|
->label('Sticker ID')
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use App\Models\StickerMappingMaster;
|
|||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Livewire\Attributes\Reactive;
|
use Livewire\Attributes\Reactive;
|
||||||
|
use Livewire\Attributes\On;
|
||||||
|
|
||||||
class RandomSerialNumberList extends Component
|
class RandomSerialNumberList extends Component
|
||||||
{
|
{
|
||||||
@@ -225,6 +226,12 @@ class RandomSerialNumberList extends Component
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[On('load-serial-numbers')]
|
||||||
|
public function loadSerialNumbers(array $serialNumbers = []): void
|
||||||
|
{
|
||||||
|
$this->serialNumbers = $serialNumbers ?: [''];
|
||||||
|
}
|
||||||
|
|
||||||
public function clear(){
|
public function clear(){
|
||||||
$this->serialNumbers = [''];
|
$this->serialNumbers = [''];
|
||||||
$this->dispatch('sticker-options-clear', stickerOptions: '');
|
$this->dispatch('sticker-options-clear', stickerOptions: '');
|
||||||
|
|||||||
Reference in New Issue
Block a user