Added validation logic against characteristics approver master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
This commit is contained in:
@@ -2875,7 +2875,7 @@ class CharacteristicsController extends Controller
|
|||||||
// $pendingCharacteristics = [];
|
// $pendingCharacteristics = [];
|
||||||
|
|
||||||
// foreach ($characteristics as $char) {
|
// foreach ($characteristics as $char) {
|
||||||
// $charName = strtolower($char['characteristic_name']) ?? null;
|
// $charName = strtoupper($char['characteristic_name']) ?? null;
|
||||||
// $pendingExists = RequestCharacteristic::where('aufnr', $jobNo)
|
// $pendingExists = RequestCharacteristic::where('aufnr', $jobNo)
|
||||||
// ->where('characteristic_name', $charName)
|
// ->where('characteristic_name', $charName)
|
||||||
// ->latest()
|
// ->latest()
|
||||||
@@ -2948,7 +2948,7 @@ class CharacteristicsController extends Controller
|
|||||||
// 'item_id' => $ItemId,
|
// 'item_id' => $ItemId,
|
||||||
// 'characteristic_approver_master_id' => $charId,
|
// 'characteristic_approver_master_id' => $charId,
|
||||||
// 'aufnr' => $jobNo,
|
// 'aufnr' => $jobNo,
|
||||||
// 'characteristic_name' => strtolower($char['characteristic_name']),
|
// 'characteristic_name' => strtoupper($char['characteristic_name']),//strtolower
|
||||||
// 'current_value' => $char['current_value'],
|
// 'current_value' => $char['current_value'],
|
||||||
// 'update_value' => $char['update_value'],
|
// 'update_value' => $char['update_value'],
|
||||||
// 'created_by' => $userName,
|
// 'created_by' => $userName,
|
||||||
@@ -3037,7 +3037,7 @@ class CharacteristicsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($charField == null || $charField == '') {
|
if ($charField == null || $charField == '') {
|
||||||
$charField = 'nil';
|
$charField = 'NIL';
|
||||||
}
|
}
|
||||||
|
|
||||||
$plant = Plant::where('code', $plantCode)->first();
|
$plant = Plant::where('code', $plantCode)->first();
|
||||||
@@ -3132,6 +3132,24 @@ class CharacteristicsController extends Controller
|
|||||||
|
|
||||||
$MachineId = $machineAgaPlant->id;
|
$MachineId = $machineAgaPlant->id;
|
||||||
|
|
||||||
|
$iCode = Item::where('code', $itemCode)->first();
|
||||||
|
if (! $iCode) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Item code '{$itemCode}' not found!",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$iCodeAgaPlant = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
||||||
|
if (! $iCodeAgaPlant) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Item code '{$itemCode}' not found for the plant code '{$plantCode}'!",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ItemId = $iCodeAgaPlant->id;
|
||||||
|
|
||||||
$pCode = CharacteristicApproverMaster::where('plant_id', $plantId)->first();
|
$pCode = CharacteristicApproverMaster::where('plant_id', $plantId)->first();
|
||||||
if (! $pCode) {
|
if (! $pCode) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@@ -3172,46 +3190,76 @@ class CharacteristicsController extends Controller
|
|||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$mNameAgaWorkCenter = CharacteristicApproverMaster::where('machine_name', $machineName)->where('machine_id', $MachineId)->first();
|
$cField = CharacteristicApproverMaster::where('characteristic_field', $charField)->first();
|
||||||
if (! $mNameAgaWorkCenter) {
|
if (! $cField) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Master characteristic field value '{$charField}' not found in characteristic approver master!",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cFieldAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('plant_id', $plantId)->first();
|
||||||
|
if (! $cFieldAgaPlant) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Master characteristic field value '{$charField}' not found for the plant code '{$plantCode}' in characteristic approver master!",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$mNameAndWorkCenter = CharacteristicApproverMaster::where('machine_name', $machineName)->where('machine_id', $MachineId)->first();
|
||||||
|
if (! $mNameAndWorkCenter) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found in characteristic approver master!",
|
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found in characteristic approver master!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$mNameAgaWorkCenterForPlant = CharacteristicApproverMaster::where('machine_name', $machineName)->where('machine_id', $MachineId)->where('plant_id', $plantId)->first();
|
$mNameAndWorkCenterAgaPlant = CharacteristicApproverMaster::where('machine_name', $machineName)->where('machine_id', $MachineId)->where('plant_id', $plantId)->first();
|
||||||
if (! $mNameAgaWorkCenterForPlant) {
|
if (! $mNameAndWorkCenterAgaPlant) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in characteristic approver master!",
|
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in characteristic approver master!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$charId = $mNameAgaWorkCenterForPlant->id;
|
$cFieldAndWorkCent = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_id', $MachineId)->first();
|
||||||
|
if (! $cFieldAndWorkCent) {
|
||||||
$iCode = Item::where('code', $itemCode)->first();
|
|
||||||
if (! $iCode) {
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Item code '{$itemCode}' not found!",
|
'status_description' => "Master characteristic field value '{$charField}' not found for the work center '{$workCenter}' in characteristic approver master!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$iCodeAgaPlant = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
$cFieldAndWorkCentAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_id', $MachineId)->where('plant_id', $plantId)->first();
|
||||||
if (! $iCodeAgaPlant) {
|
if (! $cFieldAndWorkCentAgaPlant) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Item code '{$itemCode}' not found for the plant code '{$plantCode}'!",
|
'status_description' => "Master characteristic field value '{$charField}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in characteristic approver master!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ItemId = $iCodeAgaPlant->id;
|
$cFieldAndMach = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_name', $machineName)->first();
|
||||||
|
if (! $cFieldAndMach) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Master characteristic field value '{$charField}' not found for the machine name '{$machineName}' in characteristic approver master!",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cFieldAndWorkCentAndMachAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_id', $MachineId)->where('machine_name', $machineName)->where('plant_id', $plantId)->first();
|
||||||
|
if (! $cFieldAndWorkCentAndMachAgaPlant) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', and machine name '{$machineName}' not found for the plant code '{$plantCode}' in characteristic approver master!",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$charId = $cFieldAndWorkCentAndMachAgaPlant->id;
|
||||||
|
|
||||||
$pendingCharacteristics = [];
|
$pendingCharacteristics = [];
|
||||||
|
|
||||||
foreach ($characteristics as $char) {
|
foreach ($characteristics as $char) {
|
||||||
$charName = strtolower($char['characteristic_name']) ?? null;
|
$charName = strtoupper($char['characteristic_name']) ?? null;
|
||||||
$pendingExists = RequestCharacteristic::where('plant_id', $plantId)->where('aufnr', $jobNo)->where('characteristic_name', $charName)->latest()->first();
|
$pendingExists = RequestCharacteristic::where('plant_id', $plantId)->where('aufnr', $jobNo)->where('characteristic_name', $charName)->latest()->first();
|
||||||
|
|
||||||
if ($pendingExists) {
|
if ($pendingExists) {
|
||||||
@@ -3292,7 +3340,7 @@ class CharacteristicsController extends Controller
|
|||||||
'item_id' => $ItemId,
|
'item_id' => $ItemId,
|
||||||
'characteristic_approver_master_id' => $charId,
|
'characteristic_approver_master_id' => $charId,
|
||||||
'aufnr' => $jobNo,
|
'aufnr' => $jobNo,
|
||||||
'characteristic_name' => strtolower($char['characteristic_name']),
|
'characteristic_name' => strtoupper($char['characteristic_name']), // strtolower
|
||||||
'current_value' => $char['current_value'],
|
'current_value' => $char['current_value'],
|
||||||
'update_value' => $char['update_value'],
|
'update_value' => $char['update_value'],
|
||||||
'created_by' => $userName,
|
'created_by' => $userName,
|
||||||
@@ -3720,6 +3768,8 @@ class CharacteristicsController extends Controller
|
|||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$workFlowId = strtoupper($workFlowId);
|
||||||
|
|
||||||
if (! $workFlowId) {
|
if (! $workFlowId) {
|
||||||
|
|
||||||
$records = RequestCharacteristic::with('approver')->where([
|
$records = RequestCharacteristic::with('approver')->where([
|
||||||
@@ -3782,14 +3832,14 @@ class CharacteristicsController extends Controller
|
|||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! str_ends_with(strtolower($filename), '.pdf')) {
|
// if (! str_ends_with(strtolower($filename), '.pdf')) {
|
||||||
$filename .= '.pdf';
|
// $filename .= '.pdf';
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (! Storage::disk('local')->exists($filePath)) {
|
if (! Storage::disk('local')->exists($filePath)) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => 'Pdf File not found for the provided work flow id number!',
|
'status_description' => "Pdf File not found for the provided 'Work Flow ID' number!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user