Added view rights against plant on view report and Updated alignments and load available item code logic on resource
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s

This commit is contained in:
dhanabalan
2026-01-14 09:46:49 +05:30
parent d8e722ab0e
commit 58175a245e

View File

@@ -5,11 +5,15 @@ namespace App\Filament\Resources;
use App\Filament\Exports\ProcessOrderExporter;
use App\Filament\Imports\ProcessOrderImporter;
use App\Filament\Resources\ProcessOrderResource\Pages;
use App\Models\Item;
use App\Models\Plant;
use App\Models\ProcessOrder;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Forms\Set;
@@ -18,19 +22,13 @@ use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Smalot\PdfParser\Parser;
use Storage;
use Filament\Forms\Components\DateTimePicker;
use Filament\Tables\Filters\Filter;
use Filament\Forms\Components\Select;
use App\Models\Line;
use Filament\Forms\Components\TextInput;
use App\Models\Item;
use App\Models\User;
// use App\Models\PalletValidation;
// use Dom\Text;
@@ -482,6 +480,7 @@ class ProcessOrderResource 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')
@@ -561,9 +560,6 @@ class ProcessOrderResource extends Resource
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
// ->filters([
// Tables\Filters\TrashedFilter::make(),
// ])
->filters([
Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters')
@@ -574,6 +570,7 @@ class ProcessOrderResource extends Resource
->nullable()
->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();
})
->reactive()
@@ -581,21 +578,19 @@ class ProcessOrderResource extends Resource
$set('Item', null);
}),
Select::make('Item')
->label('Item Code')
->label('Search by Item Code')
->nullable()
->searchable()
->reactive()
->options(function (callable $get) {
$plantId = $get('Plant');
if(empty($plantId)) {
return [];
return Item::whereHas('processOrders', function ($query) use ($plantId) {
if ($plantId) {
$query->where('plant_id', $plantId);
}
return Item::where('plant_id', $plantId)->pluck('code', 'id');
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
})->pluck('code', 'id');
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('process_order', null);
}),
@@ -627,6 +622,12 @@ class ProcessOrderResource extends Resource
if (! empty($data['Plant'])) {
$query->where('plant_id', $data['Plant']);
} else {
$userHas = Filament::auth()->user()->plant_id;
if ($userHas && strlen($userHas) > 0) {
return $query->whereRaw('1 = 0');
}
}
if (! empty($data['Item'])) {
@@ -660,6 +661,12 @@ class ProcessOrderResource extends Resource
if (! empty($data['Plant'])) {
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
} else {
$userHas = Filament::auth()->user()->plant_id;
if ($userHas && strlen($userHas) > 0) {
return 'Plant: Choose plant to filter records.';
}
}
if (! empty($data['Item'])) {
@@ -687,7 +694,7 @@ class ProcessOrderResource extends Resource
}
return $indicators;
})
}),
])
->filtersFormMaxHeight('280px')
->actions([
@@ -787,6 +794,7 @@ class ProcessOrderResource extends Resource
if (! $plantId || ! $itemId || ! $processOrder || ! $state) {
$set('received_quantity', null);
$set('machine_name', null);
return;
}
@@ -815,6 +823,7 @@ class ProcessOrderResource extends Resource
// })
->action(function (array $data) {
$username = Filament::auth()->user()->name;
return redirect()->route('download-reprint-process-pdf', [
'plant' => $data['plant'],
'item' => $data['Item'],