CHANGE_addEmployeeAndDependenceAPI:GWM
This commit is contained in:
parent
12d1b898e1
commit
e5cdd231c2
@ -246,7 +246,6 @@ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfi
|
||||
$routes->post("/calculatePremium", "EmployeeRestController::calculatePremium");
|
||||
|
||||
|
||||
|
||||
$routes->group("employeeRest", ["filter" => "authJWT"], function($routes){
|
||||
|
||||
$routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile");
|
||||
|
||||
@ -170,7 +170,7 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
public function addEmployeeAndDependence()
|
||||
{
|
||||
// try {
|
||||
try {
|
||||
$data = $this->request->getJSON();
|
||||
|
||||
if ($data) {
|
||||
@ -197,10 +197,6 @@ class EmployeeRestController extends AdminController
|
||||
$employee = $this->employeeModel->insert($item);
|
||||
|
||||
if ($employee) {
|
||||
if(!isset($item->is_addon_value))
|
||||
{
|
||||
$this->createEmployeePolicyData($employee,$item->emp_code,$item->client_id,$item->client_policy_id);
|
||||
}
|
||||
$Count++;
|
||||
}
|
||||
|
||||
@ -210,10 +206,16 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
if ($Count > 0) {
|
||||
|
||||
if(!isset($data[0]->is_addon_value))
|
||||
if(!isset($item->is_addon_value))
|
||||
{
|
||||
$this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code);
|
||||
$this->createEmployeePolicyData($employee,$item->emp_code,$item->client_id,$item->client_policy_id);
|
||||
}else{
|
||||
$this->createEmployeePolicyData($employee,$item->emp_code,$item->client_id,$item->client_policy_id,$item->basic_cover_si);
|
||||
}
|
||||
|
||||
|
||||
$this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code);
|
||||
|
||||
|
||||
$result = [];
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
|
||||
@ -222,18 +224,19 @@ class EmployeeRestController extends AdminController
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 404);
|
||||
}
|
||||
}
|
||||
// } catch (\Exception $e) {
|
||||
// return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||
// }
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function createEmployeePolicyData($employee_id,$emp_code,$client_id,$client_policy_id)
|
||||
public function createEmployeePolicyData($employee_id,$emp_code,$client_id,$client_policy_id,$basic_cover_si = null)
|
||||
{
|
||||
|
||||
if($basic_cover_si != null){
|
||||
$client_policy = $this->clientPolicyModel->where('id', $client_policy_id)->where('client_id', $client_id)->first();
|
||||
$policy_terms = json_decode($client_policy['policy_terms']);
|
||||
$basic_cover_si = $policy_terms->sum_insured;
|
||||
}else{ $basic_cover_si = $basic_cover_si; }
|
||||
|
||||
$checkDataExist = $this->employeePolicyModel->where('employee_id',$employee_id)->where('client_policy_id',$client_policy_id)->first();
|
||||
|
||||
@ -989,6 +992,7 @@ public function getEmployeePolicy()
|
||||
|
||||
// Map family floaters that already exist in the employee table
|
||||
$familyFloates = $array->Policy_Terms->family_floaters;
|
||||
|
||||
// Generate Notes string based on familyFloates terms
|
||||
$array->notes = $this->FloterNotesConvertion($familyFloates);
|
||||
// Convert familyFloaters terms data to plain array
|
||||
@ -1115,6 +1119,8 @@ public function FloterNotesConvertion($array){
|
||||
$string = ucwords($string);
|
||||
$result .= ' + '.$string;
|
||||
}else if($value != 0 && $key ==='self') {
|
||||
}else if($value != 0 && $key ==='childrens') {
|
||||
if($value > 1){ $result .= ' + '.$value.' Children'; }else{ $result .= ' + '.$value.' Child'; }
|
||||
}else{
|
||||
$string = str_replace('-', ' ', $key);
|
||||
$string = ucwords($string);
|
||||
@ -1122,7 +1128,7 @@ public function FloterNotesConvertion($array){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -1342,12 +1348,11 @@ public function iAgreeForAddOn()
|
||||
|
||||
$this->employeeModel->where('emp_code', $emp_code )
|
||||
->where('is_active', 1 )
|
||||
->set(array('emp_status'=>'Enrolled'))
|
||||
->set(array('emp_status'=>'enrolled'))
|
||||
->update();
|
||||
$this->employeePolicyModel->where('client_id', $client_id )
|
||||
->where('client_policy_id', $client_policy_id )
|
||||
$this->employeePolicyModel->where('client_policy_id', $client_policy_id )
|
||||
->where('is_active', 1 )
|
||||
->set(array('status'=>'Enrolled'))
|
||||
->set(array('status'=>'enrolled'))
|
||||
->update();
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user