CHANGES_ HR api Hr access control change : GWM

This commit is contained in:
Gowtham M 2025-06-27 14:56:52 +05:30
parent a61c17efa4
commit 1b0a1c2099
2 changed files with 41 additions and 1 deletions

View File

@ -2490,12 +2490,29 @@ class EmployeeRestController extends AdminController
public function getPolicyLevelEmployeeSummaryData()
{
$hr_id = $this->request->getGet('hr_id');
$restAuthController = new RestAuthenticationController;
//call and get allowed policy data from post enrollment
$queryParams = [
'hr_id' => $hr_id,
'request_for' => 'pre_enrollment'
];
$HRAccessRes = $restAuthController->callThirdPartyGETAPI($queryParams,'getHRAccessData');
$HRAccessData = json_decode($HRAccessRes,true);
if(isset($HRAccessData['data']['allowed_pre_policies']))
{
$policyId = json_decode($HRAccessData['data']['allowed_pre_policies'],true);
}else{
$policyId = [];
}
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type ')
->where('client_policy.client_id', $this->request->getGet('client_id') )
->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') )
->where('client_policy.is_active', 1 )
->where('client_policy.policy_status', 1)
->whereIn('client_policy.id', $policyId)
->findAll();
$result = [];
// dd( $ClientPolicyData);

View File

@ -73,6 +73,20 @@ class RestAuthenticationController extends AdminController
return $response->getBody();
}
public function callThirdPartyGETAPI($queryParams, $endPoint)
{
$client = \Config\Services::curlrequest();
$url = env('POST_ENROLLMENT_BASEURL') . $endPoint;
$response = $client->get($url, [
'query' => $queryParams, // pass as query parameters
'http_errors' => false // prevent exception on non-200 status
]);
return $response->getBody();
}
// employee auth api's start
@ -418,8 +432,17 @@ class RestAuthenticationController extends AdminController
->find();
}
//call and get allowed module data from post enrollment
$queryParams = [
'hr_id' => $hrData['0']['id'],
'request_for' => 'pre_enrollment'
];
$HRAccessRes = $this->callThirdPartyGETAPI($queryParams,'getHRAccessData');
$HRAccessData = json_decode($HRAccessRes,true);
if(isset($HRAccessData['data']['allowed_modules'])){ $hrData['0']['allowed_modules'] = json_decode($HRAccessData['data']['allowed_modules'],true)['pre']; }else{ $hrData['0']['allowed_modules'] = []; }
$result = JWTToken::encode($hrData['0']);
// Call the third-party API function
$apiResponse = $this->callThirdPartyAPI($this->request->getJSON(),'getVerifiedHrData');
return $this->respond(['status' => 'success','code' => 200,'data' => $result , 'post_enrollment'=> json_decode($apiResponse, true)],200);