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
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
This commit is contained in:
@@ -5,11 +5,15 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\ProcessOrderExporter;
|
use App\Filament\Exports\ProcessOrderExporter;
|
||||||
use App\Filament\Imports\ProcessOrderImporter;
|
use App\Filament\Imports\ProcessOrderImporter;
|
||||||
use App\Filament\Resources\ProcessOrderResource\Pages;
|
use App\Filament\Resources\ProcessOrderResource\Pages;
|
||||||
|
use App\Models\Item;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\ProcessOrder;
|
use App\Models\ProcessOrder;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Components\Actions\Action;
|
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\Form;
|
||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
use Filament\Forms\Set;
|
use Filament\Forms\Set;
|
||||||
@@ -18,19 +22,13 @@ use Filament\Resources\Resource;
|
|||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Filament\Tables\Actions\ExportAction;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
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 Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||||
use Smalot\PdfParser\Parser;
|
use Smalot\PdfParser\Parser;
|
||||||
use Storage;
|
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 App\Models\PalletValidation;
|
||||||
// use Dom\Text;
|
// use Dom\Text;
|
||||||
@@ -482,6 +480,7 @@ class ProcessOrderResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
@@ -561,9 +560,6 @@ class ProcessOrderResource extends Resource
|
|||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
])
|
])
|
||||||
// ->filters([
|
|
||||||
// Tables\Filters\TrashedFilter::make(),
|
|
||||||
// ])
|
|
||||||
->filters([
|
->filters([
|
||||||
Tables\Filters\TrashedFilter::make(),
|
Tables\Filters\TrashedFilter::make(),
|
||||||
Filter::make('advanced_filters')
|
Filter::make('advanced_filters')
|
||||||
@@ -574,6 +570,7 @@ class ProcessOrderResource extends Resource
|
|||||||
->nullable()
|
->nullable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -581,21 +578,19 @@ class ProcessOrderResource extends Resource
|
|||||||
$set('Item', null);
|
$set('Item', null);
|
||||||
}),
|
}),
|
||||||
Select::make('Item')
|
Select::make('Item')
|
||||||
->label('Item Code')
|
->label('Search by Item Code')
|
||||||
->nullable()
|
->nullable()
|
||||||
->searchable()
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
if(empty($plantId)) {
|
return Item::whereHas('processOrders', function ($query) use ($plantId) {
|
||||||
return [];
|
if ($plantId) {
|
||||||
|
$query->where('plant_id', $plantId);
|
||||||
}
|
}
|
||||||
|
})->pluck('code', 'id');
|
||||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
|
||||||
|
|
||||||
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
|
||||||
})
|
})
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('process_order', null);
|
$set('process_order', null);
|
||||||
}),
|
}),
|
||||||
@@ -627,6 +622,12 @@ class ProcessOrderResource extends Resource
|
|||||||
|
|
||||||
if (! empty($data['Plant'])) {
|
if (! empty($data['Plant'])) {
|
||||||
$query->where('plant_id', $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'])) {
|
if (! empty($data['Item'])) {
|
||||||
@@ -660,6 +661,12 @@ class ProcessOrderResource extends Resource
|
|||||||
|
|
||||||
if (! empty($data['Plant'])) {
|
if (! empty($data['Plant'])) {
|
||||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
$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'])) {
|
if (! empty($data['Item'])) {
|
||||||
@@ -687,7 +694,7 @@ class ProcessOrderResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $indicators;
|
return $indicators;
|
||||||
})
|
}),
|
||||||
])
|
])
|
||||||
->filtersFormMaxHeight('280px')
|
->filtersFormMaxHeight('280px')
|
||||||
->actions([
|
->actions([
|
||||||
@@ -787,6 +794,7 @@ class ProcessOrderResource extends Resource
|
|||||||
if (! $plantId || ! $itemId || ! $processOrder || ! $state) {
|
if (! $plantId || ! $itemId || ! $processOrder || ! $state) {
|
||||||
$set('received_quantity', null);
|
$set('received_quantity', null);
|
||||||
$set('machine_name', null);
|
$set('machine_name', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -815,6 +823,7 @@ class ProcessOrderResource extends Resource
|
|||||||
// })
|
// })
|
||||||
->action(function (array $data) {
|
->action(function (array $data) {
|
||||||
$username = Filament::auth()->user()->name;
|
$username = Filament::auth()->user()->name;
|
||||||
|
|
||||||
return redirect()->route('download-reprint-process-pdf', [
|
return redirect()->route('download-reprint-process-pdf', [
|
||||||
'plant' => $data['plant'],
|
'plant' => $data['plant'],
|
||||||
'item' => $data['Item'],
|
'item' => $data['Item'],
|
||||||
|
|||||||
Reference in New Issue
Block a user