diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 3f03147..be71528 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -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); diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 2c57f1a..6ebd109 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -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);