FEAT_COPY_POLICY
This commit is contained in:
parent
1231e28e99
commit
e1def8e953
@ -499,6 +499,8 @@ $routes->group("employeeRest", ['filter' => ['appSignature' , 'authJWT'] ], func
|
||||
$routes->get("hrFileDownload", "EmployeeRestController::hrFileDownload");
|
||||
$routes->post("hrFileUpload", "EmployeeRestController::hrFileUpload");
|
||||
|
||||
$routes->get("copyActiveEmployeeAndDependentDetails", "EmployeeRestController::copyActiveEmployeeAndDependentDetails");
|
||||
|
||||
});
|
||||
|
||||
$routes->group("employeeRest", ['filter' => ['appSignature'] ], function ($routes) {
|
||||
|
||||
@ -3682,8 +3682,8 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
|
||||
public function hrFileUpload()
|
||||
{
|
||||
try {
|
||||
@ -3832,4 +3832,98 @@ class EmployeeRestController extends AdminController
|
||||
}
|
||||
|
||||
|
||||
// copy the active enrolled employee data
|
||||
public function copyActiveEmployeeAndDependentDetails()
|
||||
{
|
||||
$received_payload = $this->request->getGet();
|
||||
$client_id = $received_payload['client_id'] ?? null;
|
||||
$emp_code = $received_payload['emp_code'] ?? null;
|
||||
$new_client_policy_id = $received_payload['new_client_policy_id'] ?? null;
|
||||
|
||||
if (empty($client_id)) {
|
||||
return $this->respond(['status' => "failed", 'code' => 404, 'message' => "client_id is required"], 200);
|
||||
}
|
||||
|
||||
if (empty($new_client_policy_id)) {
|
||||
return $this->respond(['status' => "failed", 'code' => 404, 'message' => "client_policy_id is required"], 200);
|
||||
}
|
||||
|
||||
if (empty($emp_code)) {
|
||||
return $this->respond(['status' => "failed", 'code' => 404, 'message' => "emp_code is required"], 200);
|
||||
}
|
||||
|
||||
$client_policy_data = $this->clientPolicyModel
|
||||
->where('is_active', 1)
|
||||
->where('client_id', $client_id)
|
||||
->where('id', $new_client_policy_id)
|
||||
->whereIn('policy_type_id', [2, 3, 4, 5])
|
||||
->first();
|
||||
|
||||
if (empty($client_policy_data)) {
|
||||
return $this->respond(['status' => "failed", 'code' => 404, 'message' => "Policy data not found", 'data' => []], 200);
|
||||
}
|
||||
|
||||
$policy_terms = $client_policy_data['policy_terms'] ?? null;
|
||||
|
||||
if (empty($policy_terms)) {
|
||||
return $this->respond(['status' => "failed", 'code' => 404, 'message' => "Policy terms not found", 'data' => []], 200);
|
||||
}
|
||||
|
||||
$policy_terms = json_decode($policy_terms, true);
|
||||
|
||||
$family_floaters = $policy_terms['family_floaters'];
|
||||
|
||||
$empData = $this->employeeModel
|
||||
->where('emp_code', $emp_code)
|
||||
->where('client_id', $client_id)
|
||||
->where('emp_status', 'enrolled')
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
if (empty($empData)) {
|
||||
return $this->respond(['status' => "failed", 'code' => 404, 'message' => "employee data not found", 'data' => []], 200);
|
||||
}
|
||||
|
||||
$floters = $this->FloterConvertion($family_floaters);
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($floters 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'] = $this->convertDateFormatDMY($value['dob']);
|
||||
$temp['data']['client_policy_id'] = $new_client_policy_id;
|
||||
$temp['data']['form_type'] = $dependent;
|
||||
$temp['data']['basic_cover_si'] = null;
|
||||
|
||||
|
||||
$temp['data']['age_validation'] = $this->getAgeRange($policy_terms, $familyFloatesValue);
|
||||
|
||||
|
||||
array_push($data, $temp);
|
||||
unset($empData[$key]);
|
||||
$floters = array_diff($floters, [$familyFloatesValue]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($data)){
|
||||
return $this->respond(['status' => "succese", 'code' => 200, 'data' => $data], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => "failed", 'code' => 404, 'message' => "No data found", 'data' => []], 200);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user