Compare commits
8 Commits
2e167c75b0
...
renovate/t
| Author | SHA1 | Date | |
|---|---|---|---|
| f82ff3191d | |||
| 79e3427cdb | |||
|
|
cdd746d5da | ||
| 81a5fa16c4 | |||
|
|
385103323a | ||
| 6520c3ca87 | |||
|
|
6ead4bce3d | ||
|
|
5917ae4717 |
@@ -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 { }
|
||||
}),
|
||||
|
||||
@@ -126,17 +135,32 @@ class InvoiceValidationResource extends Resource
|
||||
->label('Serial Number')
|
||||
->reactive()
|
||||
->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' => 'processSerialNumber(value)', // Using wire:keydown
|
||||
'wire:keydown.enter.prevent' => 'processSerial(value)', // Using wire:keydown
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
// ->dehydrated(false) // Do not trigger Livewire syncing
|
||||
// ->extraAttributes([
|
||||
// 'id' => 'serial_number_input',
|
||||
// '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, 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 processSerial($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';
|
||||
|
||||
@@ -5,21 +5,19 @@ namespace App\Filament\Resources;
|
||||
use App\Filament\Exports\WorkGroupMasterExporter;
|
||||
use App\Filament\Imports\WorkGroupMasterImporter;
|
||||
use App\Filament\Resources\WorkGroupMasterResource\Pages;
|
||||
use App\Filament\Resources\WorkGroupMasterResource\RelationManagers;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class WorkGroupMasterResource extends Resource
|
||||
@@ -37,68 +35,70 @@ class WorkGroupMasterResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if (!$plantId) {
|
||||
$set('pqPlantError', 'Please select a plant first.');
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
return;
|
||||
}
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
$set('validationError', null);
|
||||
$set('pqPlantError', null);
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->minLength(6)
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('work_group_masters', 'name')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('operation_number')
|
||||
->label('Operation Number')
|
||||
->numeric()
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->required()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('work_group_masters', 'operation_number')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('description')
|
||||
->label('Description')
|
||||
->required()
|
||||
->minLength(5)
|
||||
->reactive()
|
||||
->columnSpan(['default' => 1, 'sm' => 3]),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 3]),
|
||||
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('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->minLength(6)
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('work_group_masters', 'name')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('operation_number')
|
||||
->label('Operation Number')
|
||||
->numeric()
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->required(),
|
||||
// ->rule(function (callable $get) {
|
||||
// return Rule::unique('work_group_masters', 'operation_number')
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->ignore($get('id'));
|
||||
// }),
|
||||
Forms\Components\TextInput::make('description')
|
||||
->label('Description')
|
||||
->required()
|
||||
->minLength(5)
|
||||
->reactive()
|
||||
->columnSpan(['default' => 1, 'sm' => 3]),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 3]),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ class WorkGroupMasterResource extends Resource
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
@@ -177,14 +178,14 @@ class WorkGroupMasterResource extends Resource
|
||||
->label('Import Work Group Masters')
|
||||
->color('warning')
|
||||
->importer(WorkGroupMasterImporter::class)
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import work group master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Work Group Masters')
|
||||
->color('warning')
|
||||
->exporter(WorkGroupMasterExporter::class)
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export work group master');
|
||||
}),
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('work_group_masters', function (Blueprint $table) {
|
||||
$table->dropUnique('work_group_masters_plant_id_operation_number_key');
|
||||
});
|
||||
|
||||
// $sql = <<<'SQL'
|
||||
// ALTER TABLE work_group_masters
|
||||
// DROP INDEX work_group_masters_plant_id_operation_number_key;
|
||||
// SQL;
|
||||
|
||||
// DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('work_group_masters', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -12,7 +12,7 @@
|
||||
"concurrently": "^9.0.1",
|
||||
"laravel-vite-plugin": "^1.2.0",
|
||||
"postcss": "^8.4.47",
|
||||
"tailwindcss": "^3.4.13",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"vite": "^6.0.11"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user