ranjith-dev #416
@@ -17,6 +17,7 @@ use Filament\Forms\Components\DateTimePicker;
|
|||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Filament\Tables\Actions\ExportAction;
|
||||||
@@ -41,20 +42,22 @@ class CharacteristicValueResource extends Resource
|
|||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->label('Plant')
|
->label('Plant Name')
|
||||||
|
->nullable()
|
||||||
->searchable()
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->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::orderBy('code')->pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->default(function () {
|
->default(function () {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(CharacteristicValue::latest()->first())->plant_id;
|
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(CharacteristicValue::latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
$set('line_id', null);
|
$set('line_id', null);
|
||||||
@@ -76,8 +79,10 @@ class CharacteristicValueResource extends Resource
|
|||||||
->hintColor('danger')
|
->hintColor('danger')
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('line_id')
|
Forms\Components\Select::make('line_id')
|
||||||
->label('Line')
|
->label('Line Name')
|
||||||
|
->nullable()
|
||||||
->searchable()
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
if (! $get('plant_id')) {
|
if (! $get('plant_id')) {
|
||||||
return [];
|
return [];
|
||||||
@@ -87,6 +92,7 @@ class CharacteristicValueResource extends Resource
|
|||||||
->pluck('name', 'id')
|
->pluck('name', 'id')
|
||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
@@ -101,11 +107,12 @@ class CharacteristicValueResource extends Resource
|
|||||||
$set('poPlantError', 'Please select a plant first.');
|
$set('poPlantError', 'Please select a plant first.');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->reactive()
|
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('item_id')
|
Forms\Components\Select::make('item_id')
|
||||||
->label('Item')
|
->label('Item Code')
|
||||||
|
->nullable()
|
||||||
->searchable()
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
if (! $get('plant_id') || ! $get('line_id')) {
|
if (! $get('plant_id') || ! $get('line_id')) {
|
||||||
return [];
|
return [];
|
||||||
@@ -115,6 +122,7 @@ class CharacteristicValueResource extends Resource
|
|||||||
->pluck('code', 'id')
|
->pluck('code', 'id')
|
||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
$set('machine_id', null);
|
$set('machine_id', null);
|
||||||
@@ -128,11 +136,12 @@ class CharacteristicValueResource extends Resource
|
|||||||
$set('poPlantError', 'Please select a plant first.');
|
$set('poPlantError', 'Please select a plant first.');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->reactive()
|
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('machine_id')
|
Forms\Components\Select::make('machine_id')
|
||||||
->label('Machine')
|
->label('Work Center')
|
||||||
|
->nullable()
|
||||||
->searchable()
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
if (! $get('plant_id') || ! $get('line_id') || ! $get('item_id')) {
|
if (! $get('plant_id') || ! $get('line_id') || ! $get('item_id')) {
|
||||||
return [];
|
return [];
|
||||||
@@ -143,6 +152,7 @@ class CharacteristicValueResource extends Resource
|
|||||||
->pluck('work_center', 'id')
|
->pluck('work_center', 'id')
|
||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
$set('process_order', null);
|
$set('process_order', null);
|
||||||
@@ -155,7 +165,6 @@ class CharacteristicValueResource extends Resource
|
|||||||
$set('poPlantError', 'Please select a plant first.');
|
$set('poPlantError', 'Please select a plant first.');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->reactive()
|
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\TextInput::make('process_order')
|
Forms\Components\TextInput::make('process_order')
|
||||||
->label('Process Order')
|
->label('Process Order')
|
||||||
@@ -325,12 +334,12 @@ class CharacteristicValueResource extends Resource
|
|||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->label('Plant')
|
->label('Plant Name')
|
||||||
->searchable()
|
->searchable()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('line.name')
|
Tables\Columns\TextColumn::make('line.name')
|
||||||
->label('Line')
|
->label('Line Name')
|
||||||
->searchable()
|
->searchable()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
@@ -340,12 +349,12 @@ class CharacteristicValueResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('item.description')
|
Tables\Columns\TextColumn::make('item.description')
|
||||||
->label('Description')
|
->label('Item Description')
|
||||||
->searchable()
|
->searchable()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('machine.work_center')
|
Tables\Columns\TextColumn::make('machine.work_center')
|
||||||
->label('Machine')
|
->label('Work Center')
|
||||||
->searchable()
|
->searchable()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
@@ -427,39 +436,32 @@ class CharacteristicValueResource extends Resource
|
|||||||
->label('Advanced Filters')
|
->label('Advanced Filters')
|
||||||
->form([
|
->form([
|
||||||
Select::make('Plant')
|
Select::make('Plant')
|
||||||
->label('Select Plant')
|
->label('Search by Plant Name')
|
||||||
->nullable()
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->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::orderBy('code')->pluck('name', 'id')->toArray();
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
|
} else {
|
||||||
|
return Plant::whereHas('characteristicValues', function ($query) {
|
||||||
|
$query->whereNotNull('id');
|
||||||
|
})->orderBy('code')->pluck('name', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('Item', null);
|
$set('Item', null);
|
||||||
|
$set('Machine', null);
|
||||||
}),
|
}),
|
||||||
Select::make('Line')
|
Select::make('Line')
|
||||||
->label('Select Line')
|
->label('Search by Line Name')
|
||||||
->nullable()
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$plantId = $get('Plant');
|
|
||||||
|
|
||||||
if (empty($plantId)) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
|
||||||
|
|
||||||
// return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
|
||||||
})
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
||||||
$set('Item', null);
|
|
||||||
}),
|
|
||||||
Select::make('Item')
|
|
||||||
->label('Item Code')
|
|
||||||
->nullable()
|
->nullable()
|
||||||
->searchable()
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
@@ -467,17 +469,44 @@ class CharacteristicValueResource extends Resource
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
return Line::whereHas('characteristicValues', function ($query) use ($plantId) {
|
||||||
|
if ($plantId) {
|
||||||
|
$query->where('plant_id', $plantId);
|
||||||
|
}
|
||||||
|
})->pluck('name', 'id');
|
||||||
// return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
// return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||||
})
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('Item', null);
|
||||||
|
$set('Machine', null);
|
||||||
|
}),
|
||||||
|
Select::make('Item')
|
||||||
|
->label('Search by Item Code')
|
||||||
|
->nullable()
|
||||||
|
->searchable()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
|
if (empty($plantId)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Item::whereHas('characteristicValues', function ($query) use ($plantId) {
|
||||||
|
if ($plantId) {
|
||||||
|
$query->where('plant_id', $plantId);
|
||||||
|
}
|
||||||
|
})->pluck('code', 'id');
|
||||||
|
// return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||||
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('process_order', null);
|
$set('process_order', null);
|
||||||
}),
|
}),
|
||||||
Select::make('Machine')
|
Select::make('Machine')
|
||||||
->label('Select Machine')
|
->label('Search by Work Center')
|
||||||
->nullable()
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
$lineId = $get('Line');
|
$lineId = $get('Line');
|
||||||
@@ -486,11 +515,13 @@ class CharacteristicValueResource extends Resource
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Machine::where('plant_id', $plantId)->where('line_id', $lineId)->pluck('work_center', 'id');
|
return Machine::whereHas('characteristicValues', function ($query) use ($plantId, $lineId) {
|
||||||
|
if ($plantId && $lineId) {
|
||||||
|
$query->where('plant_id', $plantId)->where('line_id', $lineId);
|
||||||
|
}
|
||||||
|
})->pluck('work_center', 'id');
|
||||||
// return $plantId ? 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);
|
||||||
}),
|
}),
|
||||||
@@ -546,11 +577,11 @@ class CharacteristicValueResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['process_order'])) {
|
if (! empty($data['process_order'])) {
|
||||||
$query->where('process_order', $data['process_order']);
|
$query->where('process_order', 'like', '%'.$data['process_order'].'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['coil_number'])) {
|
if (! empty($data['coil_number'])) {
|
||||||
$query->where('coil_number', $data['coil_number']);
|
$query->where('coil_number', 'like', '%'.$data['coil_number'].'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['status'])) {
|
if (! empty($data['status'])) {
|
||||||
@@ -571,7 +602,7 @@ class CharacteristicValueResource extends Resource
|
|||||||
$indicators = [];
|
$indicators = [];
|
||||||
|
|
||||||
if (! empty($data['Plant'])) {
|
if (! empty($data['Plant'])) {
|
||||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||||
} else {
|
} else {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
@@ -581,15 +612,15 @@ class CharacteristicValueResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['Line'])) {
|
if (! empty($data['Line'])) {
|
||||||
$indicators[] = 'Line: '.Line::where('id', $data['Line'])->value('name');
|
$indicators[] = 'Line Name: '.Line::where('id', $data['Line'])->value('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['Item'])) {
|
if (! empty($data['Item'])) {
|
||||||
$indicators[] = 'Item: '.Item::where('id', $data['Item'])->value('code');
|
$indicators[] = 'Item Code: '.Item::where('id', $data['Item'])->value('code');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['Machine'])) {
|
if (! empty($data['Machine'])) {
|
||||||
$indicators[] = 'Machine: '.Machine::where('id', $data['Machine'])->value('work_center');
|
$indicators[] = 'Work Center: '.Machine::where('id', $data['Machine'])->value('work_center');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['process_order'])) {
|
if (! empty($data['process_order'])) {
|
||||||
|
|||||||
@@ -786,7 +786,15 @@ class ProcessOrderResource extends Resource
|
|||||||
->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::orderBy('code')->pluck('name', 'id')->toArray();
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
|
} else {
|
||||||
|
return Plant::whereHas('processOrders', function ($query) {
|
||||||
|
$query->whereNotNull('id');
|
||||||
|
})->orderBy('code')->pluck('name', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('Item', null);
|
$set('Item', null);
|
||||||
@@ -800,6 +808,10 @@ class ProcessOrderResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
|
if (empty($plantId)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
return Line::whereHas('processOrders', function ($query) use ($plantId) {
|
return Line::whereHas('processOrders', function ($query) use ($plantId) {
|
||||||
if ($plantId) {
|
if ($plantId) {
|
||||||
$query->where('plant_id', $plantId);
|
$query->where('plant_id', $plantId);
|
||||||
@@ -817,6 +829,10 @@ class ProcessOrderResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
|
if (empty($plantId)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
return Item::whereHas('processOrders', function ($query) use ($plantId) {
|
return Item::whereHas('processOrders', function ($query) use ($plantId) {
|
||||||
if ($plantId) {
|
if ($plantId) {
|
||||||
$query->where('plant_id', $plantId);
|
$query->where('plant_id', $plantId);
|
||||||
@@ -924,7 +940,7 @@ class ProcessOrderResource extends Resource
|
|||||||
$indicators = [];
|
$indicators = [];
|
||||||
|
|
||||||
if (! empty($data['Plant'])) {
|
if (! empty($data['Plant'])) {
|
||||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||||
} else {
|
} else {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->label('Plant')
|
->label('Plant Name')
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->searchable()
|
->searchable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
@@ -101,7 +101,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
])
|
])
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('line_id')
|
Forms\Components\Select::make('line_id')
|
||||||
->label('Line')
|
->label('Line Name')
|
||||||
->reactive()
|
->reactive()
|
||||||
->searchable()
|
->searchable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
@@ -331,7 +331,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->label('Plant')
|
->label('Plant Name')
|
||||||
->searchable()
|
->searchable()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
@@ -346,7 +346,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('line.name')
|
Tables\Columns\TextColumn::make('line.name')
|
||||||
->label('Line')
|
->label('Line Name')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
@@ -425,20 +425,32 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
->label('Advanced Filters')
|
->label('Advanced Filters')
|
||||||
->form([
|
->form([
|
||||||
Select::make('Plant')
|
Select::make('Plant')
|
||||||
->label('Select Plant')
|
->label('Search by Plant Name')
|
||||||
->nullable()
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->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::orderBy('code')->pluck('name', 'id')->toArray();
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
|
} else {
|
||||||
|
return Plant::whereHas('productCharacteristicsMasters', function ($query) {
|
||||||
|
$query->whereNotNull('id');
|
||||||
|
})->orderBy('code')->pluck('name', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('Item', null);
|
$set('Item', null);
|
||||||
|
$set('Machine', null);
|
||||||
}),
|
}),
|
||||||
Select::make('Line')
|
Select::make('Line')
|
||||||
->label('Select Line')
|
->label('Search by Line Name')
|
||||||
->nullable()
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
@@ -446,34 +458,41 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
return Line::whereHas('productCharacteristicsMasters', function ($query) use ($plantId) {
|
||||||
|
if ($plantId) {
|
||||||
// return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
$query->where('plant_id', $plantId);
|
||||||
|
}
|
||||||
|
})->pluck('name', 'id');
|
||||||
})
|
})
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('Item', null);
|
$set('Machine', null);
|
||||||
}),
|
}),
|
||||||
Select::make('Item')
|
Select::make('Item')
|
||||||
->label('Search by 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 [];
|
||||||
|
}
|
||||||
|
|
||||||
return Item::whereHas('productCharacteristicsMasters', function ($query) use ($plantId) {
|
return Item::whereHas('productCharacteristicsMasters', function ($query) use ($plantId) {
|
||||||
if ($plantId) {
|
if ($plantId) {
|
||||||
$query->where('plant_id', $plantId);
|
$query->where('plant_id', $plantId);
|
||||||
}
|
}
|
||||||
})->pluck('code', 'id');
|
})->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);
|
||||||
// }),
|
// }),
|
||||||
Select::make('work_group_master')
|
Select::make('work_group_master')
|
||||||
->label('Select Work Group Master')
|
->label('Search by Group Work Center')
|
||||||
->nullable()
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
@@ -481,45 +500,65 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return WorkGroupMaster::where('plant_id', $plantId)->pluck('name', 'id');
|
return WorkGroupMaster::whereHas('productCharacteristicsMasters', function ($query) use ($plantId) {
|
||||||
|
if ($plantId) {
|
||||||
|
$query->where('plant_id', $plantId);
|
||||||
|
}
|
||||||
|
})->pluck('name', 'id');
|
||||||
// return $plantId ? 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('Machine', null);
|
$set('Machine', null);
|
||||||
}),
|
}),
|
||||||
Select::make('Machine')
|
Select::make('Machine')
|
||||||
->label('Select Machine')
|
->label('Search by Work Center')
|
||||||
->nullable()
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
$lineId = $get('Line');
|
$lineId = $get('Line');
|
||||||
|
$workGroupMasterId = $get('work_group_master');
|
||||||
|
|
||||||
if (empty($plantId) || empty($lineId)) {
|
if (empty($plantId) || empty($lineId) || empty($workGroupMasterId)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Machine::where('plant_id', $plantId)->where('line_id', $lineId)->pluck('work_center', 'id');
|
return Machine::whereHas('productCharacteristicsMasters', function ($query) use ($plantId, $lineId, $workGroupMasterId) {
|
||||||
|
if ($plantId && $lineId && $workGroupMasterId) {
|
||||||
|
$query->where('plant_id', $plantId)->where('line_id', $lineId)->where('work_group_master_id', $workGroupMasterId);
|
||||||
|
}
|
||||||
|
})->pluck('work_center', 'id');
|
||||||
// return $plantId ? 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);
|
||||||
// }),
|
// }),
|
||||||
// TextInput::make('process_order')
|
// TextInput::make('process_order')
|
||||||
// ->label('Process Order')
|
// ->label('Process Order')
|
||||||
// ->placeholder('Enter Process Order'),
|
// ->placeholder('Enter Process Order'),
|
||||||
// TextInput::make('coil_number')
|
TextInput::make('name')
|
||||||
// ->label('Coil Number')
|
->label('characteristics Name')
|
||||||
// ->placeholder(placeholder: 'Enter Coil Number'),
|
->reactive()
|
||||||
|
->placeholder(placeholder: 'Enter characteristics Name'),
|
||||||
Select::make('characteristics_type')
|
Select::make('characteristics_type')
|
||||||
->label('Characteristics Type')
|
->label('Search by Characteristics Type')
|
||||||
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->options([
|
->options([
|
||||||
'Product' => 'Product',
|
'Product' => 'Product',
|
||||||
'Process' => 'Process',
|
'Process' => 'Process',
|
||||||
]),
|
]),
|
||||||
|
Select::make('inspection_type')
|
||||||
|
->label('Search by Inspection Type')
|
||||||
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
|
->options([
|
||||||
|
'Visual' => 'Visual',
|
||||||
|
'Value' => 'Value',
|
||||||
|
]),
|
||||||
DateTimePicker::make(name: 'created_from')
|
DateTimePicker::make(name: 'created_from')
|
||||||
->label('Created From')
|
->label('Created From')
|
||||||
->placeholder(placeholder: 'Select From DateTime')
|
->placeholder(placeholder: 'Select From DateTime')
|
||||||
@@ -533,7 +572,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
])
|
])
|
||||||
->query(function ($query, array $data) {
|
->query(function ($query, array $data) {
|
||||||
// Hide all records initially if no filters are applied
|
// Hide all records initially if no filters are applied
|
||||||
if (empty($data['Plant']) && empty($data['Line']) && empty($data['Item']) && empty($data['work_group_master']) && empty($data['Machine']) && empty($data['characteristics_type']) && empty($data['created_from']) && empty($data['created_to'])) {
|
if (empty($data['Plant']) && empty($data['Line']) && empty($data['Item']) && empty($data['work_group_master']) && empty($data['Machine']) && empty($data['name']) && empty($data['characteristics_type']) && empty($data['inspection_type']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||||
return $query->whereRaw('1 = 0');
|
return $query->whereRaw('1 = 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,10 +602,18 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
$query->where('machine_id', $data['Machine']);
|
$query->where('machine_id', $data['Machine']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['name'])) {
|
||||||
|
$query->where('name', 'like', '%'.$data['name'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($data['characteristics_type'])) {
|
if (! empty($data['characteristics_type'])) {
|
||||||
$query->where('characteristics_type', $data['characteristics_type']);
|
$query->where('characteristics_type', $data['characteristics_type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['inspection_type'])) {
|
||||||
|
$query->where('inspection_type', $data['inspection_type']);
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($data['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
$query->where('created_at', '>=', $data['created_from']);
|
$query->where('created_at', '>=', $data['created_from']);
|
||||||
}
|
}
|
||||||
@@ -581,7 +628,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
$indicators = [];
|
$indicators = [];
|
||||||
|
|
||||||
if (! empty($data['Plant'])) {
|
if (! empty($data['Plant'])) {
|
||||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||||
} else {
|
} else {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
@@ -591,25 +638,33 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['Line'])) {
|
if (! empty($data['Line'])) {
|
||||||
$indicators[] = 'Line: '.Line::where('id', $data['Line'])->value('name');
|
$indicators[] = 'Line Name: '.Line::where('id', $data['Line'])->value('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['Item'])) {
|
if (! empty($data['Item'])) {
|
||||||
$indicators[] = 'Item: '.Item::where('id', $data['Item'])->value('code');
|
$indicators[] = 'Item Name: '.Item::where('id', $data['Item'])->value('code');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['work_group_master'])) {
|
if (! empty($data['work_group_master'])) {
|
||||||
$indicators[] = 'Work Group Master: '.WorkGroupMaster::where('id', $data['work_group_master'])->value('name');
|
$indicators[] = 'Group Work Center: '.WorkGroupMaster::where('id', $data['work_group_master'])->value('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['Machine'])) {
|
if (! empty($data['Machine'])) {
|
||||||
$indicators[] = 'Machine: '.Machine::where('id', $data['Machine'])->value('work_center');
|
$indicators[] = 'Work Center: '.Machine::where('id', $data['Machine'])->value('work_center');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['name'])) {
|
||||||
|
$indicators[] = 'Characteristics Name: '.$data['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['characteristics_type'])) {
|
if (! empty($data['characteristics_type'])) {
|
||||||
$indicators[] = 'Characteristics Type: '.$data['characteristics_type'];
|
$indicators[] = 'Characteristics Type: '.$data['characteristics_type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['inspection_type'])) {
|
||||||
|
$indicators[] = 'Inspection Type: '.$data['inspection_type'];
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($data['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
$indicators[] = 'From: '.$data['created_from'];
|
$indicators[] = 'From: '.$data['created_from'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
class Item extends Model
|
class Item extends Model
|
||||||
@@ -60,6 +59,11 @@ class Item extends Model
|
|||||||
return $this->hasMany(ProductCharacteristicsMaster::class);
|
return $this->hasMany(ProductCharacteristicsMaster::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function characteristicValues()
|
||||||
|
{
|
||||||
|
return $this->hasMany(CharacteristicValue::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function weightValidations()
|
public function weightValidations()
|
||||||
{
|
{
|
||||||
return $this->hasMany(WeightValidation::class);
|
return $this->hasMany(WeightValidation::class);
|
||||||
|
|||||||
@@ -56,6 +56,16 @@ class Line extends Model
|
|||||||
return $this->hasMany(ProcessOrder::class);
|
return $this->hasMany(ProcessOrder::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function productCharacteristicsMasters()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProductCharacteristicsMaster::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function characteristicValues()
|
||||||
|
{
|
||||||
|
return $this->hasMany(CharacteristicValue::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function workGroup1()
|
public function workGroup1()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group1_id', 'id');
|
return $this->belongsTo(WorkGroupMaster::class, 'work_group1_id', 'id');
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ class Machine extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'plant_id',
|
'plant_id',
|
||||||
'line_id',
|
'line_id',
|
||||||
'work_group_master_id',
|
'work_group_master_id',
|
||||||
'name',
|
'name',
|
||||||
'work_center',
|
'work_center',
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ class Machine extends Model
|
|||||||
return $this->belongsTo(Plant::class);
|
return $this->belongsTo(Plant::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function line(): BelongsTo
|
public function line(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Line::class);
|
return $this->belongsTo(Line::class);
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,11 @@ class Machine extends Model
|
|||||||
return $this->belongsTo(WorkGroupMaster::class);
|
return $this->belongsTo(WorkGroupMaster::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function productCharacteristicsMasters()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProductCharacteristicsMaster::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function testingPanelReadings()
|
public function testingPanelReadings()
|
||||||
{
|
{
|
||||||
return $this->hasMany(TestingPanelReading::class);
|
return $this->hasMany(TestingPanelReading::class);
|
||||||
@@ -42,5 +47,4 @@ class Machine extends Model
|
|||||||
{
|
{
|
||||||
return $this->hasMany(EquipmentMaster::class, 'machine_id', 'id');
|
return $this->hasMany(EquipmentMaster::class, 'machine_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,21 @@ class Plant extends Model
|
|||||||
return $this->hasMany(WorkGroupMaster::class, 'plant_id', 'id');
|
return $this->hasMany(WorkGroupMaster::class, 'plant_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function processOrders()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProcessOrder::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function productCharacteristicsMasters()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProductCharacteristicsMaster::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function characteristicValues()
|
||||||
|
{
|
||||||
|
return $this->hasMany(CharacteristicValue::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function equipmentMasters()
|
public function equipmentMasters()
|
||||||
{
|
{
|
||||||
return $this->hasMany(EquipmentMaster::class, 'plant_id', 'id');
|
return $this->hasMany(EquipmentMaster::class, 'plant_id', 'id');
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
|
|
||||||
class WorkGroupMaster extends Model
|
class WorkGroupMaster extends Model
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'plant_id',
|
'plant_id',
|
||||||
@@ -25,6 +25,11 @@ class WorkGroupMaster extends Model
|
|||||||
return $this->belongsTo(Plant::class);
|
return $this->belongsTo(Plant::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function productCharacteristicsMasters()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProductCharacteristicsMaster::class);
|
||||||
|
}
|
||||||
|
|
||||||
// public function rejectReasons()
|
// public function rejectReasons()
|
||||||
// {
|
// {
|
||||||
// return $this->hasMany(RejectReason::class, 'work_group_master_id', 'id');
|
// return $this->hasMany(RejectReason::class, 'work_group_master_id', 'id');
|
||||||
|
|||||||
Reference in New Issue
Block a user