From 00dd88a6eb3f16c8ba476a152e37f9e2eb94aa76 Mon Sep 17 00:00:00 2001 From: velz Date: Mon, 3 Jun 2024 13:56:47 +0530 Subject: [PATCH] CHANGE_DATE_DAYS_ISSUE&ADDTION_ENDORSEMENT --- app/Controllers/EmployeeRestController.php | 2 +- app/Controllers/EmployeeServiceController.php | 20 ++++++++++++++++++- app/Helpers/excel_util_helper.php | 9 +++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index c31cabe7..b6fbcf86 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1372,7 +1372,7 @@ public function getAddOnPolicy() if(count($clientPolicy)) { - $band = $addOnEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('client_branch_id',$this->request->getGet('client_branch_id'))->where('family_floater_key','self')->get()->getRow()->band; + $band = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('client_branch_id',$this->request->getGet('client_branch_id'))->where('family_floater_key','self')->get()->getRow()->band; $PolicyData = []; foreach ($clientPolicy as $key => $array) { $responce = []; diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index cb6705f4..d1286daa 100644 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -956,7 +956,19 @@ class EmployeeServiceController extends AdminController $this->employeePolicyModel->save($policy_data); $emp_policy_id = $this->employeePolicyModel->getInsertID(); - if($emp_policy_id != 0){ $log_message .= ' with PK ' . $emp_policy_id; } + if($emp_policy_id != 0)//emp policy inserted + { + $log_message .= ' with PK ' . $emp_policy_id; + + //make endorsement entry if action is addition OR Dependt addition + if(($file['action'] == 'dependent_addition' || $file['action'] == 'addition') && $value['temp']['source'] == 'excel') + { + $actions = ($file['action'] == 'dependent_addition' ? 'da' : ($file['action'] == 'addition' ? 'a' : NULL)); + $addition_endorse_data = ['pk' => $emp_policy_id,'group_key' => rand(100000, 999999),'emp_cdoe' => $value['emp_code'],'table_name' => 'employee_polices','actions' => $actions,'field_name' => 'basic_cover_si','old_value' => NULL,'new_value' => $policy_data['basic_cover_si'],'remarks' => 'addition endorsement','file_id' => $file['id'],'created_by' => $file['created_by']]; + $this->employeeEndorsementforAddtionAndDependentAddition($addition_endorse_data); + } + + } else{ $emp_policy_id = $employee_policy[0]['id']; } $this->myLogger->logme('error',$log_message); @@ -965,6 +977,12 @@ class EmployeeServiceController extends AdminController }// for end }//function end + + public function employeeEndorsementforAddtionAndDependentAddition($employee) + { + $this->empEndorsementModel->save($employee); + } + // $employee -> holds existing emp model obj and $policy_data holds new policy changes as array public function employeesSIEnhanceProcessWhileOnbboard(array $employee,array $policy_data,array $file) { diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index f48669a8..07794f45 100644 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -7,14 +7,19 @@ use Kint\Kint; if(!function_exists('calculate_days_bw_dates')) { - function calculate_days_bw_dates(string $from_date = "", string $to_date ="") + function calculate_days_bw_dates(string $from_date = "", string $to_date ="",bool $include_start_date = true) { if($to_date == ""){ $currentDateTime = new DateTime(); } else{ $currentDateTime = new DateTime($to_date); } if($from_date == ""){ $passedDateTime = new DateTime(); } else{ $passedDateTime = new DateTime($from_date); } - return $interval = $currentDateTime->diff($passedDateTime); + $interval = $currentDateTime->diff($passedDateTime); + if ($include_start_date) { + $interval->days += 1; + } + + return $interval; } }