From bcb83b85bf1367401bab8933132c0c11090783d1 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Tue, 19 Mar 2024 21:45:04 +0530 Subject: [PATCH] GWM:CHANGES-IN-EMP-POLICY-API --- app/Controllers/EmployeeModel.php | 57 ++++++++++++++++++++++ app/Controllers/EmployeeRestController.php | 14 ++++++ 2 files changed, 71 insertions(+) create mode 100644 app/Controllers/EmployeeModel.php diff --git a/app/Controllers/EmployeeModel.php b/app/Controllers/EmployeeModel.php new file mode 100644 index 00000000..52382dc1 --- /dev/null +++ b/app/Controllers/EmployeeModel.php @@ -0,0 +1,57 @@ +db->table('employee_polices') + ->select(' policies.name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment') // Select all columns from both tables + ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id') + ->join('policies', 'policies.id = client_policy.policy_id') + ->where('employee_polices.employee_id', $id) + ->get() + ->getResult(); + } + + + + + // for EMP rest API process do not change + public function checkExistingEmpEntrollment($arr) + { + return $this->where('emp_code',$arr['emp_code'])->where('name',$arr['name'])->first(); + } + +} diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 1d9d8088..cdeca663 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -161,12 +161,14 @@ class EmployeeRestController extends AdminController if (isset($item->id)) { //update old data $id = $item->id; + $item->family_floater_key = $this->RelationshipMap($item->relationship); $employee = $this->employeeModel->update($id, (array)$item); if ($employee) { $Count++; } }else{ //create new data + $item->family_floater_key = $this->RelationshipMap($item->relationship); $employee = $this->employeeModel->insert($item); if ($employee) { $Count++; @@ -190,6 +192,18 @@ class EmployeeRestController extends AdminController } + public function RelationshipMap($value){ + + if ($value === 'Mother' || $value === 'Father') { + return 'parent'; + } else if($value === 'Son' || $value === 'Daughter'){ + return 'child'; + }else if($value === 'Father in Law' || $value === 'Mother in Law'){ + return 'parent_in_law'; + }else if($value === 'Spouse'){ + return 'spouse'; + } + } public function deleteDependence() { try {