From e20892cc83c62b1890649887508f40cfd7adbaa2 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 11 Mar 2026 19:36:48 +0530 Subject: [PATCH] Refactored alignments on resource page --- app/Filament/Pages/CycleCount.php | 579 +++++++++++++++--------------- 1 file changed, 295 insertions(+), 284 deletions(-) diff --git a/app/Filament/Pages/CycleCount.php b/app/Filament/Pages/CycleCount.php index 84c373c..878bafd 100644 --- a/app/Filament/Pages/CycleCount.php +++ b/app/Filament/Pages/CycleCount.php @@ -2,25 +2,22 @@ namespace App\Filament\Pages; -use App\Models\CustomerPoMaster; use App\Models\InvoiceValidation; use App\Models\Item; use App\Models\NotInStock; use App\Models\Plant; use App\Models\StickerMaster; use App\Models\StockDataMaster; -use App\Models\WireMasterPacking; -use Carbon\Carbon; +use Filament\Actions\Action; +use Filament\Actions\Concerns\InteractsWithActions; use Filament\Facades\Filament; -use Filament\Pages\Page; -use Filament\Forms\Form; -use Filament\Forms\Concerns\InteractsWithForms; use Filament\Forms\Components\Section; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; +use Filament\Forms\Concerns\InteractsWithForms; +use Filament\Forms\Form; use Filament\Notifications\Notification; -use Filament\Actions\Action; -use Filament\Actions\Concerns\InteractsWithActions; +use Filament\Pages\Page; use Illuminate\Support\Facades\Auth; class CycleCount extends Page @@ -28,28 +25,40 @@ class CycleCount extends Page protected static ?string $navigationIcon = 'heroicon-o-document-text'; protected static string $view = 'filament.pages.cycle-count'; + protected static ?string $navigationGroup = 'Cycle Count Software'; - use InteractsWithForms; - use InteractsWithActions; + use InteractsWithForms; public $serialNumber; - public $location, $bin; + public $location; + + public $bin; public $snoCount = 0; public $state = []; - public $plantId, $itemCode, $batch, $docNo, $quantity, $sNo; + public $plantId; + + public $itemCode; + + public $batch; + + public $docNo; + + public $quantity; + + public $sNo; public array $filters = []; public function mount() { $this->form->fill([ - 'plant_id'=>$this->plantId, + 'plant_id' => $this->plantId, 'pallet_quantity' => 0, ]); } @@ -66,6 +75,7 @@ class CycleCount extends Page ->reactive() ->options(function (callable $get) { $userHas = Filament::auth()->user()->plant_id; + return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray(); }) ->required(), @@ -74,9 +84,9 @@ class CycleCount extends Page ->reactive() ->required() ->readOnly(fn (callable $get) => ! $get('plant_id')), - // ->extraAttributes([ - // 'wire:keydown.enter' => 'processLocation($event.target.value)', - // ]), + // ->extraAttributes([ + // 'wire:keydown.enter' => 'processLocation($event.target.value)', + // ]), TextInput::make('bin') ->label('Bin') ->readOnly(fn (callable $get) => ! $get('plant_id') || ! $get('location')) @@ -95,7 +105,7 @@ class CycleCount extends Page // ->reactive() // ->readOnly(), ]) - ->columns(4) + ->columns(4), ]); } @@ -123,8 +133,7 @@ class CycleCount extends Page // $pattern2 = '/^[^|]+\|[^|]+\|[^|]+\|?$/'; Optional Pipeline at end - if (!preg_match($pattern1, $value) && !preg_match($pattern2, $value) && !preg_match($pattern3, $value)) - { + if (! preg_match($pattern1, $value) && ! preg_match($pattern2, $value) && ! preg_match($pattern3, $value)) { Notification::make() ->danger() ->title('Invalid QR Format') @@ -142,20 +151,18 @@ class CycleCount extends Page return; } - if(preg_match($pattern1, $value)) - { + if (preg_match($pattern1, $value)) { $value = rtrim($value, '#'); $parts = explode('#', $value); $this->itemCode = $parts[0] ?? null; - $this->batch = $parts[1] ?? null; - $this->docNo = $parts[2] ?? null; + $this->batch = $parts[1] ?? null; + $this->docNo = $parts[2] ?? null; $this->quantity = $parts[3] ?? null; - if (strlen($this->itemCode) < 6) - { + if (strlen($this->itemCode) < 6) { Notification::make() - ->title("Unknown Item Code") + ->title('Unknown Item Code') ->body("Item Code should contain minimum 6 digits '$this->itemCode'") ->danger() ->send(); @@ -165,11 +172,11 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; - } - elseif(!ctype_alnum($this->itemCode)){ + } elseif (! ctype_alnum($this->itemCode)) { Notification::make() - ->title("Unknown Item Code") + ->title('Unknown Item Code') ->body("Item Code should contain alpha-numeric values '$this->itemCode'") ->danger() ->duration(5000) @@ -180,13 +187,13 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); - return; - } - elseif($this->batch != '' || $this->batch != null){ - if(strlen($this->batch) < 5){ + return; + } elseif ($this->batch != '' || $this->batch != null) { + + if (strlen($this->batch) < 5) { Notification::make() - ->title("Unknown Batch") + ->title('Unknown Batch') ->body("Batch should contain minimum 5 digits '$this->batch'") ->danger() ->duration(5000) @@ -197,13 +204,13 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; } - } - elseif(strlen($this->docNo) < 5){ + } elseif (strlen($this->docNo) < 5) { Notification::make() - ->title("Unknown Doc No") + ->title('Unknown Doc No') ->body("Doc No should contain minimum 5 digits '$this->docNo'") ->danger() ->duration(5000) @@ -214,11 +221,11 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; - } - elseif (!ctype_digit($this->quantity)) { + } elseif (! ctype_digit($this->quantity)) { Notification::make() - ->title("Unknown Quantity") + ->title('Unknown Quantity') ->body("Quantity must be an integer value '$this->quantity'") ->danger() ->duration(5000) @@ -229,14 +236,15 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; } $item = Item::where('code', $this->itemCode)->first(); - if(!$item){ + if (! $item) { Notification::make() - ->title("Item Code Not Found") + ->title('Item Code Not Found') ->body("Item code not found '$this->itemCode'") ->danger() ->duration(5000) @@ -247,6 +255,7 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; } @@ -256,9 +265,9 @@ class CycleCount extends Page $plantCode = $plantCo->code; - if(!$itemCodeAgaPlant){ + if (! $itemCodeAgaPlant) { Notification::make() - ->title("Item Code Not Found") + ->title('Item Code Not Found') ->body("Item code '$this->itemCode' not found against plant code '$plantCode'") ->danger() ->duration(5000) @@ -269,15 +278,16 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; } $stickerExists = StickerMaster::where('item_id', $item->id)->first(); - if (!$stickerExists) { + if (! $stickerExists) { Notification::make() - ->title("Unknown Sticker Master") + ->title('Unknown Sticker Master') ->body("Item code not found in sticker master '{$this->itemCode}'") ->danger() ->duration(5000) @@ -297,10 +307,10 @@ class CycleCount extends Page ->where('item_id', $item->id) ->first(); - if (!$stickerExists) { + if (! $stickerExists) { Notification::make() - ->title("Unknown Sticker Master") + ->title('Unknown Sticker Master') ->body("Item code not found in sticker master '{$this->itemCode}' in plant '{$plantCode}'") ->danger() ->duration(5000) @@ -322,7 +332,7 @@ class CycleCount extends Page ->where('location', $location) ->first(); - if(!$locationExist){ + if (! $locationExist) { $existingInOtherLocation = NotInStock::where('plant_id', $plantId) ->where('serial_number', $this->sNo) @@ -361,8 +371,8 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity - ]) + 'quantity' => $this->quantity, + ]), ]) ->send(); @@ -372,6 +382,7 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; } @@ -380,7 +391,7 @@ class CycleCount extends Page ->where('location', $location) ->first(); - if(!$locationAgaPlant){ + if (! $locationAgaPlant) { $existingInOtherLocation = NotInStock::where('plant_id', $plantId) ->where('serial_number', $this->sNo) @@ -418,8 +429,8 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity - ]) + 'quantity' => $this->quantity, + ]), ]) ->send(); @@ -439,7 +450,7 @@ class CycleCount extends Page ->where('sticker_master_id', $stickerMasterId) ->first(); - if(!$locationItemAgaPlant){ + if (! $locationItemAgaPlant) { $existingInOtherLocation = NotInStock::where('plant_id', $plantId) ->where('serial_number', $this->sNo) @@ -477,17 +488,17 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); - $this->form->fill([ - 'plant_id' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'qr_code' => null, - ]); + $this->form->fill([ + 'plant_id' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'qr_code' => null, + ]); return; } @@ -530,17 +541,17 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); - $this->form->fill([ - 'plant_id' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'qr_code' => null, - ]); + $this->form->fill([ + 'plant_id' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'qr_code' => null, + ]); return; } @@ -583,17 +594,17 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); - $this->form->fill([ - 'plant_id' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'qr_code' => null, - ]); + $this->form->fill([ + 'plant_id' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'qr_code' => null, + ]); return; } @@ -611,7 +622,7 @@ class CycleCount extends Page // $remainingStock = $stock->quantity - $currentScanned; - if($stock->scanned_status == 'Scanned'){ + if ($stock->scanned_status == 'Scanned') { Notification::make() ->title('Duplicate Serial Number') @@ -629,17 +640,18 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); - $this->form->fill([ - 'plant_id' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'qr_code' => null, - ]); + $this->form->fill([ + 'plant_id' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'qr_code' => null, + ]); + return; } @@ -667,31 +679,29 @@ class CycleCount extends Page 'bin' => $bin, 'batch' => $this->batch, 'scanned_quantity' => $newScannedQty, - 'scanned_status' => $status + 'scanned_status' => $status, ]); $this->dispatch('refreshSfgData', location: $location, plantId: $plantId, itemCode: $this->itemCode, docNo: $this->docNo); - } - else - { + } else { Notification::make() - ->title('Unknown : Data Found') - ->body("No matching record found for the given Location, Item Code, Batch, and Document Number under Plant Code '$plantCode' in stock data master.") - ->danger() - ->actions([ - \Filament\Notifications\Actions\Action::make('confirm_update') - ->label('Yes, Update') - ->button() - ->dispatch('confirmStockUpdate', [ - 'plantId' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'stickerMasterId' => $stickerMasterId, - 'batch' => $this->batch, - 'docNo' => $this->docNo, - 'quantity' => $this->quantity - ]), - ]) - ->send(); + ->title('Unknown : Data Found') + ->body("No matching record found for the given Location, Item Code, Batch, and Document Number under Plant Code '$plantCode' in stock data master.") + ->danger() + ->actions([ + \Filament\Notifications\Actions\Action::make('confirm_update') + ->label('Yes, Update') + ->button() + ->dispatch('confirmStockUpdate', [ + 'plantId' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'stickerMasterId' => $stickerMasterId, + 'batch' => $this->batch, + 'docNo' => $this->docNo, + 'quantity' => $this->quantity, + ]), + ]) + ->send(); $this->form->fill([ 'plant_id' => $plantId, @@ -705,25 +715,22 @@ class CycleCount extends Page return; } - } - else if(preg_match($pattern2, $value)) - { + } elseif (preg_match($pattern2, $value)) { $value = rtrim($value, '|'); $parts = explode('|', $value); $this->itemCode = $parts[0] ?? null; if (strlen($parts[1]) > strlen($parts[2])) { - $this->sNo = $parts[1]; + $this->sNo = $parts[1]; $this->batch = $parts[2]; } else { $this->batch = $parts[1]; - $this->sNo = $parts[2]; + $this->sNo = $parts[2]; } - if (strlen($this->itemCode) < 6) - { + if (strlen($this->itemCode) < 6) { Notification::make() - ->title("Unknown Item Code") + ->title('Unknown Item Code') ->body("Item Code should contain minimum 6 digits '$this->itemCode'") ->danger() ->send(); @@ -734,11 +741,11 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; - } - elseif(!ctype_alnum($this->itemCode)){ + } elseif (! ctype_alnum($this->itemCode)) { Notification::make() - ->title("Unknown Item Code") + ->title('Unknown Item Code') ->body("Item Code should contain alpha-numeric values '$this->itemCode'") ->danger() ->duration(5000) @@ -749,20 +756,20 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; - } - elseif(strlen($this->batch) < 5){ + } elseif (strlen($this->batch) < 5) { Notification::make() - ->title("Unknown Batch") + ->title('Unknown Batch') ->body("Batch should contain minimum 5 digits '$this->batch'") ->danger() ->duration(5000) ->send(); + return; - } - elseif(strlen($this->sNo) < 9){ + } elseif (strlen($this->sNo) < 9) { Notification::make() - ->title("Unknown Serial Number") + ->title('Unknown Serial Number') ->body("Serial Number should contain minimum 9 digits '$this->sNo'") ->danger() ->duration(5000) @@ -773,11 +780,11 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; - } - elseif(!ctype_alnum($this->sNo)){ + } elseif (! ctype_alnum($this->sNo)) { Notification::make() - ->title("Unknown Serial Number") + ->title('Unknown Serial Number') ->body("Serial Number should contain alpha-numeric values '$this->sNo'") ->danger() ->duration(5000) @@ -788,14 +795,15 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; } $item = Item::where('code', $this->itemCode)->first(); - if(!$item){ + if (! $item) { Notification::make() - ->title("Item Code Not Found") + ->title('Item Code Not Found') ->body("Item code not found '$this->itemCode'") ->danger() ->duration(5000) @@ -806,6 +814,7 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; } @@ -815,9 +824,9 @@ class CycleCount extends Page $plantCode = $plantCo->code; - if(!$itemCodeAgaPlant){ + if (! $itemCodeAgaPlant) { Notification::make() - ->title("Item Code Not Found") + ->title('Item Code Not Found') ->body("Item code '$this->itemCode' not found against plant code '$plantCode'") ->danger() ->duration(5000) @@ -828,15 +837,16 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; } $stickerExists = StickerMaster::where('item_id', $item->id)->first(); - if (!$stickerExists) { + if (! $stickerExists) { Notification::make() - ->title("Unknown Sticker Master") + ->title('Unknown Sticker Master') ->body("Item code not found in sticker master '{$this->itemCode}'") ->danger() ->duration(5000) @@ -856,9 +866,9 @@ class CycleCount extends Page ->where('item_id', $item->id) ->first(); - if (!$stickerExists) { + if (! $stickerExists) { Notification::make() - ->title("Unknown Sticker Master") + ->title('Unknown Sticker Master') ->body("Item code not found in sticker master '{$this->itemCode}' in plant '{$plantCode}'") ->danger() ->duration(5000) @@ -869,6 +879,7 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; } @@ -878,7 +889,7 @@ class CycleCount extends Page ->where('type', '1') ->first(); - if(!$locationExist){ + if (! $locationExist) { $existingInOtherLocation = NotInStock::where('plant_id', $plantId) ->where('serial_number', $this->sNo) @@ -917,7 +928,7 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); @@ -937,7 +948,7 @@ class CycleCount extends Page ->where('type', '1') ->first(); - if(!$locationAgaPlant){ + if (! $locationAgaPlant) { $existingInOtherLocation = NotInStock::where('plant_id', $plantId) ->where('serial_number', $this->sNo) @@ -976,7 +987,7 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); @@ -991,7 +1002,7 @@ class CycleCount extends Page return; } - if($bin == '' || $bin == null){ + if ($bin == '' || $bin == null) { Notification::make() ->title('Unknown Bin') ->body("Bin can't be empty!") @@ -1010,7 +1021,7 @@ class CycleCount extends Page $serialExist = StockDataMaster::where('serial_number', $this->sNo)->where('type', '1')->first(); - if(!$serialExist){ + if (! $serialExist) { $existingInOtherLocation = NotInStock::where('plant_id', $plantId) ->where('serial_number', $this->sNo) @@ -1049,7 +1060,7 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); @@ -1066,7 +1077,7 @@ class CycleCount extends Page $serialAgaPlant = StockDataMaster::where('plant_id', $plantId)->where('serial_number', $this->sNo)->where('type', '1')->first(); - if(!$serialAgaPlant){ + if (! $serialAgaPlant) { $sNoExist = NotInStock::where('plant_id', $plantId) ->where('serial_number', $this->sNo) @@ -1105,7 +1116,7 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); @@ -1159,7 +1170,7 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); @@ -1213,7 +1224,7 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); @@ -1230,11 +1241,11 @@ class CycleCount extends Page if ($serialAgaPlant->batch != '' || $serialAgaPlant->batch != null) { - if($serialAgaPlant->batch != $this->batch){ + if ($serialAgaPlant->batch != $this->batch) { $sNoExistLocation = NotInStock::where('plant_id', $plantId) - ->where('serial_number', $this->sNo) - ->first(); + ->where('serial_number', $this->sNo) + ->first(); if ($sNoExistLocation) { Notification::make() @@ -1269,7 +1280,7 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); @@ -1326,14 +1337,13 @@ class CycleCount extends Page // } // } - $serial = StockDataMaster::where('plant_id', $plantId) ->where('serial_number', $this->sNo) ->where('location', $location) ->where('type', '1') ->first(); - if($serial->quantity == '' || $serial->quantity == null){ + if ($serial->quantity == '' || $serial->quantity == null) { Notification::make() ->warning() ->title('Unknown Quantity') @@ -1341,16 +1351,15 @@ class CycleCount extends Page ->seconds(3) ->send(); - $this->form->fill([ - 'plant_id' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'qr_code' => null, - ]); + $this->form->fill([ + 'plant_id' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'qr_code' => null, + ]); - return; - } - elseif ((int) $serial->quantity > 1) { + return; + } elseif ((int) $serial->quantity > 1) { Notification::make() ->warning() ->title('Invalid Quantity') @@ -1358,19 +1367,19 @@ class CycleCount extends Page ->seconds(3) ->send(); - $this->form->fill([ - 'plant_id' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'qr_code' => null, - ]); + $this->form->fill([ + 'plant_id' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'qr_code' => null, + ]); - return; + return; } if ($serial) { - if($serial->scanned_status == 'Scanned'){ + if ($serial->scanned_status == 'Scanned') { Notification::make() ->title('Duplicate Serial Number') @@ -1388,17 +1397,18 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); - $this->form->fill([ - 'plant_id' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'qr_code' => null, - ]); + $this->form->fill([ + 'plant_id' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'qr_code' => null, + ]); + return; } @@ -1406,10 +1416,10 @@ class CycleCount extends Page 'bin' => $bin ?? null, 'batch' => $this->batch ?? null, 'doc_no' => $this->docNo ?? null, - 'scanned_status' => 'Scanned', - 'scanned_quantity' => '1', + 'scanned_status' => 'Scanned', + 'scanned_quantity' => '1', 'updated_at' => now(), - 'updated_by' => $operatorName + 'updated_by' => $operatorName, ]); $this->form->fill([ @@ -1421,9 +1431,7 @@ class CycleCount extends Page $this->dispatch('refreshSfgNonData', location: $location, plantId: $plantId, serialNumber: $this->sNo, itemCode: $this->itemCode); } - } - else - { + } else { $serNo = $value; if (! preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPp])?\|?$/', $serNo, $matches)) { @@ -1489,12 +1497,12 @@ class CycleCount extends Page ->where('code', $itemCode) ->first(); - if(!$item){ + if (! $item) { Notification::make() - ->title('Invalid Item Code') - ->body("Item code '$this->itemCode' not found for the type FG against plant code '$plantCode'.") - ->danger() - ->send(); + ->title('Invalid Item Code') + ->body("Item code '$this->itemCode' not found for the type FG against plant code '$plantCode'.") + ->danger() + ->send(); $this->form->fill([ 'plant_id' => $plantId, @@ -1502,6 +1510,7 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; } @@ -1511,12 +1520,12 @@ class CycleCount extends Page ->where('item_id', $itemId) ->first(); - if(!$stickerMaster){ + if (! $stickerMaster) { Notification::make() - ->title('Invalid Item Code') - ->body("Item code '$this->itemCode' not found in sticker master for the type FG against plant code '$plantCode'.") - ->danger() - ->send(); + ->title('Invalid Item Code') + ->body("Item code '$this->itemCode' not found in sticker master for the type FG against plant code '$plantCode'.") + ->danger() + ->send(); $this->form->fill([ 'plant_id' => $plantId, @@ -1524,6 +1533,7 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; } @@ -1533,7 +1543,7 @@ class CycleCount extends Page ->where('type', '0') ->first(); - if(!$locationExist){ + if (! $locationExist) { $existingInOtherLocation = NotInStock::where('plant_id', $plantId) ->where('serial_number', $this->sNo) @@ -1572,7 +1582,7 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); @@ -1592,48 +1602,17 @@ class CycleCount extends Page ->where('type', '0') ->first(); - if(!$locationAgaPlant){ + if (! $locationAgaPlant) { - $existingInOtherLocation = NotInStock::where('plant_id', $plantId) - ->where('serial_number', $this->sNo) - ->first(); - - if ($existingInOtherLocation) { - Notification::make() - ->title('Serial Number : Not In Stock') - ->body("Serial number '{$this->sNo}' already exists against plant code '$plantCode' in not in stock table.") - ->danger() - ->send(); - - $this->form->fill([ - 'plant_id' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'qr_code' => null, - ]); - - return; - } + $existingInOtherLocation = NotInStock::where('plant_id', $plantId) + ->where('serial_number', $this->sNo) + ->first(); + if ($existingInOtherLocation) { Notification::make() - ->title('Unknown Location') - ->body("location '$location' not found in stock data master for the type FG against plant code '$plantCode'.
Do you want to update in not in stock table?") + ->title('Serial Number : Not In Stock') + ->body("Serial number '{$this->sNo}' already exists against plant code '$plantCode' in not in stock table.") ->danger() - ->actions([ - \Filament\Notifications\Actions\Action::make('confirm') - ->label('Yes, Update') - ->button() - ->dispatch('confirmSerialUpdate', [ - 'plantId' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'serial_number' => $this->sNo, - 'stickerMasterId' => $stickerMasterId, - 'batch' => $this->batch, - 'docNo' => $this->docNo, - 'quantity' => $this->quantity - ]), - ]) ->send(); $this->form->fill([ @@ -1646,6 +1625,37 @@ class CycleCount extends Page return; } + Notification::make() + ->title('Unknown Location') + ->body("location '$location' not found in stock data master for the type FG against plant code '$plantCode'.
Do you want to update in not in stock table?") + ->danger() + ->actions([ + \Filament\Notifications\Actions\Action::make('confirm') + ->label('Yes, Update') + ->button() + ->dispatch('confirmSerialUpdate', [ + 'plantId' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'serial_number' => $this->sNo, + 'stickerMasterId' => $stickerMasterId, + 'batch' => $this->batch, + 'docNo' => $this->docNo, + 'quantity' => $this->quantity, + ]), + ]) + ->send(); + + $this->form->fill([ + 'plant_id' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'qr_code' => null, + ]); + + return; + } + $record = StockDataMaster::where('serial_number', $serialNumber) ->where('plant_id', $plantId) ->where('type', '0') @@ -1681,22 +1691,22 @@ class CycleCount extends Page $message = "serial number not found '$serialNumber' for the type FG against item code '$itemCode' and plant code '$plantCode'
Do you want to update in not in stock table"; Notification::make() - ->title('Invalid Item Code') - ->body($message) - ->danger() - ->actions([ - \Filament\Notifications\Actions\Action::make('confirm_update') - ->label('Yes, Update') - ->button() - ->dispatch('confirmSerialFGUpdate', [ - 'plantId' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'serial_number' => $this->sNo, - 'stickerMasterId' => $stickerMasterId, - ]), - ]) - ->send(); + ->title('Invalid Item Code') + ->body($message) + ->danger() + ->actions([ + \Filament\Notifications\Actions\Action::make('confirm_update') + ->label('Yes, Update') + ->button() + ->dispatch('confirmSerialFGUpdate', [ + 'plantId' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'serial_number' => $this->sNo, + 'stickerMasterId' => $stickerMasterId, + ]), + ]) + ->send(); $this->form->fill([ 'plant_id' => $plantId, @@ -1704,6 +1714,7 @@ class CycleCount extends Page 'bin' => $bin, 'qr_code' => null, ]); + return; } @@ -1755,17 +1766,17 @@ class CycleCount extends Page ]) ->send(); - $this->form->fill([ - 'plant_id' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'qr_code' => null, - ]); + $this->form->fill([ + 'plant_id' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'qr_code' => null, + ]); return; } - if($record->scanned_status == 'Scanned'){ + if ($record->scanned_status == 'Scanned') { Notification::make() ->title('Duplicate Serial Number') @@ -1783,17 +1794,17 @@ class CycleCount extends Page 'stickerMasterId' => $stickerMasterId, 'batch' => $this->batch, 'docNo' => $this->docNo, - 'quantity' => $this->quantity + 'quantity' => $this->quantity, ]), ]) ->send(); - $this->form->fill([ - 'plant_id' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'qr_code' => null, - ]); + $this->form->fill([ + 'plant_id' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'qr_code' => null, + ]); return; @@ -1839,8 +1850,7 @@ class CycleCount extends Page $hasMotorQr = $record->stickerMasterRelation->pack_slip_motor ?? null; $hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null; $hasPumpSetQr = $record->stickerMasterRelation->pack_slip_pumpset ?? null; - } - else { + } else { if (! $hasPumpSetQr && ! $hasPumpQr) { $hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null; } @@ -2037,15 +2047,14 @@ class CycleCount extends Page // ->send(); $this->form->fill([ - 'plant_id' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'qr_code' => null, - ]); + 'plant_id' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'qr_code' => null, + ]); return; - } - elseif ($isMarkPs) { + } elseif ($isMarkPs) { if (! $hasPumpSetQr) { Notification::make() ->title('Unknown: Pump Set QR') @@ -2112,11 +2121,11 @@ class CycleCount extends Page // ->send(); $this->form->fill([ - 'plant_id' => $plantId, - 'location' => $location, - 'bin' => $bin, - 'qr_code' => null, - ]); + 'plant_id' => $plantId, + 'location' => $location, + 'bin' => $bin, + 'qr_code' => null, + ]); return; } @@ -2144,9 +2153,9 @@ class CycleCount extends Page $bin = $this->bin; $stickerMaster = StickerMaster::whereHas('item', function ($query) use ($itemCode, $plantId) { - $query->where('code', $itemCode) - ->where('plant_id', $plantId); - }) + $query->where('code', $itemCode) + ->where('plant_id', $plantId); + }) ->first(); if (! $stickerMaster) { @@ -2155,6 +2164,7 @@ class CycleCount extends Page ->title('Sticker Master Not Found') ->danger() ->send(); + return; } $existingRecord = NotInStock::where('serial_number', $this->serialNumber) @@ -2174,6 +2184,7 @@ class CycleCount extends Page ->body("Serial number '{$this->serialNumber}' already exists with Item Code '{$existingItemCode}'.") ->danger() ->send(); + return; } } @@ -2186,21 +2197,22 @@ class CycleCount extends Page }) ->first(); - if($record){ + if ($record) { Notification::make() ->title('Duplicate : Item Code') ->body("Item Code '$itemCode' with Serial number '$this->serialNumber' already exist in not in stock table!") ->danger() ->send(); + return; } NotInStock::create([ 'serial_number' => $this->serialNumber, - 'sticker_master_id' => $stickerMaster->id, - 'plant_id' => $plantId, - 'location' => $location, - 'bin' => $bin, + 'sticker_master_id' => $stickerMaster->id, + 'plant_id' => $plantId, + 'location' => $location, + 'bin' => $bin, ]); Notification::make() @@ -2215,5 +2227,4 @@ class CycleCount extends Page { return Auth::check() && Auth::user()->can('view cycle count page'); } - }