Merge pull request 'solved quick scanning issue in invoice validation' (#79) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Reviewed-on: #79
This commit was merged in pull request #79.
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
|
||||
use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
|
||||
use App\Filament\Exports\InvoiceValidationExporter;
|
||||
use App\Filament\Resources\InvoiceValidationResource\Pages;
|
||||
use App\Mail\InvoiceNotification;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
@@ -29,7 +30,6 @@ use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\View;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Actions\Action;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
@@ -38,6 +38,10 @@ use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Livewire\Livewire;
|
||||
use Str;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Filament\Forms\Components\View;
|
||||
|
||||
|
||||
class InvoiceValidationResource extends Resource
|
||||
{
|
||||
@@ -49,6 +53,8 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
public $invoiceNumber;
|
||||
|
||||
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -119,6 +125,9 @@ class InvoiceValidationResource extends Resource
|
||||
$invNo = $get('invoice_number');
|
||||
$set('serial_number', null);
|
||||
$set('update_invoice', null);
|
||||
//Session::put('invoice_number', $state);
|
||||
session(['invoice_number' => $state]);
|
||||
|
||||
// if (!$invNo) { return; } else { }
|
||||
}),
|
||||
|
||||
@@ -127,16 +136,31 @@ class InvoiceValidationResource extends Resource
|
||||
->reactive()
|
||||
->readOnly(fn (callable $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([
|
||||
'id' => 'serial_number_input',
|
||||
'x-data' => '{ value: "" }',
|
||||
'x-model' => 'value',
|
||||
'wire:keydown.enter.prevent' => 'processSerialNumber(value)', // Using wire:keydown
|
||||
'x-on:keydown.enter.prevent' => "
|
||||
let serial = \$event.target.value;
|
||||
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);
|
||||
// $this->dispatch('focus-serial-number');
|
||||
// if (!$invNo) { return; } else { }
|
||||
// if ($state) {
|
||||
// $livewire('process-scan', $state);
|
||||
// $set('serial_number', null);
|
||||
// }
|
||||
})
|
||||
->columnSpan(1),
|
||||
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
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
|
||||
@@ -19,6 +19,7 @@ use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Str;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
class CreateInvoiceValidation extends CreateRecord
|
||||
{
|
||||
@@ -2260,7 +2261,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
];
|
||||
}
|
||||
|
||||
public function processSerialNumber($serNo)
|
||||
public function processSer($serNo)
|
||||
{
|
||||
$serNo = trim($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
|
||||
{
|
||||
return 'Scan Invoice Validation';
|
||||
|
||||
Reference in New Issue
Block a user