diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 6cc150f..6e416b8 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -591,38 +591,71 @@ class RestAuthenticationController extends AdminController if(isset($this->request->getJSON()->mobile_no)){ - $hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id') + $getAllhrData = $this->hrModel->select('level_contacts.id ,level_contacts.mobile , level_contacts.email , clients.id as client_id, clients.client_name, clients.short_name , client_branch.id as client_branch_id,client_branch.branch_name , client_branch.post_branch_id') ->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left') + ->join('clients', 'client_branch.client_id = clients.id', 'left') ->where('level_contacts.mobile', $mobile_number ) ->where('level_contacts.contact_type', 'client') - ->find(); + ->findAll(); }else if(isset($this->request->getJSON()->otp)){ $this->hrModel->where('email', $email)->where('otp', $otp)->where('contact_type', 'client')->set(['otp'=>null])->update(); - $hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id') - ->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left') - ->where('level_contacts.email', $email ) - ->where('level_contacts.contact_type', 'client') - ->find(); + $getAllhrData = $this->hrModel->select('level_contacts.id ,level_contacts.mobile , level_contacts.email , clients.id as client_id, clients.client_name, clients.short_name , client_branch.id as client_branch_id,client_branch.branch_name , client_branch.post_branch_id') + ->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left') + ->join('clients', 'client_branch.client_id = clients.id', 'left') + ->where('level_contacts.email', $email ) + ->where('level_contacts.contact_type', 'client') + ->findAll(); + } + + if(count($getAllhrData)) + { + $db2 = \Config\Database::connect('postDB'); + foreach ($getAllhrData as $key => $value) { + + $HRAccessData = $db2->table('hr_access_control hr') + ->where('hr.pre_client_id',$value['client_id']) + ->where('hr.pre_branch_id', $value['client_branch_id']) + ->where('hr.pre_hr_id', $value['id']) + ->get()->getRowArray(); + + + if (!empty($HRAccessData) && isset($HRAccessData['allowed_modules'])) { + + $decoded = json_decode($HRAccessData['allowed_modules'], true); + $getAllhrData[$key]['allowed_modules'] = $decoded; + + $token = JWTToken::encode($HRAccessData); + $getAllhrData[$key]['token'] = $token; + + } else { + $getAllhrData[$key]['allowed_modules'] = []; + $getAllhrData[$key]['token'] = ""; + } + + } } - //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'] = []; } - - $hrData['0']['token_type'] = 'pre'; - $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); + return $this->respond(['status' => 'success','code' => 200,'data' => $getAllhrData , 'post_enrollment'=> json_decode($apiResponse, true)],200); + + //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'] = []; } + + // $hrData['0']['token_type'] = 'pre'; + // $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); } else { diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index 01ff5d5..8698874 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -875,7 +875,7 @@ class sendMailNotification // $client_id = $params['client_id']; // $client_policy_id = $params['client_policy_id']; // $common = $params['common']; -data: name: name: + // data: name: name: // $clientModel = new ClientModel(); // $clientPolicyModel = new ClientPolicyModel(); // $PolicyPremium1Model = new PolicyPremium1Model(); diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 33630d0..aa201ad 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -329,84 +329,8 @@ }); - -
@@ -420,24 +344,219 @@ -