Merge branch 'dev' of bitbucket.org:jubilian/nhance-enrollment into dev
This commit is contained in:
commit
ef057590c9
@ -435,6 +435,7 @@ $routes->post("/employeeRest/verifyEmployeeEmailId", "RestAuthenticationControll
|
||||
|
||||
//HR login api's
|
||||
$routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber");
|
||||
$routes->post("/employeeRest/verifyHrWithEmail", "RestAuthenticationController::verifyHrWithEmail");
|
||||
$routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController::getVerifiedHrData");
|
||||
|
||||
$routes->group("/api", ["filter" => "authJWT"], function ($routes) {
|
||||
@ -476,7 +477,8 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
$routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn");
|
||||
|
||||
$routes->get("exportDataByClientPolicyId", "EmployeeRestController::exportDataByClientPolicyId");
|
||||
$routes->get("getCashDepositData", "EmployeeRestController::getCashDepositData");
|
||||
|
||||
$routes->get("getPolicyLevelEmployeeSummaryData", "EmployeeRestController::getPolicyLevelEmployeeSummaryData");
|
||||
$routes->get("exportCashDepositData", "EmployeeRestController::exportCashDepositData");
|
||||
|
||||
$routes->get("removeEmpAndEmpPolicyData", "EmployeeRestController::removeEmpAndEmpPolicyData");
|
||||
|
||||
@ -230,16 +230,23 @@ class EmployeeRestController extends AdminController
|
||||
try {
|
||||
$data = $this->request->getJSON();
|
||||
|
||||
// dd($data);
|
||||
|
||||
$validationFailed = $this->employeeHelper->validation_addEmployeeAndDependence($data);
|
||||
|
||||
if($validationFailed){
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "validation_addEmployeeAndDependence failed ..!!"], 404);
|
||||
//enrolment check
|
||||
$openForEnrollment = $this->findThePolicyIsOpenForEnrollment($data[0]->client_policy_id);
|
||||
if($openForEnrollment == false){
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => [],'message' => 'Enrollment closed.'], 200);
|
||||
}
|
||||
|
||||
$openForEnrollment = $this->findThePolicyIsOpenForEnrollment($data[0]->client_policy_id);
|
||||
if($openForEnrollment == false){ return $this->respond(['status' => 'failed','code' => 404,'data' => 'Enrollment closed'], 404); }
|
||||
//dependent duplicate check
|
||||
if ( ! isset($data[0]->id) ) {
|
||||
$validationFailed = $this->employeeHelper->validation_addEmployeeAndDependence($data);
|
||||
|
||||
if($validationFailed){
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => [],'message' => "Relation already exists."], 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($data) {
|
||||
|
||||
@ -288,14 +295,14 @@ class EmployeeRestController extends AdminController
|
||||
$this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code , $data[0]->client_branch_id);
|
||||
|
||||
$result = [];
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result,'message' => "Successfully updated."], 200);
|
||||
} else {
|
||||
$result = "No Matches";
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 404);
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result,'message' => "Action failed."], 200);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage(),'message' => "Action failed."], 500);
|
||||
}
|
||||
|
||||
}
|
||||
@ -2480,72 +2487,68 @@ class EmployeeRestController extends AdminController
|
||||
}
|
||||
|
||||
|
||||
public function getCashDepositData()
|
||||
public function getPolicyLevelEmployeeSummaryData()
|
||||
{
|
||||
|
||||
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.client_id as clientId , client_policy.insurer_id as insurerId,insurers.name as insurer_name')
|
||||
->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
|
||||
->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)
|
||||
->groupBy('client_policy.insurer_id')
|
||||
->findAll();
|
||||
$result = [];
|
||||
$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 = [];
|
||||
}
|
||||
|
||||
if(count($ClientPolicyData))
|
||||
{
|
||||
foreach ($ClientPolicyData as $key => $value) {
|
||||
if(count($policyId) == 0){
|
||||
return $this->respond(['status' => 'failed','code' => (count($policyId) ? 200 : 404),'data' => [] ], 200);
|
||||
}
|
||||
|
||||
|
||||
$data['clientId'] = $value['clientId'];
|
||||
$data['insurerId'] = $value['insurerId'];
|
||||
$data['insurerName'] = $value['insurer_name'];
|
||||
$data['depositData'] = $this->clientPolicyModel->getdepositData($value['clientId'],$value['insurerId']);
|
||||
$data['balance'] = count($data['depositData']) ? $data['depositData'][0]->balance : 0;
|
||||
|
||||
$data['policyDetails'] = [];
|
||||
$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.insurer_id', $value['insurerId'] )
|
||||
->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)
|
||||
->findAll();
|
||||
// dd( $ClientPolicyData);
|
||||
foreach ($ClientPolicyData as $key => $value)
|
||||
|
||||
$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);
|
||||
foreach ($ClientPolicyData as $key => $value)
|
||||
{
|
||||
$policyTypeData = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow();
|
||||
$value['type'] = $policyTypeData->policy_type;
|
||||
$value['policy_name'] = $policyTypeData->long_name;
|
||||
$employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0,branch_id:$this->request->getGet('client_branch_id'));
|
||||
$enrolledCount = 0;
|
||||
$draftCount = 0;
|
||||
if(count($employeeDetails))
|
||||
{
|
||||
$policyTypeData = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow();
|
||||
$value['type'] = $policyTypeData->policy_type;
|
||||
$value['policy_name'] = $policyTypeData->long_name;
|
||||
$employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0,branch_id:$this->request->getGet('client_branch_id'));
|
||||
$enrolledCount = 0;
|
||||
$draftCount = 0;
|
||||
if(count($employeeDetails))
|
||||
{
|
||||
foreach ($employeeDetails as $item) {
|
||||
if ($item['emp_status'] === 'enrolled') {
|
||||
$enrolledCount++;
|
||||
} elseif ($item['emp_status'] === 'draft') {
|
||||
$draftCount++;
|
||||
}
|
||||
foreach ($employeeDetails as $item) {
|
||||
if ($item['emp_status'] === 'enrolled') {
|
||||
$enrolledCount++;
|
||||
} elseif ($item['emp_status'] === 'draft') {
|
||||
$draftCount++;
|
||||
}
|
||||
}
|
||||
|
||||
$value['totalMembersCount'] = count($employeeDetails);
|
||||
$value['membersCountOfEnrolled'] = $enrolledCount;
|
||||
$value['membersCountOfDraft'] = $draftCount;
|
||||
|
||||
array_push($data['policyDetails'],$value);
|
||||
}
|
||||
|
||||
|
||||
array_push($result,$data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$value['totalMembersCount'] = count($employeeDetails);
|
||||
$value['membersCountOfEnrolled'] = $enrolledCount;
|
||||
$value['membersCountOfDraft'] = $draftCount;
|
||||
|
||||
|
||||
array_push($result,$value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($result)
|
||||
{
|
||||
|
||||
@ -73,9 +73,23 @@ 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
|
||||
|
||||
public function verifyEmployeeWithMobileNumber()
|
||||
{
|
||||
@ -268,6 +282,11 @@ class RestAuthenticationController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
// employee auth api's end
|
||||
|
||||
|
||||
// HR auth api's start
|
||||
|
||||
public function verifyHrWithMobileNumber()
|
||||
{
|
||||
try {
|
||||
@ -283,8 +302,74 @@ class RestAuthenticationController extends AdminController
|
||||
$result = ['user_verification' => true ,'message' => "Verified Successfully"];
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
} else {
|
||||
$result = ['user_verification' => false , 'message' => "User not found"];
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
|
||||
// Call the third-party API function
|
||||
return $this->callThirdPartyAPI($this->request->getJSON(),'verifyHrWithMobileNumber');
|
||||
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyHrWithEmail()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = $this->request->getJSON();
|
||||
|
||||
$email = $data->email;
|
||||
|
||||
$HrData = $this->hrModel->where('email', $email)
|
||||
->where('contact_type', 'client')
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if ($HrData) {
|
||||
|
||||
$otp = random_int(100000, 999999);
|
||||
|
||||
$sql = "
|
||||
UPDATE level_contacts
|
||||
SET otp = ?
|
||||
WHERE email = ?
|
||||
AND contact_type = 'client'
|
||||
AND is_active = 1
|
||||
";
|
||||
|
||||
$db = db_connect();
|
||||
$update = $db->query($sql, [$otp, $email]);
|
||||
|
||||
if($update)
|
||||
{
|
||||
$data->otp = $otp;
|
||||
$this->callThirdPartyAPI($data, 'updateHROTP');
|
||||
|
||||
$common = [
|
||||
'login_type' => 'HR login',
|
||||
'login_email' => $email,
|
||||
'mail_type' => 'otp_mail'
|
||||
];
|
||||
$subject = 'Nhance user verification - OTP';
|
||||
$mail_content = $otp . ' is your verification code for Nhance.';
|
||||
$res = MailHelper::send_email(['mail' => $email, 'subject' => $subject, 'common' => $common, 'message' => $mail_content]);
|
||||
$this->myLogger->logme("info", $res);
|
||||
|
||||
if (json_decode($res)->status == 'success') {
|
||||
$result = ['user_verification' => true, 'message' => "Verified Successfully"];
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
|
||||
} else {
|
||||
$result = ['user_verification' => false, 'message' => "Mail sending failed , try again"];
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||
}
|
||||
} else {
|
||||
|
||||
$result = ['user_verification' => false, 'message' => "Verification failed , try again"];
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Call the third-party API function
|
||||
return $this->callThirdPartyAPI($this->request->getJSON(),'verifyHrWithEmail');
|
||||
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
@ -296,11 +381,23 @@ class RestAuthenticationController extends AdminController
|
||||
public function getVerifiedHrData()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
$otp_verification = $this->request->getJSON()->otp_verification;
|
||||
// mobile number
|
||||
$otp_verification = isset($this->request->getJSON()->otp_verification) ? $this->request->getJSON()->otp_verification : null;
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
// email id
|
||||
$otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null;
|
||||
$email = isset($this->request->getJSON()->email) ? $this->request->getJSON()->email : null;
|
||||
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$hrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->first();
|
||||
}else{
|
||||
$hrData = $this->hrModel->where('email', $email)->where('contact_type', 'client')->where('otp', $otp)->first();
|
||||
}
|
||||
|
||||
if ($hrData && $otp_verification == true || $hrData && isset($this->request->getJSON()->otp) )
|
||||
{
|
||||
|
||||
$hrData = $this->hrModel->where('mobile', $mobile_number)->first();
|
||||
if ($hrData && $otp_verification == true) {
|
||||
$auth = HttpRequestHelper::getRequestInfo();
|
||||
if ($auth) {
|
||||
$data = [
|
||||
@ -316,15 +413,46 @@ class RestAuthenticationController extends AdminController
|
||||
}
|
||||
|
||||
|
||||
$hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id')
|
||||
if(isset($this->request->getJSON()->mobile_number)){
|
||||
|
||||
$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.mobile', $mobile_number )
|
||||
->where('level_contacts.contact_type', 'client')
|
||||
->find();
|
||||
|
||||
}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.mobile', $mobile_number )
|
||||
->where('level_contacts.email', $email )
|
||||
->where('level_contacts.contact_type', 'client')
|
||||
->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']);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
|
||||
// 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 {
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],200);
|
||||
|
||||
// Call the third-party API function
|
||||
$apiResponse = $this->callThirdPartyAPI($this->request->getJSON(),'getVerifiedHrData');
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP" , 'post_enrollment'=> json_decode($apiResponse, true)],200);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
|
||||
|
||||
@ -30,12 +30,12 @@ class EmployeeHelper
|
||||
public function validation_addEmployeeAndDependence($data){
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('emp_code',$data[0]->emp_code)
|
||||
->where('client_id',$data[0]->client_id)
|
||||
->where('client_branch_id',$data[0]->client_branch_id)
|
||||
->where('is_active', 1 )
|
||||
->where('is_addon_value',0)
|
||||
->findAll();
|
||||
$employeeData = $this->employeeModel->where('emp_code',$data[0]->emp_code)
|
||||
->where('client_id',$data[0]->client_id)
|
||||
->where('client_branch_id',$data[0]->client_branch_id)
|
||||
->where('is_active', 1 )
|
||||
->where('is_addon_value',0)
|
||||
->findAll();
|
||||
|
||||
$arr [] = $data;
|
||||
|
||||
@ -81,7 +81,7 @@ class EmployeeHelper
|
||||
if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1)
|
||||
{
|
||||
if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;}
|
||||
if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;}
|
||||
if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;}
|
||||
}
|
||||
|
||||
$temp['is_value_exist'] = true;
|
||||
@ -160,7 +160,6 @@ class EmployeeHelper
|
||||
|
||||
$input_relationship = $data[0]->relationship ;
|
||||
|
||||
var_dump($newData);
|
||||
|
||||
foreach($newData as $index => $eachData){
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user