Added operator_id and production_order column, and searchable filter in view and removed chunkSize in import action
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Models\Item;
|
|||||||
use App\Models\ProductionQuantity;
|
use App\Models\ProductionQuantity;
|
||||||
use App\Models\Shift;
|
use App\Models\Shift;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
@@ -46,7 +47,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
->reactive()
|
->reactive()
|
||||||
->columnSpan(1)
|
->columnSpan(2) //1
|
||||||
// ->default(fn () => optional(ProductionQuantity::latest()->first())->plant_id)
|
// ->default(fn () => optional(ProductionQuantity::latest()->first())->plant_id)
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(ProductionQuantity::latest()->first())->plant_id;
|
return optional(ProductionQuantity::latest()->first())->plant_id;
|
||||||
@@ -98,6 +99,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
Forms\Components\Select::make('block_name')
|
Forms\Components\Select::make('block_name')
|
||||||
|
->label('Block')
|
||||||
->required()
|
->required()
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
->columnSpan(1)
|
->columnSpan(1)
|
||||||
@@ -151,6 +153,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
Forms\Components\Select::make('shift_id')
|
Forms\Components\Select::make('shift_id')
|
||||||
->relationship('shift', 'name')
|
->relationship('shift', 'name')
|
||||||
->required()
|
->required()
|
||||||
|
->columnSpan(1)
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
if (!$get('plant_id') || !$get('block_name')) {
|
if (!$get('plant_id') || !$get('block_name')) {
|
||||||
@@ -202,6 +205,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
Forms\Components\Select::make('line_id')
|
Forms\Components\Select::make('line_id')
|
||||||
->relationship('line', 'name')
|
->relationship('line', 'name')
|
||||||
->required()
|
->required()
|
||||||
|
->columnSpan(2)
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
// ->options(fn (callable $get) =>
|
// ->options(fn (callable $get) =>
|
||||||
// \App\Models\Line::where('plant_id', $get('plant_id'))
|
// \App\Models\Line::where('plant_id', $get('plant_id'))
|
||||||
@@ -288,12 +292,29 @@ class ProductionQuantityResource extends Resource
|
|||||||
// // ->autocapitalize('item_code'),
|
// // ->autocapitalize('item_code'),
|
||||||
// // //->columnSpanFull(),
|
// // //->columnSpanFull(),
|
||||||
// Virtual field for code input (not stored in DB)
|
// Virtual field for code input (not stored in DB)
|
||||||
|
Forms\Components\TextInput::make('production_order')
|
||||||
|
->label('Production Order')
|
||||||
|
->reactive()
|
||||||
|
->required()
|
||||||
|
->columnSpan(2)
|
||||||
|
->disabled(function ($get) {
|
||||||
|
return $get('item_code');
|
||||||
|
})
|
||||||
|
->default(function () {
|
||||||
|
// Get the latest 'item_id' foreign key from 'production_quantities' table
|
||||||
|
$latestProductionOrder = ProductionQuantity::latest()->first()->production_order;
|
||||||
|
return $latestProductionOrder ?? null;
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('item_code')
|
Forms\Components\TextInput::make('item_code')
|
||||||
->label('Item Code')
|
->label('Item Code')
|
||||||
// ->required()
|
// ->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->columnSpan(2)
|
||||||
->autofocus(true)
|
->autofocus(true)
|
||||||
->debounce(100)
|
->debounce(100)
|
||||||
|
->disabled(function ($get) {
|
||||||
|
return !$get('production_order');
|
||||||
|
})
|
||||||
// ->submitOnEnter()
|
// ->submitOnEnter()
|
||||||
->afterStateUpdated(function ($state, callable $get, callable $set) {
|
->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||||
$set('success_msg', null);
|
$set('success_msg', null);
|
||||||
@@ -672,6 +693,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
->title('Invalid Serial Number')
|
->title('Invalid Serial Number')
|
||||||
->body("Serial Number must contain alpha-numeric values only.")
|
->body("Serial Number must contain alpha-numeric values only.")
|
||||||
->danger()
|
->danger()
|
||||||
|
->duration(800)
|
||||||
->send();
|
->send();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -686,6 +708,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
->title('Invalid Serial Number')
|
->title('Invalid Serial Number')
|
||||||
->body("Serial Number must be at least 9 digits.")
|
->body("Serial Number must be at least 9 digits.")
|
||||||
->danger()
|
->danger()
|
||||||
|
->duration(800)
|
||||||
->send();
|
->send();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -811,6 +834,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
Forms\Components\TextInput::make('recent_qr') //item_description
|
Forms\Components\TextInput::make('recent_qr') //item_description
|
||||||
->label('Last scanned QR')
|
->label('Last scanned QR')
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->columnSpan(2)
|
||||||
->default(function () {
|
->default(function () {
|
||||||
// Get the latest 'item_id' foreign key from 'production_quantities' table
|
// Get the latest 'item_id' foreign key from 'production_quantities' table
|
||||||
$latestProductionQuantity = ProductionQuantity::latest()->first();
|
$latestProductionQuantity = ProductionQuantity::latest()->first();
|
||||||
@@ -831,8 +855,11 @@ class ProductionQuantityResource extends Resource
|
|||||||
Forms\Components\TextInput::make('id')
|
Forms\Components\TextInput::make('id')
|
||||||
->hidden()
|
->hidden()
|
||||||
->readOnly(),
|
->readOnly(),
|
||||||
|
Forms\Components\Hidden::make('operator_id')
|
||||||
|
->default(Filament::auth()->user()->name),
|
||||||
|
|
||||||
])
|
])
|
||||||
->columns(6),
|
->columns(12), //6
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -845,15 +872,20 @@ class ProductionQuantityResource extends Resource
|
|||||||
->numeric()
|
->numeric()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('item.code')
|
Tables\Columns\TextColumn::make('item.code')
|
||||||
->sortable(),
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('serial_number')
|
Tables\Columns\TextColumn::make('serial_number')
|
||||||
->sortable(),
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('line.name')
|
Tables\Columns\TextColumn::make('line.name')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('shift.name')
|
Tables\Columns\TextColumn::make('shift.name')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('operator_id')
|
||||||
|
->label('Operator ID')
|
||||||
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
@@ -883,8 +915,8 @@ class ProductionQuantityResource extends Resource
|
|||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
ImportAction::make()
|
ImportAction::make()
|
||||||
->importer(ProductionQuantityImporter::class)
|
->importer(ProductionQuantityImporter::class),
|
||||||
->chunkSize(1000),
|
// ->chunkSize(250),
|
||||||
// ->maxRows(100000),
|
// ->maxRows(100000),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->exporter(ProductionQuantityExporter::class),
|
->exporter(ProductionQuantityExporter::class),
|
||||||
|
|||||||
Reference in New Issue
Block a user