FIX_PRE_POLICY_COUNT_GET_FUNCTION_ISSUE_AND_GET_EMPLOYEE_POLICY_ONLY_ACTIVE_STATUS

This commit is contained in:
VENKATESHWARAN 2025-11-04 18:42:48 +05:30
parent ff63ea8ecd
commit 8f71e5a7e2
3 changed files with 43 additions and 17 deletions

View File

@ -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));

View File

@ -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();

View File

@ -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();
}