ranjith-dev #470

Merged
jothi merged 2 commits from ranjith-dev into master 2026-03-11 04:58:56 +00:00
3 changed files with 78 additions and 20 deletions

View File

@@ -328,7 +328,7 @@ class StockDataMasterResource extends Resource
->reactive() ->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void { ->afterStateUpdated(function ($state, callable $set, callable $get): void {
$set('sticker_master_id', null); $set('sticker_master_id', null);
$set('operator_id', null); $set('updated_by', null);
}), }),
TextInput::make('location') TextInput::make('location')
->label('Location') ->label('Location')
@@ -388,7 +388,7 @@ class StockDataMasterResource extends Resource
->native(false), ->native(false),
]) ])
->query(function ($query, array $data) { ->query(function ($query, array $data) {
if (!isset($data['type']) && (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) { if (!isset($data['type']) && (empty($data['Plant']) && empty($data['location']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
if (empty($data['type'])) { if (empty($data['type'])) {
Notification::make() Notification::make()
@@ -399,33 +399,53 @@ class StockDataMasterResource extends Resource
return $query->whereRaw('1 = 0'); return $query->whereRaw('1 = 0');
} }
if ($data['type'] == '0') { if($data['type'] != ''){
$query->where('type', '0'); if ($data['type'] == '0') {
if (!empty($data['scanned_status'])) { $query->where('type', '0');
if (!empty($data['scanned_status'])) {
if ($data['scanned_status'] == 'Scanned') {
$query->whereNotNull('scanned_status')
->where('scanned_status', '!=', '');
} elseif ($data['scanned_status'] == 'Pending') {
$query->where(function ($query) {
$query->whereNull('scanned_status')
->orWhere('scanned_status', '!=', 'Scanned');
});
}
}
} elseif ($data['type'] == '1') {
$query->where('type', '1')
->whereNotNull('quantity');
if ($data['scanned_status']) {
if ($data['scanned_status'] == 'Scanned') {
if ($data['scanned_status'] == 'Scanned') {
$query->whereNotNull('scanned_status') $query->whereNotNull('scanned_status')
->where('scanned_status', '!=', ''); ->where('scanned_status', '!=', '');
} elseif ($data['scanned_status'] == 'Pending') {
$query->where(function ($query) { } elseif ($data['scanned_status'] == 'Pending') {
$query->whereNull('scanned_status')
$query->where(function ($q) {
$q->whereNull('scanned_status')
->orWhere('scanned_status', '!=', 'Scanned'); ->orWhere('scanned_status', '!=', 'Scanned');
}); });
}
} }
} }
} elseif ($data['type'] == '1') { }
$query->where('type', '1') else{
->whereNotNull('quantity');
if ($data['scanned_status']) { if ($data['scanned_status']) {
if ($data['scanned_status'] == 'Scanned') { if ($data['scanned_status'] == 'Scanned') {
$query->whereNotNull('scanned_status') $query->whereNotNull('scanned_status')
->where('scanned_status', '!=', ''); ->where('scanned_status', '!=', '');
} elseif ($data['scanned_status'] == 'Pending') { } elseif ($data['scanned_status'] == 'Pending') {

View File

@@ -2,6 +2,7 @@
namespace App\Livewire; namespace App\Livewire;
use App\Models\DuplicateStock;
use App\Models\Item; use App\Models\Item;
use App\Models\NotInStock; use App\Models\NotInStock;
use App\Models\StickerMaster; use App\Models\StickerMaster;
@@ -65,7 +66,8 @@ class StockDataTable extends Component
'refreshSfgNonData' => 'loadSfgNonQuanData', 'refreshSfgNonData' => 'loadSfgNonQuanData',
'confirmStockUpdate', 'confirmStockUpdate',
'confirmSerialUpdate', 'confirmSerialUpdate',
'confirmSerialFGUpdate' 'confirmSerialFGUpdate',
'confirmDuplicateUpdate'
]; ];
public $capacitorInput = ''; public $capacitorInput = '';
@@ -170,6 +172,43 @@ class StockDataTable extends Component
} }
} }
public function confirmDuplicateUpdate($plantId, $location, $bin, $serial_number, $stickerMasterId, $batch, $docNo, $quantity)
{
$sNo = $serial_number;
$stockRecord = StockDataMaster::where('serial_number', $sNo)
->where('plant_id', $plantId)
->first();
if (!$stockRecord) {
return;
}
$record = DuplicateStock::where('stock_data_master_id', $stockRecord->id)->first();
if (!$record) {
DuplicateStock::create([
'stock_data_master_id' => $stockRecord->id,
]);
Notification::make()
->title('Record inserted successfully in duplicate stock table.')
->success()
->send();
} else {
DuplicateStock::create([
'stock_data_master_id' => $stockRecord->id,
]);
Notification::make()
->title('Record inserted successfully in duplicate stock table.')
->success()
->send();
}
}
public function confirmSerialFGUpdate($plantId, $location, $bin, $sNo, $stickerMasterId) public function confirmSerialFGUpdate($plantId, $location, $bin, $sNo, $stickerMasterId)
{ {

View File

@@ -1,7 +1,6 @@
<?php <?php
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration
@@ -11,7 +10,7 @@ return new class extends Migration
*/ */
public function up(): void public function up(): void
{ {
$sql = <<<'SQL' $sql = <<<'SQL'
CREATE TABLE device_masters ( CREATE TABLE device_masters (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY, id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
plant_id BIGINT NOT NULL, plant_id BIGINT NOT NULL,