diff --git a/app/Filament/Pages/ProductionQuantityPage.php b/app/Filament/Pages/ProductionQuantityPage.php index a77b5374c..44aac93a9 100644 --- a/app/Filament/Pages/ProductionQuantityPage.php +++ b/app/Filament/Pages/ProductionQuantityPage.php @@ -20,6 +20,8 @@ use Route; use Illuminate\Support\Facades\Request; use Filament\Notifications\Notification; use Illuminate\Support\Facades\Auth; +use Livewire\Attributes\On; + class ProductionQuantityPage extends Page implements HasForms { @@ -321,7 +323,8 @@ class ProductionQuantityPage extends Page implements HasForms ->label('Production Order') ->reactive() ->required() - ->columnSpan(1) + //->columnSpan(1) + ->columnSpan(['default' => 1, 'sm' => 1]) ->afterStateUpdated(function ($state, callable $get, callable $set): void { $set('item_code', null); $set('item_id', null); @@ -335,16 +338,16 @@ class ProductionQuantityPage extends Page implements HasForms // } }), - TextInput::make('item_code') - ->label('Item Code') - ->columnSpan(1) - ->autofocus(true) - //->reactive() - ->live(onBlur: true) // avoids per-keystroke triggering - ->default(fn () => $this->clear_qr) - ->extraAttributes([ - 'wire:keydown.enter' => 'processAllValues($event.target.value)', - ]), + // TextInput::make('item_code') + // ->label('Item Code') + // ->columnSpan(1) + // ->autofocus(true) + // //->reactive() + // ->live(onBlur: true) // avoids per-keystroke triggering + // ->default(fn () => $this->clear_qr) + // ->extraAttributes([ + // 'wire:keydown.enter' => 'processAllValues($event.target.value)', + // ]), Hidden::make('serial_number') ->required(), @@ -358,7 +361,8 @@ class ProductionQuantityPage extends Page implements HasForms TextInput::make('recent_qr') ->label('Last scanned QR') ->reactive() - ->columnSpan(1) + ->columnSpan(['default' => 1, 'sm' => 2]) + //->columnSpan(2) // ->default(function () { // // Get the latest 'item_id' foreign key from 'production_quantities' table // $latestProductionQuantity = ProductionQuantity::latest()->first(); @@ -387,11 +391,19 @@ class ProductionQuantityPage extends Page implements HasForms Hidden::make('operator_id') ->default(Filament::auth()->user()->name), ]) - ->columns(7); + // ->columns(6); + ->columns(['default' => 1, 'sm' => 7]); } // Method to process the value when Enter is pressed + + #[On('handleQrScan')] + public function handleQrScan($value) + { + $this->processAllValues($value); + } + public function processAllValues($formQRData) { @@ -421,6 +433,11 @@ class ProductionQuantityPage extends Page implements HasForms $this->recQr = $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null; } + Notification::make() + ->title("Scanned the valid QR code is $formQRData)") + ->info() + ->send(); + if (empty($formQRData)) { $this->form->fill([ @@ -1268,7 +1285,7 @@ class ProductionQuantityPage extends Page implements HasForms 'shift_id'=> $this->sId, 'line_id'=> $this->lId, 'item_id'=> null, - // 'item_code'=> null, + //'item_code'=> null, 'serial_number'=> null, 'success_msg'=> null, 'production_order'=> $this->prodOrder, @@ -1293,25 +1310,25 @@ class ProductionQuantityPage extends Page implements HasForms // For example: $model = ProductionQuantity::create($formValues); - // dd('Production Updated Event Dispatched'); + // dd('Production Updated Event Dispatched'); $this->dispatch('productionUpdated'); // // Optionally, you can emit an event or perform a redirect after saving // $this->emit('formSaved', $model->id); } - public function triggerChartUpdate(): void - { - if (session()->has('select_plant') && session()->has('select_line')) { - $this->dispatch('filtersUpdated'); - } - } + public function triggerChartUpdate(): void + { + if (session()->has('select_plant') && session()->has('select_line')) { + $this->dispatch('filtersUpdated'); + } + } - // Override the getTitle method - public function getTitle(): string - { - return ''; // Return an empty string to remove the title - } + // Override the getTitle method + public function getTitle(): string + { + return ''; // Return an empty string to remove the title + } public static function getNavigationLabel(): string { diff --git a/resources/views/filament/pages/production-quantity.blade.php b/resources/views/filament/pages/production-quantity.blade.php index 2a6edcdab..dfa783273 100644 --- a/resources/views/filament/pages/production-quantity.blade.php +++ b/resources/views/filament/pages/production-quantity.blade.php @@ -7,10 +7,55 @@ {{ $this->form }} + {{-- --}} +