diff --git a/app/Filament/Imports/CustomerPoMasterImporter.php b/app/Filament/Imports/CustomerPoMasterImporter.php index 430f81b..bf089bf 100644 --- a/app/Filament/Imports/CustomerPoMasterImporter.php +++ b/app/Filament/Imports/CustomerPoMasterImporter.php @@ -17,6 +17,8 @@ class CustomerPoMasterImporter extends Importer { protected static ?string $model = CustomerPoMaster::class; + protected array $importedPos = []; + public static function getColumns(): array { return [ @@ -67,6 +69,8 @@ class CustomerPoMasterImporter extends Importer $plantCod = $this->data['plant']; $plant = null; $item = null; + $customerPo = trim($this->data['customer_po']); + $customerName = trim($this->data['customer_name']); if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) { $warnMsg[] = 'Invalid plant code found'; @@ -90,6 +94,23 @@ class CustomerPoMasterImporter extends Importer $warnMsg[] = 'Customer PO cannot be empty.'; } + if (isset($this->importedPos[$customerPo])) { + + if (strtolower(trim($this->importedPos[$customerPo])) != strtolower($customerName)){ + $warnMsg[] = "Customer PO '{$customerPo}' has multiple customer names in the import file."; + } + } + else { + $this->importedPos[$customerPo] = $customerName; + } + + $existingPo = CustomerPoMaster::where('plant_id', $plant->id)->where('customer_po', $this->data['customer_po'])->first(); + + if ($existingPo && trim(strtolower($existingPo->customer_name)) != trim(strtolower($this->data['customer_name']))) + { + $warnMsg[] = "Customer PO '{$this->data['customer_po']}' is already mapped to customer '{$existingPo->customer_name}'."; + } + // $user = User::where('name', $this->data['created_by'])->first(); // if (! $user) { // $warnMsg[] = 'User not found'; diff --git a/app/Filament/Resources/MachineResource.php b/app/Filament/Resources/MachineResource.php index dd2cbab..06cd34c 100644 --- a/app/Filament/Resources/MachineResource.php +++ b/app/Filament/Resources/MachineResource.php @@ -43,6 +43,7 @@ class MachineResource extends Resource Forms\Components\Select::make('plant_id') ->label('Plant Name') ->relationship('plant', 'name') + ->searchable() ->required() ->columnSpan(1) ->reactive() @@ -75,6 +76,7 @@ class MachineResource extends Resource Forms\Components\Select::make('line_id') ->label('Line Name') ->relationship('line', 'name') + ->searchable() ->required() ->columnSpan(1) ->reactive() @@ -115,6 +117,7 @@ class MachineResource extends Resource Forms\Components\Select::make('work_group_master_id') ->label('Group Work Center') ->relationship('workGroupMaster', 'name') + ->searchable() ->required() ->columnSpan(1) ->reactive() @@ -142,6 +145,7 @@ class MachineResource extends Resource $lineId = $get('line_id'); if (! $lineId) { $set('mGroupWorkError', 'Please select a line first.'); + $set('work_group_master_id', null); return; } else { diff --git a/app/Filament/Resources/WorkGroupMasterResource.php b/app/Filament/Resources/WorkGroupMasterResource.php index eaecff0..8b21ab2 100644 --- a/app/Filament/Resources/WorkGroupMasterResource.php +++ b/app/Filament/Resources/WorkGroupMasterResource.php @@ -40,6 +40,7 @@ class WorkGroupMasterResource extends Resource Forms\Components\Select::make('plant_id') ->label('Plant Name') ->relationship('plant', 'name') + ->searchable() ->reactive() ->columnSpan(1) ->required() @@ -55,22 +56,20 @@ class WorkGroupMasterResource extends Resource ->afterStateUpdated(function ($state, $set, callable $get) { $plantId = $get('plant_id'); - if (! $plantId) { - $set('pqPlantError', 'Please select a plant first.'); - $set('name', null); - $set('description', null); - $set('operation_number', null); - - return; - } - - $set('validationError', null); - $set('pqPlantError', null); + $set('wgmPlantError', null); $set('name', null); $set('description', null); $set('operation_number', null); + if (! $plantId) { + $set('wgmPlantError', 'Please select a plant first.'); + + return; + } }) - ->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null) + ->extraAttributes(fn ($get) => [ + 'class' => $get('wgmPlantError') ? 'border-red-500' : '', + ]) + ->hint(fn ($get) => $get('wgmPlantError') ? $get('wgmPlantError') : null) ->hintColor('danger'), Forms\Components\TextInput::make('name') ->label('Group Work Center') diff --git a/resources/views/pdf/wire-pallet.blade.php b/resources/views/pdf/wire-pallet.blade.php index 5112374..39f7bd1 100644 --- a/resources/views/pdf/wire-pallet.blade.php +++ b/resources/views/pdf/wire-pallet.blade.php @@ -12,10 +12,10 @@ $headerRows = [ 'PRODUCT' => $product, - 'MONTH/YEAR' => $monthYear, + 'MFG. MONTH & YEAR' => $monthYear, 'CUSTOMER PO' => $customerCode, 'CUSTOMER NAME' => $customerName, - 'NO OF MASTER BOX' => $masterBox, + 'MASTER BOX NO.' => $masterBox, ]; $titleHeight = 10; @@ -55,6 +55,9 @@ if ($numItems == 1) { $itemRowHeight -= 0.5; } + if ($numItems == 2) { + $itemRowHeight += 0.4; + } if ($itemRowHeight < 3) { $itemFontSize = '5.5px'; @@ -290,7 +293,7 @@ style="height: mm; max-width: mm; width: auto;"> - C.R.I POLY WRAPPED WINDING WIRE + C.R.I. POLY WRAPPED WINDING WIRE
{{--