21 Commits

Author SHA1 Message Date
dhanabalan
10081fd20e Removed plant select box in not in stock
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-22 13:48:34 +05:30
dhanabalan
5d7b9d52f8 Added plant select box in not in stock for testing
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-22 13:47:14 +05:30
dhanabalan
499fa0b2dd Changed dashboard logic as welcome page in dashboard page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-22 09:31:00 +05:30
dhanabalan
27b5ad2cfe Updated laser cloud communication logics
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-21 16:22:44 +05:30
dhanabalan
4c7bed8c63 Updated validation logic against machin name on resource and import page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-20 16:16:04 +05:30
dhanabalan
253d319587 Added updated order quantity in importer and exporter
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-20 14:10:05 +05:30
dhanabalan
ead2edc63b Changed logic in post api of process order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-03-20 14:08:57 +05:30
dhanabalan
18f23ce097 Added updated order quantity in resource pages
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-03-20 14:07:30 +05:30
dhanabalan
198b901671 Added updated order quantity in process order model file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-20 14:06:11 +05:30
dhanabalan
3192e32d5d Added updated order quantity column in process order table
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-03-20 14:05:21 +05:30
dhanabalan
61be13c367 Updated marked_datetime column default value as current datetime instead of null in migration
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-19 18:54:34 +05:30
dhanabalan
3d139c005a Added hasMany relationship on model files
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-16 19:23:09 +05:30
dhanabalan
4325f2695f Added separate get user data api for clarity
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-16 19:01:18 +05:30
dhanabalan
8eeb23e2aa Updated method name on UserController
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-03-16 18:59:12 +05:30
dhanabalan
73611a417b Updated received quantity exceed validation on process order resource page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-14 13:20:10 +05:30
dhanabalan
37df670eab Updated quantity exceed warning message against process order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-13 15:42:04 +05:30
dhanabalan
58b801b8e2 Updated quantity exceed validation against process order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-13 14:54:11 +05:30
dhanabalan
5aa2e7a871 Updated type from SFG to NON-FG on Livewire page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-03-13 08:50:50 +05:30
dhanabalan
97fb46883f Updated process order value validation on import
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-12 12:58:14 +05:30
dhanabalan
e20892cc83 Refactored alignments on resource page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-11 19:36:48 +05:30
dhanabalan
658db00ac8 Refactored alignments and updated type from SFG to NON-FG on resource / importer / exporter pages
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-03-11 19:29:31 +05:30
25 changed files with 2262 additions and 891 deletions

View File

@@ -36,6 +36,8 @@ class ProcessOrderExporter extends Exporter
->label('COIL NUMBER'), ->label('COIL NUMBER'),
ExportColumn::make('order_quantity') ExportColumn::make('order_quantity')
->label('ORDER QUANTITY'), ->label('ORDER QUANTITY'),
ExportColumn::make('updated_order_quantity')
->label('UPDATED ORDER QUANTITY'),
ExportColumn::make('received_quantity') ExportColumn::make('received_quantity')
->label('RECEIVED QUANTITY'), ->label('RECEIVED QUANTITY'),
ExportColumn::make('sfg_number') ExportColumn::make('sfg_number')

View File

@@ -14,6 +14,7 @@ class StockDataMasterExporter extends Exporter
public static function getColumns(): array public static function getColumns(): array
{ {
static $rowNumber = 0; static $rowNumber = 0;
return [ return [
ExportColumn::make('no') ExportColumn::make('no')
->label('NO') ->label('NO')
@@ -29,7 +30,7 @@ class StockDataMasterExporter extends Exporter
->label('TYPE') ->label('TYPE')
->formatStateUsing(fn ($state) => match ($state) { ->formatStateUsing(fn ($state) => match ($state) {
'0' => 'FG', '0' => 'FG',
'1' => 'SFG', '1' => 'NON-FG',
default => '-', default => '-',
}), }),
ExportColumn::make('location') ExportColumn::make('location')
@@ -131,10 +132,10 @@ class StockDataMasterExporter extends Exporter
public static function getCompletedNotificationBody(Export $export): string public static function getCompletedNotificationBody(Export $export): string
{ {
$body = 'Your stock data master export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.'; $body = 'Your stock data master export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) { if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.'; $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
} }
return $body; return $body;

View File

@@ -52,6 +52,9 @@ class ProcessOrderImporter extends Importer
->example('1000') ->example('1000')
->label('ORDER QUANTITY') ->label('ORDER QUANTITY')
->rules(['required']), ->rules(['required']),
ImportColumn::make('updated_order_quantity')
->exampleHeader('UPDATED ORDER QUANTITY')
->label('UPDATED ORDER QUANTITY'),
ImportColumn::make('coil_number') ImportColumn::make('coil_number')
->exampleHeader('COIL NUMBER') ->exampleHeader('COIL NUMBER')
// ->example('01') // ->example('01')
@@ -110,6 +113,7 @@ class ProcessOrderImporter extends Importer
$sfgNo = trim($this->data['sfg_number'] ?? ''); $sfgNo = trim($this->data['sfg_number'] ?? '');
$machineName = trim($this->data['machine_name'] ?? ''); $machineName = trim($this->data['machine_name'] ?? '');
$orderQuan = trim($this->data['order_quantity'] ?? ''); $orderQuan = trim($this->data['order_quantity'] ?? '');
$updatedOrderQuan = trim($this->data['updated_order_quantity'] ?? '');
$scrapQuan = trim($this->data['scrap_quantity'] ?? ''); $scrapQuan = trim($this->data['scrap_quantity'] ?? '');
$reworkStatus = trim($this->data['rework_status'] ?? ''); $reworkStatus = trim($this->data['rework_status'] ?? '');
$recQuan = trim($this->data['received_quantity'] ?? ''); $recQuan = trim($this->data['received_quantity'] ?? '');
@@ -128,11 +132,14 @@ class ProcessOrderImporter extends Importer
if ($iCode == null || $iCode == '') { if ($iCode == null || $iCode == '') {
$warnMsg[] = "Item code can't be empty!"; $warnMsg[] = "Item code can't be empty!";
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) { } elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
$warnMsg[] = 'Invalid item code found'; $warnMsg[] = 'Invalid item code found!';
}
if ($machineName != null && $machineName != '' && Str::length($machineName) > 18) {
$warnMsg[] = 'Invalid machine name found!';
} }
if ($processOrder == null || $processOrder == '') { if ($processOrder == null || $processOrder == '') {
$warnMsg[] = "Process order can't be empty!"; $warnMsg[] = "Process order can't be empty!";
} elseif ($processOrder && Str::contains($processOrder, '.')) { } elseif ($processOrder && (Str::contains($processOrder, '.') || Str::contains($processOrder, 'E', ignoreCase: true))) {
$warnMsg[] = 'Invalid process order found!'; $warnMsg[] = 'Invalid process order found!';
} }
if ($lineNam == null || $lineNam == '') { if ($lineNam == null || $lineNam == '') {
@@ -145,6 +152,12 @@ class ProcessOrderImporter extends Importer
} elseif (Str::length($orderQuan) >= 1 && ! is_numeric($orderQuan)) { } elseif (Str::length($orderQuan) >= 1 && ! is_numeric($orderQuan)) {
$warnMsg[] = 'Invalid order quantity found!'; $warnMsg[] = 'Invalid order quantity found!';
} }
if ($updatedOrderQuan == null || $updatedOrderQuan == '' || $updatedOrderQuan == 0 || $updatedOrderQuan == '0') {
$updatedOrderQuan = $orderQuan;
} elseif (Str::length($updatedOrderQuan) >= 1 && ! is_numeric($updatedOrderQuan)) {
$warnMsg[] = 'Invalid Updated order quantity found!';
}
if ($coilNo == null || $coilNo == '') { if ($coilNo == null || $coilNo == '') {
$coilNo = '0'; $coilNo = '0';
} }
@@ -159,7 +172,7 @@ class ProcessOrderImporter extends Importer
} elseif ($reworkStatus == 1 || $reworkStatus = '1') { } elseif ($reworkStatus == 1 || $reworkStatus = '1') {
$reworkStatus = 1; $reworkStatus = 1;
} else { } else {
$warnMsg[] = 'Invalid rework status found'; $warnMsg[] = 'Invalid rework status found!';
} }
if (! empty($warnMsg)) { if (! empty($warnMsg)) {
@@ -223,7 +236,7 @@ class ProcessOrderImporter extends Importer
->first(); ->first();
if ($existingOrder && $existingOrder->item_id !== ($itemId ?? null)) { if ($existingOrder && $existingOrder->item_id !== ($itemId ?? null)) {
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code'; $warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code!';
} }
} }
@@ -243,6 +256,39 @@ class ProcessOrderImporter extends Importer
throw new RowImportFailedException(implode(', ', $warnMsg)); throw new RowImportFailedException(implode(', ', $warnMsg));
} }
$existing = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
// ->where('coil_number', $coilNo)
->first();
$receivedQty = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->sum('received_quantity');
if ($existing) {
$liveOrdQuan = (float) $existing->order_quantity;
$liveUpdatedOrdQuan = (float) $existing->updated_order_quantity;
$allowedIncrease = $liveOrdQuan * 0.10;
$maxAllowedQty = $liveOrdQuan + $allowedIncrease;
$minAllowedQty = $liveOrdQuan - $allowedIncrease;
if ($liveUpdatedOrdQuan > $maxAllowedQty) {
throw new RowImportFailedException(
"Updated order quantity cannot exceed 10% of existing order quantity. Max allowed: {$maxAllowedQty}!"
);
} elseif ($liveUpdatedOrdQuan < $minAllowedQty) {
throw new RowImportFailedException(
"Updated order quantity cannot decrease -10% of existing order quantity. Min allowed: {$minAllowedQty}!"
);
} elseif ($liveUpdatedOrdQuan < $receivedQty) {
throw new RowImportFailedException(
"Updated order quantity cannot decrease below its received quantity {$receivedQty}!"
);
}
}
if ($coilNo != null && $coilNo != '' && $scrapQuan && $reworkStatus && $recQuan && $createdAt && $createdBy && $updatedAt && $updatedBy && Filament::auth()->user()->hasRole('Super Admin')) { if ($coilNo != null && $coilNo != '' && $scrapQuan && $reworkStatus && $recQuan && $createdAt && $createdBy && $updatedAt && $updatedBy && Filament::auth()->user()->hasRole('Super Admin')) {
$existingCoil = ProcessOrder::where('plant_id', $plantId) $existingCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder) ->where('process_order', $processOrder)
@@ -250,6 +296,17 @@ class ProcessOrderImporter extends Importer
->where('coil_number', $coilNo) ->where('coil_number', $coilNo)
->first(); ->first();
// $existingProcess = ProcessOrder::where('plant_id', $plantId)
// ->where('process_order', $processOrder)
// ->where('line_id', $lineId)
// ->first();
if ($existing) {
$existUpdateOrdQuan = $existing->updated_order_quantity;
} else {
$existUpdateOrdQuan = $updatedOrderQuan;
}
if (! $existingCoil) { if (! $existingCoil) {
ProcessOrder::Create( ProcessOrder::Create(
[ [
@@ -259,6 +316,7 @@ class ProcessOrderImporter extends Importer
'item_id' => $itemId, 'item_id' => $itemId,
'coil_number' => $coilNo, 'coil_number' => $coilNo,
'order_quantity' => $orderQuan, 'order_quantity' => $orderQuan,
'updated_order_quantity' => $existUpdateOrdQuan,
'received_quantity' => $recQuan, 'received_quantity' => $recQuan,
'scrap_quantity' => $scrapQuan, 'scrap_quantity' => $scrapQuan,
'sfg_number' => $sfgNo, 'sfg_number' => $sfgNo,
@@ -288,10 +346,16 @@ class ProcessOrderImporter extends Importer
} }
} else { } else {
$coilNo = '0'; $coilNo = '0';
$existing = ProcessOrder::where('plant_id', $plantId) // $existing = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder) // ->where('process_order', $processOrder)
// ->where('coil_number', $coilNo) // // ->where('coil_number', $coilNo)
->first(); // ->first();
if ($existing) {
$existUpdateOrdQuan = $existing->updated_order_quantity;
} else {
$existUpdateOrdQuan = $updatedOrderQuan;
}
if (! $existing && ($coilNo == '0' || $coilNo == 0)) { if (! $existing && ($coilNo == '0' || $coilNo == 0)) {
ProcessOrder::create([ ProcessOrder::create([
@@ -301,6 +365,7 @@ class ProcessOrderImporter extends Importer
'process_order' => $processOrder, 'process_order' => $processOrder,
'coil_number' => '0', 'coil_number' => '0',
'order_quantity' => $orderQuan, 'order_quantity' => $orderQuan,
'updated_order_quantity' => $existUpdateOrdQuan,
'received_quantity' => 0, 'received_quantity' => 0,
'scrap_quantity' => 0, 'scrap_quantity' => 0,
'created_by' => $createdBy, 'created_by' => $createdBy,
@@ -315,6 +380,7 @@ class ProcessOrderImporter extends Importer
'process_order' => $processOrder, 'process_order' => $processOrder,
'coil_number' => $coilNo, 'coil_number' => $coilNo,
'order_quantity' => $orderQuan, 'order_quantity' => $orderQuan,
'updated_order_quantity' => $existUpdateOrdQuan,
'received_quantity' => $recQuan, 'received_quantity' => $recQuan,
'scrap_quantity' => $scrapQuan ?? 0, 'scrap_quantity' => $scrapQuan ?? 0,
'sfg_number' => $sfgNo, 'sfg_number' => $sfgNo,

View File

@@ -6,12 +6,12 @@ use App\Models\Item;
use App\Models\Plant; use App\Models\Plant;
use App\Models\StickerMaster; use App\Models\StickerMaster;
use App\Models\StockDataMaster; use App\Models\StockDataMaster;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn; use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer; use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import; use Filament\Actions\Imports\Models\Import;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Str; use Str;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
class StockDataMasterImporter extends Importer class StockDataMasterImporter extends Importer
{ {
@@ -23,46 +23,46 @@ class StockDataMasterImporter extends Importer
ImportColumn::make('plant') ImportColumn::make('plant')
->requiredMapping() ->requiredMapping()
->exampleHeader('PLANT CODE') ->exampleHeader('PLANT CODE')
->example('1000') ->examples(['1000', '1000'])
->label('PLANT CODE') ->label('PLANT CODE')
->relationship(resolveUsing: 'code') ->relationship(resolveUsing: 'code')
->rules(['required']), ->rules(['required']),
ImportColumn::make('type') ImportColumn::make('type')
->requiredMapping() ->requiredMapping()
->exampleHeader('TYPE') ->exampleHeader('TYPE')
->example('FG/SFG') ->examples(['FG', 'NON-FG'])
->label('TYPE'), ->label('TYPE'),
ImportColumn::make('location') ImportColumn::make('location')
->requiredMapping() ->requiredMapping()
->exampleHeader('LOCATION') ->exampleHeader('LOCATION')
->example('2001') ->examples(['2001', '2002'])
->label('LOCATION') ->label('LOCATION')
->rules(['required']), ->rules(['required']),
ImportColumn::make('item_reference')// stickerMaster ImportColumn::make('item_reference')
->requiredMapping() ->requiredMapping()
->exampleHeader('ITEM CODE') ->exampleHeader('ITEM CODE')
->example('123456') ->examples(['123456', '246118'])
->label('ITEM CODE') ->label('ITEM CODE')
->rules(['required']), ->rules(['required']),
ImportColumn::make('serial_number') ImportColumn::make('serial_number')
->requiredMapping() ->requiredMapping()
->exampleHeader('SERIAL NUMBER') ->exampleHeader('SERIAL NUMBER')
->example('200235236622') ->examples(['200235236622', '200235236623'])
->label('SERIAL NUMBER'), ->label('SERIAL NUMBER'),
ImportColumn::make('batch') ImportColumn::make('batch')
->requiredMapping() ->requiredMapping()
->exampleHeader('BATCH') ->exampleHeader('BATCH')
->example('20102') ->examples(['20102', '20103'])
->label('BATCH'), ->label('BATCH'),
ImportColumn::make('quantity') ImportColumn::make('quantity')
->requiredMapping() ->requiredMapping()
->exampleHeader('QUANTITY') ->exampleHeader('QUANTITY')
->example('1') ->examples(['1', '1'])
->label('QUANTITY'), ->label('QUANTITY'),
ImportColumn::make('doc_no') ImportColumn::make('doc_no')
->requiredMapping() ->requiredMapping()
->exampleHeader('DOCUMENT NUMBER') ->exampleHeader('DOCUMENT NUMBER')
->example('156566') ->examples(['82128', '21222'])
->label('DOCUMENT NUMBER'), ->label('DOCUMENT NUMBER'),
]; ];
} }
@@ -86,26 +86,21 @@ class StockDataMasterImporter extends Importer
$operatorName = $user->name; $operatorName = $user->name;
if ($plantCod == null || $plantCod == '') { if ($plantCod == null || $plantCod == '') {
$warnMsg[] = "Plant code can't be empty!"; $warnMsg[] = "Plant code can't be empty!";
} } elseif ($typeValue == null || $typeValue == '') {
else if ($typeValue == null || $typeValue == '') {
$warnMsg[] = "Type can't be empty!"; $warnMsg[] = "Type can't be empty!";
} } elseif ($iCode == null || $iCode == '') {
else if ($iCode == null || $iCode == '') {
$warnMsg[] = "Item code can't be empty!"; $warnMsg[] = "Item code can't be empty!";
} } elseif ($location == null || $location == '') {
else if ($location == null || $location == '') {
$warnMsg[] = "Location can't be empty!"; $warnMsg[] = "Location can't be empty!";
} } elseif ($serialNumber == null || $serialNumber == '') {
else if ($serialNumber == null || $serialNumber == '') {
$warnMsg[] = "Serial number can't be empty!"; $warnMsg[] = "Serial number can't be empty!";
} }
// else if ($batch == null || $batch == '') { // else if ($batch == null || $batch == '') {
// $warnMsg[] = "Batch can't be empty!"; // $warnMsg[] = "Batch can't be empty!";
// } // }
else if ($quantity == null || $quantity == '') { elseif ($quantity == null || $quantity == '') {
$warnMsg[] = "Quantity can't be empty!"; $warnMsg[] = "Quantity can't be empty!";
} }
// else if ($docNo == null || $docNo == '') { // else if ($docNo == null || $docNo == '') {
@@ -152,33 +147,27 @@ class StockDataMasterImporter extends Importer
$typeValue = strtoupper($typeValue); $typeValue = strtoupper($typeValue);
if (! in_array($typeValue, ['FG', 'SFG'])) { if (! in_array($typeValue, ['FG', 'NON-FG'])) {
$warnMsg[] = 'Invalid type found! It should be either FG or SFG and fg/sfg.'; $warnMsg[] = 'Invalid type found! It should be either FG or NON-FG.';
} } elseif (Str::length($location) < 4) {
else if (Str::length($location) < 4) {
$warnMsg[] = 'Location should contain minimum 4 digits!'; $warnMsg[] = 'Location should contain minimum 4 digits!';
} } elseif (! ctype_digit((string) $location)) {
else if (! ctype_digit((string) $location)) {
$warnMsg[] = 'Location must be an integer!'; $warnMsg[] = 'Location must be an integer!';
} } elseif (Str::length($serialNumber) < 9) {
else if (Str::length($serialNumber) < 9) {
$warnMsg[] = 'Serial number should contain minimum 9 digits!'; $warnMsg[] = 'Serial number should contain minimum 9 digits!';
} } elseif (! ctype_alnum($serialNumber)) {
else if (!ctype_alnum($serialNumber)) {
$warnMsg[] = 'Serial number should contain alpha-numeric values!'; $warnMsg[] = 'Serial number should contain alpha-numeric values!';
} } elseif (! ctype_digit((string) $quantity) || (int) $quantity <= 0) {
else if (! ctype_digit((string) $quantity) || (int) $quantity <= 0) {
$warnMsg[] = 'Quantity must be an integer and greater than 0!'; $warnMsg[] = 'Quantity must be an integer and greater than 0!';
} }
if($batch){ if ($batch) {
if (Str::length($batch) < 5) { if (Str::length($batch) < 5) {
$warnMsg[] = 'Batch should contain minimum 5 digits!'; $warnMsg[] = 'Batch should contain minimum 5 digits!';
} }
} }
if($docNo){ if ($docNo) {
if (Str::length($docNo) < 5) { if (Str::length($docNo) < 5) {
$warnMsg[] = 'Document number contain minimum 5 digits!'; $warnMsg[] = 'Document number contain minimum 5 digits!';
} }
@@ -190,7 +179,7 @@ class StockDataMasterImporter extends Importer
$type = match ($typeValue) { $type = match ($typeValue) {
'FG' => '0', 'FG' => '0',
'SFG' => '1', 'NON-FG' => '1',
default => null, default => null,
}; };
@@ -199,7 +188,7 @@ class StockDataMasterImporter extends Importer
$record = StockDataMaster::where([ $record = StockDataMaster::where([
'plant_id' => $plantId, 'plant_id' => $plantId,
'sticker_master_id' => $stickId, 'sticker_master_id' => $stickId,
'serial_number' => $serialNumber 'serial_number' => $serialNumber,
])->first(); ])->first();
if ($record) { if ($record) {
@@ -234,10 +223,10 @@ class StockDataMasterImporter extends Importer
public static function getCompletedNotificationBody(Import $import): string public static function getCompletedNotificationBody(Import $import): string
{ {
$body = 'Your stock data master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.'; $body = 'Your stock data master import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) { if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.'; $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
} }
return $body; return $body;

View File

@@ -2,25 +2,22 @@
namespace App\Filament\Pages; namespace App\Filament\Pages;
use App\Models\CustomerPoMaster;
use App\Models\InvoiceValidation; use App\Models\InvoiceValidation;
use App\Models\Item; use App\Models\Item;
use App\Models\NotInStock; use App\Models\NotInStock;
use App\Models\Plant; use App\Models\Plant;
use App\Models\StickerMaster; use App\Models\StickerMaster;
use App\Models\StockDataMaster; use App\Models\StockDataMaster;
use App\Models\WireMasterPacking; use Filament\Actions\Action;
use Carbon\Carbon; use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Facades\Filament; 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\Section;
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Filament\Actions\Action; use Filament\Pages\Page;
use Filament\Actions\Concerns\InteractsWithActions;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
class CycleCount extends Page class CycleCount extends Page
@@ -28,28 +25,40 @@ class CycleCount extends Page
protected static ?string $navigationIcon = 'heroicon-o-document-text'; protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.cycle-count'; protected static string $view = 'filament.pages.cycle-count';
protected static ?string $navigationGroup = 'Cycle Count Software'; protected static ?string $navigationGroup = 'Cycle Count Software';
use InteractsWithForms;
use InteractsWithActions; use InteractsWithActions;
use InteractsWithForms;
public $serialNumber; public $serialNumber;
public $location, $bin; public $location;
public $bin;
public $snoCount = 0; public $snoCount = 0;
public $state = []; 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 array $filters = [];
public function mount() public function mount()
{ {
$this->form->fill([ $this->form->fill([
'plant_id'=>$this->plantId, 'plant_id' => $this->plantId,
'pallet_quantity' => 0, 'pallet_quantity' => 0,
]); ]);
} }
@@ -66,6 +75,7 @@ class CycleCount extends Page
->reactive() ->reactive()
->options(function (callable $get) { ->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id; $userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray(); return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
}) })
->required(), ->required(),
@@ -95,7 +105,7 @@ class CycleCount extends Page
// ->reactive() // ->reactive()
// ->readOnly(), // ->readOnly(),
]) ])
->columns(4) ->columns(4),
]); ]);
} }
@@ -123,12 +133,11 @@ class CycleCount extends Page
// $pattern2 = '/^[^|]+\|[^|]+\|[^|]+\|?$/'; Optional Pipeline at end // $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() Notification::make()
->danger() ->danger()
->title('Invalid QR Format') ->title('Invalid QR Format')
->body('Scan the valid QR code to proceed either SFG or FG!') ->body('Scan the valid QR code to proceed either FG or Non-FG!')
->seconds(3) ->seconds(3)
->send(); ->send();
@@ -142,8 +151,7 @@ class CycleCount extends Page
return; return;
} }
if(preg_match($pattern1, $value)) if (preg_match($pattern1, $value)) {
{
$value = rtrim($value, '#'); $value = rtrim($value, '#');
$parts = explode('#', $value); $parts = explode('#', $value);
@@ -152,10 +160,9 @@ class CycleCount extends Page
$this->docNo = $parts[2] ?? null; $this->docNo = $parts[2] ?? null;
$this->quantity = $parts[3] ?? null; $this->quantity = $parts[3] ?? null;
if (strlen($this->itemCode) < 6) if (strlen($this->itemCode) < 6) {
{
Notification::make() Notification::make()
->title("Unknown Item Code") ->title('Unknown Item Code')
->body("Item Code should contain minimum 6 digits '$this->itemCode'") ->body("Item Code should contain minimum 6 digits '$this->itemCode'")
->danger() ->danger()
->send(); ->send();
@@ -165,11 +172,11 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} } elseif (! ctype_alnum($this->itemCode)) {
elseif(!ctype_alnum($this->itemCode)){
Notification::make() Notification::make()
->title("Unknown Item Code") ->title('Unknown Item Code')
->body("Item Code should contain alpha-numeric values '$this->itemCode'") ->body("Item Code should contain alpha-numeric values '$this->itemCode'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -180,13 +187,13 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, '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() Notification::make()
->title("Unknown Batch") ->title('Unknown Batch')
->body("Batch should contain minimum 5 digits '$this->batch'") ->body("Batch should contain minimum 5 digits '$this->batch'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -197,13 +204,13 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
} } elseif (strlen($this->docNo) < 5) {
elseif(strlen($this->docNo) < 5){
Notification::make() Notification::make()
->title("Unknown Doc No") ->title('Unknown Doc No')
->body("Doc No should contain minimum 5 digits '$this->docNo'") ->body("Doc No should contain minimum 5 digits '$this->docNo'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -214,11 +221,11 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} } elseif (! ctype_digit($this->quantity)) {
elseif (!ctype_digit($this->quantity)) {
Notification::make() Notification::make()
->title("Unknown Quantity") ->title('Unknown Quantity')
->body("Quantity must be an integer value '$this->quantity'") ->body("Quantity must be an integer value '$this->quantity'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -229,14 +236,15 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
$item = Item::where('code', $this->itemCode)->first(); $item = Item::where('code', $this->itemCode)->first();
if(!$item){ if (! $item) {
Notification::make() Notification::make()
->title("Item Code Not Found") ->title('Item Code Not Found')
->body("Item code not found '$this->itemCode'") ->body("Item code not found '$this->itemCode'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -247,6 +255,7 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
@@ -256,9 +265,9 @@ class CycleCount extends Page
$plantCode = $plantCo->code; $plantCode = $plantCo->code;
if(!$itemCodeAgaPlant){ if (! $itemCodeAgaPlant) {
Notification::make() Notification::make()
->title("Item Code Not Found") ->title('Item Code Not Found')
->body("Item code '$this->itemCode' not found against plant code '$plantCode'") ->body("Item code '$this->itemCode' not found against plant code '$plantCode'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -269,15 +278,16 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
$stickerExists = StickerMaster::where('item_id', $item->id)->first(); $stickerExists = StickerMaster::where('item_id', $item->id)->first();
if (!$stickerExists) { if (! $stickerExists) {
Notification::make() Notification::make()
->title("Unknown Sticker Master") ->title('Unknown Sticker Master')
->body("Item code not found in sticker master '{$this->itemCode}'") ->body("Item code not found in sticker master '{$this->itemCode}'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -297,10 +307,10 @@ class CycleCount extends Page
->where('item_id', $item->id) ->where('item_id', $item->id)
->first(); ->first();
if (!$stickerExists) { if (! $stickerExists) {
Notification::make() Notification::make()
->title("Unknown Sticker Master") ->title('Unknown Sticker Master')
->body("Item code not found in sticker master '{$this->itemCode}' in plant '{$plantCode}'") ->body("Item code not found in sticker master '{$this->itemCode}' in plant '{$plantCode}'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -322,7 +332,7 @@ class CycleCount extends Page
->where('location', $location) ->where('location', $location)
->first(); ->first();
if(!$locationExist){ if (! $locationExist) {
$existingInOtherLocation = NotInStock::where('plant_id', $plantId) $existingInOtherLocation = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo) ->where('serial_number', $this->sNo)
@@ -347,7 +357,7 @@ class CycleCount extends Page
Notification::make() Notification::make()
->title('Unknown Location') ->title('Unknown Location')
->body("Location '$location' not found for the type SFG.") ->body("Location '$location' not found for the type Non-FG.")
->danger() ->danger()
->persistent() ->persistent()
->actions([ ->actions([
@@ -361,8 +371,8 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]) ]),
]) ])
->send(); ->send();
@@ -372,6 +382,7 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
@@ -380,7 +391,7 @@ class CycleCount extends Page
->where('location', $location) ->where('location', $location)
->first(); ->first();
if(!$locationAgaPlant){ if (! $locationAgaPlant) {
$existingInOtherLocation = NotInStock::where('plant_id', $plantId) $existingInOtherLocation = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo) ->where('serial_number', $this->sNo)
@@ -405,7 +416,7 @@ class CycleCount extends Page
Notification::make() Notification::make()
->title('Unknown Location') ->title('Unknown Location')
->body("Location '$location' not found for the type SFG against plant code '$plantCode'.") ->body("Location '$location' not found for the type Non-FG against plant code '$plantCode'.")
->danger() ->danger()
->actions([ ->actions([
\Filament\Notifications\Actions\Action::make('confirm_update') \Filament\Notifications\Actions\Action::make('confirm_update')
@@ -418,8 +429,8 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]) ]),
]) ])
->send(); ->send();
@@ -439,7 +450,7 @@ class CycleCount extends Page
->where('sticker_master_id', $stickerMasterId) ->where('sticker_master_id', $stickerMasterId)
->first(); ->first();
if(!$locationItemAgaPlant){ if (! $locationItemAgaPlant) {
$existingInOtherLocation = NotInStock::where('plant_id', $plantId) $existingInOtherLocation = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo) ->where('serial_number', $this->sNo)
@@ -464,7 +475,7 @@ class CycleCount extends Page
Notification::make() Notification::make()
->title('Item Not Found in Location') ->title('Item Not Found in Location')
->body("Item Code '$this->itemCode' is not available in location '$location' (Type: SFG) for Plant Code '$plantCode'.") ->body("Item Code '$this->itemCode' is not available in location '$location' (Type: Non-FG) for Plant Code '$plantCode'.")
->danger() ->danger()
->actions([ ->actions([
\Filament\Notifications\Actions\Action::make('confirm_update') \Filament\Notifications\Actions\Action::make('confirm_update')
@@ -477,7 +488,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -530,7 +541,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -583,7 +594,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -611,11 +622,11 @@ class CycleCount extends Page
// $remainingStock = $stock->quantity - $currentScanned; // $remainingStock = $stock->quantity - $currentScanned;
if($stock->scanned_status == 'Scanned'){ if ($stock->scanned_status == 'Scanned') {
Notification::make() Notification::make()
->title('Duplicate Serial Number') ->title('Duplicate Serial Number')
->body("Serial number '$this->sNo' has already been scanned in stock data master for the type SFG against plant code '$plantCode'.<br>Do you want to update in duplicate stock table?") ->body("Serial number '$this->sNo' has already been scanned in stock data master for the type Non-FG against plant code '$plantCode'.<br>Do you want to update in duplicate stock table?")
->danger() ->danger()
->actions([ ->actions([
\Filament\Notifications\Actions\Action::make('confirm') \Filament\Notifications\Actions\Action::make('confirm')
@@ -629,7 +640,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -640,6 +651,7 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
@@ -666,13 +678,12 @@ class CycleCount extends Page
$stock->update([ $stock->update([
'bin' => $bin, 'bin' => $bin,
'batch' => $this->batch, 'batch' => $this->batch,
// 'doc_no' =>$this->docNo,
'scanned_quantity' => $newScannedQty, 'scanned_quantity' => $newScannedQty,
'scanned_status' => $status 'scanned_status' => $status,
]); ]);
$this->dispatch('refreshSfgData', location: $location, plantId: $plantId, itemCode: $this->itemCode, docNo: $this->docNo); $this->dispatch('refreshSfgData', location: $location, plantId: $plantId, itemCode: $this->itemCode, docNo: $this->docNo);
} } else {
else
{
Notification::make() Notification::make()
->title('Unknown : Data Found') ->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.") ->body("No matching record found for the given Location, Item Code, Batch, and Document Number under Plant Code '$plantCode' in stock data master.")
@@ -688,7 +699,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -705,9 +716,7 @@ class CycleCount extends Page
return; return;
} }
} } elseif (preg_match($pattern2, $value)) {
else if(preg_match($pattern2, $value))
{
$value = rtrim($value, '|'); $value = rtrim($value, '|');
$parts = explode('|', $value); $parts = explode('|', $value);
@@ -720,10 +729,9 @@ class CycleCount extends Page
$this->sNo = $parts[2]; $this->sNo = $parts[2];
} }
if (strlen($this->itemCode) < 6) if (strlen($this->itemCode) < 6) {
{
Notification::make() Notification::make()
->title("Unknown Item Code") ->title('Unknown Item Code')
->body("Item Code should contain minimum 6 digits '$this->itemCode'") ->body("Item Code should contain minimum 6 digits '$this->itemCode'")
->danger() ->danger()
->send(); ->send();
@@ -734,11 +742,11 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} } elseif (! ctype_alnum($this->itemCode)) {
elseif(!ctype_alnum($this->itemCode)){
Notification::make() Notification::make()
->title("Unknown Item Code") ->title('Unknown Item Code')
->body("Item Code should contain alpha-numeric values '$this->itemCode'") ->body("Item Code should contain alpha-numeric values '$this->itemCode'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -749,20 +757,20 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} } elseif (strlen($this->batch) < 5) {
elseif(strlen($this->batch) < 5){
Notification::make() Notification::make()
->title("Unknown Batch") ->title('Unknown Batch')
->body("Batch should contain minimum 5 digits '$this->batch'") ->body("Batch should contain minimum 5 digits '$this->batch'")
->danger() ->danger()
->duration(5000) ->duration(5000)
->send(); ->send();
return; return;
} } elseif (strlen($this->sNo) < 9) {
elseif(strlen($this->sNo) < 9){
Notification::make() Notification::make()
->title("Unknown Serial Number") ->title('Unknown Serial Number')
->body("Serial Number should contain minimum 9 digits '$this->sNo'") ->body("Serial Number should contain minimum 9 digits '$this->sNo'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -773,11 +781,11 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} } elseif (! ctype_alnum($this->sNo)) {
elseif(!ctype_alnum($this->sNo)){
Notification::make() Notification::make()
->title("Unknown Serial Number") ->title('Unknown Serial Number')
->body("Serial Number should contain alpha-numeric values '$this->sNo'") ->body("Serial Number should contain alpha-numeric values '$this->sNo'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -788,14 +796,15 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
$item = Item::where('code', $this->itemCode)->first(); $item = Item::where('code', $this->itemCode)->first();
if(!$item){ if (! $item) {
Notification::make() Notification::make()
->title("Item Code Not Found") ->title('Item Code Not Found')
->body("Item code not found '$this->itemCode'") ->body("Item code not found '$this->itemCode'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -806,6 +815,7 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
@@ -815,9 +825,9 @@ class CycleCount extends Page
$plantCode = $plantCo->code; $plantCode = $plantCo->code;
if(!$itemCodeAgaPlant){ if (! $itemCodeAgaPlant) {
Notification::make() Notification::make()
->title("Item Code Not Found") ->title('Item Code Not Found')
->body("Item code '$this->itemCode' not found against plant code '$plantCode'") ->body("Item code '$this->itemCode' not found against plant code '$plantCode'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -828,15 +838,16 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
$stickerExists = StickerMaster::where('item_id', $item->id)->first(); $stickerExists = StickerMaster::where('item_id', $item->id)->first();
if (!$stickerExists) { if (! $stickerExists) {
Notification::make() Notification::make()
->title("Unknown Sticker Master") ->title('Unknown Sticker Master')
->body("Item code not found in sticker master '{$this->itemCode}'") ->body("Item code not found in sticker master '{$this->itemCode}'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -856,9 +867,9 @@ class CycleCount extends Page
->where('item_id', $item->id) ->where('item_id', $item->id)
->first(); ->first();
if (!$stickerExists) { if (! $stickerExists) {
Notification::make() Notification::make()
->title("Unknown Sticker Master") ->title('Unknown Sticker Master')
->body("Item code not found in sticker master '{$this->itemCode}' in plant '{$plantCode}'") ->body("Item code not found in sticker master '{$this->itemCode}' in plant '{$plantCode}'")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -869,6 +880,7 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
@@ -878,7 +890,7 @@ class CycleCount extends Page
->where('type', '1') ->where('type', '1')
->first(); ->first();
if(!$locationExist){ if (! $locationExist) {
$existingInOtherLocation = NotInStock::where('plant_id', $plantId) $existingInOtherLocation = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo) ->where('serial_number', $this->sNo)
@@ -903,7 +915,7 @@ class CycleCount extends Page
Notification::make() Notification::make()
->title('Unknown Location') ->title('Unknown Location')
->body("location '$location' not found in stock data master for the type SFG.<br>Do you want to update in not in stock table?") ->body("location '$location' not found in stock data master for the type Non-FG.<br>Do you want to update in not in stock table?")
->danger() ->danger()
->actions([ ->actions([
\Filament\Notifications\Actions\Action::make('confirm') \Filament\Notifications\Actions\Action::make('confirm')
@@ -917,7 +929,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -937,7 +949,7 @@ class CycleCount extends Page
->where('type', '1') ->where('type', '1')
->first(); ->first();
if(!$locationAgaPlant){ if (! $locationAgaPlant) {
$existingInOtherLocation = NotInStock::where('plant_id', $plantId) $existingInOtherLocation = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo) ->where('serial_number', $this->sNo)
@@ -962,7 +974,7 @@ class CycleCount extends Page
Notification::make() Notification::make()
->title('Unknown Location') ->title('Unknown Location')
->body("location '$location' not found in stock data master for the type SFG against plant code '$plantCode'.<br>Do you want to update in not in stock table?") ->body("location '$location' not found in stock data master for the type Non-FG against plant code '$plantCode'.<br>Do you want to update in not in stock table?")
->danger() ->danger()
->actions([ ->actions([
\Filament\Notifications\Actions\Action::make('confirm') \Filament\Notifications\Actions\Action::make('confirm')
@@ -976,7 +988,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -991,7 +1003,7 @@ class CycleCount extends Page
return; return;
} }
if($bin == '' || $bin == null){ if ($bin == '' || $bin == null) {
Notification::make() Notification::make()
->title('Unknown Bin') ->title('Unknown Bin')
->body("Bin can't be empty!") ->body("Bin can't be empty!")
@@ -1010,7 +1022,7 @@ class CycleCount extends Page
$serialExist = StockDataMaster::where('serial_number', $this->sNo)->where('type', '1')->first(); $serialExist = StockDataMaster::where('serial_number', $this->sNo)->where('type', '1')->first();
if(!$serialExist){ if (! $serialExist) {
$existingInOtherLocation = NotInStock::where('plant_id', $plantId) $existingInOtherLocation = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo) ->where('serial_number', $this->sNo)
@@ -1035,7 +1047,7 @@ class CycleCount extends Page
Notification::make() Notification::make()
->title('Unknown Serial Number') ->title('Unknown Serial Number')
->body('Scanned serial number not found in stock data master for the type SFG.<br>Do you want to update in not in stock table?') ->body('Scanned serial number not found in stock data master for the type Non-FG.<br>Do you want to update in not in stock table?')
->danger() ->danger()
->actions([ ->actions([
\Filament\Notifications\Actions\Action::make('confirm') \Filament\Notifications\Actions\Action::make('confirm')
@@ -1049,7 +1061,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -1066,7 +1078,7 @@ class CycleCount extends Page
$serialAgaPlant = StockDataMaster::where('plant_id', $plantId)->where('serial_number', $this->sNo)->where('type', '1')->first(); $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) $sNoExist = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo) ->where('serial_number', $this->sNo)
@@ -1091,7 +1103,7 @@ class CycleCount extends Page
Notification::make() Notification::make()
->title('Unknown Serial Number') ->title('Unknown Serial Number')
->body("Scanned serial number not found in stock data master for the type SFG against plant code '$plantCode'.<br>Do you want to update in not in stock table?") ->body("Scanned serial number not found in stock data master for the type Non-FG against plant code '$plantCode'.<br>Do you want to update in not in stock table?")
->danger() ->danger()
->actions([ ->actions([
\Filament\Notifications\Actions\Action::make('confirm_update') \Filament\Notifications\Actions\Action::make('confirm_update')
@@ -1105,7 +1117,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -1145,7 +1157,7 @@ class CycleCount extends Page
Notification::make() Notification::make()
->title('Invalid Location') ->title('Invalid Location')
->body("Serial number '$this->sNo' does not belong to location '$location' for the type SFG against plant code '$plantCode'.<br>Do you want to update in not in stock table?") ->body("Serial number '$this->sNo' does not belong to location '$location' for the type Non-FG against plant code '$plantCode'.<br>Do you want to update in not in stock table?")
->danger() ->danger()
->actions([ ->actions([
\Filament\Notifications\Actions\Action::make('confirm_update') \Filament\Notifications\Actions\Action::make('confirm_update')
@@ -1159,7 +1171,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -1199,7 +1211,7 @@ class CycleCount extends Page
Notification::make() Notification::make()
->title('Invalid Item Code') ->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'.<br>Do you want to update in not in stock table?") ->body("Serial number '$this->sNo' does not belong to item code '$this->itemCode' for the type Non-FG against plant code '$plantCode'.<br>Do you want to update in not in stock table?")
->danger() ->danger()
->actions([ ->actions([
\Filament\Notifications\Actions\Action::make('confirm_update') \Filament\Notifications\Actions\Action::make('confirm_update')
@@ -1213,7 +1225,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -1230,7 +1242,7 @@ class CycleCount extends Page
if ($serialAgaPlant->batch != '' || $serialAgaPlant->batch != null) { if ($serialAgaPlant->batch != '' || $serialAgaPlant->batch != null) {
if($serialAgaPlant->batch != $this->batch){ if ($serialAgaPlant->batch != $this->batch) {
$sNoExistLocation = NotInStock::where('plant_id', $plantId) $sNoExistLocation = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo) ->where('serial_number', $this->sNo)
@@ -1255,7 +1267,7 @@ class CycleCount extends Page
Notification::make() Notification::make()
->title('Invalid Batch') ->title('Invalid Batch')
->body("Serial number '$this->sNo' does not belong to batch '$this->batch' for the type SFG against plant code '$plantCode'.<br>Do you want to update in not in stock table?") ->body("Serial number '$this->sNo' does not belong to batch '$this->batch' for the type Non-FG against plant code '$plantCode'.<br>Do you want to update in not in stock table?")
->danger() ->danger()
->actions([ ->actions([
\Filament\Notifications\Actions\Action::make('confirm_update') \Filament\Notifications\Actions\Action::make('confirm_update')
@@ -1269,7 +1281,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -1291,13 +1303,13 @@ class CycleCount extends Page
// Notification::make() // Notification::make()
// ->danger() // ->danger()
// ->title('Invalid Bin') // ->title('Invalid Bin')
// ->body("Serial number '$this->sNo' does not belong to bin '$bin' for the type SFG against plant code '$plantCode'.") // ->body("Serial number '$this->sNo' does not belong to bin '$bin' for the type Non-FG against plant code '$plantCode'.")
// ->seconds(3) // ->seconds(3)
// ->send(); // ->send();
// Notification::make() // Notification::make()
// ->title('Invalid Bin') // ->title('Invalid Bin')
// ->body("Serial number '$this->sNo' does not belong to bin '$bin' for the type SFG against plant code '$plantCode'.") // ->body("Serial number '$this->sNo' does not belong to bin '$bin' for the type Non-FG against plant code '$plantCode'.")
// ->danger() // ->danger()
// ->actions([ // ->actions([
// \Filament\Notifications\Actions\Action::make('confirm_update') // \Filament\Notifications\Actions\Action::make('confirm_update')
@@ -1326,18 +1338,17 @@ class CycleCount extends Page
// } // }
// } // }
$serial = StockDataMaster::where('plant_id', $plantId) $serial = StockDataMaster::where('plant_id', $plantId)
->where('serial_number', $this->sNo) ->where('serial_number', $this->sNo)
->where('location', $location) ->where('location', $location)
->where('type', '1') ->where('type', '1')
->first(); ->first();
if($serial->quantity == '' || $serial->quantity == null){ if ($serial->quantity == '' || $serial->quantity == null) {
Notification::make() Notification::make()
->warning() ->warning()
->title('Unknown Quantity') ->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.") ->body("Quantity is missing for serial number '$this->sNo' (Type: Non-FG) in Plant Code '$plantCode'. Please update it in Stock Data Master.")
->seconds(3) ->seconds(3)
->send(); ->send();
@@ -1349,12 +1360,11 @@ class CycleCount extends Page
]); ]);
return; return;
} } elseif ((int) $serial->quantity > 1) {
elseif ((int) $serial->quantity > 1) {
Notification::make() Notification::make()
->warning() ->warning()
->title('Invalid Quantity') ->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.") ->body("Quantity should be '1' against '$this->sNo' for the type Non-FG against plant code '$plantCode'!Please update quantity in stock data master.")
->seconds(3) ->seconds(3)
->send(); ->send();
@@ -1370,11 +1380,11 @@ class CycleCount extends Page
if ($serial) { if ($serial) {
if($serial->scanned_status == 'Scanned'){ if ($serial->scanned_status == 'Scanned') {
Notification::make() Notification::make()
->title('Duplicate Serial Number') ->title('Duplicate Serial Number')
->body("Serial number '$this->sNo' has already been scanned in stock data master for the type SFG against plant code '$plantCode'.<br>Do you want to update in duplicate stock table?") ->body("Serial number '$this->sNo' has already been scanned in stock data master for the type Non-FG against plant code '$plantCode'.<br>Do you want to update in duplicate stock table?")
->danger() ->danger()
->actions([ ->actions([
\Filament\Notifications\Actions\Action::make('confirm') \Filament\Notifications\Actions\Action::make('confirm')
@@ -1388,7 +1398,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -1399,6 +1409,7 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
@@ -1409,7 +1420,7 @@ class CycleCount extends Page
'scanned_status' => 'Scanned', 'scanned_status' => 'Scanned',
'scanned_quantity' => '1', 'scanned_quantity' => '1',
'updated_at' => now(), 'updated_at' => now(),
'updated_by' => $operatorName 'updated_by' => $operatorName,
]); ]);
$this->form->fill([ $this->form->fill([
@@ -1421,9 +1432,7 @@ class CycleCount extends Page
$this->dispatch('refreshSfgNonData', location: $location, plantId: $plantId, serialNumber: $this->sNo, itemCode: $this->itemCode); $this->dispatch('refreshSfgNonData', location: $location, plantId: $plantId, serialNumber: $this->sNo, itemCode: $this->itemCode);
} }
} } else {
else
{
$serNo = $value; $serNo = $value;
if (! preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPp])?\|?$/', $serNo, $matches)) { if (! preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPp])?\|?$/', $serNo, $matches)) {
@@ -1489,7 +1498,7 @@ class CycleCount extends Page
->where('code', $itemCode) ->where('code', $itemCode)
->first(); ->first();
if(!$item){ if (! $item) {
Notification::make() Notification::make()
->title('Invalid Item Code') ->title('Invalid Item Code')
->body("Item code '$this->itemCode' not found for the type FG against plant code '$plantCode'.") ->body("Item code '$this->itemCode' not found for the type FG against plant code '$plantCode'.")
@@ -1502,6 +1511,7 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
@@ -1511,7 +1521,7 @@ class CycleCount extends Page
->where('item_id', $itemId) ->where('item_id', $itemId)
->first(); ->first();
if(!$stickerMaster){ if (! $stickerMaster) {
Notification::make() Notification::make()
->title('Invalid Item Code') ->title('Invalid Item Code')
->body("Item code '$this->itemCode' not found in sticker master for the type FG against plant code '$plantCode'.") ->body("Item code '$this->itemCode' not found in sticker master for the type FG against plant code '$plantCode'.")
@@ -1524,6 +1534,7 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
@@ -1533,7 +1544,7 @@ class CycleCount extends Page
->where('type', '0') ->where('type', '0')
->first(); ->first();
if(!$locationExist){ if (! $locationExist) {
$existingInOtherLocation = NotInStock::where('plant_id', $plantId) $existingInOtherLocation = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo) ->where('serial_number', $this->sNo)
@@ -1564,7 +1575,7 @@ class CycleCount extends Page
\Filament\Notifications\Actions\Action::make('confirm') \Filament\Notifications\Actions\Action::make('confirm')
->label('Yes, Update') ->label('Yes, Update')
->button() ->button()
->dispatch('confirmSerialUpdate', [ ->dispatch('confirmSerialFGUpdate', [
'plantId' => $plantId, 'plantId' => $plantId,
'location' => $location, 'location' => $location,
'bin' => $bin, 'bin' => $bin,
@@ -1572,7 +1583,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -1592,7 +1603,7 @@ class CycleCount extends Page
->where('type', '0') ->where('type', '0')
->first(); ->first();
if(!$locationAgaPlant){ if (! $locationAgaPlant) {
$existingInOtherLocation = NotInStock::where('plant_id', $plantId) $existingInOtherLocation = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo) ->where('serial_number', $this->sNo)
@@ -1623,7 +1634,7 @@ class CycleCount extends Page
\Filament\Notifications\Actions\Action::make('confirm') \Filament\Notifications\Actions\Action::make('confirm')
->label('Yes, Update') ->label('Yes, Update')
->button() ->button()
->dispatch('confirmSerialUpdate', [ ->dispatch('confirmSerialFGUpdate', [
'plantId' => $plantId, 'plantId' => $plantId,
'location' => $location, 'location' => $location,
'bin' => $bin, 'bin' => $bin,
@@ -1631,7 +1642,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -1704,6 +1715,7 @@ class CycleCount extends Page
'bin' => $bin, 'bin' => $bin,
'qr_code' => null, 'qr_code' => null,
]); ]);
return; return;
} }
@@ -1765,7 +1777,7 @@ class CycleCount extends Page
return; return;
} }
if($record->scanned_status == 'Scanned'){ if ($record->scanned_status == 'Scanned') {
Notification::make() Notification::make()
->title('Duplicate Serial Number') ->title('Duplicate Serial Number')
@@ -1783,7 +1795,7 @@ class CycleCount extends Page
'stickerMasterId' => $stickerMasterId, 'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch, 'batch' => $this->batch,
'docNo' => $this->docNo, 'docNo' => $this->docNo,
'quantity' => $this->quantity 'quantity' => $this->quantity,
]), ]),
]) ])
->send(); ->send();
@@ -1839,8 +1851,7 @@ class CycleCount extends Page
$hasMotorQr = $record->stickerMasterRelation->pack_slip_motor ?? null; $hasMotorQr = $record->stickerMasterRelation->pack_slip_motor ?? null;
$hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null; $hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null;
$hasPumpSetQr = $record->stickerMasterRelation->pack_slip_pumpset ?? null; $hasPumpSetQr = $record->stickerMasterRelation->pack_slip_pumpset ?? null;
} } else {
else {
if (! $hasPumpSetQr && ! $hasPumpQr) { if (! $hasPumpSetQr && ! $hasPumpQr) {
$hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null; $hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null;
} }
@@ -2044,8 +2055,7 @@ class CycleCount extends Page
]); ]);
return; return;
} } elseif ($isMarkPs) {
elseif ($isMarkPs) {
if (! $hasPumpSetQr) { if (! $hasPumpSetQr) {
Notification::make() Notification::make()
->title('Unknown: Pump Set QR') ->title('Unknown: Pump Set QR')
@@ -2155,6 +2165,7 @@ class CycleCount extends Page
->title('Sticker Master Not Found') ->title('Sticker Master Not Found')
->danger() ->danger()
->send(); ->send();
return; return;
} }
$existingRecord = NotInStock::where('serial_number', $this->serialNumber) $existingRecord = NotInStock::where('serial_number', $this->serialNumber)
@@ -2174,6 +2185,7 @@ class CycleCount extends Page
->body("Serial number '{$this->serialNumber}' already exists with Item Code '{$existingItemCode}'.") ->body("Serial number '{$this->serialNumber}' already exists with Item Code '{$existingItemCode}'.")
->danger() ->danger()
->send(); ->send();
return; return;
} }
} }
@@ -2186,12 +2198,13 @@ class CycleCount extends Page
}) })
->first(); ->first();
if($record){ if ($record) {
Notification::make() Notification::make()
->title('Duplicate : Item Code') ->title('Duplicate : Item Code')
->body("Item Code '$itemCode' with Serial number '$this->serialNumber' already exist in not in stock table!") ->body("Item Code '$itemCode' with Serial number '$this->serialNumber' already exist in not in stock table!")
->danger() ->danger()
->send(); ->send();
return; return;
} }
@@ -2215,5 +2228,4 @@ class CycleCount extends Page
{ {
return Auth::check() && Auth::user()->can('view cycle count page'); return Auth::check() && Auth::user()->can('view cycle count page');
} }
} }

View File

@@ -2,6 +2,7 @@
namespace App\Filament\Pages; namespace App\Filament\Pages;
use App\Filament\Widgets\CumulativeChart; use App\Filament\Widgets\CumulativeChart;
use App\Filament\Widgets\ProductionQuantityStat;
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Forms\Form; use Filament\Forms\Form;
@@ -9,6 +10,8 @@ use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Filament\Tables\Filters\SelectFilter; use Filament\Tables\Filters\SelectFilter;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use App\Models\Plant; use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms\Components\DatePicker;
use Filament\Widgets\Widget; use Filament\Widgets\Widget;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@@ -16,57 +19,108 @@ class Dashboard extends \Filament\Pages\Dashboard
{ {
use HasFiltersForm; use HasFiltersForm;
protected static ?string $navigationGroup = 'Production DashBoard'; protected static ?string $navigationIcon = 'heroicon-s-gift';
public function mount(): void protected static string $view = 'filament.pages.dashboard';
{
session()->forget(['selected_plant']);
$this->filtersForm->fill([
'plant' => null
]);
}
public function filtersForm(Form $form): Form // public function mount(): void
{ // {
return $form // session()->forget(['selected_plant']);
->statePath('filters') // Store form state in 'filters' // session()->forget(['from_date']);
->schema([ // session()->forget(['to_date']);
Select::make('plant') // $this->filtersForm->fill([
->options(Plant::pluck('name', 'id')) // 'plant' => null,
->label('Select Plant') // 'from_date' => null,
->reactive() // 'to_date' => null,
->afterStateUpdated(function ($state) { // // 'success_status' => null
session(['selected_plant' => $state]); // fixed typo // ]);
//$this->dispatch('cumulativeChart'); // custom Livewire event // }
}),
]);
} // public function filtersForm(Form $form): Form
// {
// return $form
// ->statePath('filters') // Store form state in 'filters'
// ->schema([
// Select::make('plant')
// ->label('Select Plant')
// ->reactive()
// // ->options(Plant::pluck('name', 'id'))
// ->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();
// })
// ->afterStateUpdated(function ($state,callable $set) {
// session(['selected_plant' => $state]); // fixed typo
// //$this->dispatch('cumulativeChart'); // custom Livewire event
// // Reset success_status whenever plant changes
// $set('success_status', null);
// session()->forget('success_status');
// }),
// // Select::make('success_status')
// // ->label('Select Status')
// // ->options([
// // 'Ok' => 'Ok',
// // 'Not Ok' => 'Not Ok',
// // ])
// // ->reactive()
// // ->afterStateUpdated(function ($state) {
// // session(['success_status' => $state]);
// // }),
// DatePicker::make('created_from')
// ->label('Created From')
// ->reactive()
// ->afterStateUpdated(function ($state,callable $set) {
// session(['from_date' => $state]);
// }),
// DatePicker::make('created_to')
// ->label('Created To')
// ->reactive()
// ->afterStateUpdated(function ($state,callable $set) {
// session(['to_date' => $state]);
// }),
// ]);
// }
public static function getNavigationLabel(): string // public static function getNavigationLabel(): string
{ // {
return 'Production Line Count'; // return 'Production Line Count';
} // }
// public function getHeading(): string
// {
// return 'Production Line Count';
// }
// public function getWidgets(): array
// {
// $widgets = [];
// if (CumulativeChart::canView()) {
// $widgets[] = CumulativeChart::class;
// }
// return $widgets;
// }
// public static function canAccess(): bool
// {
// return Auth::check() && Auth::user()->can('view production line count dashboard');
// }
public function getHeading(): string public function getHeading(): string
{ {
return 'Production Line Count'; return '';
} }
public function getWidgets(): array public static function getNavigationLabel(): string
{ {
$widgets = []; return 'Welcome';
if (CumulativeChart::canView()) {
$widgets[] = CumulativeChart::class;
}
return $widgets;
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view production line count dashboard');
} }
} }

View File

@@ -1,23 +1,124 @@
<?php <?php
namespace App\Filament\Pages; namespace App\Filament\Pages;
use Filament\Pages\Page; use App\Filament\Widgets\CumulativeChart;
use App\Filament\Widgets\ProductionQuantityStat;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Filament\Tables\Filters\SelectFilter;
use Illuminate\Support\Facades\DB;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms\Components\DatePicker;
use Filament\Widgets\Widget;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Filament\Pages\Page;
use Filament\Forms\Concerns\InteractsWithForms;
class Welcome extends Page class Welcome extends Page
{ {
protected static ?string $navigationIcon = 'heroicon-s-gift'; // 'heroicon-o-document-text';
protected static string $view = 'filament.pages.welcome'; protected static string $view = 'filament.pages.welcome';
public function getHeading(): string protected static ?string $navigationIcon = 'heroicon-o-document-text';
use HasFiltersForm;
use InteractsWithForms;
protected static ?string $navigationGroup = 'Production DashBoard';
protected static ?string $slug = 'production-line-count';
public function mount(): void
{ {
return ''; session()->forget(['selected_plant']);
// session()->forget(['from_date']);
// session()->forget(['to_date']);
$this->filtersForm->fill([
'plant' => null,
// 'from_date' => null,
// 'to_date' => null,
// 'success_status' => null
]);
} }
// public static function canAccess(): bool public function filtersForm(Form $form): Form
{
return $form
->statePath('filters')
->schema([
Select::make('plant')
->label('Select Plant')
->reactive()
// ->options(Plant::pluck('name', 'id'))
->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();
})
->afterStateUpdated(function ($state,callable $set) {
session(['selected_plant' => $state]);
//$this->dispatch('cumulativeChart'); // custom Livewire event
// Reset success_status whenever plant changes
// $set('success_status', null);
// session()->forget('success_status');
}),
// Select::make('success_status')
// ->label('Select Status')
// ->options([
// 'Ok' => 'Ok',
// 'Not Ok' => 'Not Ok',
// ])
// ->reactive()
// ->afterStateUpdated(function ($state) {
// session(['success_status' => $state]);
// }),
// DatePicker::make('created_from')
// ->label('Created From')
// ->reactive()
// ->afterStateUpdated(function ($state,callable $set) {
// session(['from_date' => $state]);
// }),
// DatePicker::make('created_to')
// ->label('Created To')
// ->reactive()
// ->afterStateUpdated(function ($state,callable $set) {
// session(['to_date' => $state]);
// }),
]);
}
public static function getNavigationLabel(): string
{
return 'Production Line Count';
}
public function getHeading(): string
{
return 'Production Line Count';
}
// public function getWidgets(): array
// { // {
// return Auth::check() && Auth::user()->can('view welcome page'); // $widgets = [];
// if (CumulativeChart::canView()) {
// $widgets[] = CumulativeChart::class;
// } // }
// return $widgets;
// }
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view production line count dashboard');
}
} }

View File

@@ -3,7 +3,6 @@
namespace App\Filament\Resources; namespace App\Filament\Resources;
use App\Filament\Resources\DuplicateStockResource\Pages; use App\Filament\Resources\DuplicateStockResource\Pages;
use App\Filament\Resources\DuplicateStockResource\RelationManagers;
use App\Models\DuplicateStock; use App\Models\DuplicateStock;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Filament\Forms; use Filament\Forms;
@@ -97,7 +96,7 @@ class DuplicateStockResource extends Resource
->searchable() ->searchable()
->formatStateUsing(fn ($state) => match ($state) { ->formatStateUsing(fn ($state) => match ($state) {
'0' => 'FG', '0' => 'FG',
'1' => 'SFG', '1' => 'NON-FG',
default => '-', default => '-',
}) })
->sortable(), ->sortable(),

View File

@@ -2,8 +2,9 @@
namespace App\Filament\Resources; namespace App\Filament\Resources;
use App\Filament\Exports\NotInStockExporter;
use App\Filament\Imports\NotInStockImporter;
use App\Filament\Resources\NotInStockResource\Pages; use App\Filament\Resources\NotInStockResource\Pages;
use App\Filament\Resources\NotInStockResource\RelationManagers;
use App\Models\NotInStock; use App\Models\NotInStock;
use App\Models\StickerMaster; use App\Models\StickerMaster;
use Filament\Facades\Filament; use Filament\Facades\Filament;
@@ -14,6 +15,9 @@ use Filament\Tables;
use Filament\Tables\Table; use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope; use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
class NotInStockResource extends Resource class NotInStockResource extends Resource
{ {
@@ -38,7 +42,7 @@ class NotInStockResource extends Resource
->required() ->required()
->searchable() ->searchable()
->options(function ($get) { ->options(function ($get) {
if (!$get('plant_id')) { if (! $get('plant_id')) {
return []; return [];
} }
@@ -64,7 +68,7 @@ class NotInStockResource extends Resource
->label('Type') ->label('Type')
->options([ ->options([
'0' => 'FG', '0' => 'FG',
'1' => 'SFG', '1' => 'NON-FG',
]), ]),
Forms\Components\TextInput::make('motor_scanned_status') Forms\Components\TextInput::make('motor_scanned_status')
->label('Motor Scanned Status'), ->label('Motor Scanned Status'),
@@ -122,7 +126,7 @@ class NotInStockResource extends Resource
->searchable() ->searchable()
->formatStateUsing(fn ($state) => match ($state) { ->formatStateUsing(fn ($state) => match ($state) {
'0' => 'FG', '0' => 'FG',
'1' => 'SFG', '1' => 'NON-FG',
default => '-', default => '-',
}) })
->sortable(), ->sortable(),
@@ -233,6 +237,22 @@ class NotInStockResource extends Resource
Tables\Actions\ForceDeleteBulkAction::make(), Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(), Tables\Actions\RestoreBulkAction::make(),
]), ]),
])
->headerActions([
ImportAction::make()
->label('Import Not In Stock')
->color('warning')
->importer(NotInStockImporter::class)
->visible(function () {
return Filament::auth()->user()->can('view import not in stock');
}),
ExportAction::make()
->label('Export Not In Stock')
->color('warning')
->exporter(NotInStockExporter::class)
->visible(function () {
return Filament::auth()->user()->can('view export not in stock');
}),
]); ]);
} }
@@ -253,6 +273,7 @@ class NotInStockResource extends Resource
]; ];
} }
public static function getEloquentQuery(): Builder public static function getEloquentQuery(): Builder
{ {
return parent::getEloquentQuery() return parent::getEloquentQuery()

View File

@@ -74,6 +74,7 @@ class ProcessOrderResource extends Resource
$set('process_order', null); $set('process_order', null);
$set('coil_number', '0'); $set('coil_number', '0');
$set('order_quantity', '0'); $set('order_quantity', '0');
$set('updated_order_quantity', '0');
$set('received_quantity', '0'); $set('received_quantity', '0');
$set('scrap_quantity', '0'); $set('scrap_quantity', '0');
$set('sfg_number', null); $set('sfg_number', null);
@@ -113,6 +114,7 @@ class ProcessOrderResource extends Resource
$set('process_order', null); $set('process_order', null);
$set('coil_number', '0'); $set('coil_number', '0');
$set('order_quantity', '0'); $set('order_quantity', '0');
$set('updated_order_quantity', '0');
$set('received_quantity', '0'); $set('received_quantity', '0');
$set('scrap_quantity', '0'); $set('scrap_quantity', '0');
$set('sfg_number', null); $set('sfg_number', null);
@@ -141,6 +143,7 @@ class ProcessOrderResource extends Resource
$set('process_order', null); $set('process_order', null);
$set('coil_number', '0'); $set('coil_number', '0');
$set('order_quantity', '0'); $set('order_quantity', '0');
$set('updated_order_quantity', '0');
$set('received_quantity', '0'); $set('received_quantity', '0');
$set('scrap_quantity', '0'); $set('scrap_quantity', '0');
$set('sfg_number', null); $set('sfg_number', null);
@@ -217,6 +220,7 @@ class ProcessOrderResource extends Resource
$plantId = $get('plant_id'); $plantId = $get('plant_id');
$set('coil_number', '0'); $set('coil_number', '0');
$set('order_quantity', '0'); $set('order_quantity', '0');
$set('updated_order_quantity', '0');
$set('received_quantity', '0'); $set('received_quantity', '0');
$set('scrap_quantity', '0'); $set('scrap_quantity', '0');
$set('sfg_number', null); $set('sfg_number', null);
@@ -280,10 +284,10 @@ class ProcessOrderResource extends Resource
->required() ->required()
->reactive() ->reactive()
->numeric() ->numeric()
->readOnly(fn ($get) => ($get('process_order') == null)) ->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
->afterStateUpdated(function ($state, $set, callable $get, $livewire) { ->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
$plantId = $get('plant_id'); $plantId = $get('plant_id');
$processOrder = $get('process_order'); $processOrder = trim($get('process_order'));
// $coilNo = $get('coil_number'); // $coilNo = $get('coil_number');
if (! $plantId) { if (! $plantId) {
$set('poPlantError', 'Please select a plant first.'); $set('poPlantError', 'Please select a plant first.');
@@ -319,22 +323,37 @@ class ProcessOrderResource extends Resource
function (callable $get) { function (callable $get) {
return Rule::unique('process_orders', 'coil_number') return Rule::unique('process_orders', 'coil_number')
->where('plant_id', $get('plant_id')) ->where('plant_id', $get('plant_id'))
->where('process_order', $get('process_order')) ->where('process_order', trim($get('process_order')))
->ignore($get('id')); ->ignore($get('id'));
}, },
function (callable $get): Closure { function (callable $get): Closure {
return function (string $attribute, $value, Closure $fail) use ($get) { return function (string $attribute, $value, Closure $fail) use ($get) {
$rework = $get('rework_status'); $rework = $get('rework_status');
if ($value && Str::contains($value, '.') && $rework == 0) { $plantId = $get('plant_id');
$processOrder = trim($get('process_order'));
if ($value && Str::contains($value, '.')) {
if ($rework == 0) {
$fail("Rework status should be 'Yes' for rework coil number '{$value}'!"); $fail("Rework status should be 'Yes' for rework coil number '{$value}'!");
} }
} elseif ($value > 1) {
$prevCoilNo = (string) ($value - 1);
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('coil_number', $prevCoilNo)
->first();
if (! $existPrevCoil) {
$fail("Previous coil number '{$prevCoilNo}' not exist against plant and process order!");
}
}
}; };
}, },
]) ])
// ->rule(function (callable $get) { // ->rule(function (callable $get) {
// return Rule::unique('process_orders', 'coil_number') // return Rule::unique('process_orders', 'coil_number')
// ->where('plant_id', $get('plant_id')) // ->where('plant_id', $get('plant_id'))
// ->where('process_order', $get('process_order')) // ->where('process_order', trim($get('process_order')))
// ->ignore($get('id')); // ->ignore($get('id'));
// }) // })
->extraAttributes(fn ($get) => [ ->extraAttributes(fn ($get) => [
@@ -348,15 +367,17 @@ class ProcessOrderResource extends Resource
->required() ->required()
->reactive() ->reactive()
->numeric() ->numeric()
->readOnly(fn ($get) => ($get('process_order') == null)) ->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
->afterStateUpdated(function (callable $set, callable $get, ?string $state) { ->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$plantId = $get('plant_id'); $plantId = $get('plant_id');
$itemId = $get('item_id'); $itemId = $get('item_id');
$processOrder = trim($get('process_order')); $processOrder = trim($get('process_order'));
$set('received_quantity', '0'); $set('received_quantity', '0');
// $set('updated_order_quantity', $state);
$set('scrap_quantity', '0'); $set('scrap_quantity', '0');
if (! $plantId || ! $itemId || ! $processOrder) { if (! $plantId || ! $itemId || ! $processOrder) {
$set('order_quantity', '0'); $set('order_quantity', '0');
$set('updated_order_quantity', '0');
} }
$query = ProcessOrder::where('plant_id', $plantId) $query = ProcessOrder::where('plant_id', $plantId)
@@ -372,13 +393,175 @@ class ProcessOrderResource extends Resource
} }
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
Forms\Components\TextInput::make('updated_order_quantity')
->label('Updated Order Quantity')
->required()
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == '' || trim($get('order_quantity')) == '' || trim($get('order_quantity')) == null))
->reactive()
->rules([
function (callable $get): Closure {
return function (string $attribute, $value, Closure $fail) use ($get) {
$plantId = $get('plant_id');
$processOrder = trim($get('process_order'));
$receivedQty = $get('received_quantity');
$currentId = $get('id');
$orderQty = (float) $get('order_quantity');
$updatedQty = (float) $value;
$allowedVariance = $orderQty * 0.10;
$maxAllowed = $orderQty + $allowedVariance;
$minAllowed = $orderQty - $allowedVariance;
if ($updatedQty > $maxAllowed || $updatedQty < $minAllowed) {
$fail('Quantity can vary by ±10% of the order quantity.');
}
$otherReceivedQty = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->when($currentId, fn ($q) => $q->where('id', '!=', $currentId))
->sum('received_quantity');
$currentReceivedQty = (float) $get('received_quantity');
$totalReceivedQty = $otherReceivedQty + $currentReceivedQty;
if ($updatedQty < $totalReceivedQty) {
$fail("You cannot set quantity below received quantity ({$totalReceivedQty}).");
}
};
},
]),
Forms\Components\TextInput::make('received_quantity') Forms\Components\TextInput::make('received_quantity')
->label('Received Quantity') ->label('Received Quantity')
->default('0.000') ->default('0.000')
->required() ->required()
->reactive() ->reactive()
->numeric() ->numeric()
->readOnly(fn ($get) => ($get('process_order') == null)) ->maxValue(fn (Get $get) => $get('order_quantity') ?? PHP_INT_MAX)
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
->rule(function (callable $get) {
return function (string $attribute, $value, Closure $fail) use ($get) {
$rework = $get('rework_status');
$plantId = $get('plant_id');
$lineId = $get('line_id');
$itemId = $get('item_id');
$processOrder = trim($get('process_order'));
$coilNo = trim($get('coil_number'));
$orderExist = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('item_id', $itemId)->latest()->first();
if ($orderExist) {
// $orderQty = $orderExist->order_quantity ?? 0;
$orderQty = $orderExist->updated_order_quantity ?? 0;
$alreadyReceived = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('item_id', $itemId)
->sum('received_quantity');
$total = $alreadyReceived + $value;
if ($rework == 1) {
if ($coilNo && Str::contains($coilNo, '.')) {
$coilMain = explode('.', $coilNo)[0];
$existingCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineId)
->where('coil_number', $coilMain)
->first();
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('item_id', $itemId)
->where('coil_number', $coilNo)
->first();
if ($existPrevCoil && $existPrevCoil->received_quantity < $value) {
$fail('Rework received quantity should not exceed exist received quantity!');
return;
}
if ($existingCoil && $existingCoil->rework_status == 1 && $total > $orderQty) {
$fail("Rework received quantity should not exceed exist order quantity! Already Exist Total Received Qty = '{$alreadyReceived}'.");
}
} else {
if ($coilNo > 1) {
$prevCoilNo = (string) ($coilNo - 1);
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('coil_number', $prevCoilNo)
->first();
if (! $existPrevCoil) {
return;
}
}
$existingCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineId)
->where('coil_number', $coilNo)
->first();
if (! $existingCoil) {
return;
}
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('item_id', $itemId)
->where('coil_number', $coilNo)
->first();
if ($existPrevCoil && $existPrevCoil->received_quantity < $value) {
$fail('Rework received quantity should not exceed exist received quantity!');
return;
}
}
} else {
if ($coilNo && Str::contains($coilNo, '.')) {
return;
}
$existing = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('coil_number', $coilNo)
->first();
if ($existing) {
if ($existing->received_quantity < $value) {
$fail('Received quantity should not exceed exist received quantity!'); // Exist Received Qty = '{$existing->received_quantity}'.
}
return;
}
if ($coilNo > 1) {
$prevCoilNo = (string) ($coilNo - 1);
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('coil_number', $prevCoilNo)
->first();
if (! $existPrevCoil) {
return;
}
}
if ($total > $orderQty) {
$fail("Received quantity should not exceed exist order quantity! Already Exist Total Received Qty = '{$alreadyReceived}'.");
}
}
}
};
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) { ->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('scrap_quantity', '0'); $set('scrap_quantity', '0');
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
@@ -387,7 +570,7 @@ class ProcessOrderResource extends Resource
->label('Scrap Quantity') ->label('Scrap Quantity')
->default('0.000') ->default('0.000')
->required() ->required()
->readOnly(fn ($get) => ($get('rework_status') == 0 || $get('process_order') == null)) ->readOnly(fn ($get) => ($get('rework_status') == 0 || trim($get('process_order')) == null || trim($get('process_order')) == ''))
->reactive() ->reactive()
->numeric() ->numeric()
->afterStateUpdated(function (callable $set, callable $get, ?string $state) { ->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
@@ -414,7 +597,7 @@ class ProcessOrderResource extends Resource
Forms\Components\TextInput::make('sfg_number') Forms\Components\TextInput::make('sfg_number')
->label('SFG Number') ->label('SFG Number')
->reactive() ->reactive()
->readOnly(fn ($get) => ($get('process_order') == null)) ->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
->afterStateUpdated(function ($state, $set, callable $get, $livewire) { ->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
$plantId = $get('plant_id'); $plantId = $get('plant_id');
$sfgNo = $get('sfg_number'); $sfgNo = $get('sfg_number');
@@ -448,7 +631,8 @@ class ProcessOrderResource extends Resource
Forms\Components\TextInput::make('machine_name') Forms\Components\TextInput::make('machine_name')
->label('Machine Name') ->label('Machine Name')
->reactive() ->reactive()
->readOnly(fn ($get) => ($get('process_order') == null)) ->maxLength(18)
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
->afterStateUpdated(function (callable $set, callable $get, ?string $state) { ->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
@@ -576,7 +760,7 @@ class ProcessOrderResource extends Resource
} }
// Get the value of process_order field // Get the value of process_order field
$processOrder = $get('process_order'); $processOrder = trim($get('process_order'));
if ($batchId != $processOrder) { if ($batchId != $processOrder) {
Notification::make() Notification::make()
@@ -621,7 +805,7 @@ class ProcessOrderResource extends Resource
return Filament::auth()->user()->can('view process order packing slip'); return Filament::auth()->user()->can('view process order packing slip');
}) })
->action(function ($get, callable $set) { ->action(function ($get, callable $set) {
$equipmentNumber = $get('process_order'); $equipmentNumber = trim($get('process_order'));
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
if (! $equipmentNumber) { if (! $equipmentNumber) {
@@ -720,6 +904,11 @@ class ProcessOrderResource extends Resource
->alignCenter() ->alignCenter()
->searchable() ->searchable()
->sortable(), ->sortable(),
Tables\Columns\TextColumn::make('updated_order_quantity')
->label('Updated Order Quantity')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('received_quantity') Tables\Columns\TextColumn::make('received_quantity')
->label('Received Quantity') ->label('Received Quantity')
->alignCenter() ->alignCenter()
@@ -1064,7 +1253,7 @@ class ProcessOrderResource extends Resource
->options(function (callable $get) { ->options(function (callable $get) {
$plantId = $get('plant'); $plantId = $get('plant');
$itemId = $get('Item'); $itemId = $get('Item');
$processOrder = $get('process_order'); $processOrder = trim($get('process_order'));
if (empty($plantId) || empty($itemId) || empty($processOrder)) { if (empty($plantId) || empty($itemId) || empty($processOrder)) {
return []; return [];
@@ -1081,7 +1270,7 @@ class ProcessOrderResource extends Resource
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant'); $plantId = $get('plant');
$itemId = $get('Item'); $itemId = $get('Item');
$processOrder = $get('process_order'); $processOrder = trim($get('process_order'));
if (! $plantId || ! $itemId || ! $processOrder || ! $state) { if (! $plantId || ! $itemId || ! $processOrder || ! $state) {
$set('received_quantity', null); $set('received_quantity', null);

View File

@@ -3,10 +3,28 @@
namespace App\Filament\Resources\ProcessOrderResource\Pages; namespace App\Filament\Resources\ProcessOrderResource\Pages;
use App\Filament\Resources\ProcessOrderResource; use App\Filament\Resources\ProcessOrderResource;
use App\Models\ProcessOrder;
use Filament\Actions; use Filament\Actions;
use Filament\Facades\Filament;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\CreateRecord; use Filament\Resources\Pages\CreateRecord;
class CreateProcessOrder extends CreateRecord class CreateProcessOrder extends CreateRecord
{ {
protected static string $resource = ProcessOrderResource::class; protected static string $resource = ProcessOrderResource::class;
protected function afterCreate(): void
{
$plantId = $this->data['plant_id'];
$processOrder = $this->data['process_order'];
$updatedQty = (float) $this->data['updated_order_quantity'];
ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->update([
'updated_order_quantity' => $updatedQty,
'updated_by' => Filament::auth()->user()->name,
]);
}
} }

View File

@@ -3,13 +3,78 @@
namespace App\Filament\Resources\ProcessOrderResource\Pages; namespace App\Filament\Resources\ProcessOrderResource\Pages;
use App\Filament\Resources\ProcessOrderResource; use App\Filament\Resources\ProcessOrderResource;
use App\Models\ProcessOrder;
use Filament\Actions; use Filament\Actions;
use Filament\Facades\Filament;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord; use Filament\Resources\Pages\EditRecord;
class EditProcessOrder extends EditRecord class EditProcessOrder extends EditRecord
{ {
protected static string $resource = ProcessOrderResource::class; protected static string $resource = ProcessOrderResource::class;
protected function beforeSave(): void
{
$plantId = $this->data['plant_id'] ?? null;
$processOrder = $this->data['process_order'] ?? null;
$extraQty = (float) ($this->data['updated_order_quantity'] ?? 0);
$extraQtyRaw = $this->data['updated_order_quantity'] ?? '';
if (!preg_match('/^\d+(\.\d{1,3})?$/', $extraQtyRaw)) {
Notification::make()
->title('Invalid Quantity')
->body('Only positive numbers with up to 3 decimal places are allowed.')
->danger()
->send();
$this->halt(); // stop save
}
if ($extraQty < 0)
{
Notification::make()
->title('Invalid Quantity')
->body('Negative values are not allowed.')
->danger()
->send();
$this->halt();
}
if ($extraQty > 0) {
$order = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->first();
if ($order) {
$baseQty = (float) $order->order_quantity;
$maxAllowed = $baseQty * 0.10;
$maxFinalQty = $baseQty + $maxAllowed;
if ($extraQty > $maxFinalQty) {
Notification::make()
->title('Limit Exceeded')
->body("You can only increase the order by 10% (Max allowed: {$maxFinalQty}).")
->danger()
->send();
$this->halt(); // stops save
}
ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->update([
'updated_order_quantity' => $extraQty,
'updated_by' => Filament::auth()->user()?->name,
]);
}
}
}
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [

View File

@@ -5,28 +5,26 @@ namespace App\Filament\Resources;
use App\Filament\Exports\StockDataMasterExporter; use App\Filament\Exports\StockDataMasterExporter;
use App\Filament\Imports\StockDataMasterImporter; use App\Filament\Imports\StockDataMasterImporter;
use App\Filament\Resources\StockDataMasterResource\Pages; use App\Filament\Resources\StockDataMasterResource\Pages;
use App\Filament\Resources\StockDataMasterResource\RelationManagers;
use App\Models\Item; use App\Models\Item;
use App\Models\Plant; use App\Models\Plant;
use App\Models\SerialValidation;
use App\Models\StickerMaster; use App\Models\StickerMaster;
use App\Models\StockDataMaster; use App\Models\StockDataMaster;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Filament\Forms; use Filament\Forms;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form; use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Resources\Resource; use Filament\Resources\Resource;
use Filament\Tables; use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Tables\Actions\ExportAction; use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction; use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Filters\Filter; use Filament\Tables\Filters\Filter;
use Filament\Forms\Components\Select; use Filament\Tables\Table;
use Filament\Forms\Components\TextInput; use Illuminate\Database\Eloquent\Builder;
use Filament\Forms\Components\DateTimePicker; use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Radio;
use Filament\Notifications\Notification;
class StockDataMasterResource extends Resource class StockDataMasterResource extends Resource
{ {
@@ -51,7 +49,7 @@ class StockDataMasterResource extends Resource
->required() ->required()
->searchable() ->searchable()
->options(function ($get) { ->options(function ($get) {
if (!$get('plant_id')) { if (! $get('plant_id')) {
return []; return [];
} }
@@ -77,7 +75,7 @@ class StockDataMasterResource extends Resource
->label('Type') ->label('Type')
->options([ ->options([
'0' => 'FG', '0' => 'FG',
'1' => 'SFG', '1' => 'NON-FG',
]), ]),
Forms\Components\TextInput::make('motor_scanned_status') Forms\Components\TextInput::make('motor_scanned_status')
->label('Motor Scanned Status'), ->label('Motor Scanned Status'),
@@ -135,7 +133,7 @@ class StockDataMasterResource extends Resource
->searchable() ->searchable()
->formatStateUsing(fn ($state) => match ($state) { ->formatStateUsing(fn ($state) => match ($state) {
'0' => 'FG', '0' => 'FG',
'1' => 'SFG', '1' => 'NON-FG',
default => '-', default => '-',
}) })
->sortable(), ->sortable(),
@@ -307,7 +305,7 @@ class StockDataMasterResource extends Resource
->label('Stock Type') ->label('Stock Type')
->options([ ->options([
'0' => 'FG', '0' => 'FG',
'1' => 'SFG', '1' => 'NON-FG',
]) ])
->inline() ->inline()
->default('0') ->default('0')
@@ -346,6 +344,7 @@ class StockDataMasterResource extends Resource
if (empty($pId)) { if (empty($pId)) {
return []; return [];
} }
return Item::whereHas('stickerMasters', function ($query) use ($pId) { return Item::whereHas('stickerMasters', function ($query) use ($pId) {
if ($pId) { if ($pId) {
$query->where('plant_id', $pId); $query->where('plant_id', $pId);
@@ -389,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['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 (! 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()
@@ -397,16 +396,17 @@ class StockDataMasterResource extends Resource
->danger() ->danger()
->send(); ->send();
} }
return $query->whereRaw('1 = 0'); return $query->whereRaw('1 = 0');
} }
if($data['type'] != ''){ if ($data['type'] != '') {
if ($data['type'] == '0') { if ($data['type'] == '0') {
$query->where('type', '0'); $query->where('type', '0');
if (!empty($data['scanned_status'])) { if (! empty($data['scanned_status'])) {
if ($data['scanned_status'] == 'Scanned') { if ($data['scanned_status'] == 'Scanned') {
$query->whereNotNull('scanned_status') $query->whereNotNull('scanned_status')
@@ -440,8 +440,7 @@ class StockDataMasterResource extends Resource
} }
} }
} }
} } else {
else{
if ($data['scanned_status']) { if ($data['scanned_status']) {
if ($data['scanned_status'] == 'Scanned') { if ($data['scanned_status'] == 'Scanned') {

File diff suppressed because it is too large Load Diff

View File

@@ -627,7 +627,7 @@ class PdfController extends Controller
// 'coil_number' => $proOrdAgPlant->coil_number ?? "", // 'coil_number' => $proOrdAgPlant->coil_number ?? "",
// 'order_quantity' => (string)$proOrdAgPlant->order_quantity ?? "", // 'order_quantity' => (string)$proOrdAgPlant->order_quantity ?? "",
'coil_number' => $currentCoil, 'coil_number' => $currentCoil,
'order_quantity' => (string) $lastRecord->order_quantity ?? '0.000', 'order_quantity' => (string) $lastRecord->updated_order_quantity ?? '0.000',
'ok_quantity' => (string) $okQty ?? '0', 'ok_quantity' => (string) $okQty ?? '0',
'not_ok_quantity' => (string) $notOkQty ?? '0', 'not_ok_quantity' => (string) $notOkQty ?? '0',
'received_quantity' => (string) (($totalReceivedQty == 0) ? '0.000' : $totalReceivedQty) ?? '0.000', 'received_quantity' => (string) (($totalReceivedQty == 0) ? '0.000' : $totalReceivedQty) ?? '0.000',
@@ -686,7 +686,7 @@ class PdfController extends Controller
$itemCode = $data['item_code'] ?? ''; $itemCode = $data['item_code'] ?? '';
$lineName = $data['line_name'] ?? ''; $lineName = $data['line_name'] ?? '';
$coilNo = $data['coil_number'] ?? ''; $coilNo = $data['coil_number'] ?? '';
$orderQty = $data['order_quantity'] ?? 0; $updatedOrderQty = $data['order_quantity'] ?? 0;
$receivedQty = $data['received_quantity'] ?? 0; $receivedQty = $data['received_quantity'] ?? 0;
$scrapQty = $data['scrap_quantity'] ?? 0; $scrapQty = $data['scrap_quantity'] ?? 0;
$sfgNo = $data['sfg_number'] ?? ''; $sfgNo = $data['sfg_number'] ?? '';
@@ -728,6 +728,17 @@ class PdfController extends Controller
], 404); ], 404);
} }
if ($scrapQty == null || $scrapQty == '') {
$scrapQty = 0;
}
if ($rework == null || $rework == '' || ! $rework) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Rework value can't be empty!",
], 404);
}
$line = Line::where('name', $lineName)->first(); $line = Line::where('name', $lineName)->first();
if (! $line) { if (! $line) {
@@ -861,7 +872,8 @@ class PdfController extends Controller
->where('item_id', $itemId) ->where('item_id', $itemId)
->sum('received_quantity'); ->sum('received_quantity');
if ($orderQty == 0) { $orderQty = 0;
if ($updatedOrderQty == 0) {
$orderExist = ProcessOrder::where('plant_id', $plantId) $orderExist = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder) ->where('process_order', $processOrder)
->where('item_id', $itemId)->latest()->first(); ->where('item_id', $itemId)->latest()->first();
@@ -869,6 +881,7 @@ class PdfController extends Controller
if ($orderExist) { if ($orderExist) {
$orderQty = $orderExist->order_quantity ?? 0; $orderQty = $orderExist->order_quantity ?? 0;
$updatedOrderQty = $orderExist->updated_order_quantity ?? 0;
} else { } else {
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
@@ -882,9 +895,11 @@ class PdfController extends Controller
// ->value('order_quantity') ?? 0; // ->value('order_quantity') ?? 0;
if ($orderExist) { if ($orderExist) {
$existOrderQty = $orderExist->order_quantity ?? 0; // $existOrderQty = $orderExist->updated_order_quantity ?? 0;
$orderQty = $orderExist->order_quantity ?? 0;
$existUpdatedOrdQuan = $orderExist->updated_order_quantity ?? 0;
if ($existOrderQty != $orderQty) { if ($existUpdatedOrdQuan != $updatedOrderQty) {
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => "Order quantity doesn't equal to exist process order '{$processOrder}'", 'status_description' => "Order quantity doesn't equal to exist process order '{$processOrder}'",
@@ -895,20 +910,6 @@ class PdfController extends Controller
$total = $alreadyReceived + $receivedQty; $total = $alreadyReceived + $receivedQty;
if ($total > $orderQty) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Received quantity should not exceed order quantity! Order Qty = {$orderQty}, Already Received Qty = {$alreadyReceived}, Trying to Insert Qty = {$receivedQty}",
], 404);
}
if ($rework == null || $rework == '' || ! $rework) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Rework value can't be empty!",
], 404);
}
if ($rework != 'Yes' && $rework != 'No') { if ($rework != 'Yes' && $rework != 'No') {
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
@@ -949,6 +950,13 @@ class PdfController extends Controller
], 404); ], 404);
} }
if ($total > $updatedOrderQty) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Rework received quantity should not exceed exist order quantity! Exist Order Qty = '{$updatedOrderQty}', Already Exist Total Received Qty = '{$alreadyReceived}', Trying to Insert Rework Received Qty = '{$receivedQty}'",
], 404);
}
$existingCoil = ProcessOrder::where('plant_id', $plantId) $existingCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder) ->where('process_order', $processOrder)
->where('line_id', $lineNamePlantId) ->where('line_id', $lineNamePlantId)
@@ -964,6 +972,7 @@ class PdfController extends Controller
'item_id' => $itemId, 'item_id' => $itemId,
'coil_number' => $coilNo, 'coil_number' => $coilNo,
'order_quantity' => $orderQty, 'order_quantity' => $orderQty,
'updated_order_quantity' => $updatedOrderQty,
'received_quantity' => $receivedQty, 'received_quantity' => $receivedQty,
'scrap_quantity' => $scrapQty, 'scrap_quantity' => $scrapQty,
'sfg_number' => $sfgNo, 'sfg_number' => $sfgNo,
@@ -994,7 +1003,7 @@ class PdfController extends Controller
]); ]);
} }
} else { } else {
if ($coilNo >= 1) { if ($coilNo > 1) {
$prevCoilNo = (string) ($coilNo - 1); $prevCoilNo = (string) ($coilNo - 1);
$existPrevCoil = ProcessOrder::where('plant_id', $plantId) $existPrevCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder) ->where('process_order', $processOrder)
@@ -1004,7 +1013,7 @@ class PdfController extends Controller
if (! $existPrevCoil) { if (! $existPrevCoil) {
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => "Previouse coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!", 'status_description' => "Previous coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
], 404); ], 404);
} }
} }
@@ -1022,6 +1031,19 @@ class PdfController extends Controller
], 404); ], 404);
} }
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('item_id', $itemId)
->where('coil_number', $coilNo)
->first();
if ($existPrevCoil->received_quantity < $receivedQty) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Rework received quantity should not exceed exist received quantity! Exist Received Qty = '{$existPrevCoil->received_quantity}', Trying to Insert Rework Received Qty = '{$receivedQty}'",
], 404);
}
$updated = ProcessOrder::where('plant_id', $plantId) $updated = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder) ->where('process_order', $processOrder)
->where('line_id', $lineNamePlantId) ->where('line_id', $lineNamePlantId)
@@ -1070,7 +1092,7 @@ class PdfController extends Controller
], 404); ], 404);
} }
if ($coilNo >= 1) { if ($coilNo > 1) {
$prevCoilNo = (string) ($coilNo - 1); $prevCoilNo = (string) ($coilNo - 1);
$existPrevCoil = ProcessOrder::where('plant_id', $plantId) $existPrevCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder) ->where('process_order', $processOrder)
@@ -1080,11 +1102,18 @@ class PdfController extends Controller
if (! $existPrevCoil) { if (! $existPrevCoil) {
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => "Previouse coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!", 'status_description' => "Previous coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
], 404); ], 404);
} }
} }
if ($total > $updatedOrderQty) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Received quantity should not exceed exist order quantity! Exist Order Qty = '{$updatedOrderQty}', Already Exist Total Received Qty = '{$alreadyReceived}', Trying to Insert Received Qty = '{$receivedQty}'",
], 404);
}
ProcessOrder::Create( ProcessOrder::Create(
[ [
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -1093,6 +1122,7 @@ class PdfController extends Controller
'item_id' => $itemId, 'item_id' => $itemId,
'coil_number' => $coilNo, 'coil_number' => $coilNo,
'order_quantity' => $orderQty, 'order_quantity' => $orderQty,
'updated_order_quantity' => $updatedOrderQty,
'received_quantity' => $receivedQty, 'received_quantity' => $receivedQty,
'scrap_quantity' => $scrapQty, 'scrap_quantity' => $scrapQty,
'sfg_number' => $sfgNo, 'sfg_number' => $sfgNo,

View File

@@ -30,7 +30,7 @@ class UserController extends Controller
* Display the specified resource. * Display the specified resource.
*/ */
// show(string $id) // show(string $id)
public function get_testing_data(Request $request) public function get_user_data(Request $request)
{ {
$expectedUser = env('API_AUTH_USER'); $expectedUser = env('API_AUTH_USER');
$expectedPw = env('API_AUTH_PW'); $expectedPw = env('API_AUTH_PW');

View File

@@ -64,6 +64,11 @@ class Item extends Model
return $this->hasMany(CharacteristicValue::class); return $this->hasMany(CharacteristicValue::class);
} }
public function ClassCharacteristics()
{
return $this->hasMany(ClassCharacteristic::class, 'item_id', 'id');
}
public function weightValidations() public function weightValidations()
{ {
return $this->hasMany(WeightValidation::class); return $this->hasMany(WeightValidation::class);

View File

@@ -43,6 +43,11 @@ class Machine extends Model
return $this->hasMany(CharacteristicValue::class); return $this->hasMany(CharacteristicValue::class);
} }
public function ClassCharacteristics()
{
return $this->hasMany(ClassCharacteristic::class, 'machine_id', 'id');
}
public function testingPanelReadings() public function testingPanelReadings()
{ {
return $this->hasMany(TestingPanelReading::class); return $this->hasMany(TestingPanelReading::class);

View File

@@ -113,6 +113,11 @@ class Plant extends Model
return $this->hasMany(EquipmentMaster::class, 'plant_id', 'id'); return $this->hasMany(EquipmentMaster::class, 'plant_id', 'id');
} }
public function ClassCharacteristics()
{
return $this->hasMany(ClassCharacteristic::class, 'plant_id', 'id');
}
// public function rejectReasons() // public function rejectReasons()
// { // {
// return $this->hasMany(RejectReason::class, 'plant_id', 'id'); // return $this->hasMany(RejectReason::class, 'plant_id', 'id');

View File

@@ -21,6 +21,7 @@ class ProcessOrder extends Model
'coil_number', 'coil_number',
'order_quantity', 'order_quantity',
'received_quantity', 'received_quantity',
'updated_order_quantity',
'sfg_number', 'sfg_number',
'machine_name', 'machine_name',
'scrap_quantity', 'scrap_quantity',

View File

@@ -142,7 +142,7 @@ return new class extends Migration
zmm_type TEXT DEFAULT NULL, zmm_type TEXT DEFAULT NULL,
zmm_usp TEXT DEFAULT NULL, zmm_usp TEXT DEFAULT NULL,
mark_status TEXT DEFAULT NULL, mark_status TEXT DEFAULT NULL,
marked_datetime TIMESTAMP DEFAULT NULL, marked_datetime TIMESTAMP NOT NULL DEFAULT NOW(),
marked_physical_count TEXT DEFAULT '0', marked_physical_count TEXT DEFAULT '0',
marked_expected_time TEXT DEFAULT '0', marked_expected_time TEXT DEFAULT '0',
marked_by TEXT DEFAULT NULL, marked_by TEXT DEFAULT NULL,

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$sql1 = <<<'SQL'
ALTER TABLE process_orders
ADD COLUMN updated_order_quantity NUMERIC(10,3) NULL
SQL;
DB::statement($sql1);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('process_orders', function (Blueprint $table) {
// //
// });
}
};

View File

@@ -0,0 +1,126 @@
<x-filament-panels::page>
<!-- HEADER -->
<div class="mb-8">
<h1 class="text-4xl font-bold tracking-tight">
CRI Digital Manufacturing IIoT Platform
</h1>
<p class="text-lg text-gray-600 mt-2">
Complete visibility, traceability, and control across your manufacturing operations.
</p>
</div>
<!-- BANNER -->
{{-- <div class="w-full overflow-hidden rounded-2xl shadow mb-10"> --}}
<div class="w-full overflow-hidden rounded-xl shadow">
<img
src="{{ asset('images/iiot-banner.jpg') }}"
alt="CRI Digital Manufacturing IIoT"
class="w-full h-72 object-cover"
>
</div>
<!-- INTRO -->
<div class="max-w-4xl mb-10">
<p class="text-lg text-gray-700 mb-4">
CRI Digital Manufacturing IIoT is built to deliver
<strong>end-to-end traceability, real-time insights, and operational transparency</strong>
across plants, lines, and production processes.
</p>
<p class="text-lg text-gray-700">
The platform ensures <strong>right quality and on-time delivery</strong> by enabling
complete tracking of materials, production orders, and finished goods—helping teams
make faster, data-driven decisions with confidence.
</p>
</div>
<!-- KEY PILLARS -->
<div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-10">
<div class="bg-white rounded-xl border p-6 shadow-sm">
<h3 class="text-lg font-semibold mb-2">🔍 Traceability</h3>
<p class="text-gray-600">
Track materials, batches, and serials from input to dispatch.
</p>
</div>
<div class="bg-white rounded-xl border p-6 shadow-sm">
<h3 class="text-lg font-semibold mb-2"> Quality Assurance</h3>
<p class="text-gray-600">
Validate process data and ensure first-time-right production.
</p>
</div>
<div class="bg-white rounded-xl border p-6 shadow-sm">
<h3 class="text-lg font-semibold mb-2"> On-Time Delivery</h3>
<p class="text-gray-600">
Identify delays early and meet production commitments.
</p>
</div>
<div class="bg-white rounded-xl border p-6 shadow-sm">
<h3 class="text-lg font-semibold mb-2">📊 Real-Time Insights</h3>
<p class="text-gray-600">
Monitor performance and take quick corrective actions.
</p>
</div>
</div>
<!-- SUPPORT -->
<div class="bg-white rounded-xl border p-6 shadow-sm">
<h2 class="text-2xl font-semibold mb-3">24×7 Support</h2>
<p class="text-gray-700 mb-2">
Our dedicated IIoT support team is available round-the-clock to ensure
uninterrupted operations and quick issue resolution.
</p>
<p class="text-lg font-medium text-gray-900">
📞 Support Landline: <span class="font-semibold">0422 711 7179</span>
</p>
{{-- <p class="text-lg font-medium text-gray-900">
📞 Technical Support Contact: <span class="font-semibold">9952468104 / 9100832269</span>
</p> --}}
</div>
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
<h2 class="text-2xl font-semibold mb-4">24×7 Support</h2>
<p class="text-lg text-gray-700 mb-4">
Our support structure is designed to ensure quick resolution based on the type
of issue whether it is on-site, application-related, or infrastructure-related.
</p>
<div class="space-y-3">
<p class="text-lg font-medium text-gray-900">
🏭 <strong>Plant & On-Site Support</strong> <br>
<span class="text-gray-700">
For plant visits, industry-level issues, and on-ground validation
</span><br>
📞 <span class="font-semibold">8925899458 / 8925899459</span>
</p>
<p class="text-lg font-medium text-gray-900">
💻 <strong>Application & Logic Support</strong> <br>
<span class="text-gray-700">
For website errors, logic issues, and application-level problems
</span><br>
📞 <span class="font-semibold">9952468104 / 9100832269</span>
</p>
</div>
</div> --}}
<!-- TEAM -->
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
<h2 class="text-2xl font-semibold mb-4">IIOT Team Members</h2>
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 text-gray-700">
<div class="flex items-center gap-2">👤 Jothikumar</div>
<div class="flex items-center gap-2">👤 Jeithef Shibu</div>
<div class="flex items-center gap-2">👤 Dhanabalan</div>
<div class="flex items-center gap-2">👤 Ranjith</div>
<div class="flex items-center gap-2">👤 Srimathy</div>
<div class="flex items-center gap-2">👤 Gokul</div>
</div>
</div> --}}
</x-filament-panels::page>

View File

@@ -1,126 +1,13 @@
<x-filament-panels::page> <x-filament-panels::page>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2 sm:gap-4 md:gap-4 p-2 md:p-4 items-start">
<!-- HEADER --> {{-- Filters form --}}
<div class="mb-8"> <div class="space-y-4 w-full max-w-full col-span-1">
<h1 class="text-4xl font-bold tracking-tight"> {{ $this->filtersForm($this->form) }}
CRI Digital Manufacturing IIoT Platform
</h1>
<p class="text-lg text-gray-600 mt-2">
Complete visibility, traceability, and control across your manufacturing operations.
</p>
</div> </div>
<!-- BANNER --> {{-- Stat widget --}}
{{-- <div class="w-full overflow-hidden rounded-2xl shadow mb-10"> --}} <div class="w-full max-w-full col-span-1 sm:col-span-1 lg:col-span-2">
<div class="w-full overflow-hidden rounded-xl shadow"> @livewire(\App\Filament\Widgets\CumulativeChart::class)
<img
src="{{ asset('images/iiot-banner.jpg') }}"
alt="CRI Digital Manufacturing IIoT"
class="w-full h-72 object-cover"
>
</div>
<!-- INTRO -->
<div class="max-w-4xl mb-10">
<p class="text-lg text-gray-700 mb-4">
CRI Digital Manufacturing IIoT is built to deliver
<strong>end-to-end traceability, real-time insights, and operational transparency</strong>
across plants, lines, and production processes.
</p>
<p class="text-lg text-gray-700">
The platform ensures <strong>right quality and on-time delivery</strong> by enabling
complete tracking of materials, production orders, and finished goods—helping teams
make faster, data-driven decisions with confidence.
</p>
</div>
<!-- KEY PILLARS -->
<div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-10">
<div class="bg-white rounded-xl border p-6 shadow-sm">
<h3 class="text-lg font-semibold mb-2">🔍 Traceability</h3>
<p class="text-gray-600">
Track materials, batches, and serials from input to dispatch.
</p>
</div>
<div class="bg-white rounded-xl border p-6 shadow-sm">
<h3 class="text-lg font-semibold mb-2"> Quality Assurance</h3>
<p class="text-gray-600">
Validate process data and ensure first-time-right production.
</p>
</div>
<div class="bg-white rounded-xl border p-6 shadow-sm">
<h3 class="text-lg font-semibold mb-2"> On-Time Delivery</h3>
<p class="text-gray-600">
Identify delays early and meet production commitments.
</p>
</div>
<div class="bg-white rounded-xl border p-6 shadow-sm">
<h3 class="text-lg font-semibold mb-2">📊 Real-Time Insights</h3>
<p class="text-gray-600">
Monitor performance and take quick corrective actions.
</p>
</div> </div>
</div> </div>
<!-- SUPPORT -->
<div class="bg-white rounded-xl border p-6 shadow-sm">
<h2 class="text-2xl font-semibold mb-3">24×7 Support</h2>
<p class="text-gray-700 mb-2">
Our dedicated IIoT support team is available round-the-clock to ensure
uninterrupted operations and quick issue resolution.
</p>
<p class="text-lg font-medium text-gray-900">
📞 Support Landline: <span class="font-semibold">0422 711 7179</span>
</p>
{{-- <p class="text-lg font-medium text-gray-900">
📞 Technical Support Contact: <span class="font-semibold">9952468104 / 9100832269</span>
</p> --}}
</div>
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
<h2 class="text-2xl font-semibold mb-4">24×7 Support</h2>
<p class="text-lg text-gray-700 mb-4">
Our support structure is designed to ensure quick resolution based on the type
of issue whether it is on-site, application-related, or infrastructure-related.
</p>
<div class="space-y-3">
<p class="text-lg font-medium text-gray-900">
🏭 <strong>Plant & On-Site Support</strong> <br>
<span class="text-gray-700">
For plant visits, industry-level issues, and on-ground validation
</span><br>
📞 <span class="font-semibold">8925899458 / 8925899459</span>
</p>
<p class="text-lg font-medium text-gray-900">
💻 <strong>Application & Logic Support</strong> <br>
<span class="text-gray-700">
For website errors, logic issues, and application-level problems
</span><br>
📞 <span class="font-semibold">9952468104 / 9100832269</span>
</p>
</div>
</div> --}}
<!-- TEAM -->
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
<h2 class="text-2xl font-semibold mb-4">IIOT Team Members</h2>
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 text-gray-700">
<div class="flex items-center gap-2">👤 Jothikumar</div>
<div class="flex items-center gap-2">👤 Jeithef Shibu</div>
<div class="flex items-center gap-2">👤 Dhanabalan</div>
<div class="flex items-center gap-2">👤 Ranjith</div>
<div class="flex items-center gap-2">👤 Srimathy</div>
<div class="flex items-center gap-2">👤 Gokul</div>
</div>
</div> --}}
</x-filament-panels::page> </x-filament-panels::page>

View File

@@ -136,9 +136,13 @@ Route::post('serial-invoice/store-data', [InvoiceValidationController::class, 's
Route::post('material-invoice/store-data', [InvoiceValidationController::class, 'materialInvoice']); Route::post('material-invoice/store-data', [InvoiceValidationController::class, 'materialInvoice']);
// User Controller
Route::get('user/get-data', [UserController::class, 'get_user_data']);
// Testing panel Controller // Testing panel Controller
Route::get('testing/user/get-data', [UserController::class, 'get_testing_data']); Route::get('testing/user/get-data', [UserController::class, 'get_user_data']);
Route::get('testing/item/get-master-data', [TestingPanelController::class, 'get_motor_master']); Route::get('testing/item/get-master-data', [TestingPanelController::class, 'get_motor_master']);
@@ -170,7 +174,7 @@ Route::get('laser/characteristics/check', [CharacteristicsController::class, 'ch
Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']); Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']);
// ..serial (auto or manual) // ..Marked serial (auto or manual)
Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']); Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);