Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
443e9e1173
@ -233,7 +233,6 @@ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfi
|
||||
|
||||
|
||||
|
||||
|
||||
$routes->group("employeeRest", ["filter" => "authJWT"], function($routes){
|
||||
$routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
|
||||
$routes->get("relationshipList", "EmployeeRestController::relationshipList");
|
||||
|
||||
@ -308,134 +308,134 @@ class EmployeeRestController extends AdminController
|
||||
}
|
||||
|
||||
|
||||
public function getEmployeePolicy()
|
||||
{
|
||||
try {
|
||||
$id = $this->request->getGet('id');
|
||||
$emp_code = $this->request->getGet('emp_code');
|
||||
// public function getEmployeePolicy()
|
||||
// {
|
||||
// try {
|
||||
// $id = $this->request->getGet('id');
|
||||
// $emp_code = $this->request->getGet('emp_code');
|
||||
|
||||
$keysToRemove = ["removable_keys"];
|
||||
// $keysToRemove = ["removable_keys"];
|
||||
|
||||
$empPolicy = $this->employeeModel->getEmployeePolicy($id);
|
||||
// $empPolicy = $this->employeeModel->getEmployeePolicy($id);
|
||||
|
||||
$empData = $this->employeeModel->where('emp_code',$emp_code)->findAll();
|
||||
if ($empPolicy) {
|
||||
// $empData = $this->employeeModel->where('emp_code',$emp_code)->findAll();
|
||||
// if ($empPolicy) {
|
||||
|
||||
$result = [];
|
||||
foreach ($empPolicy as $array) {
|
||||
// $result = [];
|
||||
// foreach ($empPolicy as $array) {
|
||||
|
||||
$decodedArray = json_decode($array->Policy_Terms);
|
||||
$refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove));
|
||||
// $decodedArray = json_decode($array->Policy_Terms);
|
||||
// $refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove));
|
||||
|
||||
|
||||
$array->Policy_Terms = $refusingData;
|
||||
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId);
|
||||
$array->SlabRates = $getSlabAndGridData['slab_rates'];
|
||||
$array->GridMaster = $getSlabAndGridData['grid_master'];
|
||||
// $array->Policy_Terms = $refusingData;
|
||||
// $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId);
|
||||
// $array->SlabRates = $getSlabAndGridData['slab_rates'];
|
||||
// $array->GridMaster = $getSlabAndGridData['grid_master'];
|
||||
|
||||
if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){
|
||||
$default_si = $array->Policy_Terms->sumInsured2;
|
||||
$index = -1;
|
||||
foreach ($array->SlabRates as $key => $value) {
|
||||
if ($value['si'] == $default_si) {
|
||||
$index = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($index >= 0) {
|
||||
$element =$array->SlabRates[$index];
|
||||
array_splice($array->SlabRates, $index, 1);
|
||||
array_unshift($array->SlabRates, $element);
|
||||
}
|
||||
// if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){
|
||||
// $default_si = $array->Policy_Terms->sumInsured2;
|
||||
// $index = -1;
|
||||
// foreach ($array->SlabRates as $key => $value) {
|
||||
// if ($value['si'] == $default_si) {
|
||||
// $index = $key;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if ($index >= 0) {
|
||||
// $element =$array->SlabRates[$index];
|
||||
// array_splice($array->SlabRates, $index, 1);
|
||||
// array_unshift($array->SlabRates, $element);
|
||||
// }
|
||||
|
||||
$employee_policy = $this->employeePolicyModel->where('employee_id',$id)->where('client_policy_id',$array->ClientPolicyId)->get()->getRow();
|
||||
if($employee_policy){
|
||||
$gpaSI['family_floater_key'] = 'self';
|
||||
$gpaSI['label'] = 'Self';
|
||||
$gpaSI['employee_id'] = $employee_policy->employee_id;
|
||||
$gpaSI['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
|
||||
$gpaSI['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
|
||||
$gpaSI['client_policy_id'] = $array->ClientPolicyId;
|
||||
// $employee_policy = $this->employeePolicyModel->where('employee_id',$id)->where('client_policy_id',$array->ClientPolicyId)->get()->getRow();
|
||||
// if($employee_policy){
|
||||
// $gpaSI['family_floater_key'] = 'self';
|
||||
// $gpaSI['label'] = 'Self';
|
||||
// $gpaSI['employee_id'] = $employee_policy->employee_id;
|
||||
// $gpaSI['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
|
||||
// $gpaSI['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
|
||||
// $gpaSI['client_policy_id'] = $array->ClientPolicyId;
|
||||
|
||||
$array->mapped_family_floaters = $gpaSI;
|
||||
}else{
|
||||
$gpaSI['family_floater_key'] = 'self';
|
||||
$gpaSI['label'] = 'Self';
|
||||
$gpaSI['employee_id'] = $id;
|
||||
$gpaSI['basic_cover_si'] = null;
|
||||
$gpaSI['premium'] = null;
|
||||
$gpaSI['client_policy_id'] = $array->ClientPolicyId;
|
||||
// $array->mapped_family_floaters = $gpaSI;
|
||||
// }else{
|
||||
// $gpaSI['family_floater_key'] = 'self';
|
||||
// $gpaSI['label'] = 'Self';
|
||||
// $gpaSI['employee_id'] = $id;
|
||||
// $gpaSI['basic_cover_si'] = null;
|
||||
// $gpaSI['premium'] = null;
|
||||
// $gpaSI['client_policy_id'] = $array->ClientPolicyId;
|
||||
|
||||
$array->mapped_family_floaters = $gpaSI;
|
||||
}
|
||||
// $array->mapped_family_floaters = $gpaSI;
|
||||
// }
|
||||
|
||||
}else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){
|
||||
// }else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){
|
||||
|
||||
// re-arranging order of si
|
||||
$default_si = $array->Policy_Terms->sum_insured;
|
||||
// Filter the array using the callback function
|
||||
$getPremium = array_filter($array->SlabRates , function ($value) use ($default_si) { return $value['si'] == $default_si; } );
|
||||
$default_premium = $getPremium[0]['premium'];
|
||||
// // re-arranging order of si
|
||||
// $default_si = $array->Policy_Terms->sum_insured;
|
||||
// // Filter the array using the callback function
|
||||
// $getPremium = array_filter($array->SlabRates , function ($value) use ($default_si) { return $value['si'] == $default_si; } );
|
||||
// $default_premium = $getPremium[0]['premium'];
|
||||
|
||||
$index = -1;
|
||||
foreach ($array->SlabRates as $key => $value) {
|
||||
if ($value['si'] == $default_si) {
|
||||
$index = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($index >= 0) {
|
||||
$element =$array->SlabRates[$index];
|
||||
array_splice($array->SlabRates, $index, 1);
|
||||
array_unshift($array->SlabRates, $element);
|
||||
}
|
||||
// $index = -1;
|
||||
// foreach ($array->SlabRates as $key => $value) {
|
||||
// if ($value['si'] == $default_si) {
|
||||
// $index = $key;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if ($index >= 0) {
|
||||
// $element =$array->SlabRates[$index];
|
||||
// array_splice($array->SlabRates, $index, 1);
|
||||
// array_unshift($array->SlabRates, $element);
|
||||
// }
|
||||
|
||||
//map family floates array to employee and dependent
|
||||
$familyFloates = $array->Policy_Terms->family_floaters;
|
||||
$data = [];
|
||||
foreach ($familyFloates as $familyFloatesValue) {
|
||||
$dependent = preg_replace('/\d/', '', $familyFloatesValue);
|
||||
if(count($empData)){
|
||||
foreach ($empData as $key => $value) {
|
||||
if ($value['family_floater_key'] === $dependent) {
|
||||
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->get()->getRow();
|
||||
$temp['family_floater_key'] = $familyFloatesValue;
|
||||
$temp['label'] = $value['relationship'];
|
||||
$temp['name'] = $value['name'];
|
||||
$temp['employee_id'] = $value['id'];
|
||||
$temp['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
|
||||
$temp['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
|
||||
$temp['client_policy_id'] = $array->ClientPolicyId;
|
||||
array_push($data,$temp);
|
||||
unset($empData[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$array->mapped_family_floaters = $data;
|
||||
// //map family floates array to employee and dependent
|
||||
// $familyFloates = $array->Policy_Terms->family_floaters;
|
||||
// $data = [];
|
||||
// foreach ($familyFloates as $familyFloatesValue) {
|
||||
// $dependent = preg_replace('/\d/', '', $familyFloatesValue);
|
||||
// if(count($empData)){
|
||||
// foreach ($empData as $key => $value) {
|
||||
// if ($value['family_floater_key'] === $dependent) {
|
||||
// $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->get()->getRow();
|
||||
// $temp['family_floater_key'] = $familyFloatesValue;
|
||||
// $temp['label'] = $value['relationship'];
|
||||
// $temp['name'] = $value['name'];
|
||||
// $temp['employee_id'] = $value['id'];
|
||||
// $temp['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
|
||||
// $temp['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
|
||||
// $temp['client_policy_id'] = $array->ClientPolicyId;
|
||||
// array_push($data,$temp);
|
||||
// unset($empData[$key]);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// $array->mapped_family_floaters = $data;
|
||||
|
||||
$temp2=[];
|
||||
foreach ($array->SlabRates as $key => $value) {
|
||||
$value['additional_premium'] = $value['premium'] - $default_premium;
|
||||
array_push($temp2,$value);
|
||||
}
|
||||
$array->SlabRates = $temp2;
|
||||
// $temp2=[];
|
||||
// foreach ($array->SlabRates as $key => $value) {
|
||||
// $value['additional_premium'] = $value['premium'] - $default_premium;
|
||||
// array_push($temp2,$value);
|
||||
// }
|
||||
// $array->SlabRates = $temp2;
|
||||
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
$result[] = $array;
|
||||
}
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
// $result[] = $array;
|
||||
// }
|
||||
// return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
|
||||
// }else{
|
||||
// return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
|
||||
// }
|
||||
// } catch (\Exception $e) {
|
||||
// return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Get the RelationShip list
|
||||
|
||||
@ -451,17 +451,21 @@ class EmployeeRestController extends AdminController
|
||||
$checkIfExist = $this->employeePolicyModel->where('employee_id', $value->employee_id)
|
||||
->where('client_policy_id', $value->client_policy_id)
|
||||
->findAll();
|
||||
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($value->client_policy_id,$value->client_id);
|
||||
$SlabRatesArray = $getSlabAndGridData['slab_rates'];
|
||||
$premium = $this->findPremiumAmount($SlabRatesArray, $value->basic_cover_si);
|
||||
|
||||
// dd($checkIfExist);
|
||||
if ($checkIfExist) {
|
||||
|
||||
$empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id, $value->employee_id, $value->basic_cover_si,$value->premium);
|
||||
$empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id, $value->employee_id, $value->basic_cover_si,$premium);
|
||||
|
||||
}else{
|
||||
|
||||
$data['employee_id']= $value->employee_id;
|
||||
$data['client_policy_id']= $value->client_policy_id;
|
||||
$data['basic_cover_si']= $value->basic_cover_si;
|
||||
$data['premium']= $value->premium;
|
||||
$data['premium']= $premium;
|
||||
|
||||
$this->employeePolicyModel->insert($data);
|
||||
}
|
||||
@ -473,7 +477,15 @@ class EmployeeRestController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function findPremiumAmount($slabArray,$siAmount)
|
||||
{
|
||||
foreach ($slabArray as $key => $value) {
|
||||
if($value['si'] == $siAmount){
|
||||
return $value['premium'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public function relationshipList()
|
||||
{
|
||||
try {
|
||||
@ -778,6 +790,112 @@ class EmployeeRestController extends AdminController
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
public function getEmployeePolicy()
|
||||
{
|
||||
try {
|
||||
$id = $this->request->getGet('id');
|
||||
$emp_code = $this->request->getGet('emp_code');
|
||||
|
||||
$keysToRemove = ["removable_keys"];
|
||||
|
||||
$empPolicy = $this->employeeModel->getEmployeePolicy($id);
|
||||
|
||||
$empData = $this->employeeModel->where('emp_code',$emp_code)->findAll();
|
||||
// print_r($empData);die;
|
||||
if ($empPolicy) {
|
||||
|
||||
$result = [];
|
||||
foreach ($empPolicy as $array) {
|
||||
|
||||
$decodedArray = json_decode($array->Policy_Terms);
|
||||
$refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove));
|
||||
|
||||
|
||||
$array->Policy_Terms = $refusingData;
|
||||
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId);
|
||||
$array->SlabRates = $getSlabAndGridData['slab_rates'];
|
||||
$array->GridMaster = $getSlabAndGridData['grid_master'];
|
||||
|
||||
if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){
|
||||
|
||||
$selfData = array_filter($empData, fn($arr) => $arr['family_floater_key'] === 'self');
|
||||
$self['is_value_exist'] = true;
|
||||
$self['data']['family_floater_key'] = 'self';
|
||||
$self['data']['employee_id'] = $id;
|
||||
$self['data']['relationship'] = 'Self';
|
||||
$self['data']['name'] = $selfData[0]['name'];
|
||||
$self['data']['dob'] = $selfData[0]['dob'];
|
||||
$self['data']['client_policy_id'] = $array->ClientPolicyId;
|
||||
|
||||
$array->mapped_family_floaters = $self;
|
||||
|
||||
|
||||
if($this->request->getGet('policy') == 'GPA'){
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $array], 200);
|
||||
}
|
||||
|
||||
}else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){
|
||||
|
||||
|
||||
|
||||
//map family floates array to employee and dependent
|
||||
$familyFloates = $array->Policy_Terms->family_floaters;
|
||||
$data = [];
|
||||
foreach ($familyFloates as $familyFloatesValue) {
|
||||
$dependent = preg_replace('/\d/', '', $familyFloatesValue);
|
||||
if(count($empData)){
|
||||
foreach ($empData as $key => $value) {
|
||||
if ($value['family_floater_key'] === $dependent) {
|
||||
$temp['is_value_exist'] = true;
|
||||
$temp['data']['family_floater_key'] = $familyFloatesValue;
|
||||
$temp['data']['employee_id'] = $value['id'];
|
||||
$temp['data']['relationship'] = $value['relationship'];
|
||||
$temp['data']['name'] = $value['name'];
|
||||
$temp['data']['dob'] = $value['dob'];
|
||||
$temp['data']['client_policy_id'] = $array->ClientPolicyId;
|
||||
array_push($data,$temp);
|
||||
unset($empData[$key]);
|
||||
$familyFloates = array_diff($familyFloates, [$familyFloatesValue]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($familyFloates as $familyFloatesValue) {
|
||||
|
||||
$temp2['is_value_exist'] = false;
|
||||
$temp2['data']['family_floater_key'] = $familyFloatesValue;
|
||||
$temp2['data']['client_policy_id'] = $array->ClientPolicyId;
|
||||
$temp2['data']['button_name'] = 'Add '.ucfirst(preg_replace('/\d/', '', $familyFloatesValue));
|
||||
$temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue);
|
||||
|
||||
array_push($data,$temp2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$array->mapped_family_floaters = $data;
|
||||
|
||||
|
||||
|
||||
if($this->request->getGet('policy') == 'GMC'){
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $array], 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$result[] = $array;
|
||||
}
|
||||
//return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -18,15 +18,7 @@ class AuthJWT implements FilterInterface
|
||||
{
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
|
||||
$jwt ='';
|
||||
|
||||
if($request->headers()['Auth']){
|
||||
$jwt = $request->headers()['Auth'];
|
||||
}else{
|
||||
$jwt = $request->getHeader('Authorization');
|
||||
}
|
||||
|
||||
$jwt = $request->getHeader('Authorization');
|
||||
|
||||
if ($jwt) {
|
||||
if (JWTToken::validateJWT($jwt)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user