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