Added operator_id field to ProductionQuantity and QualityValidation in report filter
This commit is contained in:
@@ -1035,6 +1035,7 @@ class ProductionQuantityResource extends Resource
|
||||
$set('Shift', null);
|
||||
$set('Item', null);
|
||||
$set('sap_msg_status', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
|
||||
//line
|
||||
@@ -1050,7 +1051,10 @@ class ProductionQuantityResource extends Resource
|
||||
return Line::where('plant_id', $plantId)
|
||||
->pluck('name', 'id');
|
||||
})
|
||||
->reactive(),
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
|
||||
//block
|
||||
Select::make('Block')
|
||||
@@ -1067,6 +1071,7 @@ class ProductionQuantityResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Shift', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
|
||||
//shift
|
||||
@@ -1085,7 +1090,10 @@ class ProductionQuantityResource extends Resource
|
||||
->where('block_id', $blockId)
|
||||
->pluck('name', 'id');
|
||||
})
|
||||
->reactive(),
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
@@ -1133,6 +1141,37 @@ class ProductionQuantityResource extends Resource
|
||||
// ->options(QualityValidation::whereNotNull('sap_msg_status')->select('sap_msg_status')->distinct()->pluck('sap_msg_status', 'sap_msg_status'))
|
||||
->reactive(),
|
||||
|
||||
Select::make('operator_id')
|
||||
->label('Created By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
$lineId = $get('Line');
|
||||
$shiftId = $get('Shift');
|
||||
if (!$plantId && !$lineId && !$shiftId)
|
||||
{
|
||||
return ProductionQuantity::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else if ($plantId && !$lineId && !$shiftId)
|
||||
{
|
||||
return ProductionQuantity::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else if ($plantId && $lineId && !$shiftId)
|
||||
{
|
||||
return ProductionQuantity::where('plant_id', $plantId)->where('line_id', $lineId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else if ($plantId && !$lineId && $shiftId)
|
||||
{
|
||||
return ProductionQuantity::where('plant_id', $plantId)->where('shift_id', $shiftId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else// if ($plantId && $lineId && $shiftId)
|
||||
{
|
||||
return ProductionQuantity::where('plant_id', $plantId)->where('line_id', $lineId)->where('shift_id', $shiftId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
@@ -1146,7 +1185,7 @@ class ProductionQuantityResource extends Resource
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
if (empty($data['Plant']) && empty($data['Shift']) && empty($data['Line']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['Item']) && empty($data['sap_msg_status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
if (empty($data['Plant']) && empty($data['Shift']) && empty($data['Line']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['Item']) && empty($data['operator_id']) && empty($data['sap_msg_status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -1185,6 +1224,11 @@ class ProductionQuantityResource extends Resource
|
||||
if ($to = $data['created_to'] ?? null) {
|
||||
$query->where('created_at', '<=', $to);
|
||||
}
|
||||
|
||||
if (!empty($data['operator_id'])) {
|
||||
$query->where('operator_id', $data['operator_id']);
|
||||
}
|
||||
|
||||
// return $query;
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
@@ -1226,6 +1270,10 @@ class ProductionQuantityResource extends Resource
|
||||
$indicators[] = 'To: ' . $data['created_to'];
|
||||
}
|
||||
|
||||
if (!empty($data['operator_id'])) {
|
||||
$indicators[] = 'Created By: ' . $data['operator_id'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user