Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
aadhavan valli 2024-05-15 17:05:39 +05:30
commit 883ed5a046
2 changed files with 105 additions and 16 deletions

View File

@ -284,6 +284,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->post("calculatePremium", "EmployeeRestController::calculatePremium");
$routes->get("getEmployeeOldPolicy", "EmployeeRestController::getEmployeeOldPolicy");
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
});
$routes->post("sendEmail", "EmployeeRestController::send_email");

View File

@ -916,7 +916,19 @@ class EmployeeRestController extends AdminController
//-------------------------------------
public function getAgeRange($terms,$familyFloatesValue)
{
$ageRangeArray = ['self' => ['min' => 18, 'max' => 60] , 'spouse' => ['min' => 18, 'max' => 60] , 'child' => ['min' => 0, 'max' => 25] , 'elders' => ['min' => 18, 'max' => 60] ];
$ageKey = (preg_replace('/\d/', '', $familyFloatesValue) == 'parent' || preg_replace('/\d/', '', $familyFloatesValue) == 'parent_in_law') ? 'elders' : preg_replace('/\d/', '', $familyFloatesValue);
if(isset($terms->age_ratio)){
return $terms->age_ratio->$ageKey;
}else{
return $ageRangeArray[$ageKey];
}
}
public function getEmployeePolicy()
{
try {
@ -1021,10 +1033,10 @@ public function getEmployeePolicy()
$temp['data']['dob'] = $this->convertDateFormatDMY($value['dob']);
$temp['data']['client_policy_id'] = $array->ClientPolicyId;
$temp['data']['form_type'] = $dependent;
$temp['data']['basic_cover_si'] = $employee_policy->basic_cover_si;
$ageKey = ($dependent == 'parent' || $dependent == 'parent_in_law') ? 'elders' : $dependent;
$temp['data']['age_validation'] = $decodedArray->age_ratio->$ageKey;
$temp['data']['basic_cover_si'] = $employee_policy->basic_cover_si;
$temp['data']['age_validation'] = $this->getAgeRange($decodedArray,$familyFloatesValue);
array_push($data,$temp);
unset($empData[$key]);
@ -1063,9 +1075,9 @@ public function getEmployeePolicy()
$temp2['data']['client_policy_id'] = $array->ClientPolicyId;
$temp2['data']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue)));
$temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue);
$ageKey = (preg_replace('/\d/', '', $familyFloatesValue) == 'parent' || preg_replace('/\d/', '', $familyFloatesValue) == 'parent_in_law') ? 'elders' : preg_replace('/\d/', '', $familyFloatesValue);
$temp2['data']['age_validation'] = $decodedArray->age_ratio->$ageKey;
$temp2['data']['age_validation'] = $this->getAgeRange($decodedArray,$familyFloatesValue);
array_push($data,$temp2);
@ -1193,8 +1205,8 @@ public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id)
$temp['data']['client_policy_id'] = $array->ClientPolicyId;
$temp['data']['form_type'] = $dependent;
$temp['data']['basic_cover_si'] = $employee_policy->basic_cover_si;
$ageKey = ($dependent == 'parent' || $dependent == 'parent_in_law') ? 'elders' : $dependent;
$temp['data']['age_validation'] = $array->Policy_Terms->age_ratio->$ageKey;
$temp['data']['age_validation'] = $this->getAgeRange($array->Policy_Terms,$familyFloatesValue);
array_push($data,$temp);
unset($empData[$key]);
@ -1231,9 +1243,7 @@ public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id)
$temp2['data']['client_policy_id'] = $array->ClientPolicyId;
$temp2['data']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue)));
$temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue);
$ageKey = (preg_replace('/\d/', '', $familyFloatesValue) == 'parent' || preg_replace('/\d/', '', $familyFloatesValue) == 'parent_in_law') ? 'elders' : preg_replace('/\d/', '', $familyFloatesValue);
$temp2['data']['age_validation'] = $array->Policy_Terms->age_ratio->$ageKey;
$temp2['data']['age_validation'] = $this->getAgeRange($array->Policy_Terms,$familyFloatesValue);
array_push($data,$temp2);
}
@ -1434,7 +1444,9 @@ public function getAddOnPolicy()
$temp['data']['client_policy_id'] = $array['id'];
$temp['data']['form_type'] = $dependent;
$temp['data']['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
$temp['data']['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
$temp['data']['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
$temp['data']['age_validation'] = $this->getAgeRange($decodedArray,$familyFloatesValue);
array_push($data,$temp);
unset($addOnEmployeeData[$key]);
$floters = array_diff($floters, [$familyFloatesValue]);
@ -1491,9 +1503,8 @@ public function getAddOnPolicy()
$temp2['data']['client_policy_id'] = $array['id'];
$temp2['data']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue)));
$temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue);
$ageKey = (preg_replace('/\d/', '', $familyFloatesValue) == 'parent' || preg_replace('/\d/', '', $familyFloatesValue) == 'parent_in_law') ? 'elders' : preg_replace('/\d/', '', $familyFloatesValue);
$temp2['data']['age_validation'] = $decodedArray->age_ratio->$ageKey;
$temp2['data']['age_validation'] = $this->getAgeRange($decodedArray,$familyFloatesValue);
array_push($data,$temp2);
@ -2037,6 +2048,83 @@ function getEmployeeOldPolicy()
}
function getEmployeeActiveOrInactivePolicy()
{
if($this->request->getGet('type') == 'Active'){ $value = 1; }else{ $value = 0; }
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policies.name as policy_name , policy_type.policy_type as policy_type')
->join('policies', 'client_policy.policy_id = policies.id', 'left')
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
->where('client_policy.client_id', $this->request->getGet('client_id') )
->where('client_policy.is_active', 1 )
->where('client_policy.policy_status', $value)
->orderby('client_policy.id' , 'ASC')
->findAll();
// Retrieve employee and dependents data by passing the employee code
$employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
->where('client_id',$this->request->getGet('client_id'))
->where('is_active', 1 )->findAll();
$whereArrayForId = [];
foreach ( $employeeData as $key => $value) { array_push($whereArrayForId, $value['id']); }
if(count($ClientPolicyData) > 0 && count($employeeData) > 0)
{
$result = [];
foreach ($ClientPolicyData as $key => $ClientPolicyValue) {
$terms = json_decode($ClientPolicyValue['policy_terms']);
// dd($terms);
$data['client_id'] = $ClientPolicyValue['client_id'];
$data['client_policy_id'] = $ClientPolicyValue['id'];
$data['policy_name'] = $ClientPolicyValue['policy_name'];
$data['policy_type'] = $ClientPolicyValue['policy_type'];
$data['policy_type'] = $ClientPolicyValue['policy_type'];
$data['policy_start_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_start_date']);
$data['policy_end_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_end_date']);
if($ClientPolicyValue['policy_type_id'] == 1){ $data['heading'] = 'Group Personal Accident Coverage'; }else
if($ClientPolicyValue['policy_type_id'] == 2){ $data['heading'] = 'Group Medical Coverage'; }else
if($ClientPolicyValue['policy_type_id'] == 3){ $data['heading'] = 'Group Medical Coverage - Parents'; }else
if($ClientPolicyValue['policy_type_id'] == 4){ $data['heading'] = 'Group Medical Coverage - Top Up'; }else
if($ClientPolicyValue['policy_type_id'] == 5){ $data['heading'] = 'Group Medical Coverage - Parents (Top Up)'; }
if($ClientPolicyValue['policy_type_id'] == 1){ $data['floter_text_heading'] = 'Sum Insured'; }
else
{
if($terms->family_floater == 1){ $data['floter_text_heading'] = 'Floter Sum Insured'; }else{ $data['floter_text_heading'] = 'Sum Insured'; }
}
$employee_policy = $this->employeePolicyModel->select('employees.*,employee_polices.employee_id , employee_polices.basic_cover_si , employee_polices.premium , employee_polices.gst , employee_polices.tpa_id , employee_polices.rand_string')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->whereIn('employee_polices.employee_id',$whereArrayForId)
->where('employee_polices.client_policy_id',$ClientPolicyValue['id'])
->where('employee_polices.is_active', 1 )->findAll();
$si_value = 0;
$si_premium_value = 0;
$si_gst_value = 0;
foreach ($employee_policy as $key => $value) {
if(isset($value['basic_cover_si'])){ $si_value = $value['basic_cover_si']; }
if(isset($value['premium'])){ $si_premium_value = $si_premium_value + $value['premium'];}
if(isset($value['gst'])){ $si_gst_value = $si_gst_value + $value['gst'];}
}
$data['si_value'] = $si_value;
$data['si_premium_value'] = ($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 2) ? 0 : $si_premium_value;
$data['si_gst_value'] = ($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 2) ? 0 : $si_gst_value;
$data['EmployeePolicy'] = $employee_policy;
array_push($result, $data);
}
return $this->respond(['status' => 'success','code' => 200,'data' => $result ], 200);
}else{
return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 200);
}
}
private function convertDateFormatDisplay($dateString)
{