From 32b64d236d1a6812acc423e6cc86b228a7661b1b Mon Sep 17 00:00:00 2001 From: Smart Date: Sat, 26 Oct 2024 17:01:29 +0530 Subject: [PATCH] CHANGE_create date_coverage filed value while dependent creation : GWM --- app/Controllers/EmployeeRestController.php | 51 +++++++++++++++++----- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index b4359c53..dd807973 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -309,6 +309,7 @@ class EmployeeRestController extends AdminController $data['client_policy_id']= $client_policy_id; $data['basic_cover_si']= $basic_cover_si; $data['status']= 'draft'; + $data['date_coverage'] = $this->getEmployeeCoverageDate($emp_code, $client_policy_id); $this->employeePolicyModel->insert($data); @@ -320,10 +321,7 @@ class EmployeeRestController extends AdminController public function updatePremiumAmount($client_policy_id , $emp_code , $client_branch_id) { $response = $this->calculatePremium($client_policy_id , $emp_code , null , $client_branch_id); - // echo '
';
-        // print_r($response);
-        // echo '
'; - // die(); + if(count($response[$emp_code])) { @@ -354,6 +352,45 @@ class EmployeeRestController extends AdminController } } + public function getEmployeeCoverageDate($emp_code, $client_policy_id) + { + $empData = $this->employeeModel->where('emp_code',$emp_code)->where('relationship', 'self')->where('is_active',1)->first();; + if($empData) + { + $empPolicyData = $this->employeePolicyModel->select('employee_polices.employee_id,employee_polices.client_policy_id,employee_polices.date_coverage,client_policy.policy_type_id,client_policy.base_policy') + ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id', 'left') + ->where('employee_polices.employee_id' , $empData['id'] ) + ->where('employee_polices.is_active' , 1 ) + ->findAll(); + if(count($empPolicyData)) + { + // find same policy 'self' date of coverage + $filterSelfPolicy = array_filter($empPolicyData, function($row) use ($client_policy_id) { + return $row['client_policy_id'] == $client_policy_id; + }); + $filterSelfPolicy = array_values($filterSelfPolicy); // Reset the index of the filtered result + + if(count($filterSelfPolicy)){ + return $filterSelfPolicy[0]['date_coverage']; + }else{ + // find base policy 'self' date of coverage + $basePolicy = $this->clientPolicyModel->where('id',$client_policy_id)->get()->getRow()->base_policy; + + $filterSelfBasePolicy = array_filter($empPolicyData, function($row) use ($basePolicy) { + return $row['client_policy_id'] == $basePolicy; + }); + $filterSelfBasePolicy = array_values($filterSelfBasePolicy); // Reset the index of the filtered result + + if(count($filterSelfBasePolicy)){ + return $filterSelfBasePolicy[0]['date_coverage']; + }else{ return null; } + } + + }else{ return null; } + + }else{ return null; } + } + public function RelationshipMap($value){ @@ -432,7 +469,6 @@ class EmployeeRestController extends AdminController } - // Get the RelationShip list public function createOrUpdateEmployeePolicySiAmount() { @@ -632,11 +668,6 @@ class EmployeeRestController extends AdminController } - - - - - // Upload the Employee Detail in DB by Sheet Data public function employeeUpload() {