Merge pull request 'ranjith-dev' (#499) from ranjith-dev into master
Some checks are pending
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Waiting to run
Some checks are pending
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Waiting to run
Reviewed-on: #499
This commit was merged in pull request #499.
This commit is contained in:
@@ -211,9 +211,9 @@ class MotorTestingMasterImporter extends Importer
|
|||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Plant')
|
->exampleHeader('Plant Code')
|
||||||
->example(['1000', '1010', '1020'])
|
->example(['1000', '1010', '1020'])
|
||||||
->label('Plant')
|
->label('Plant Code')
|
||||||
->relationship(resolveUsing: 'code')
|
->relationship(resolveUsing: 'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('created_by')
|
ImportColumn::make('created_by')
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use Filament\Tables\Actions\ImportAction;
|
|||||||
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 Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class ConfigurationResource extends Resource
|
class ConfigurationResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -107,7 +108,16 @@ class ConfigurationResource extends Resource
|
|||||||
->required(),
|
->required(),
|
||||||
Forms\Components\TextInput::make('c_value')
|
Forms\Components\TextInput::make('c_value')
|
||||||
->label('Value')
|
->label('Value')
|
||||||
->required(),
|
->required()
|
||||||
|
->rule(function (callable $get) {
|
||||||
|
return Rule::unique('configurations', 'c_value')
|
||||||
|
->where('plant_id', $get('plant_id'))
|
||||||
|
->where('line_id', $get('line_id'))
|
||||||
|
->where('c_type', $get('c_type'))
|
||||||
|
->where('c_group', $get('c_group'))
|
||||||
|
->where('c_name', $get('c_name'))
|
||||||
|
->ignore($get('id')); // Ignore current record during updates
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('id')
|
Forms\Components\TextInput::make('id')
|
||||||
->hidden()
|
->hidden()
|
||||||
->readOnly(),
|
->readOnly(),
|
||||||
|
|||||||
@@ -42,9 +42,10 @@ class MotorTestingMasterResource 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')
|
||||||
->required()
|
->required()
|
||||||
|
->searchable()
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
@@ -64,6 +65,8 @@ class MotorTestingMasterResource extends Resource
|
|||||||
} else {
|
} else {
|
||||||
$set('mTmError', null);
|
$set('mTmError', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
'class' => $get('mTmError') ? 'border-red-500' : '',
|
'class' => $get('mTmError') ? 'border-red-500' : '',
|
||||||
@@ -74,6 +77,9 @@ class MotorTestingMasterResource extends Resource
|
|||||||
->label('Routine Test Time')
|
->label('Routine Test Time')
|
||||||
->default('00:40:00')
|
->default('00:40:00')
|
||||||
->required()
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
})
|
||||||
->reactive(),
|
->reactive(),
|
||||||
Forms\Components\Select::make('item_id')
|
Forms\Components\Select::make('item_id')
|
||||||
->label('Item Code')
|
->label('Item Code')
|
||||||
@@ -84,13 +90,27 @@ class MotorTestingMasterResource extends Resource
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Item::where('plant_id', $plantId)
|
if (! $get('id')) {
|
||||||
->pluck('code', 'id')
|
// whereHas
|
||||||
->toArray();
|
return Item::where('plant_id', $plantId)->whereDoesntHave('motorTestingMasters')->pluck('code', 'id');
|
||||||
|
} else {
|
||||||
|
$itemId = MotorTestingMaster::where('id', $get('id'))->first()?->item_id;
|
||||||
|
|
||||||
|
return Item::where('plant_id', $plantId)
|
||||||
|
->where(function ($query) use ($itemId) {
|
||||||
|
$query->whereDoesntHave('motorTestingMasters')
|
||||||
|
->orWhere('id', $itemId);
|
||||||
|
})
|
||||||
|
->pluck('code', 'id');
|
||||||
|
}
|
||||||
|
// return Item::where('plant_id', $plantId)->pluck('code', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->required()
|
->required()
|
||||||
->searchable()
|
->searchable()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
})
|
||||||
->rule(function (callable $get) {
|
->rule(function (callable $get) {
|
||||||
return Rule::unique('motor_testing_masters', 'item_id')
|
return Rule::unique('motor_testing_masters', 'item_id')
|
||||||
->where('plant_id', $get('plant_id'))
|
->where('plant_id', $get('plant_id'))
|
||||||
@@ -122,6 +142,8 @@ class MotorTestingMasterResource extends Resource
|
|||||||
}
|
}
|
||||||
$set('iCodeError', null);
|
$set('iCodeError', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
'class' => $get('iCodeError') ? 'border-red-500' : '',
|
'class' => $get('iCodeError') ? 'border-red-500' : '',
|
||||||
@@ -138,6 +160,9 @@ class MotorTestingMasterResource extends Resource
|
|||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
->default(1)
|
->default(1)
|
||||||
->required()
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
})
|
||||||
->reactive(),
|
->reactive(),
|
||||||
Forms\Components\Select::make('phase')
|
Forms\Components\Select::make('phase')
|
||||||
->label('Phase')
|
->label('Phase')
|
||||||
@@ -159,35 +184,57 @@ class MotorTestingMasterResource extends Resource
|
|||||||
})
|
})
|
||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
|
||||||
if ($state == 'Single' && $get('connection') == 'Star-Delta') {
|
if ($state == 'Single' && $get('connection') == 'Star-Delta') {
|
||||||
$set('phase', 'Three');
|
$set('phase', 'Three');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->default('Single')
|
->default('Single')
|
||||||
->required()
|
->required()
|
||||||
->reactive(),
|
->reactive(),
|
||||||
Forms\Components\TextInput::make('hp')
|
Forms\Components\TextInput::make('hp')
|
||||||
->label('HP')
|
->label('HP')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('kw')
|
Forms\Components\TextInput::make('kw')
|
||||||
->label('KW')
|
->label('KW')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('volt')
|
Forms\Components\TextInput::make('volt')
|
||||||
->label('Volt')
|
->label('Volt')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('current')
|
Forms\Components\TextInput::make('current')
|
||||||
->label('Current')
|
->label('Current')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('rpm')
|
Forms\Components\TextInput::make('rpm')
|
||||||
->label('RPM')
|
->label('RPM')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('torque')
|
Forms\Components\TextInput::make('torque')
|
||||||
->label('Torque')
|
->label('Torque')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('frequency')
|
Forms\Components\TextInput::make('frequency')
|
||||||
->label('Frequency')
|
->label('Frequency')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\Select::make('connection')
|
Forms\Components\Select::make('connection')
|
||||||
->label('Connection')
|
->label('Connection')
|
||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
@@ -210,12 +257,17 @@ class MotorTestingMasterResource extends Resource
|
|||||||
if ($state == 'Star-Delta') {
|
if ($state == 'Star-Delta') {
|
||||||
$set('phase', 'Three');
|
$set('phase', 'Three');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->required()
|
->required()
|
||||||
->default('Star')
|
->default('Star')
|
||||||
->reactive(),
|
->reactive(),
|
||||||
Forms\Components\TextInput::make('ins_res_limit')
|
Forms\Components\TextInput::make('ins_res_limit')
|
||||||
->label('Insulation Resistance Limit')
|
->label('Insulation Resistance Limit')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
})
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('ins_res_type')
|
Forms\Components\Select::make('ins_res_type')
|
||||||
->label('Insulation Resistance Type')
|
->label('Insulation Resistance Type')
|
||||||
@@ -236,55 +288,106 @@ class MotorTestingMasterResource extends Resource
|
|||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('res_ry_ll')
|
Forms\Components\TextInput::make('res_ry_ll')
|
||||||
->label('Resistance RY LL')
|
->label('Resistance RY LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('res_ry_ul')
|
Forms\Components\TextInput::make('res_ry_ul')
|
||||||
->label('Resistance RY UL')
|
->label('Resistance RY UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('res_yb_ll')
|
Forms\Components\TextInput::make('res_yb_ll')
|
||||||
->label('Resistance YB LL')
|
->label('Resistance YB LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('res_yb_ul')
|
Forms\Components\TextInput::make('res_yb_ul')
|
||||||
->label('Resistance YB UL')
|
->label('Resistance YB UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('res_br_ll')
|
Forms\Components\TextInput::make('res_br_ll')
|
||||||
->label('Resistance BR LL')
|
->label('Resistance BR LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('res_br_ul')
|
Forms\Components\TextInput::make('res_br_ul')
|
||||||
->label('Resistance BR UL')
|
->label('Resistance BR UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('lock_volt_limit')
|
Forms\Components\TextInput::make('lock_volt_limit')
|
||||||
->label('Lock Volt Limit')
|
->label('Lock Volt Limit')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('leak_cur_limit')
|
Forms\Components\TextInput::make('leak_cur_limit')
|
||||||
->label('Leakage Current Limit')
|
->label('Leakage Current Limit')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('lock_cur_ll')
|
Forms\Components\TextInput::make('lock_cur_ll')
|
||||||
->label('Lock Current LL')
|
->label('Lock Current LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('lock_cur_ul')
|
Forms\Components\TextInput::make('lock_cur_ul')
|
||||||
->label('Lock Current UL')
|
->label('Lock Current UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('noload_cur_ll')
|
Forms\Components\TextInput::make('noload_cur_ll')
|
||||||
->label('No Load Current LL')
|
->label('No Load Current LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('noload_cur_ul')
|
Forms\Components\TextInput::make('noload_cur_ul')
|
||||||
->label('No Load Current UL')
|
->label('No Load Current UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('noload_pow_ll')
|
Forms\Components\TextInput::make('noload_pow_ll')
|
||||||
->label('No Load Power LL')
|
->label('No Load Power LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('noload_pow_ul')
|
Forms\Components\TextInput::make('noload_pow_ul')
|
||||||
->label('No Load Power UL')
|
->label('No Load Power UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('noload_spd_ll')
|
Forms\Components\TextInput::make('noload_spd_ll')
|
||||||
->label('No Load Speed LL')
|
->label('No Load Speed LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('noload_spd_ul')
|
Forms\Components\TextInput::make('noload_spd_ul')
|
||||||
->label('No Load Speed UL')
|
->label('No Load Speed UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\Hidden::make('created_by')
|
Forms\Components\Hidden::make('created_by')
|
||||||
->default(fn () => Filament::auth()->user()?->name)
|
->default(fn () => Filament::auth()->user()?->name)
|
||||||
->required(),
|
->required(),
|
||||||
@@ -311,7 +414,7 @@ class MotorTestingMasterResource 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(),
|
||||||
@@ -458,17 +561,26 @@ class MotorTestingMasterResource 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 () {
|
// ->options(function () {
|
||||||
// return Plant::pluck('name', 'id');
|
// return Plant::pluck('name', 'id');
|
||||||
// })
|
// })
|
||||||
->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) {
|
||||||
|
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
|
} else {
|
||||||
|
return Plant::whereHas('motorTestingMasters', 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('isi_type', null);
|
$set('isi_type', null);
|
||||||
@@ -681,7 +793,7 @@ class MotorTestingMasterResource 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;
|
||||||
|
|
||||||
|
|||||||
@@ -728,6 +728,7 @@ class ProcessOrderResource extends Resource
|
|||||||
if ($uploaded instanceof TemporaryUploadedFile) {
|
if ($uploaded instanceof TemporaryUploadedFile) {
|
||||||
$originalName = $uploaded->getClientOriginalName();
|
$originalName = $uploaded->getClientOriginalName();
|
||||||
$path = 'uploads/ProcessOrder/'.$originalName;
|
$path = 'uploads/ProcessOrder/'.$originalName;
|
||||||
|
$processOrder = trim($get('process_order'));
|
||||||
|
|
||||||
// Check if file already exists
|
// Check if file already exists
|
||||||
if (Storage::disk('local')->exists($path)) {
|
if (Storage::disk('local')->exists($path)) {
|
||||||
@@ -765,34 +766,34 @@ class ProcessOrderResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the value of process_order field
|
// Get the value of process_order field
|
||||||
$processOrder = trim($get('process_order'));
|
|
||||||
|
|
||||||
if ($batchId != $processOrder) {
|
|
||||||
Notification::make()
|
|
||||||
->title('Mismatch')
|
|
||||||
->body("Batch ID ($batchId) does not match Process Order ($processOrder)")
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
|
|
||||||
return;
|
// if ($batchId != $processOrder) {
|
||||||
}
|
// Notification::make()
|
||||||
|
// ->title('Mismatch')
|
||||||
|
// ->body("Batch ID ($batchId) does not match Process Order ($processOrder)")
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
|
||||||
if ($batchId == $processOrder) {
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if ($batchId == $processOrder) {
|
||||||
// If batch matches, store the PDF permanently
|
// If batch matches, store the PDF permanently
|
||||||
$storedPath = $uploaded->storeAs(
|
$storedPath = $uploaded->storeAs(
|
||||||
'uploads/ProcessOrder',
|
'uploads/ProcessOrder',
|
||||||
$originalName,
|
$processOrder,
|
||||||
'local'
|
'local'
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Success')
|
->title('Success')
|
||||||
->body("Batch ID matches Process Order: $batchId. PDF uploaded successfully.")
|
->body("Process Order: $processOrder. PDF uploaded successfully.")
|
||||||
->success()
|
->success()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
|
|||||||
@@ -832,7 +832,7 @@ class StickerMasterResource 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;
|
||||||
|
|
||||||
|
|||||||
@@ -56,8 +56,9 @@ class TestingPanelReadingResource 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()
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
@@ -73,17 +74,19 @@ class TestingPanelReadingResource extends Resource
|
|||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
if (! $plantId) {
|
if (! $plantId) {
|
||||||
$set('line_id', null);
|
$set('line_id', null);
|
||||||
$set('item_id', null);
|
$set('motor_testing_master_id', null);
|
||||||
$set('machine_id', null);
|
$set('machine_id', null);
|
||||||
$set('tPrError', 'Please select a plant first.');
|
$set('tPrError', 'Please select a plant first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
$set('line_id', null);
|
$set('line_id', null);
|
||||||
$set('item_id', null);
|
$set('motor_testing_master_id', null);
|
||||||
$set('machine_id', null);
|
$set('machine_id', null);
|
||||||
$set('tPrError', null);
|
$set('tPrError', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
'class' => $get('tPrError') ? 'border-red-500' : '',
|
'class' => $get('tPrError') ? 'border-red-500' : '',
|
||||||
@@ -91,8 +94,9 @@ class TestingPanelReadingResource extends Resource
|
|||||||
->hint(fn ($get) => $get('tPrError') ? $get('tPrError') : null)
|
->hint(fn ($get) => $get('tPrError') ? $get('tPrError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
Forms\Components\Select::make('line_id')
|
Forms\Components\Select::make('line_id')
|
||||||
->label('Line')
|
->label('Line Name')
|
||||||
->relationship('line', 'name')
|
->relationship('line', 'name')
|
||||||
|
->searchable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
if (! $plantId) {
|
if (! $plantId) {
|
||||||
@@ -109,10 +113,14 @@ class TestingPanelReadingResource extends Resource
|
|||||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(fn (callable $set) => $set('item_id', null)),
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('motor_testing_master_id', null);
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\Select::make('machine_id')
|
Forms\Components\Select::make('machine_id')
|
||||||
->label('Machine')
|
->label('Work Center')
|
||||||
->relationship('machine', 'name')
|
->relationship('machine', 'work_center')
|
||||||
|
->searchable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$lineId = $get('line_id');
|
$lineId = $get('line_id');
|
||||||
if (! $lineId) {
|
if (! $lineId) {
|
||||||
@@ -121,7 +129,7 @@ class TestingPanelReadingResource extends Resource
|
|||||||
|
|
||||||
// Only show machines for the selected line
|
// Only show machines for the selected line
|
||||||
return Machine::where('line_id', $lineId)
|
return Machine::where('line_id', $lineId)
|
||||||
->pluck('name', 'id')
|
->pluck('work_center', 'id')
|
||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
@@ -129,7 +137,10 @@ class TestingPanelReadingResource extends Resource
|
|||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->required()
|
->required()
|
||||||
->reactive(),
|
->reactive()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\Select::make('motor_testing_master_id')
|
Forms\Components\Select::make('motor_testing_master_id')
|
||||||
->label('Item Code')
|
->label('Item Code')
|
||||||
// ->relationship('motorTestingMaster', 'item.code')
|
// ->relationship('motorTestingMaster', 'item.code')
|
||||||
@@ -163,101 +174,234 @@ class TestingPanelReadingResource extends Resource
|
|||||||
// )
|
// )
|
||||||
->required()
|
->required()
|
||||||
->searchable()
|
->searchable()
|
||||||
->reactive(),
|
->reactive()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('output')
|
Forms\Components\TextInput::make('output')
|
||||||
->label('Output')
|
->label('Output')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('serial_number')
|
Forms\Components\TextInput::make('serial_number')
|
||||||
->label('Serial Number')
|
->label('Serial Number')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('winded_serial_number')
|
Forms\Components\TextInput::make('winded_serial_number')
|
||||||
->label('Winded Serial Number'),
|
->label('Winded Serial Number')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('before_fr_volt')
|
Forms\Components\TextInput::make('before_fr_volt')
|
||||||
->label('Before FR Volt'),
|
->label('Before FR Volt')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('before_fr_cur')
|
Forms\Components\TextInput::make('before_fr_cur')
|
||||||
->label('Before FR Current'),
|
->label('Before FR Current')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('before_fr_pow')
|
Forms\Components\TextInput::make('before_fr_pow')
|
||||||
->label('Before FR Power'),
|
->label('Before FR Power')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('before_fr_res_ry')
|
Forms\Components\TextInput::make('before_fr_res_ry')
|
||||||
->label('Before FR Resistance RY'),
|
->label('Before FR Resistance RY')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('before_fr_res_yb')
|
Forms\Components\TextInput::make('before_fr_res_yb')
|
||||||
->label('Before FR Resistance YB'),
|
->label('Before FR Resistance YB')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('before_fr_res_br')
|
Forms\Components\TextInput::make('before_fr_res_br')
|
||||||
->label('Before FR Resistance BR'),
|
->label('Before FR Resistance BR')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('before_fr_ir')
|
Forms\Components\TextInput::make('before_fr_ir')
|
||||||
->label('Before FR IR'),
|
->label('Before FR IR')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('before_fr_ir_r')
|
Forms\Components\TextInput::make('before_fr_ir_r')
|
||||||
->label('Before FR IR R'),
|
->label('Before FR IR R')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('before_fr_ir_y')
|
Forms\Components\TextInput::make('before_fr_ir_y')
|
||||||
->label('Before FR IR Y'),
|
->label('Before FR IR Y')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('before_fr_ir_b')
|
Forms\Components\TextInput::make('before_fr_ir_b')
|
||||||
->label('Before FR IR B'),
|
->label('Before FR IR B')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('before_fr_freq')
|
Forms\Components\TextInput::make('before_fr_freq')
|
||||||
->label('Before FR Frequency'),
|
->label('Before FR Frequency')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('before_fr_speed')
|
Forms\Components\TextInput::make('before_fr_speed')
|
||||||
->label('Before FR Speed'),
|
->label('Before FR Speed')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_vol')
|
Forms\Components\TextInput::make('after_fr_vol')
|
||||||
->label('After FR Volt'),
|
->label('After FR Volt')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_cur')
|
Forms\Components\TextInput::make('after_fr_cur')
|
||||||
->label('After FR Current'),
|
->label('After FR Current')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_pow')
|
Forms\Components\TextInput::make('after_fr_pow')
|
||||||
->label('After FR Power'),
|
->label('After FR Power')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_ir_hot')
|
Forms\Components\TextInput::make('after_fr_ir_hot')
|
||||||
->label('After FR IR Hot'),
|
->label('After FR IR Hot')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_ir_hot_r')
|
Forms\Components\TextInput::make('after_fr_ir_hot_r')
|
||||||
->label('After FR IR Hot R'),
|
->label('After FR IR Hot R')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_ir_hot_y')
|
Forms\Components\TextInput::make('after_fr_ir_hot_y')
|
||||||
->label('After FR IR Hot Y'),
|
->label('After FR IR Hot Y')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_ir_hot_b')
|
Forms\Components\TextInput::make('after_fr_ir_hot_b')
|
||||||
->label('After FR IR Hot B'),
|
->label('After FR IR Hot B')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_ir_cool')
|
Forms\Components\TextInput::make('after_fr_ir_cool')
|
||||||
->label('After FR IR Cool'),
|
->label('After FR IR Cool')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_ir_cool_r')
|
Forms\Components\TextInput::make('after_fr_ir_cool_r')
|
||||||
->label('After FR IR Cool R'),
|
->label('After FR IR Cool R')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_ir_cool_y')
|
Forms\Components\TextInput::make('after_fr_ir_cool_y')
|
||||||
->label('After FR IR Cool Y'),
|
->label('After FR IR Cool Y')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_ir_cool_b')
|
Forms\Components\TextInput::make('after_fr_ir_cool_b')
|
||||||
->label('After FR IR Cool B'),
|
->label('After FR IR Cool B')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_freq')
|
Forms\Components\TextInput::make('after_fr_freq')
|
||||||
->label('After FR Frequency'),
|
->label('After FR Frequency')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_speed')
|
Forms\Components\TextInput::make('after_fr_speed')
|
||||||
->label('After FR Speed'),
|
->label('After FR Speed')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('after_fr_leak_cur')
|
Forms\Components\TextInput::make('after_fr_leak_cur')
|
||||||
->label('After FR Leak Current'),
|
->label('After FR Leak Current')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('locked_rt_volt')
|
Forms\Components\TextInput::make('locked_rt_volt')
|
||||||
->label('Locked RT Volt'),
|
->label('Locked RT Volt')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('locked_rt_cur')
|
Forms\Components\TextInput::make('locked_rt_cur')
|
||||||
->label('Locked RT Current'),
|
->label('Locked RT Current')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('locked_rt_pow')
|
Forms\Components\TextInput::make('locked_rt_pow')
|
||||||
->label('Locked RT Power'),
|
->label('Locked RT Power')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('no_load_pickup_volt')
|
Forms\Components\TextInput::make('no_load_pickup_volt')
|
||||||
->label('No Load Pickup Volt'),
|
->label('No Load Pickup Volt')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('room_temperature')
|
Forms\Components\TextInput::make('room_temperature')
|
||||||
->label('Room Temperature'),
|
->label('Room Temperature')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('hv_test')
|
Forms\Components\TextInput::make('hv_test')
|
||||||
->label('High Voltage Test'),
|
->label('High Voltage Test')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('batch_number')
|
Forms\Components\TextInput::make('batch_number')
|
||||||
->label('Batch Number'),
|
->label('Batch Number')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('batch_count')
|
Forms\Components\TextInput::make('batch_count')
|
||||||
->label('Batch Count')
|
->label('Batch Count')
|
||||||
->default('0'),
|
->default('0')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('result')
|
Forms\Components\TextInput::make('result')
|
||||||
->label('Result'),
|
->label('Result')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('remark')
|
Forms\Components\TextInput::make('remark')
|
||||||
->label('Remark'),
|
->label('Remark')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('rework_count')
|
Forms\Components\TextInput::make('rework_count')
|
||||||
->label('Rework Count')
|
->label('Rework Count')
|
||||||
->default('0'),
|
->default('0')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('update_count')
|
Forms\Components\TextInput::make('update_count')
|
||||||
->label('Update Count')
|
->label('Update Count')
|
||||||
->default('0'),
|
->default('0')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('output_flag')
|
Forms\Components\TextInput::make('output_flag')
|
||||||
->label('Output Flag')
|
->label('Output Flag')
|
||||||
->default('0'),
|
->default('0')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('tested_by')
|
Forms\Components\TextInput::make('tested_by')
|
||||||
->label('Tested By'),
|
->label('Tested By')
|
||||||
|
->default(fn () => Filament::auth()->user()?->name)
|
||||||
|
->required(),
|
||||||
Forms\Components\TextInput::make('updated_by')
|
Forms\Components\TextInput::make('updated_by')
|
||||||
->label('Updated By'),
|
->label('Updated By')
|
||||||
|
->default(fn () => Filament::auth()->user()?->name)
|
||||||
|
->required(),
|
||||||
Forms\Components\TextInput::make('id')
|
Forms\Components\TextInput::make('id')
|
||||||
->hidden()
|
->hidden()
|
||||||
->readOnly(),
|
->readOnly(),
|
||||||
@@ -283,17 +427,20 @@ class TestingPanelReadingResource 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')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('line.name')
|
Tables\Columns\TextColumn::make('line.name')
|
||||||
->label('Line')
|
->label('Line Name')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('machine.name')
|
Tables\Columns\TextColumn::make('machine.work_center')
|
||||||
->label('Machine')
|
->label('Work Center')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('motorTestingMaster.item.code')
|
Tables\Columns\TextColumn::make('motorTestingMaster.item.code')
|
||||||
->label('Item Code')
|
->label('Item Code')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
|
Tables\Columns\TextColumn::make('motorTestingMaster.subassembly_code')
|
||||||
|
->label('Subassembly Code')
|
||||||
|
->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('motorTestingMaster.item.description')
|
Tables\Columns\TextColumn::make('motorTestingMaster.item.description')
|
||||||
->label('Model')
|
->label('Model')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
@@ -477,13 +624,22 @@ class TestingPanelReadingResource extends Resource
|
|||||||
->label('Advanced Filters')
|
->label('Advanced Filters')
|
||||||
->form([
|
->form([
|
||||||
Select::make('Plant')
|
Select::make('Plant')
|
||||||
->label('Select Plant')
|
->label('Search by Plant Name')
|
||||||
|
->searchable()
|
||||||
->nullable()
|
->nullable()
|
||||||
->options(function () {
|
->options(function () {
|
||||||
// return Plant::pluck('name', 'id');
|
// return Plant::pluck('name', 'id');
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
|
} else {
|
||||||
|
return Plant::whereHas('testingPanelReadings', 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();
|
//return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
@@ -492,7 +648,8 @@ class TestingPanelReadingResource extends Resource
|
|||||||
|
|
||||||
}),
|
}),
|
||||||
Select::make('Line')
|
Select::make('Line')
|
||||||
->label('Select Line')
|
->label('Search by Line Name')
|
||||||
|
->searchable()
|
||||||
->nullable()
|
->nullable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
@@ -507,11 +664,11 @@ class TestingPanelReadingResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('item_code', null);
|
$set('item_code', null);
|
||||||
|
|
||||||
}),
|
}),
|
||||||
Select::make('item_code')
|
Select::make('item_code')
|
||||||
->label('Item Code')
|
->label('Search by Item Code')
|
||||||
->searchable()
|
->searchable()
|
||||||
|
->nullable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
if ($plantId) {
|
if ($plantId) {
|
||||||
@@ -520,15 +677,20 @@ class TestingPanelReadingResource extends Resource
|
|||||||
->pluck('code', 'id')
|
->pluck('code', 'id')
|
||||||
->toArray();
|
->toArray();
|
||||||
} else {
|
} else {
|
||||||
return Item::whereHas('motorTestingMasters')
|
return [];
|
||||||
->pluck('code', 'id')
|
// return Item::whereHas('motorTestingMasters')
|
||||||
->toArray();
|
// ->pluck('code', 'id')
|
||||||
|
// ->toArray();
|
||||||
}
|
}
|
||||||
// return [];
|
|
||||||
})
|
})
|
||||||
->reactive(),
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('item_description', null);
|
||||||
|
}),
|
||||||
Select::make('machine_name')
|
Select::make('machine_name')
|
||||||
->label('Machine Name')
|
->label('Search by Work Center')
|
||||||
|
->searchable()
|
||||||
|
->nullable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
$lineId = $get('Line');
|
$lineId = $get('Line');
|
||||||
@@ -539,30 +701,43 @@ class TestingPanelReadingResource extends Resource
|
|||||||
|
|
||||||
return Machine::where('plant_id', $plantId)
|
return Machine::where('plant_id', $plantId)
|
||||||
->where('line_id', $lineId)
|
->where('line_id', $lineId)
|
||||||
->pluck('name', 'id')
|
->pluck('work_center', 'id')
|
||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
->reactive(),
|
->reactive(),
|
||||||
TextInput::make('serial_number')
|
TextInput::make('serial_number')
|
||||||
->label('Serial Number')
|
->label('Serial Number')
|
||||||
->reactive()
|
->reactive()
|
||||||
->placeholder(placeholder: 'Enter Serial Number'),
|
->placeholder('Enter Serial Number'),
|
||||||
Select::make('item_description')
|
Select::make('item_description')
|
||||||
->label('Model')
|
->label('Model')
|
||||||
->searchable()
|
->searchable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
$query = Item::query();
|
// $query = Item::query();
|
||||||
|
// if ($plantId) {
|
||||||
|
// $query->where('plant_id', $plantId);
|
||||||
|
// }
|
||||||
|
|
||||||
|
$plantId = $get('Plant');
|
||||||
if ($plantId) {
|
if ($plantId) {
|
||||||
$query->where('plant_id', $plantId);
|
return Item::where('plant_id', $plantId)
|
||||||
|
->whereHas('motorTestingMasters')
|
||||||
|
->pluck('description', 'id')
|
||||||
|
->toArray();
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
// return Item::whereHas('motorTestingMasters')
|
||||||
|
// ->pluck('description', 'id')
|
||||||
|
// ->toArray();
|
||||||
}
|
}
|
||||||
|
//return $query->pluck('description', 'description')->toArray();
|
||||||
return $query->pluck('description', 'description')->toArray();
|
|
||||||
|
|
||||||
})
|
})
|
||||||
->reactive(),
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('item_code', null);
|
||||||
|
}),
|
||||||
Select::make('output')
|
Select::make('output')
|
||||||
->label('Output')
|
->label('Output')
|
||||||
->searchable()
|
->searchable()
|
||||||
@@ -702,12 +877,23 @@ class TestingPanelReadingResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['item_description'])) {
|
if (! empty($data['item_description'])) {
|
||||||
$item = Item::where('description', $data['item_description'])->first();
|
$itemId = $data['item_description']; // Item::where('description', $data['item_description'])->first()?->id ?? null;
|
||||||
|
|
||||||
if ($item) {
|
if ($itemId) { // $item
|
||||||
$query->whereHas('motorTestingMaster', function ($subQuery) use ($item) {
|
$mastId = MotorTestingMaster::where('item_id', $itemId)->first()?->id ?? null;
|
||||||
$subQuery->where('item_id', $item->id);
|
if ($mastId) { // $item
|
||||||
});
|
$motId = TestingPanelReading::where('motor_testing_master_id', $mastId)->first()?->id ?? null;
|
||||||
|
if ($motId) { // $item
|
||||||
|
$query->where('motor_testing_master_id', $mastId);
|
||||||
|
// $query->whereHas('motorTestingMaster', function ($subQuery) use ($itemId) {
|
||||||
|
// $subQuery->where('item_id', $itemId); //$item->id
|
||||||
|
// });
|
||||||
|
} else {
|
||||||
|
$query->whereRaw('1 = 0');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$query->whereRaw('1 = 0');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$query->whereRaw('1 = 0');
|
$query->whereRaw('1 = 0');
|
||||||
}
|
}
|
||||||
@@ -756,7 +942,7 @@ class TestingPanelReadingResource 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;
|
||||||
|
|
||||||
@@ -765,26 +951,27 @@ class TestingPanelReadingResource 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_code'])) {
|
if (! empty($data['item_code'])) {
|
||||||
$indicators[] = 'Item Code: '.Item::where('id', $data['item_code'])->value('code');
|
$indicators[] = 'Item Code: '.Item::where('id', $data['item_code'])->value('code');
|
||||||
}
|
}
|
||||||
if (! empty($data['machine_name'])) {
|
if (! empty($data['machine_name'])) {
|
||||||
$indicators[] = 'Machine: '.Machine::where('id', $data['machine_name'])->value('name');
|
$indicators[] = 'Work Center: '.Machine::where('id', $data['machine_name'])->value('work_center');
|
||||||
}
|
}
|
||||||
if (! empty($data['output'])) {
|
if (! empty($data['output'])) {
|
||||||
$indicators[] = 'Output: '.$data['output'];
|
$indicators[] = 'Output: '.$data['output'];
|
||||||
}
|
}
|
||||||
if (! empty($data['item_description'])) {
|
if (! empty($data['item_description'])) {
|
||||||
$indicators[] = 'Model: '.$data['item_description'];
|
$item = Item::where('id', $data['item_description'])->first()?->description ?? null;
|
||||||
|
$indicators[] = 'Model: '.$item;
|
||||||
}
|
}
|
||||||
// if (!empty($data['phase'])) {
|
// if (!empty($data['phase'])) {
|
||||||
// $indicators[] = 'Phase: ' . $data['phase'];
|
// $indicators[] = 'Phase: ' . $data['phase'];
|
||||||
// }
|
// }
|
||||||
// if (!empty($data['connection'])) {
|
if (!empty($data['connection'])) {
|
||||||
// $indicators[] = 'Connection: ' . $data['connection'];
|
$indicators[] = 'Connection: ' . $data['connection'];
|
||||||
// }
|
}
|
||||||
if (! empty($data['remark'])) {
|
if (! empty($data['remark'])) {
|
||||||
$indicators[] = 'Remark: '.$data['remark'];
|
$indicators[] = 'Remark: '.$data['remark'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class Item extends Model
|
|||||||
|
|
||||||
public function motorTestingMasters()
|
public function motorTestingMasters()
|
||||||
{
|
{
|
||||||
return $this->hasMany(MotorTestingMaster::class);
|
return $this->hasMany(MotorTestingMaster::class, 'item_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testingPanelReadings()
|
public function testingPanelReadings()
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ class Plant extends Model
|
|||||||
return $this->hasMany(QualityValidation::class, 'plant_id', 'id');
|
return $this->hasMany(QualityValidation::class, 'plant_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function motorTestingMasters()
|
||||||
|
{
|
||||||
|
return $this->hasMany(MotorTestingMaster::class, 'plant_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function testingPanelReadings()
|
public function testingPanelReadings()
|
||||||
{
|
{
|
||||||
return $this->hasMany(TestingPanelReading::class, 'plant_id', 'id');
|
return $this->hasMany(TestingPanelReading::class, 'plant_id', 'id');
|
||||||
|
|||||||
Reference in New Issue
Block a user