Added cycle count page and stock data table livewire page #466

Merged
jothi merged 1 commits from ranjith-dev into master 2026-03-10 05:24:41 +00:00
2 changed files with 362 additions and 91 deletions

View File

@@ -557,14 +557,25 @@ class CycleCount extends Page
else
{
Notification::make()
->danger()
->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.")
->seconds(3)
->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->dispatch('playWarnSound');
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
@@ -572,6 +583,8 @@ class CycleCount extends Page
'qr_code' => null,
]);
$this->dispatch('playWarnSound');
return;
}
@@ -597,6 +610,13 @@ class CycleCount extends Page
->body("Item Code should contain minimum 6 digits '$this->itemCode'")
->danger()
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
elseif(!ctype_alnum($this->itemCode)){
@@ -606,6 +626,12 @@ class CycleCount extends Page
->danger()
->duration(5000)
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
elseif(strlen($this->batch) < 5){
@@ -624,6 +650,12 @@ class CycleCount extends Page
->danger()
->duration(5000)
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
elseif(!ctype_alnum($this->sNo)){
@@ -633,6 +665,12 @@ class CycleCount extends Page
->danger()
->duration(5000)
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
@@ -645,6 +683,12 @@ class CycleCount extends Page
->danger()
->duration(5000)
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
@@ -661,6 +705,12 @@ class CycleCount extends Page
->danger()
->duration(5000)
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
@@ -675,6 +725,13 @@ class CycleCount extends Page
->duration(5000)
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
@@ -689,93 +746,24 @@ class CycleCount extends Page
->danger()
->duration(5000)
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
$stickerMasterId = $stickerExists->id;
$serialExist = StockDataMaster::where('serial_number', $this->sNo)->where('type', '1')->first();
if(!$serialExist){
Notification::make()
->danger()
->title('Unknown Serial Number')
->body('Scanned serial number not found in stock data master for the type SFG')
->seconds(3)
->send();
return;
}
$serialAgaPlant = StockDataMaster::where('plant_id', $plantId)->where('serial_number', $this->sNo)->where('type', '1')->first();
if(!$serialAgaPlant){
Notification::make()
->danger()
->title('Unknown Serial Number')
->body("Scanned serial number not found in stock data master for the type SFG against plant code '$plantCode'")
->seconds(3)
->send();
return;
}
if ($serialAgaPlant->location != $location) {
Notification::make()
->danger()
->title('Invalid Location')
->body("Serial number '$this->sNo' does not belong to location '$location' for the type SFG against plant code '$plantCode'.")
->seconds(3)
->send();
return;
}
if ($serialAgaPlant->sticker_master_id != $stickerMasterId) {
Notification::make()
->danger()
->title('Invalid Item Code')
->body("Serial number '$this->sNo' does not belong to item code '$this->itemCode' for the type SFG against plant code '$plantCode'.")
->seconds(3)
->send();
return;
}
if ($serialAgaPlant->batch != '' || $serialAgaPlant->batch != null) {
if($serialAgaPlant->batch != $this->batch){
Notification::make()
->danger()
->title('Invalid Batch')
->body("Serial number '$this->sNo' does not belong to batch '$this->batch' for the type SFG against plant code '$plantCode'.")
->seconds(3)
->send();
return;
}
}
if ($serialAgaPlant->bin != '' || $serialAgaPlant->bin != null) {
if($serialAgaPlant->bin != $bin){
Notification::make()
->danger()
->title('Invalid Bin')
->body("Serial number '$this->sNo' does not belong to bin '$bin' for the type SFG against plant code '$plantCode'.")
->seconds(3)
->send();
return;
}
}
$serial = StockDataMaster::where('plant_id', $plantId)
$quanExist = StockDataMaster::where('plant_id', $plantId)
->where('serial_number', $this->sNo)
->where('location', $location)
->where('type', '1')
->first();
if($serial->quantity == '' || $serial->quantity == null){
if($quanExist->quantity == '' || $quanExist->quantity == null){
Notification::make()
->warning()
->title('Unknown Quantity')
@@ -785,7 +773,7 @@ class CycleCount extends Page
return;
}
elseif ((int) $serial->quantity > 1) {
elseif ((int) $quanExist->quantity > 1) {
Notification::make()
->warning()
->title('Invalid Quantity')
@@ -796,6 +784,246 @@ class CycleCount extends Page
return;
}
$serialExist = StockDataMaster::where('serial_number', $this->sNo)->where('type', '1')->first();
if(!$serialExist){
Notification::make()
->title('Unknown Serial Number')
->body('Scanned serial number not found in stock data master for the type SFG')
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm_update')
->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;
}
$serialAgaPlant = StockDataMaster::where('plant_id', $plantId)->where('serial_number', $this->sNo)->where('type', '1')->first();
if(!$serialAgaPlant){
Notification::make()
->title('Unknown Serial Number')
->body("Scanned serial number not found in stock data master for the type SFG against plant code '$plantCode'")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm_update')
->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;
}
if ($serialAgaPlant->location != $location) {
Notification::make()
->title('Invalid Location')
->body("Serial number '$this->sNo' does not belong to location '$location' for the type SFG against plant code '$plantCode'.")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm_update')
->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;
}
if ($serialAgaPlant->sticker_master_id != $stickerMasterId) {
Notification::make()
->title('Invalid Item Code')
->body("Serial number '$this->sNo' does not belong to item code '$this->itemCode' for the type SFG against plant code '$plantCode'.")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm_update')
->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;
}
if ($serialAgaPlant->batch != '' || $serialAgaPlant->batch != null) {
if($serialAgaPlant->batch != $this->batch){
Notification::make()
->title('Invalid Batch')
->body("Serial number '$this->sNo' does not belong to batch '$this->batch' for the type SFG against plant code '$plantCode'.")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm_update')
->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;
}
}
// if ($serialAgaPlant->bin != '' || $serialAgaPlant->bin != null) {
// if($serialAgaPlant->bin != $bin){
// Notification::make()
// ->danger()
// ->title('Invalid Bin')
// ->body("Serial number '$this->sNo' does not belong to bin '$bin' for the type SFG against plant code '$plantCode'.")
// ->seconds(3)
// ->send();
// Notification::make()
// ->title('Invalid Bin')
// ->body("Serial number '$this->sNo' does not belong to bin '$bin' for the type SFG against plant code '$plantCode'.")
// ->danger()
// ->actions([
// \Filament\Notifications\Actions\Action::make('confirm_update')
// ->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;
// }
// }
$serial = StockDataMaster::where('plant_id', $plantId)
->where('serial_number', $this->sNo)
->where('location', $location)
->where('type', '1')
->first();
// if($serial->quantity == '' || $serial->quantity == null){
// Notification::make()
// ->warning()
// ->title('Unknown Quantity')
// ->body("Quantity is missing for serial number '$this->sNo' (Type: SFG) in Plant Code '$plantCode'. Please update it in Stock Data Master.")
// ->seconds(3)
// ->send();
// return;
// }
// elseif ((int) $serial->quantity > 1) {
// Notification::make()
// ->warning()
// ->title('Invalid Quantity')
// ->body("Quantity should be '1' against '$this->sNo' for the type SFG against plant code '$plantCode'!Please update quantity in stock data master.")
// ->seconds(3)
// ->send();
// return;
// }
if ($serial) {
if($serial->scanned_status == 'Scanned'){
@@ -806,7 +1034,6 @@ class CycleCount extends Page
->body("Already completed the scanning process Serial number '$this->sNo' for the type SFG against plant code '$plantCode'.")
->seconds(3)
->send();
return;
}

View File

@@ -87,6 +87,7 @@ class StockDataTable extends Component
->where('location', $location)
->where('sticker_master_id', $stickerMasterId)
->where('doc_no', $docNo)
->where('bin', $bin)
->first();
if (!$record) {
@@ -123,6 +124,49 @@ class StockDataTable extends Component
}
}
public function confirmSerialUpdate($plantId, $location, $bin, $sNo, $stickerMasterId, $batch, $docNo, $quantity)
{
$record = NotInStock::where('plant_id', $plantId)
->where('location', $location)
->where('sticker_master_id', $stickerMasterId)
->where('doc_no', $docNo)
->where('bin', $bin)
->first();
if (!$record) {
NotInStock::create([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'sticker_master_id' => $stickerMasterId,
'type' => '1',
'serial_number' => $sNo ?? null,
'batch' => $batch ?? null,
'doc_no' => $docNo ?? null,
'scanned_quantity' => $quantity ?? '1',
]);
Notification::make()
->title('Record inserted successfully in not in stock table.')
->success()
->send();
} else {
$record->update([
'batch' => $batch ?? null,
'doc_no' => $docNo ?? null,
]);
Notification::make()
->title('Record updated in not in stock table.')
->success()
->send();
}
}
public function loadCompletedData($location, $plantId, $isSerial)
{
$this->plantId = $plantId;