FIX_ENROLLMENT_ADD_ISSUE

This commit is contained in:
VENKATESHWARAN 2025-12-24 10:39:32 +05:30
parent 317723c1a7
commit 01e6ec06be

View File

@ -369,6 +369,19 @@ class EmployeeRestController extends AdminController
$basic_cover_si = $policy_terms->sum_insured;
}
$other_employee_policy_data = $this->employeePolicyModel
->select('employee_polices.*')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('employees.emp_code', $emp_code)
->where('employee_polices.client_policy_id', $client_policy_id)
->where('employee_polices.is_active', 1)
->where('employees.is_active', 1)
->where('employee_polices.status', ['draft', 'enrolled'])
->where('employees.emp_status', ['draft', 'enrolled'])
->where('employee_polices.enrollment_open_date is not null')
->where('employee_polices.enrollment_close_date is not null')
->first();
$checkDataExist = $this->employeePolicyModel->where('employee_id',$employee_id)->where('client_policy_id',$client_policy_id)->where('is_active', 1)->first();
if($checkDataExist){
@ -389,6 +402,11 @@ class EmployeeRestController extends AdminController
$data['status']= 'draft';
$data['date_coverage'] = $this->getEmployeeCoverageDate($emp_code, $client_policy_id);
if(!empty($other_employee_policy_data)){
$data['enrollment_open_date']= $other_employee_policy_data['enrollment_open_date'] ?? null;
$data['enrollment_close_date']= $other_employee_policy_data['enrollment_close_date'] ?? null;
}
// dd($data);
$this->employeePolicyModel->insert($data);
@ -470,7 +488,6 @@ class EmployeeRestController extends AdminController
}else{ return null; }
}
public function RelationshipMap($value){
if ($value === 'Mother' || $value === 'Father') {
@ -3716,20 +3733,23 @@ class EmployeeRestController extends AdminController
}
public function findThePolicyIsOpenForEnrollment($plicy_id, $emp_code)
public function findThePolicyIsOpenForEnrollment($policy_id, $emp_code)
{
// $policy = $this->clientPolicyModel->where('id',$plicy_id)->where('open_for_enrollment',1)->find();
$policy = $this->employeePolicyModel
->join('employees', 'employee_polices.employee_id = employees.id')
->where('employees.emp_code',$emp_code)
->where('employees.family_floater_key','self')
->where('employee_polices.client_policy_id',$plicy_id)
->where('employee_polices.client_policy_id',$policy_id)
->where('employee_polices.enrollment_open_date <= CURDATE()', null, false)
->where('employee_polices.enrollment_close_date >= CURDATE()', null, false)
->where('employee_polices.enrollment_open_date is not null')
->where('employee_polices.enrollment_close_date is not null')
->where('employees.is_active', 1)
->where('employee_polices.is_active', 1)
->find();
->whereIn('employee_polices.status', ['draft', 'enrolled'])
->whereIn('employees.emp_status', ['draft', 'enrolled'])
->first();
if($policy)
return true;