diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 998369a..eca94e6 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -502,4 +502,6 @@ $routes->get('enrollOpendAndClose', 'DashboardController::updatePolicyEnrollment $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail"); $routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); $routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy"); +$routes->post("addEmployeeAndDependence", "EmployeeRestController::addEmployeeAndDependence"); + diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index f13f66e..7e57728 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -268,7 +268,8 @@ class EmployeeRestController extends AdminController if(isset($data[0]->id)) { - $this->createEmployeePolicyData($data[0]->id , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id , $data[0]->basic_cover_si); + $payable_employee = $this->getEmployeePayableValue($data[0]->client_policy_id,$data[0]->relationship); + $this->createEmployeePolicyData($data[0]->id , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id , $data[0]->basic_cover_si, $payable_employee); }else { $payable_employee = $this->getEmployeePayableValue($data[0]->client_policy_id,$data[0]->relationship); @@ -1623,7 +1624,7 @@ class EmployeeRestController extends AdminController if ($value > 0 && $key != 'elders_count') { if ($value != 0 && $key === 'childrens') { - if($value > 2){ $value = 2; } + // if($value > 2){ $value = 2; } for ($i = 1; $i <= $value; $i++) { $result[] = "child" . $i; @@ -2342,75 +2343,85 @@ class EmployeeRestController extends AdminController $employee_data_group_by_family[$emp_id] = $data; foreach ($data as $value) { - $newData = []; - $newData['employee_id'] = $value['temp']['emp_id']; - $newData['client_policy_id'] = $value['policy_details']['client_policy_id']; - $newData['status'] = "draft"; - $newData['basic_cover_si'] = $value['policy_details']['basic_cover_si']; - $newData['date_coverage'] = $value['policy_details']['date_coverage']; - $newData['policy_end_date'] = $value['policy_details']['policy_end_date']; - $newData['days'] = $value['policy_details']['days']; - - $isExistingEmpAndPolicy = $this->employeePolicyModel->where('employee_id',$value['temp']['emp_id'])->where('client_policy_id',$value['policy_details']['client_policy_id'])->where('is_active', 1)->get()->getRow(); - if($isExistingEmpAndPolicy) - { - $this->employeePolicyModel->where('employee_id',$value['temp']['emp_id'])->where('client_policy_id',$value['policy_details']['client_policy_id'])->where('is_active', 1)->set($newData)->update(); - }else{ - $this->employeePolicyModel->insert($newData); + if(!empty($value)){ + $newData = []; + $newData['employee_id'] = $value['temp']['emp_id']; + $newData['client_policy_id'] = $value['policy_details']['client_policy_id']; + $newData['status'] = "draft"; + $newData['basic_cover_si'] = $value['policy_details']['basic_cover_si']; + $newData['date_coverage'] = $value['policy_details']['date_coverage']; + $newData['policy_end_date'] = $value['policy_details']['policy_end_date']; + $newData['days'] = $value['policy_details']['days']; + + + $isExistingEmpAndPolicy = $this->employeePolicyModel->where('employee_id',$value['temp']['emp_id'])->where('client_policy_id',$value['policy_details']['client_policy_id'])->where('is_active', 1)->get()->getRow(); + if($isExistingEmpAndPolicy) + { + $this->employeePolicyModel->where('employee_id',$value['temp']['emp_id'])->where('client_policy_id',$value['policy_details']['client_policy_id'])->where('is_active', 1)->set($newData)->update(); + }else{ + $this->employeePolicyModel->insert($newData); + } } } - if($this->request){ + if(empty($clientPolicyId)){ if(isset($policy_terms['policy_terms'])){ $policyTermsJson = json_decode($policy_terms['policy_terms'], true); // print_r($employee_data_group_by_family);die(); foreach ($employee_data_group_by_family[$emp_code] as $key => &$value) { - if(strtolower($value['relationship']) == 'self' && $policyTermsJson['is_payable_employee']['self'] == 0){ - $value['policy_details']['rata_premimum'] = 0; - $value['policy_details']['premium'] = 0; - $value['policy_details']['gst'] = 0; - $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['self']; + if(!empty($value)){ - }else if(strtolower($value['relationship']) == 'self' && $policyTermsJson['is_payable_employee']['self'] == 1){ - $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['self']; - } - - if(strtolower($value['relationship']) == 'spouse' && $policyTermsJson['is_payable_employee']['spouse'] == 0){ - $value['policy_details']['rata_premimum'] = 0; - $value['policy_details']['premium'] = 0; - $value['policy_details']['gst'] = 0; - $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['spouse']; + if(strtolower($value['relationship']) == 'self' && $policyTermsJson['is_payable_employee']['self'] == 0){ + $value['policy_details']['rata_premimum'] = 0; + $value['policy_details']['premium'] = 0; + $value['policy_details']['gst'] = 0; + $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['self']; - }else if(strtolower($value['relationship']) == 'spouse' && $policyTermsJson['is_payable_employee']['spouse'] == 1){ - $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['spouse']; - } - - if((strtolower($value['relationship']) == 'son' || strtolower($value['relationship']) == 'daughter') && $policyTermsJson['is_payable_employee']['childern'] == 0){ - $value['policy_details']['rata_premimum'] = 0; - $value['policy_details']['premium'] = 0; - $value['policy_details']['gst'] = 0; - $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['childern']; - - }else if((strtolower($value['relationship']) == 'son' || strtolower($value['relationship']) == 'daughter') && $policyTermsJson['is_payable_employee']['childern'] == 1){ - $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['childern']; - } - - if((strtolower($value['relationship']) == 'father in law' || strtolower($value['relationship']) == 'mother in law' || strtolower($value['relationship']) == 'father' || strtolower($value['relationship']) == 'mother' ) && $policyTermsJson['is_payable_employee']['elders'] == 0){ - $value['policy_details']['rata_premimum'] = 0; - $value['policy_details']['premium'] = 0; - $value['policy_details']['gst'] = 0; - $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['elders']; - - }else if((strtolower($value['relationship']) == 'father in law' || strtolower($value['relationship']) == 'mother in law' || strtolower($value['relationship']) == 'father' || strtolower($value['relationship']) == 'mother' ) && $policyTermsJson['is_payable_employee']['elders'] == 1){ - $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['elders']; - } + }else if(strtolower($value['relationship']) == 'self' && $policyTermsJson['is_payable_employee']['self'] == 1){ + $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['self']; + } + + if(strtolower($value['relationship']) == 'spouse' && $policyTermsJson['is_payable_employee']['spouse'] == 0){ + $value['policy_details']['rata_premimum'] = 0; + $value['policy_details']['premium'] = 0; + $value['policy_details']['gst'] = 0; + $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['spouse']; + }else if(strtolower($value['relationship']) == 'spouse' && $policyTermsJson['is_payable_employee']['spouse'] == 1){ + $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['spouse']; + } + + if((strtolower($value['relationship']) == 'son' || strtolower($value['relationship']) == 'daughter') && $policyTermsJson['is_payable_employee']['childern'] == 0){ + $value['policy_details']['rata_premimum'] = 0; + $value['policy_details']['premium'] = 0; + $value['policy_details']['gst'] = 0; + $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['childern']; + + }else if((strtolower($value['relationship']) == 'son' || strtolower($value['relationship']) == 'daughter') && $policyTermsJson['is_payable_employee']['childern'] == 1){ + $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['childern']; + } + + if((strtolower($value['relationship']) == 'father in law' || strtolower($value['relationship']) == 'mother in law' || strtolower($value['relationship']) == 'father' || strtolower($value['relationship']) == 'mother' ) && $policyTermsJson['is_payable_employee']['elders'] == 0){ + $value['policy_details']['rata_premimum'] = 0; + $value['policy_details']['premium'] = 0; + $value['policy_details']['gst'] = 0; + $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['elders']; + + }else if((strtolower($value['relationship']) == 'father in law' || strtolower($value['relationship']) == 'mother in law' || strtolower($value['relationship']) == 'father' || strtolower($value['relationship']) == 'mother' ) && $policyTermsJson['is_payable_employee']['elders'] == 1){ + $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['elders']; + } + + }else{ + unset($employee_data_group_by_family[$emp_code][$key]); + } } unset($value); + + $employee_data_group_by_family[$emp_code] = array_values($employee_data_group_by_family[$emp_code]); } }else{ if(isset($policy_terms['policy_terms'])){ @@ -2418,25 +2429,30 @@ class EmployeeRestController extends AdminController $policyTermsJson = json_decode($policy_terms['policy_terms'], true); foreach ($employee_data_group_by_family[$emp_code] as $key => &$value) { + if(!empty($value)){ - if(strtolower($value['relationship']) == 'self'){ - $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['self']; - } - - if(strtolower($value['relationship']) == 'spouse'){ - $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['spouse']; - } - - if((strtolower($value['relationship']) == 'son' || strtolower($value['relationship']) == 'daughter')){ - $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['childern']; - } - - if((strtolower($value['relationship']) == 'father in law' || strtolower($value['relationship']) == 'mother in law' || strtolower($value['relationship']) == 'father' || strtolower($value['relationship']) == 'mother' )){ - $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['elders']; - } - + if(strtolower($value['relationship']) == 'self'){ + $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['self']; + } + + if(strtolower($value['relationship']) == 'spouse'){ + $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['spouse']; + } + + if((strtolower($value['relationship']) == 'son' || strtolower($value['relationship']) == 'daughter')){ + $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['childern']; + } + + if((strtolower($value['relationship']) == 'father in law' || strtolower($value['relationship']) == 'mother in law' || strtolower($value['relationship']) == 'father' || strtolower($value['relationship']) == 'mother' )){ + $value['policy_details']['payable_employee'] = $policyTermsJson['is_payable_employee']['elders']; + } + }else{ + unset($employee_data_group_by_family[$emp_code][$key]); + } } unset($value); + + $employee_data_group_by_family[$emp_code] = array_values($employee_data_group_by_family[$emp_code]); } } diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index b76510b..691e625 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -2058,12 +2058,14 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){ $relation = 'parent'; } else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){ $relation = 'child'; - }else if(strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law'){ + }else if((strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law') || (strtolower(trim($value['relationship'])) === 'father-in-law' || strtolower(trim($value['relationship'])) === 'mother-in-law')){ $relation = 'parent_in_law'; }else if(strtolower(trim($value['relationship'])) === 'spouse'){ $relation = 'spouse'; - }else{ + }else if(strtolower(trim($value['relationship'])) === 'self'){ $relation = 'self'; + }else { + $relation = ''; } $value['family_floater_key'] = $relation; diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index a4a98d5..7f2f9f4 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -138,9 +138,24 @@ class RestAuthenticationController extends AdminController $otp = random_int(100000, 999999); - $update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'self') - ->where('is_active', 1)->set(array('otp' => $otp )) - ->update(); + // $update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'self') + // ->where('is_active', 1)->set(array('otp' => $otp )) + // ->update(); + + $sql = " + UPDATE employees + INNER JOIN employee_polices ON employee_polices.employee_id = employees.id + SET employees.otp = ? + WHERE employees.email_corporate = ? + AND employees.relationship = 'self' + AND employees.is_active = 1 + AND employee_polices.is_active = 1 + AND employee_polices.status IN ('draft', 'enrolled') + "; + + $db = db_connect(); + $update = $db->query($sql, [$otp, $email]); + if($update) { @@ -198,7 +213,18 @@ class RestAuthenticationController extends AdminController }else{ if (isset($mobile_number)) { - $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); + // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); + + $employeeData = $this->employeeModel + ->select('employees.*') + ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner') + ->where('employees.is_active', 1) + ->where('employees.relationship', 'self') + ->where('employees.emp_status !=', 'truncated') + ->where('employees.mobile', $mobile_number) + ->where('EP.is_active', 1) + ->whereIn('EP.status', ['draft', 'enrolled']) + ->first(); } else { $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); } diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 7a59f25..710ba74 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -2207,13 +2207,17 @@ if(!function_exists('generate_family_floater_key')) $relation = 'parent'; } else if(strtolower(trim($relationship)) === 'son' || strtolower(trim($relationship)) === 'daughter'){ $relation = 'child'; - }else if(strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law'){ + }else if((strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law') || (strtolower(trim($relationship)) === 'father-in-Law' || strtolower(trim($relationship)) === 'mother-in-Law')){ $relation = 'parent_in_law'; }else if(strtolower(trim($relationship)) === 'spouse'){ $relation = 'spouse'; - }else{ + }else if(strtolower(trim($relationship)) === 'self'){ $relation = 'self'; + }else{ + $relation = ''; } + + return $relation; } } diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index a337d23..877077e 100755 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -213,11 +213,11 @@