diff --git a/app/Filament/Imports/ProductionPlanImporter.php b/app/Filament/Imports/ProductionPlanImporter.php index c2f622c1..4687fd77 100644 --- a/app/Filament/Imports/ProductionPlanImporter.php +++ b/app/Filament/Imports/ProductionPlanImporter.php @@ -17,7 +17,6 @@ use Filament\Actions\Imports\Importer; use Filament\Actions\Imports\Models\Import; use Filament\Facades\Filament; use Str; -use Illuminate\Support\Facades\Log; class ProductionPlanImporter extends Importer { @@ -138,7 +137,7 @@ class ProductionPlanImporter extends Importer $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'; } else { $item = Item::where('code', $itemCod)->first(); @@ -152,13 +151,12 @@ class ProductionPlanImporter extends Importer $itemAgaPlant = Item::where('plant_id', $plantId)->where('code', $itemCod)->first(); - if(!$itemAgaPlant){ + if (! $itemAgaPlant) { $warnMsg[] = 'Item not found against plant code'; - } - else { + } else { $line = $itemAgaPlant->line_id; - if (!$line) { + if (! $line) { $warnMsg[] = 'Line not mapped for that item code'; } } @@ -167,7 +165,7 @@ class ProductionPlanImporter extends Importer $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) { $warnMsg[] = 'Invalid plan quantity found'; } @@ -199,7 +197,7 @@ class ProductionPlanImporter extends Importer ->whereYear('created_at', $year) ->first(); - if(!$previousRecord){ + if (! $previousRecord) { $warnMsg[] = 'Update this month production calendar'; } @@ -207,7 +205,6 @@ class ProductionPlanImporter extends Importer throw new RowImportFailedException(implode(', ', $warnMsg)); } - $recordDate = now(); $month = $recordDate->month; $year = $recordDate->year; @@ -257,11 +254,11 @@ class ProductionPlanImporter extends Importer for ($day = 1; $day <= 31; $day++) { if ($day <= $totalDays) { - $dailyData['day_' . $day] = - (int) ($productionPlan1->{'day_' . $day} ?? 0); + $dailyData['day_'.$day] = + (int) ($productionPlan1->{'day_'.$day} ?? 0); } else { // 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)) { $remainingDays[] = $day; } else { - $dailyData['day_' . $day] = 0; + $dailyData['day_'.$day] = 0; } } @@ -314,7 +311,7 @@ class ProductionPlanImporter extends Importer foreach ($remainingDays as $index => $day) { - $dailyData['day_' . $day] = + $dailyData['day_'.$day] = $dailyValue + ($index < $remainder ? 1 : 0); } } @@ -346,10 +343,7 @@ class ProductionPlanImporter extends Importer } - - - - //..Working Logic + // ..Working Logic // $recordDate = now(); // $month = $recordDate->month; @@ -470,7 +464,7 @@ class ProductionPlanImporter extends Importer // } - //..Old Logic + // ..Old Logic // $productionPlan1 = ProductionPlan::where('plant_id', $plant->id) // ->where('item_id', $itemAgaPlant->id)