diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 40f95ad..05211f2 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2622,7 +2622,7 @@ class EmployeeRestController extends AdminController //array_push($PolicyData, $responce); - }else if(($array['is_addon'] == 2 && $array['policy_type_id'] == 4) || ($array['is_addon'] == 2 && $array['policy_type_id'] == 72))//Topup policy + }else if(($array['is_addon'] == 2 && $array['policy_type_id'] == 4))//Topup policy { @@ -2681,11 +2681,75 @@ class EmployeeRestController extends AdminController - if($this->request->getGet('policy') == 'GMC-SI-TOPUP' || $this->request->getGet('policy') == 'GMC-OPD'){ + if($this->request->getGet('policy') == 'GMC-SI-TOPUP'){ return $this->respond(['status' => 'success','code' => 200,'data' => ['gmc_si_topup'=>$responce]], 200); } + }else if(($array['is_addon'] == 2 && $array['policy_type_id'] == 72))//OPD policy + { + + + $whereArray = []; + foreach ( $decodedArray->family_floaters as $key => $value) { + if($value != 0){ + if($key == 'parents'){ $text = ["parent"]; } + else if($key == 'childrens'){ $text = ["child"]; } + else if($key == 'parents-in-law'){ $text = ["parent_in_law"];} + else if($key ==='either-parents-pil') { $text = ["parent", "parent_in_law"];} + else{ $text = [$key]; } + $whereArray = array_merge($whereArray, $text); + } + } + + + $getAddOnType = $this->clientPolicyModel->where('id',$array['base_policy'])->where('policy_status', 1)->get()->getRow(); + $basePolicyAddOnType = $getAddOnType->is_addon; + // if is_addon value is 1 it is GMC if not it is one of the Add On policy + if($basePolicyAddOnType == 1){ $is_addon_value = 0; }else{ $is_addon_value = 1; } + $only_si_array = []; + $only_si_value = 0; + $only_si_premium_value = 0; + $only_si_gst_value = 0; + $BasePolicyEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',$is_addon_value)->whereIn('family_floater_key',$whereArray)->findAll(); + foreach ($BasePolicyEmployeeData as $key => $value) { + + $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow(); + if(isset($employee_policy->basic_cover_si)){ $only_si_value = ($only_si_value == 0) ? $employee_policy->basic_cover_si : $only_si_value; } + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + if(isset($employee_policy->rata_premimum)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;} + if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;} + } + $temp3['is_value_exist'] = true; + $temp3['data']['employee_id'] = $value['id']; + $temp3['data']['relationship'] = $value['relationship']; + $temp3['data']['name'] = $value['name']; + $temp3['data']['dob'] = $this->convertDateFormatDMY($value['dob']); + $temp3['data']['client_policy_id'] = $array['id']; + $temp3['data']['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null; + $temp3['data']['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null; + array_push($only_si_array,$temp3); + + } + + $responce['family_floaters_of_only_si_array'] = $only_si_array; + $responce['family_floaters_of_only_si_value'] = $only_si_value; + if($array['is_premium_summery']){ + $responce['family_floaters_of_only_si_premium_value'] = round($only_si_premium_value); + $responce['family_floaters_of_only_si_gst_value'] = $only_si_gst_value; + }else{ + $responce['family_floaters_of_only_si_premium_value'] = 0; + $responce['family_floaters_of_only_si_gst_value'] = 0; + } + + + + if($this->request->getGet('policy') == 'GMC-OPD'){ + return $this->respond(['status' => 'success','code' => 200,'data' => ['gmc_si_topup'=>$responce]], 200); + } + + }else if($array['is_addon'] == 2 && $array['policy_type_id'] == 5)//Parents Topup policy {