From 8f71e5a7e2637e59a65afbdc78c4d249491d6ad5 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 4 Nov 2025 18:42:48 +0530 Subject: [PATCH 1/3] FIX_PRE_POLICY_COUNT_GET_FUNCTION_ISSUE_AND_GET_EMPLOYEE_POLICY_ONLY_ACTIVE_STATUS --- app/Controllers/EmployeeRestController.php | 53 ++++++++++++++----- app/Controllers/EmployeeServiceController.php | 6 +-- app/Models/EmployeePolicyModel.php | 1 + 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 3e44328e..91086329 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2831,7 +2831,7 @@ class EmployeeRestController extends AdminController ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) ->where('client_policy.is_active', 1 ) ->where('client_policy.policy_status', $policy_status) - ->where('client_policy.enrolment_visibility', 1 ) + ->where('client_policy.enrolment_visibility', 1) ->orderby('client_policy.id' , 'ASC') ->findAll(); @@ -2840,16 +2840,25 @@ class EmployeeRestController extends AdminController ->where('client_id',$this->request->getGet('client_id')) ->where('client_branch_id',$this->request->getGet('client_branch_id')) ->where('is_active', 1 )->findAll(); - $employeeName = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code')) + + $employeeSelfData = $this->employeeModel->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')->where('is_active', 1 ) - ->get()->getRow()->name; + ->get()->getRow(); + $employeeName = $employeeSelfData->name ?? ""; + + //for get the pre enrollment policy count $empMobileNo = $this->request->getGet('mobile_no'); $clientId = $this->request->getGet('client_id'); - $prePolicyCount = $this->getPreEmployeePolicyCount($empMobileNo, $clientId); + + if(!empty($employeeSelfData) && isset($employeeSelfData->email_corporate)){ + $prePolicyCount = $this->getPreEmployeePolicyCount($empMobileNo, $clientId, $employeeSelfData->email_corporate); + }else{ + $prePolicyCount = $this->getPreEmployeePolicyCount($empMobileNo, $clientId); + } $whereArrayForId = []; foreach ( $employeeData as $key => $value) { array_push($whereArrayForId, $value['id']); } @@ -2972,7 +2981,11 @@ class EmployeeRestController extends AdminController function policyTermsFiter($terms , $type) - { + { + if(empty($terms)){ + return []; + } + $gpa = [ "sumInsured2" => "Sum Insured", "totalSumInsured" => "Total Sum Assured", @@ -4082,18 +4095,19 @@ class EmployeeRestController extends AdminController // } // } - public function getPreEmployeePolicyCount($mobile_no, $clientId = null) - { - log_message('error', 'STEP 1: getPreEmployeePolicyCount called with params: ' . json_encode(['mobile_no' => $mobile_no, 'client_id' => $clientId])); + public function getPreEmployeePolicyCount($mobile_no, $clientId = null, $email = null) + { + log_message('error', 'STEP 1: getPreEmployeePolicyCount called with params: ' . json_encode(['mobile_no' => $mobile_no, 'client_id' => $clientId, 'email' => $email])); - if (empty($mobile_no)) { - log_message('error', 'STEP 2: Mobile number is empty or null. Returning 0.'); + if (empty($mobile_no) && empty($email)) { + log_message('error', 'STEP 2: Mobile number and Email is empty or null. Returning 0.'); return 0; } $client_short_name = null; if (!empty($clientId)) { + log_message('error', 'STEP 3: Fetching client short name for client ID: ' . $clientId); $client_data = $this->clientModel->where('is_active', 1)->where('id', $clientId)->first(); @@ -4103,14 +4117,25 @@ class EmployeeRestController extends AdminController } else { log_message('error', 'STEP 4: No client found for ID: ' . $clientId); } + } else { log_message('error', 'STEP 3: No clientId provided. Skipping client lookup.'); } - $post_data = [ - 'mobile_number' => $mobile_no, - 'client_short_name' => $client_short_name - ]; + if(!empty($email)){ + $post_data = [ + 'email_id' => $email, + 'client_short_name' => $client_short_name + ]; + }else{ + $post_data = [ + 'mobile_number' => $mobile_no, + 'client_short_name' => $client_short_name + ]; + + } + + log_message('error', 'STEP 5: Calling third-party API with payload: ' . json_encode($post_data)); diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 95940c90..4b71694c 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1514,9 +1514,9 @@ class EmployeeServiceController extends AdminController ->where('employees.client_id',$file['client_id']) ->where('employees.client_branch_id',$file['client_branch_id']) ->where('employee_polices.client_policy_id',$file['policy_id']) - ->where('employees.emp_status !=','truncated') + ->where('employees.emp_status','active') ->where('employees.is_active', 1) - ->where('employee_polices.status !=','truncated') + ->where('employee_polices.status','active') ->where('employee_polices.is_active', 1) ->first(); @@ -1550,7 +1550,7 @@ class EmployeeServiceController extends AdminController $employee_policy = $this->employeePolicyModel ->where('employee_id',$employee['id']) ->where('client_policy_id',$file['policy_id']) - ->where('status !=','truncated') + ->where('status','active') ->where('is_active', 1) ->first(); diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 4a730206..1d0dc8bf 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -382,6 +382,7 @@ class EmployeePolicyModel extends Model { return $this->where('employee_id',$arr['employee_id']) ->where('client_policy_id',$arr['client_policy_id']) + ->where('status', 'active') ->where('is_active',1) ->find(); } From 581ee4a07c55e95dd71c37bc2791ea8af32a8332 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 4 Nov 2025 18:43:50 +0530 Subject: [PATCH 2/3] CHANGE_ROUTE --- app/Config/Routes.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 0bc4cbf5..73608db8 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -500,12 +500,16 @@ $routes->cli('cli/sendMailWithAutoQuery','TicketController::sendMailWithAutoQuer //Employee login api's $routes->post("/employeeRest/verifyEmployeeNumber", "RestAuthenticationController::verifyEmployeeWithMobileNumber"); $routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); -$routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin"); -$routes->post("/employeeRest/checkMpin", "RestAuthenticationController::checkMpin"); $routes->post("/employeeRest/verifyEmployeeEmailId", "RestAuthenticationController::verifyEmployeeWithEmailId"); $routes->post("/employeeRest/updateEmpOTP", "RestAuthenticationController::updateEmpOTP"); + +$routes->post("employeeRest/saveMpin", "RestAuthenticationController::saveMpin"); +$routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMpin"); +$routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin"); +$routes->post("/employeeRest/checkMpin", "RestAuthenticationController::checkMpin"); $routes->post("/employeeRest/updateEmpMPIN", "RestAuthenticationController::updateEmpMPIN"); $routes->post("employeeRest/forgotMPIN", "RestAuthenticationController::forgotMPIN"); +$routes->post("employeeRest/updateMobileNumber", "RestAuthenticationController::updateMobileNumber"); // $routes->post("/employeeRest/saveMpin", "RestAuthenticationController::saveMpin"); @@ -529,8 +533,6 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) { $routes->post("getId", "RestAuthenticationController::getUserIdFromToken"); }); -$routes->post("employeeRest/saveMpin", "RestAuthenticationController::saveMpin"); -$routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMpin"); $routes->post("employeeRest/getPostEmployeeDataForAuth", "RestAuthenticationController::getPostEmployeeDataForAuth"); // $routes->post("logHrActivity", "RestAuthenticationController::logHrActivity"); From 2dee0dc63e4028ad7407f6234811e6c7f951551a Mon Sep 17 00:00:00 2001 From: velz Date: Wed, 5 Nov 2025 09:35:26 +0530 Subject: [PATCH 3/3] FIX_LEAD_LIST_500_ERROR --- app/Controllers/LeadsController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 3ead1911..92fa8a52 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -344,10 +344,15 @@ class LeadsController extends BaseController $where = []; foreach ($search_data as $search_objects => $key) { if ($key != null && $key != '' && $key != 0 && $search_objects != 'is_dashboard') { - $where[$search_objects] = $key; + if($search_objects == 'status') + { + $where[('leads.'.$search_objects)] = $key; + }else{ + $where[$search_objects] = $key; + } } } - + // !dd($where); $data['lead_data_list'] = $this->leadsModel->getLeadDataForLising($where); $html = view('leads_list', $data);