solved quick scanning issue in invoice validation
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
|
|||||||
use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
|
use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
|
||||||
use App\Filament\Exports\InvoiceValidationExporter;
|
use App\Filament\Exports\InvoiceValidationExporter;
|
||||||
use App\Filament\Resources\InvoiceValidationResource\Pages;
|
use App\Filament\Resources\InvoiceValidationResource\Pages;
|
||||||
|
use App\Mail\InvoiceNotification;
|
||||||
use App\Models\InvoiceValidation;
|
use App\Models\InvoiceValidation;
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
@@ -29,7 +30,6 @@ 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\Forms\Components\View;
|
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Tables\Actions\Action;
|
use Filament\Tables\Actions\Action;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Filament\Tables\Actions\ExportAction;
|
||||||
@@ -38,6 +38,10 @@ use Illuminate\Support\Facades\Storage;
|
|||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use Livewire\Livewire;
|
use Livewire\Livewire;
|
||||||
use Str;
|
use Str;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Filament\Forms\Components\View;
|
||||||
|
|
||||||
|
|
||||||
class InvoiceValidationResource extends Resource
|
class InvoiceValidationResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -49,6 +53,8 @@ class InvoiceValidationResource extends Resource
|
|||||||
|
|
||||||
public $invoiceNumber;
|
public $invoiceNumber;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
@@ -119,6 +125,9 @@ class InvoiceValidationResource extends Resource
|
|||||||
$invNo = $get('invoice_number');
|
$invNo = $get('invoice_number');
|
||||||
$set('serial_number', null);
|
$set('serial_number', null);
|
||||||
$set('update_invoice', null);
|
$set('update_invoice', null);
|
||||||
|
//Session::put('invoice_number', $state);
|
||||||
|
session(['invoice_number' => $state]);
|
||||||
|
|
||||||
// if (!$invNo) { return; } else { }
|
// if (!$invNo) { return; } else { }
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -127,16 +136,31 @@ class InvoiceValidationResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->readOnly(fn (callable $get) => empty($get('invoice_number')))
|
->readOnly(fn (callable $get) => empty($get('invoice_number')))
|
||||||
//->disabled(fn (Get $get) => empty($get('invoice_number')))
|
//->disabled(fn (Get $get) => empty($get('invoice_number')))
|
||||||
|
// ->extraAttributes([
|
||||||
|
// 'id' => 'serial_number_input',
|
||||||
|
// 'x-data' => '{ value: "" }',
|
||||||
|
// 'x-model' => 'value',
|
||||||
|
// 'wire:keydown.enter.prevent' => 'processSerial(value)', // Using wire:keydown
|
||||||
|
// ])
|
||||||
|
->dehydrated(false) // Do not trigger Livewire syncing
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
'id' => 'serial_number_input',
|
'id' => 'serial_number_input',
|
||||||
'x-data' => '{ value: "" }',
|
'x-on:keydown.enter.prevent' => "
|
||||||
'x-model' => 'value',
|
let serial = \$event.target.value;
|
||||||
'wire:keydown.enter.prevent' => 'processSerialNumber(value)', // Using wire:keydown
|
if (serial.trim() != '') {
|
||||||
|
\$wire.dispatch('process-scan', serial);
|
||||||
|
\$event.target.value = '';
|
||||||
|
}
|
||||||
|
",
|
||||||
])
|
])
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get, callable $livewire) {
|
||||||
$set('update_invoice', 0);
|
$set('update_invoice', 0);
|
||||||
// $this->dispatch('focus-serial-number');
|
// $this->dispatch('focus-serial-number');
|
||||||
// if (!$invNo) { return; } else { }
|
// if (!$invNo) { return; } else { }
|
||||||
|
// if ($state) {
|
||||||
|
// $livewire('process-scan', $state);
|
||||||
|
// $set('serial_number', null);
|
||||||
|
// }
|
||||||
})
|
})
|
||||||
->columnSpan(1),
|
->columnSpan(1),
|
||||||
Forms\Components\TextInput::make('total_quantity')
|
Forms\Components\TextInput::make('total_quantity')
|
||||||
@@ -1256,6 +1280,24 @@ class InvoiceValidationResource extends Resource
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public static function render(): View
|
||||||
|
// {
|
||||||
|
// if (session()->has('invoice_number')) {
|
||||||
|
// $invoiceNumber = session('invoice_number');
|
||||||
|
|
||||||
|
// // Debug: show the invoice number
|
||||||
|
// dd($invoiceNumber); // This will stop execution and show the value
|
||||||
|
|
||||||
|
// // Trigger email
|
||||||
|
// \Mail::to('jothikumar.padmanaban@cripumps.com')
|
||||||
|
// ->send(new InvoiceNotification($invoiceNumber));
|
||||||
|
|
||||||
|
// // Clear session so it doesn't resend on next refresh
|
||||||
|
// //session()->forget('invoice_number');
|
||||||
|
// }
|
||||||
|
// // return view('filament.resources.invoice-validation-resource.pages.list-invoice-validation');
|
||||||
|
// }
|
||||||
|
|
||||||
public static function getEloquentQuery(): Builder
|
public static function getEloquentQuery(): Builder
|
||||||
{
|
{
|
||||||
return parent::getEloquentQuery()
|
return parent::getEloquentQuery()
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use Illuminate\Support\Facades\Mail;
|
|||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use Str;
|
use Str;
|
||||||
|
use Livewire\Attributes\On;
|
||||||
|
|
||||||
class CreateInvoiceValidation extends CreateRecord
|
class CreateInvoiceValidation extends CreateRecord
|
||||||
{
|
{
|
||||||
@@ -2260,7 +2261,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processSerialNumber($serNo)
|
public function processSer($serNo)
|
||||||
{
|
{
|
||||||
$serNo = trim($serNo);
|
$serNo = trim($serNo);
|
||||||
$mSerNo = $serNo;
|
$mSerNo = $serNo;
|
||||||
@@ -3764,6 +3765,12 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[On('process-scan')]
|
||||||
|
public function processSerial($serial)
|
||||||
|
{
|
||||||
|
$this->processSer($serial); // Your duplicate check + mail logic
|
||||||
|
}
|
||||||
|
|
||||||
public function getHeading(): string
|
public function getHeading(): string
|
||||||
{
|
{
|
||||||
return 'Scan Invoice Validation';
|
return 'Scan Invoice Validation';
|
||||||
|
|||||||
Reference in New Issue
Block a user