CHANGE_PRE_POLICY_COUNT : RV
This commit is contained in:
parent
2b5738a3ae
commit
7ee55190a2
@ -74,6 +74,21 @@ class Database extends Config
|
||||
'busyTimeout' => 1000,
|
||||
];
|
||||
|
||||
public $preDB = [
|
||||
'DSN' => '',
|
||||
'hostname' => 'localhost',
|
||||
'username' => 'root',
|
||||
'password' => 'root',
|
||||
'database' => 'other_db',
|
||||
'DBDriver' => 'MySQLi',
|
||||
'DBPrefix' => '',
|
||||
'pConnect' => false,
|
||||
'DBDebug' => (ENVIRONMENT !== 'production'),
|
||||
'charset' => 'utf8',
|
||||
'DBCollat' => 'utf8_general_ci',
|
||||
];
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
@ -2760,6 +2760,11 @@ class EmployeeRestController extends AdminController
|
||||
->where('client_branch_id',$this->request->getGet('client_branch_id'))
|
||||
->where('family_floater_key','self')->where('is_active', 1 )
|
||||
->get()->getRow()->name;
|
||||
|
||||
//for get the pre enrollment policy count
|
||||
$empMobileNo = $this->request->getGet('mobile_no');
|
||||
$prePolicyCount = $this->getPreEmployeePolicyCount($empMobileNo);
|
||||
|
||||
$whereArrayForId = [];
|
||||
foreach ( $employeeData as $key => $value) { array_push($whereArrayForId, $value['id']); }
|
||||
|
||||
@ -2807,6 +2812,7 @@ class EmployeeRestController extends AdminController
|
||||
$data['heading'] = $ClientPolicyValue['policy_long_name'];
|
||||
$data['claims_grace_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['claims_grace_date']);
|
||||
$data['policy_status'] = $policy_status_key;
|
||||
$data['pre_policy_count'] = $prePolicyCount;
|
||||
// $data['policy_terms'] = $terms;
|
||||
|
||||
// if($ClientPolicyValue['policy_type_id'] == 1){ $data['heading'] = 'Group Personal Accident Coverage'; }else
|
||||
@ -3583,5 +3589,61 @@ class EmployeeRestController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function getEmployeePolicyCount()
|
||||
{
|
||||
$db2 = \Config\Database::connect('preDB');
|
||||
|
||||
$mobile_no = $this->request->getGet('mobile_no');
|
||||
|
||||
$builder = $db2->table('employees')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.is_active', 1)
|
||||
->whereIn('employees.emp_status', ['draft', 'enrolled'])
|
||||
->where('employee_polices.is_active', 1)
|
||||
->whereIn('employee_polices.status', ['draft', 'enrolled'])
|
||||
->where('employees.mobile', $mobile_no)
|
||||
->groupBy('employee_polices.client_policy_id');
|
||||
|
||||
$query = $builder->get();
|
||||
$count = $query->getNumRows(); // count grouped rows manually
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'code' => 200,
|
||||
'policy_count' => $count
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function getPreEmployeePolicyCount($mobile_no)
|
||||
{
|
||||
if (empty($mobile_no)) {
|
||||
return 0; // mobile is empty, return policy count 0
|
||||
}
|
||||
|
||||
try {
|
||||
$db2 = \Config\Database::connect('preDB');
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', 'DB connection to preDB failed: ' . $e->getMessage());
|
||||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
$builder = $db2->table('employees')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.is_active', 1)
|
||||
->whereIn('employees.emp_status', ['draft', 'enrolled'])
|
||||
->where('employee_polices.is_active', 1)
|
||||
->whereIn('employee_polices.status', ['draft', 'enrolled'])
|
||||
->where('employees.mobile', $mobile_no)
|
||||
->groupBy('employee_polices.client_policy_id');
|
||||
|
||||
$query = $builder->get();
|
||||
return $query->getNumRows();
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', 'Query failed in getPreEmployeePolicyCount: ' . $e->getMessage());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user