Added operator_id field to ProductionQuantity and QualityValidation in report filter
This commit is contained in:
@@ -2133,6 +2133,8 @@ class QualityValidationResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('sticker_master_id', null);
|
||||
$set('sap_msg_status', null);
|
||||
$set('Line', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Select Line')
|
||||
@@ -2153,6 +2155,7 @@ class QualityValidationResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('sticker_master_id', null);
|
||||
$set('sap_msg_status', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
@@ -2189,6 +2192,27 @@ class QualityValidationResource 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');
|
||||
if (!$plantId && !$lineId)
|
||||
{
|
||||
return QualityValidation::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else if ($plantId && !$lineId)
|
||||
{
|
||||
return QualityValidation::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else// if ($plantId && $lineId)
|
||||
{
|
||||
return QualityValidation::where('plant_id', $plantId)->where('line_id', $lineId)->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')
|
||||
@@ -2199,10 +2223,11 @@ class QualityValidationResource extends Resource
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['sap_msg_status']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['sticker_master_id'])) {
|
||||
if (empty($data['Plant']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['sap_msg_status']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['sticker_master_id'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -2219,7 +2244,7 @@ class QualityValidationResource extends Resource
|
||||
}
|
||||
|
||||
if (!empty($data['serial_number'])) {
|
||||
$query->where('serial_number',$data['serial_number']);
|
||||
$query->where('serial_number', $data['serial_number']);
|
||||
}
|
||||
|
||||
if (!empty($data['sap_msg_status'])) {
|
||||
@@ -2234,6 +2259,10 @@ class QualityValidationResource extends Resource
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
if (!empty($data['operator_id'])) {
|
||||
$query->where('operator_id', $data['operator_id']);
|
||||
}
|
||||
|
||||
if (!empty($data['sticker_master_id'])) {
|
||||
$stickerMasterIds = StickerMaster::where('item_id', $data['sticker_master_id'])
|
||||
->pluck('id')
|
||||
@@ -2275,6 +2304,10 @@ class QualityValidationResource extends Resource
|
||||
$indicators[] = 'To: ' . $data['created_to'];
|
||||
}
|
||||
|
||||
if (!empty($data['operator_id'])) {
|
||||
$indicators[] = 'Created By: ' . $data['operator_id'];
|
||||
}
|
||||
|
||||
if (!empty($data['sticker_master_id'])) {
|
||||
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
|
||||
$indicators[] = 'Item Codes: ' . $itemCode;
|
||||
|
||||
Reference in New Issue
Block a user