All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
794 lines
39 KiB
PHP
794 lines
39 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Exports\TempStopCharacteristicExporter;
|
|
use App\Filament\Imports\TempStopCharacteristicImporter;
|
|
use App\Filament\Resources\TempStopCharacteristicResource\Pages;
|
|
use App\Models\Item;
|
|
use App\Models\Machine;
|
|
use App\Models\Plant;
|
|
use App\Models\TempStopCharacteristic;
|
|
use Filament\Facades\Filament;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Components\DateTimePicker;
|
|
use Filament\Forms\Components\Section;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Form;
|
|
use Filament\Forms\Get;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Actions\ExportAction;
|
|
use Filament\Tables\Actions\ImportAction;
|
|
use Filament\Tables\Filters\Filter;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
|
|
class TempStopCharacteristicResource extends Resource
|
|
{
|
|
protected static ?string $model = TempStopCharacteristic::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
|
|
protected static ?string $navigationGroup = 'Laser Marking';
|
|
|
|
protected static ?int $navigationSort = 5;
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Section::make('')
|
|
->schema([
|
|
Forms\Components\Select::make('plant_id')
|
|
->label('Plant Name')
|
|
->relationship('plant', 'name')
|
|
->reactive()
|
|
->searchable()
|
|
->options(function (callable $get) {
|
|
$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();
|
|
})
|
|
->required()
|
|
->default(function () {
|
|
$userHas = Filament::auth()->user()->plant_id;
|
|
|
|
return ($userHas && strlen($userHas) > 0) ? null : optional(TempStopCharacteristic::latest()->first())->plant_id ?? null;
|
|
})
|
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
$set('item_id', null);
|
|
$set('aufnr', null);
|
|
$set('gernr', null);
|
|
$set('machine_id', null);
|
|
$set('machine_name', null);
|
|
$set('has_stop_flow_id', '2');
|
|
$set('updated_by', Filament::auth()->user()?->name);
|
|
})
|
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
|
Forms\Components\Select::make('item_id')
|
|
->label('Item Code')
|
|
// ->relationship('item', 'id')
|
|
->reactive()
|
|
->required()
|
|
->searchable()
|
|
->options(function (callable $get) {
|
|
$plantId = $get('plant_id');
|
|
if (! $plantId) {
|
|
return [];
|
|
}
|
|
|
|
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
|
})
|
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
$set('aufnr', null);
|
|
$set('gernr', null);
|
|
$set('has_stop_flow_id', '2');
|
|
$set('updated_by', Filament::auth()->user()?->name);
|
|
})
|
|
->default(function () {
|
|
$userHas = Filament::auth()->user()->plant_id;
|
|
|
|
return ($userHas && strlen($userHas) > 0) ? null : optional(TempStopCharacteristic::latest()->first())->item_id ?? null;
|
|
})
|
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
|
Forms\Components\Select::make('machine_id')
|
|
->label('Work Center')
|
|
// ->relationship('machine', 'name')
|
|
->reactive()
|
|
->searchable()
|
|
->options(function (callable $get) {
|
|
$plantId = $get('plant_id');
|
|
if (! $plantId) {
|
|
return [];
|
|
}
|
|
|
|
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
|
})
|
|
->required()
|
|
->default(function () {
|
|
$userHas = Filament::auth()->user()->plant_id;
|
|
|
|
return ($userHas && strlen($userHas) > 0) ? null : optional(TempStopCharacteristic::latest()->first())->machine_id ?? null;
|
|
})
|
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
$set('machine_name', null);
|
|
$set('has_stop_flow_id', '2');
|
|
$set('updated_by', Filament::auth()->user()?->name);
|
|
})
|
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
|
Forms\Components\TextInput::make('machine_name')
|
|
->label('Machine Name')
|
|
->reactive()
|
|
->nullable()
|
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
$set('has_stop_flow_id', '2');
|
|
$set('updated_by', Filament::auth()->user()?->name);
|
|
})
|
|
->required()
|
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
|
Forms\Components\TextInput::make('aufnr')
|
|
->label('Job Number')
|
|
->reactive()
|
|
->numeric()
|
|
->minlength(7)
|
|
->maxlength(10)
|
|
->required(function (callable $get) {
|
|
$item = $get('item_id');
|
|
if ($item) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
})
|
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
$set('gernr', null);
|
|
$set('updated_by', Filament::auth()->user()?->name);
|
|
})
|
|
->default(function () {
|
|
$userHas = Filament::auth()->user()->plant_id;
|
|
|
|
return ($userHas && strlen($userHas) > 0) ? null : optional(TempStopCharacteristic::latest()->first())->aufnr ?? null;
|
|
})
|
|
->readOnly(fn ($get) => ($get('item_id') == null))
|
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
|
Forms\Components\TextInput::make('gernr')
|
|
->label('Serial Number')
|
|
->reactive()
|
|
->minLength(13)
|
|
->readOnly(fn (callable $get) => ! $get('aufnr'))
|
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
$set('updated_by', Filament::auth()->user()?->name);
|
|
})
|
|
->required()
|
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
|
Forms\Components\TextInput::make('zmm_heading')
|
|
->label('Zmm Heading')
|
|
->reactive()
|
|
->nullable()
|
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
$set('updated_by', Filament::auth()->user()?->name);
|
|
})
|
|
->required()
|
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
|
Forms\Components\Select::make('model_type')
|
|
->label('Model Type')
|
|
->reactive()
|
|
->nullable()
|
|
->searchable()
|
|
->required()
|
|
->options(function () {
|
|
return [
|
|
'MOTOR' => 'MOTOR',
|
|
'PUMP' => 'PUMP',
|
|
'NAME_PLATE' => 'NAME_PLATE',
|
|
'UNKNOWN' => 'UNKNOWN',
|
|
];
|
|
})
|
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
$set('updated_by', Filament::auth()->user()?->name);
|
|
})
|
|
->default('MOTOR')
|
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
|
Forms\Components\TextInput::make('characteristic_field')
|
|
->label('Master Characteristic Field')
|
|
->reactive()
|
|
->nullable()
|
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
$set('updated_by', Filament::auth()->user()?->name);
|
|
})
|
|
->required()
|
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
|
Forms\Components\TextInput::make('samlight_logged_name')
|
|
->label('SAMLight Logged Name')
|
|
->reactive()
|
|
->nullable()
|
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
$set('updated_by', Filament::auth()->user()?->name);
|
|
})
|
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
|
Forms\Components\DateTimePicker::make('stopped_at')
|
|
->label('Stopped At')
|
|
->default(now())
|
|
->reactive()
|
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
$set('updated_by', Filament::auth()->user()?->name);
|
|
})
|
|
->required(),
|
|
Forms\Components\TextInput::make('stopped_by')
|
|
->label('Stopped By')
|
|
->reactive()
|
|
->default(Filament::auth()->user()?->name)
|
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
$set('updated_by', Filament::auth()->user()?->name);
|
|
})
|
|
->required(),
|
|
Forms\Components\TextInput::make('has_stop_flow_id')
|
|
->label('Has Stop Flow ID')
|
|
->reactive()
|
|
->default('2')
|
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
$curId = $get('id');
|
|
if (! $curId) {
|
|
$set('has_stop_flow_id', '2');
|
|
}
|
|
$set('updated_by', Filament::auth()->user()?->name);
|
|
})
|
|
->required(),
|
|
Forms\Components\Hidden::make('created_by')
|
|
->label('Created By')
|
|
->default(Filament::auth()->user()?->name),
|
|
Forms\Components\Hidden::make('updated_by')
|
|
->label('Updated By')
|
|
->default(Filament::auth()->user()?->name),
|
|
Forms\Components\TextInput::make('id')
|
|
->hidden()
|
|
->readOnly(),
|
|
])
|
|
->columns(['default' => 1, 'sm' => 2]),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('No.')
|
|
->label('No.')
|
|
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
|
$paginator = $livewire->getTableRecords();
|
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
|
|
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
|
}),
|
|
Tables\Columns\TextColumn::make('plant.name')
|
|
->label('Plant Name')
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('machine.work_center')
|
|
->label('Work Center')
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('machine_name')
|
|
->label('Machine Name')
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('item.code')
|
|
->label('Item Code')
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('aufnr')
|
|
->label('Job Number')
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('gernr')
|
|
->label('Serial Number')
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('zmm_heading')
|
|
->label('Zmm Heading')
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('model_type')
|
|
->label('Model Type')
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('characteristic_field')
|
|
->label('Master Characteristic Field')
|
|
->alignCenter()
|
|
->searchable()
|
|
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
|
|
->extraAttributes(['class' => 'uppercase'])
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('samlight_logged_name')
|
|
->label('SAMLIGHT LOGGED NAME')
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('stopped_at')
|
|
->label('Stopped At')
|
|
->dateTime()
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('stopped_by')
|
|
->label('Stopped By')
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('has_stop_flow_id')
|
|
->label('Has Stop Flow ID')
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('created_at')
|
|
->label('Created At')
|
|
->dateTime()
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('created_by')
|
|
->label('Created By')
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('updated_at')
|
|
->label('Updated At')
|
|
->dateTime()
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
Tables\Columns\TextColumn::make('updated_by')
|
|
->label('Updated By')
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
Tables\Columns\TextColumn::make('deleted_at')
|
|
->label('Deleted At')
|
|
->dateTime()
|
|
->alignCenter()
|
|
->searchable()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->searchPlaceholder('Search Job / Serial Number')
|
|
->filters([
|
|
Tables\Filters\TrashedFilter::make(),
|
|
Filter::make('advanced_filters')
|
|
->label('Advanced Filters')
|
|
->form([
|
|
Select::make('Plant')
|
|
->label('Search by Plant Name')
|
|
->nullable()
|
|
->searchable()
|
|
->reactive()
|
|
->options(function (callable $get) {
|
|
$userHas = Filament::auth()->user()->plant_id;
|
|
|
|
if ($userHas && strlen($userHas) > 0) {
|
|
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
|
} else {
|
|
return Plant::whereHas('tempStopCharacteristics', 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): void {
|
|
$set('machine', null);
|
|
$set('item_id', null);
|
|
// $set('aufnr', null);
|
|
}),
|
|
Select::make('machine')
|
|
->label('Search by Work Center')
|
|
->nullable()
|
|
->searchable()
|
|
->reactive()
|
|
->options(function (callable $get) {
|
|
$plantId = $get('Plant');
|
|
|
|
if (empty($plantId)) {
|
|
return [];
|
|
}
|
|
|
|
return Machine::whereHas('tempStopCharacteristics', function ($query) use ($plantId) {
|
|
if ($plantId) {
|
|
$query->where('plant_id', $plantId);
|
|
}
|
|
})->pluck('work_center', 'id');
|
|
})
|
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
|
// $set('item_id', null);
|
|
// $set('aufnr', null);
|
|
}),
|
|
TextInput::make('machine_name')
|
|
->label('Machine Name')
|
|
->placeholder('Enter Machine Name'),
|
|
Select::make('item_id')
|
|
->label('Search by Item Code')
|
|
->nullable()
|
|
->searchable()
|
|
->reactive()
|
|
->options(function (callable $get) {
|
|
$plantId = $get('Plant');
|
|
|
|
if (empty($plantId)) {
|
|
return [];
|
|
}
|
|
|
|
return Item::whereHas('tempStopCharacteristics', function ($query) use ($plantId) {
|
|
if ($plantId) {
|
|
$query->where('plant_id', $plantId);
|
|
}
|
|
})->pluck('code', 'id');
|
|
})
|
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
|
// $set('aufnr', null);
|
|
}),
|
|
TextInput::make('aufnr')
|
|
->label('Job Number')
|
|
->placeholder('Enter Job Number')
|
|
->numeric()
|
|
->maxlength(10),
|
|
TextInput::make('gernr')
|
|
->label('Serial Number')
|
|
->placeholder('Enter Serial Number')
|
|
->numeric(),
|
|
TextInput::make('zmm_heading')
|
|
->label('Zmm Heading')
|
|
->placeholder('Enter Zmm Heading'),
|
|
Select::make('model_type')
|
|
->label('Search by Model Type')
|
|
->nullable()
|
|
->searchable()
|
|
->reactive()
|
|
->options(function (callable $get) {
|
|
$userHas = Filament::auth()->user()->plant_id;
|
|
$plantId = $get('Plant');
|
|
|
|
if ($userHas && strlen($userHas) > 0) {
|
|
return TempStopCharacteristic::where('plant_id', $userHas)->pluck('model_type', 'model_type')->toArray();
|
|
} elseif ($plantId) {
|
|
return TempStopCharacteristic::where('plant_id', $plantId)->select('model_type')->distinct()->pluck('model_type', 'model_type');
|
|
} else {
|
|
return TempStopCharacteristic::select('model_type')->distinct()->pluck('model_type', 'model_type');
|
|
}
|
|
}),
|
|
TextInput::make('characteristic_field')
|
|
->label('Master Characteristic Field')
|
|
->placeholder('Enter Master Characteristic Field'),
|
|
TextInput::make('samlight_logged_name')
|
|
->label('Samlight Logged Name')
|
|
->placeholder('Enter Samlight Logged Name'),
|
|
Select::make('stopped_by')
|
|
->label('Search by Stopped By')
|
|
->nullable()
|
|
->options(function (callable $get) {
|
|
$plantId = $get('Plant');
|
|
if (! $plantId) {
|
|
return TempStopCharacteristic::whereNotNull('stopped_by')->select('stopped_by')->distinct()->pluck('stopped_by', 'stopped_by');
|
|
} else {
|
|
return TempStopCharacteristic::where('plant_id', $plantId)->whereNotNull('stopped_by')->select('stopped_by')->distinct()->pluck('stopped_by', 'stopped_by');
|
|
}
|
|
})
|
|
->searchable()
|
|
->reactive(),
|
|
DateTimePicker::make('stopped_from')
|
|
->label('Stopped From')
|
|
->placeholder('Select From DateTime')
|
|
->reactive()
|
|
->native(false),
|
|
DateTimePicker::make('stopped_to')
|
|
->label('Stopped To')
|
|
->placeholder('Select To DateTime')
|
|
->reactive()
|
|
->native(false),
|
|
Select::make('created_by')
|
|
->label('Search by Created By')
|
|
->nullable()
|
|
->options(function (callable $get) {
|
|
$plantId = $get('Plant');
|
|
if (! $plantId) {
|
|
return TempStopCharacteristic::whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
|
|
} else {
|
|
return TempStopCharacteristic::where('plant_id', $plantId)->whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
|
|
}
|
|
})
|
|
->searchable()
|
|
->reactive(),
|
|
DateTimePicker::make('created_from')
|
|
->label('Created From')
|
|
->placeholder('Select From DateTime')
|
|
->reactive()
|
|
->native(false),
|
|
DateTimePicker::make('created_to')
|
|
->label('Created To')
|
|
->placeholder('Select To DateTime')
|
|
->reactive()
|
|
->native(false),
|
|
Select::make('updated_by')
|
|
->label('Search by Updated By')
|
|
->nullable()
|
|
->options(function (callable $get) {
|
|
$plantId = $get('Plant');
|
|
if (! $plantId) {
|
|
return TempStopCharacteristic::whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
|
} else {
|
|
return TempStopCharacteristic::where('plant_id', $plantId)->whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
|
}
|
|
})
|
|
->searchable()
|
|
->reactive(),
|
|
DateTimePicker::make(name: 'updated_from')
|
|
->label('Updated From')
|
|
->placeholder(placeholder: 'Select From DateTime')
|
|
->reactive()
|
|
->native(false),
|
|
DateTimePicker::make('updated_to')
|
|
->label('Updated To')
|
|
->placeholder(placeholder: 'Select To DateTime')
|
|
->reactive()
|
|
->native(false),
|
|
TextInput::make('has_stop_flow_id')
|
|
->label('Has Stop Flow ID')
|
|
->placeholder('Enter Has Stop Flow ID'),
|
|
])
|
|
->query(function ($query, array $data) {
|
|
// Hide all records initially if no filters are applied
|
|
if (empty($data['Plant']) && empty($data['machine']) && empty($data['machine_name']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['zmm_heading']) && empty($data['model_type']) && empty($data['characteristic_field']) && empty($data['samlight_logged_name']) && empty($data['stopped_by']) && empty($data['stopped_from']) && empty($data['stopped_to']) && empty($data['created_by']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['updated_from']) && empty($data['updated_to']) && empty($data['has_stop_flow_id'])) {
|
|
return $query->whereRaw('1 = 0');
|
|
}
|
|
|
|
if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null
|
|
$query->where('plant_id', $data['Plant']);
|
|
} else {
|
|
$userHas = Filament::auth()->user()->plant_id;
|
|
|
|
if ($userHas && strlen($userHas) > 0) {
|
|
return $query->whereRaw('1 = 0');
|
|
}
|
|
}
|
|
|
|
if (! empty($data['machine'])) {
|
|
$query->where('machine_id', $data['machine']);
|
|
}
|
|
|
|
if (! empty($data['machine_name'])) {
|
|
$query->where('machine_name', 'like', '%'.$data['machine_name'].'%');
|
|
}
|
|
|
|
if (! empty($data['item_id'])) {
|
|
$query->where('item_id', $data['item_id']);
|
|
}
|
|
|
|
if (! empty($data['aufnr'])) {
|
|
$query->where('aufnr', 'like', '%'.$data['aufnr'].'%');
|
|
}
|
|
|
|
if (! empty($data['gernr'])) {
|
|
$query->where('gernr', 'like', '%'.$data['gernr'].'%');
|
|
}
|
|
|
|
if (! empty($data['zmm_heading'])) {
|
|
$query->where('zmm_heading', 'like', '%'.$data['zmm_heading'].'%');
|
|
}
|
|
|
|
if (! empty($data['model_type'])) {
|
|
$query->where('model_type', $data['model_type']);
|
|
}
|
|
|
|
if (! empty($data['characteristic_field'])) {
|
|
$query->where('characteristic_field', 'like', '%'.$data['characteristic_field'].'%');
|
|
}
|
|
|
|
if (! empty($data['samlight_logged_name'])) {
|
|
$query->where('samlight_logged_name', 'like', '%'.$data['samlight_logged_name'].'%');
|
|
}
|
|
|
|
if (! empty($data['stopped_by'])) {
|
|
$query->where('stopped_by', $data['stopped_by']);
|
|
}
|
|
|
|
if (! empty($data['stopped_from'])) {
|
|
$query->where('stopped_at', '>=', $data['stopped_from']);
|
|
}
|
|
|
|
if (! empty($data['stopped_to'])) {
|
|
$query->where('stopped_at', '<=', $data['stopped_to']);
|
|
}
|
|
|
|
if (! empty($data['created_by'])) {
|
|
$query->where('created_by', $data['created_by']);
|
|
}
|
|
|
|
if (! empty($data['created_from'])) {
|
|
$query->where('created_at', '>=', $data['created_from']);
|
|
}
|
|
|
|
if (! empty($data['created_to'])) {
|
|
$query->where('created_at', '<=', $data['created_to']);
|
|
}
|
|
|
|
if (! empty($data['updated_by'])) {
|
|
$query->where('updated_by', $data['updated_by']);
|
|
}
|
|
|
|
if (! empty($data['updated_from'])) {
|
|
$query->where('updated_at', '>=', $data['updated_from']);
|
|
}
|
|
|
|
if (! empty($data['updated_to'])) {
|
|
$query->where('updated_at', '<=', $data['updated_to']);
|
|
}
|
|
|
|
if (! empty($data['has_stop_flow_id'])) {
|
|
$query->where('has_stop_flow_id', 'like', '%'.$data['has_stop_flow_id'].'%');
|
|
}
|
|
|
|
})
|
|
->indicateUsing(function (array $data) {
|
|
$indicators = [];
|
|
|
|
if (! empty($data['Plant'])) {
|
|
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
|
} else {
|
|
$userHas = Filament::auth()->user()->plant_id;
|
|
|
|
if ($userHas && strlen($userHas) > 0) {
|
|
return 'Plant: Choose plant to filter records.';
|
|
}
|
|
}
|
|
|
|
if (! empty($data['machine'])) {
|
|
$indicators[] = 'Work Center: '.Machine::where('id', $data['machine'])->value('work_center');
|
|
}
|
|
|
|
if (! empty($data['machine_name'])) {
|
|
$indicators[] = 'Machine Name: '.$data['machine_name'];
|
|
}
|
|
|
|
if (! empty($data['item_id'])) {
|
|
$indicators[] = 'Item Code: '.Item::where('id', $data['item_id'])->value('code');
|
|
}
|
|
|
|
if (! empty($data['aufnr'])) {
|
|
$indicators[] = 'Job No: '.$data['aufnr'];
|
|
}
|
|
|
|
if (! empty($data['gernr'])) {
|
|
$indicators[] = 'Serial No: '.$data['gernr'];
|
|
}
|
|
|
|
if (! empty($data['zmm_heading'])) {
|
|
$indicators[] = 'Zmm Heading: '.$data['zmm_heading'];
|
|
}
|
|
|
|
if (! empty($data['model_type'])) {
|
|
$indicators[] = 'Model Type: '.$data['model_type'];
|
|
}
|
|
|
|
if (! empty($data['characteristic_field'])) {
|
|
$indicators[] = 'Master Characteristic Field: '.$data['characteristic_field'];
|
|
}
|
|
|
|
if (! empty($data['work_flow_id'])) {
|
|
$indicators[] = 'Work Flow ID: '.$data['work_flow_id'];
|
|
}
|
|
|
|
if (! empty($data['samlight_logged_name'])) {
|
|
$indicators[] = 'Samlight Logged Name: '.$data['samlight_logged_name'];
|
|
}
|
|
|
|
if (! empty($data['stopped_by'])) {
|
|
$indicators[] = 'Stopped By: '.$data['stopped_by'];
|
|
}
|
|
|
|
if (! empty($data['stopped_from'])) {
|
|
$indicators[] = 'Stopped From: '.$data['stopped_from'];
|
|
}
|
|
|
|
if (! empty($data['stopped_to'])) {
|
|
$indicators[] = 'Stopped To: '.$data['stopped_to'];
|
|
}
|
|
|
|
if (! empty($data['created_by'])) {
|
|
$indicators[] = 'Created By: '.$data['created_by'];
|
|
}
|
|
|
|
if (! empty($data['created_from'])) {
|
|
$indicators[] = 'Created From: '.$data['created_from'];
|
|
}
|
|
|
|
if (! empty($data['created_to'])) {
|
|
$indicators[] = 'Created To: '.$data['created_to'];
|
|
}
|
|
|
|
if (! empty($data['updated_by'])) {
|
|
$indicators[] = 'Updated By: '.$data['updated_by'];
|
|
}
|
|
|
|
if (! empty($data['updated_from'])) {
|
|
$indicators[] = 'Updated From: '.$data['updated_from'];
|
|
}
|
|
|
|
if (! empty($data['updated_to'])) {
|
|
$indicators[] = 'Updated To: '.$data['updated_to'];
|
|
}
|
|
|
|
if (! empty($data['has_stop_flow_id'])) {
|
|
$indicators[] = 'Stop Flow ID: '.$data['has_stop_flow_id'];
|
|
}
|
|
|
|
return $indicators;
|
|
}),
|
|
])
|
|
->filtersFormMaxHeight('280px')
|
|
->actions([
|
|
Tables\Actions\ViewAction::make(),
|
|
Tables\Actions\EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
|
Tables\Actions\RestoreBulkAction::make(),
|
|
]),
|
|
])
|
|
->headerActions([
|
|
ImportAction::make()
|
|
->label('Import Temp Stop Characteristics')
|
|
->color('warning')
|
|
->importer(TempStopCharacteristicImporter::class)
|
|
->visible(function () {
|
|
return Filament::auth()->user()->can('view import temp stop characteristics');
|
|
}),
|
|
ExportAction::make()
|
|
->label('Export Temp Stop Characteristics')
|
|
->color('warning')
|
|
->exporter(TempStopCharacteristicExporter::class)
|
|
->visible(function () {
|
|
return Filament::auth()->user()->can('view export temp stop characteristics');
|
|
}),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListTempStopCharacteristics::route('/'),
|
|
'create' => Pages\CreateTempStopCharacteristic::route('/create'),
|
|
'view' => Pages\ViewTempStopCharacteristic::route('/{record}'),
|
|
'edit' => Pages\EditTempStopCharacteristic::route('/{record}/edit'),
|
|
];
|
|
}
|
|
|
|
public static function getEloquentQuery(): Builder
|
|
{
|
|
return parent::getEloquentQuery()
|
|
->withoutGlobalScopes([
|
|
SoftDeletingScope::class,
|
|
]);
|
|
}
|
|
}
|