Merge pull request 'Updated item code validation logic to allow alpha numeric' (#1482) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 38s

Reviewed-on: #1482
This commit was merged in pull request #1482.
This commit is contained in:
2026-11-19 14:10:14 +00:00

View File

@@ -17,7 +17,6 @@ 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 Illuminate\Support\Facades\Log;
class ProductionPlanImporter extends Importer class ProductionPlanImporter extends Importer
{ {
@@ -138,7 +137,7 @@ class ProductionPlanImporter extends Importer
$warnMsg[] = 'Plant not found'; $warnMsg[] = 'Plant not found';
} }
if (Str::length($itemCod) < 6 || ! is_numeric($itemCod)) { if (Str::length($itemCod) < 6 || ! ctype_alnum($itemCod)) {
$warnMsg[] = 'Invalid item code found'; $warnMsg[] = 'Invalid item code found';
} else { } else {
$item = Item::where('code', $itemCod)->first(); $item = Item::where('code', $itemCod)->first();
@@ -152,13 +151,12 @@ class ProductionPlanImporter extends Importer
$itemAgaPlant = Item::where('plant_id', $plantId)->where('code', $itemCod)->first(); $itemAgaPlant = Item::where('plant_id', $plantId)->where('code', $itemCod)->first();
if(!$itemAgaPlant){ if (! $itemAgaPlant) {
$warnMsg[] = 'Item not found against plant code'; $warnMsg[] = 'Item not found against plant code';
} } else {
else {
$line = $itemAgaPlant->line_id; $line = $itemAgaPlant->line_id;
if (!$line) { if (! $line) {
$warnMsg[] = 'Line not mapped for that item code'; $warnMsg[] = 'Line not mapped for that item code';
} }
} }
@@ -167,7 +165,7 @@ class ProductionPlanImporter extends Importer
$operatorName = $user->name; $operatorName = $user->name;
if (!empty($this->data['plan_quantity'])) { if (! empty($this->data['plan_quantity'])) {
if (Str::length($this->data['plan_quantity']) < 0 || ! is_numeric($this->data['plan_quantity']) || $this->data['plan_quantity'] <= 0) { if (Str::length($this->data['plan_quantity']) < 0 || ! is_numeric($this->data['plan_quantity']) || $this->data['plan_quantity'] <= 0) {
$warnMsg[] = 'Invalid plan quantity found'; $warnMsg[] = 'Invalid plan quantity found';
} }
@@ -199,7 +197,7 @@ class ProductionPlanImporter extends Importer
->whereYear('created_at', $year) ->whereYear('created_at', $year)
->first(); ->first();
if(!$previousRecord){ if (! $previousRecord) {
$warnMsg[] = 'Update this month production calendar'; $warnMsg[] = 'Update this month production calendar';
} }
@@ -207,7 +205,6 @@ class ProductionPlanImporter extends Importer
throw new RowImportFailedException(implode(', ', $warnMsg)); throw new RowImportFailedException(implode(', ', $warnMsg));
} }
$recordDate = now(); $recordDate = now();
$month = $recordDate->month; $month = $recordDate->month;
$year = $recordDate->year; $year = $recordDate->year;
@@ -257,11 +254,11 @@ class ProductionPlanImporter extends Importer
for ($day = 1; $day <= 31; $day++) { for ($day = 1; $day <= 31; $day++) {
if ($day <= $totalDays) { if ($day <= $totalDays) {
$dailyData['day_' . $day] = $dailyData['day_'.$day] =
(int) ($productionPlan1->{'day_' . $day} ?? 0); (int) ($productionPlan1->{'day_'.$day} ?? 0);
} else { } else {
// Invalid dates must always remain zero // Invalid dates must always remain zero
$dailyData['day_' . $day] = 0; $dailyData['day_'.$day] = 0;
} }
} }
@@ -296,7 +293,7 @@ class ProductionPlanImporter extends Importer
if (! in_array($day, $leaveDayNumbers, true)) { if (! in_array($day, $leaveDayNumbers, true)) {
$remainingDays[] = $day; $remainingDays[] = $day;
} else { } else {
$dailyData['day_' . $day] = 0; $dailyData['day_'.$day] = 0;
} }
} }
@@ -314,7 +311,7 @@ class ProductionPlanImporter extends Importer
foreach ($remainingDays as $index => $day) { foreach ($remainingDays as $index => $day) {
$dailyData['day_' . $day] = $dailyData['day_'.$day] =
$dailyValue + ($index < $remainder ? 1 : 0); $dailyValue + ($index < $remainder ? 1 : 0);
} }
} }
@@ -346,10 +343,7 @@ class ProductionPlanImporter extends Importer
} }
// ..Working Logic
//..Working Logic
// $recordDate = now(); // $recordDate = now();
// $month = $recordDate->month; // $month = $recordDate->month;
@@ -470,7 +464,7 @@ class ProductionPlanImporter extends Importer
// } // }
//..Old Logic // ..Old Logic
// $productionPlan1 = ProductionPlan::where('plant_id', $plant->id) // $productionPlan1 = ProductionPlan::where('plant_id', $plant->id)
// ->where('item_id', $itemAgaPlant->id) // ->where('item_id', $itemAgaPlant->id)