From fb0426a308f88286a8d93480a1ab719cadd71d18 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Mon, 16 Jun 2025 17:27:57 +0530 Subject: [PATCH] CHANGES_ in hr api's : GWM --- app/Config/Routes.php | 3 +- app/Controllers/EmployeeRestController.php | 92 ++++++++-------------- 2 files changed, 35 insertions(+), 60 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index e702f37..1b552d8 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -477,7 +477,8 @@ $routes->post("calculatePremium", "EmployeeRestController::calculatePremium"); $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn"); $routes->get("exportDataByClientPolicyId", "EmployeeRestController::exportDataByClientPolicyId"); - $routes->get("getCashDepositData", "EmployeeRestController::getCashDepositData"); + + $routes->get("getPolicyLevelEmployeeSummaryData", "EmployeeRestController::getPolicyLevelEmployeeSummaryData"); $routes->get("exportCashDepositData", "EmployeeRestController::exportCashDepositData"); $routes->get("removeEmpAndEmpPolicyData", "EmployeeRestController::removeEmpAndEmpPolicyData"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 191d356..3f03147 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2487,72 +2487,46 @@ class EmployeeRestController extends AdminController } - public function getCashDepositData() + public function getPolicyLevelEmployeeSummaryData() { - $ClientPolicyData = $this->clientPolicyModel->select('client_policy.client_id as clientId , client_policy.insurer_id as insurerId,insurers.name as insurer_name') - ->join('insurers', 'client_policy.insurer_id = insurers.id', 'left') - ->where('client_policy.client_id', $this->request->getGet('client_id') ) - ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) - ->where('client_policy.is_active', 1 ) - ->where('client_policy.policy_status', 1) - ->groupBy('client_policy.insurer_id') - ->findAll(); - $result = []; - - if(count($ClientPolicyData)) - { - foreach ($ClientPolicyData as $key => $value) { - - $data['clientId'] = $value['clientId']; - $data['insurerId'] = $value['insurerId']; - $data['insurerName'] = $value['insurer_name']; - $data['depositData'] = $this->clientPolicyModel->getdepositData($value['clientId'],$value['insurerId']); - $data['balance'] = count($data['depositData']) ? $data['depositData'][0]->balance : 0; - - $data['policyDetails'] = []; - $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type ') - - ->where('client_policy.insurer_id', $value['insurerId'] ) - ->where('client_policy.client_id', $this->request->getGet('client_id') ) - ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) - ->where('client_policy.is_active', 1 ) - ->where('client_policy.policy_status', 1) - ->findAll(); - // dd( $ClientPolicyData); - foreach ($ClientPolicyData as $key => $value) + + $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type ') + ->where('client_policy.client_id', $this->request->getGet('client_id') ) + ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) + ->where('client_policy.is_active', 1 ) + ->where('client_policy.policy_status', 1) + ->findAll(); + $result = []; + // dd( $ClientPolicyData); + foreach ($ClientPolicyData as $key => $value) + { + $policyTypeData = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow(); + $value['type'] = $policyTypeData->policy_type; + $value['policy_name'] = $policyTypeData->long_name; + $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0,branch_id:$this->request->getGet('client_branch_id')); + $enrolledCount = 0; + $draftCount = 0; + if(count($employeeDetails)) { - $policyTypeData = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow(); - $value['type'] = $policyTypeData->policy_type; - $value['policy_name'] = $policyTypeData->long_name; - $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0,branch_id:$this->request->getGet('client_branch_id')); - $enrolledCount = 0; - $draftCount = 0; - if(count($employeeDetails)) - { - foreach ($employeeDetails as $item) { - if ($item['emp_status'] === 'enrolled') { - $enrolledCount++; - } elseif ($item['emp_status'] === 'draft') { - $draftCount++; - } + foreach ($employeeDetails as $item) { + if ($item['emp_status'] === 'enrolled') { + $enrolledCount++; + } elseif ($item['emp_status'] === 'draft') { + $draftCount++; } } - - $value['totalMembersCount'] = count($employeeDetails); - $value['membersCountOfEnrolled'] = $enrolledCount; - $value['membersCountOfDraft'] = $draftCount; - - array_push($data['policyDetails'],$value); } - - - array_push($result,$data); - } - } - + $value['totalMembersCount'] = count($employeeDetails); + $value['membersCountOfEnrolled'] = $enrolledCount; + $value['membersCountOfDraft'] = $draftCount; + + array_push($result,$value); + } + + if($result) { @@ -2724,7 +2698,7 @@ class EmployeeRestController extends AdminController ->where('client_policy.enrolment_visibility', 1 ) ->orderby('client_policy.id' , 'ASC') ->findAll(); -dd( $ClientPolicyData); + // Retrieve employee and dependents data by passing the employee code $employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code')) ->where('client_id',$this->request->getGet('client_id'))