Added operator_id and scanned_status filter fields to Invoice validaitons resources and Alignment changed in filter option for Production Quantity / Quality Validation

This commit is contained in:
dhanabalan
2025-07-30 15:18:26 +05:30
parent d1f9a3176f
commit ca9695c922
3 changed files with 67 additions and 21 deletions

View File

@@ -938,6 +938,7 @@ class InvoiceValidationResource extends Resource
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {
$set('sticker_master_id', null);
$set('operator_id', null);
}),
TextInput::make('invoice_number')
->label('Invoice Number')
@@ -962,6 +963,31 @@ class InvoiceValidationResource extends Resource
})
->searchable()
->reactive(),
Select::make('operator_id')
->label('Created By')
->nullable()
->options(function (callable $get) {
$plantId = $get('Plant');
if (!$plantId)
{
return InvoiceValidation::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
}
else
{
return InvoiceValidation::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
}
})
->searchable()
->reactive(),
Select::make('scanned_status')
->label('Scanned Status')
->nullable()
->options([
'Scanned' => 'Scanned',
'Pending' => 'Pending',
])
->searchable()
->reactive(),
DateTimePicker::make(name: 'created_from')
->label('Created From')
->placeholder(placeholder: 'Select From DateTime')
@@ -975,7 +1001,7 @@ class InvoiceValidationResource extends Resource
])
->query(function ($query, array $data) {
// Hide all records initially if no filters are applied
if (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['sticker_master_id'])) {
if (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id'])) {
return $query->whereRaw('1 = 0');
}
@@ -999,6 +1025,10 @@ class InvoiceValidationResource 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')
@@ -1008,6 +1038,14 @@ class InvoiceValidationResource extends Resource
$query->whereIn('sticker_master_id', $stickerMasterIds);
}
}
if (!empty($data['scanned_status'])) {
if ($data['scanned_status'] == 'Scanned') {
$query->whereNotNull('scanned_status')->where('scanned_status', '!=', '');
} elseif ($data['scanned_status'] == 'Pending') {
$query->whereNull('scanned_status')->orWhere('scanned_status', '');
}
}
})
->indicateUsing(function (array $data) {
$indicators = [];
@@ -1024,6 +1062,15 @@ class InvoiceValidationResource extends Resource
$indicators[] = 'Serial Number: ' . $data['serial_number'];
}
if (!empty($data['sticker_master_id'])) {
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
$indicators[] = 'Item Code: ' . $itemCode;
}
if (!empty($data['operator_id'])) {
$indicators[] = 'Created By: ' . $data['operator_id'];
}
if (!empty($data['created_from'])) {
$indicators[] = 'From: ' . $data['created_from'];
}
@@ -1032,9 +1079,8 @@ class InvoiceValidationResource extends Resource
$indicators[] = 'To: ' . $data['created_to'];
}
if (!empty($data['sticker_master_id'])) {
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
$indicators[] = 'Item Code: ' . $itemCode;
if (!empty($data['scanned_status'])) {
$indicators[] = 'Scanned Status: ' . $data['scanned_status'];
}
return $indicators;

View File

@@ -1217,6 +1217,10 @@ class ProductionQuantityResource extends Resource
$query->where('sap_msg_status', $data['sap_msg_status']);
}
if (!empty($data['operator_id'])) {
$query->where('operator_id', $data['operator_id']);
}
if ($from = $data['created_from'] ?? null) {
$query->where('created_at', '>=', $from);
}
@@ -1225,10 +1229,6 @@ class ProductionQuantityResource extends Resource
$query->where('created_at', '<=', $to);
}
if (!empty($data['operator_id'])) {
$query->where('operator_id', $data['operator_id']);
}
// return $query;
})
->indicateUsing(function (array $data) {
@@ -1262,6 +1262,10 @@ class ProductionQuantityResource extends Resource
$indicators[] = 'SAP Message Status: ' . $data['sap_msg_status'];
}
if (!empty($data['operator_id'])) {
$indicators[] = 'Created By: ' . $data['operator_id'];
}
if (!empty($data['created_from'])) {
$indicators[] = 'From: ' . $data['created_from'];
}
@@ -1270,10 +1274,6 @@ class ProductionQuantityResource extends Resource
$indicators[] = 'To: ' . $data['created_to'];
}
if (!empty($data['operator_id'])) {
$indicators[] = 'Created By: ' . $data['operator_id'];
}
return $indicators;
})
])

View File

@@ -2292,10 +2292,19 @@ class QualityValidationResource extends Resource
$indicators[] = 'Serial Number: ' . $data['serial_number'];
}
if (!empty($data['sticker_master_id'])) {
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
$indicators[] = 'Item Codes: ' . $itemCode;
}
if (!empty($data['sap_msg_status'])) {
$indicators[] = 'SAP Message Status: ' . $data['sap_msg_status'];
}
if (!empty($data['operator_id'])) {
$indicators[] = 'Created By: ' . $data['operator_id'];
}
if (!empty($data['created_from'])) {
$indicators[] = 'From: ' . $data['created_from'];
}
@@ -2304,15 +2313,6 @@ 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;
}
return $indicators;
})
])