Merge branch 'dev' of bitbucket.org:jubilian/nhance-enrollment into dev
This commit is contained in:
commit
acfa3d8a37
@ -2269,12 +2269,18 @@ class EmployeeRestController extends AdminController
|
||||
try {
|
||||
|
||||
$emp_code = $this->request->getGet('emp_code');
|
||||
$client_id = $this->request->getGet('client_id');
|
||||
$client_branch_id = $this->request->getGet('client_branch_id');
|
||||
|
||||
$addOnEmployeeData = $this->employeeModel->where('is_active', 1 )
|
||||
->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('is_addon_value',1)->findAll();
|
||||
|
||||
|
||||
$policyIds = $this->getEmployeeAddOnPolicies($emp_code, $client_id, $client_branch_id);
|
||||
// dd($policyIds);
|
||||
|
||||
|
||||
$clientPolicy = $this->clientPolicyModel->select("
|
||||
@ -2305,7 +2311,11 @@ class EmployeeRestController extends AdminController
|
||||
->where('policy_status', 1)
|
||||
->where('is_active', 1)
|
||||
->where('enrolment_visibility', 1)
|
||||
->whereIn('id', $policyIds)
|
||||
->findAll();
|
||||
if(empty($policyIds)){
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => []], 200);
|
||||
}
|
||||
|
||||
if(count($clientPolicy))
|
||||
{
|
||||
@ -4438,4 +4448,61 @@ class EmployeeRestController extends AdminController
|
||||
];
|
||||
}
|
||||
|
||||
public function getEmployeeAddOnPolicies($emp_code, $client_id, $client_branch_id): array
|
||||
{
|
||||
$data = $this->employeeModel
|
||||
->select("
|
||||
client_policy.id AS gmc_client_policy_id,
|
||||
|
||||
(
|
||||
SELECT id FROM client_policy
|
||||
WHERE policy_type_id = 3
|
||||
AND base_policy = gmc_client_policy_id
|
||||
LIMIT 1
|
||||
) AS gmc_parent_policy_id,
|
||||
|
||||
(
|
||||
SELECT id FROM client_policy
|
||||
WHERE policy_type_id = 4
|
||||
AND base_policy = gmc_client_policy_id
|
||||
LIMIT 1
|
||||
) AS gmc_topup_policy_id
|
||||
")
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->join('client_policy', 'employee_polices.client_policy_id = client_policy.id')
|
||||
->where([
|
||||
'employees.is_active' => 1,
|
||||
'employee_polices.is_active' => 1,
|
||||
'client_policy.policy_type_id' => 2,
|
||||
'employees.family_floater_key' => 'self',
|
||||
'employees.emp_code' => $emp_code,
|
||||
'employees.client_id' => $client_id,
|
||||
'employees.client_branch_id' => $client_branch_id,
|
||||
])
|
||||
->first();
|
||||
|
||||
// dd($data);
|
||||
// dd( db_connect()->getLastQuery());
|
||||
|
||||
if (!empty($data) && !empty($data['gmc_parent_policy_id'])) {
|
||||
|
||||
$getParentTopUp = $this->clientPolicyModel
|
||||
->select('id AS gmc_parent_topup_policy_id')
|
||||
->where('is_active', 1)
|
||||
->where('policy_type_id', 5) // parent Top-Up
|
||||
->where('base_policy', $data['gmc_parent_policy_id'])
|
||||
->first();
|
||||
}
|
||||
|
||||
if (empty($data)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$policyIds[] = $data['gmc_topup_policy_id'];
|
||||
$policyIds[] = $data['gmc_parent_policy_id'];
|
||||
$policyIds[] = $getParentTopUp['gmc_parent_topup_policy_id'] ?? null;
|
||||
|
||||
return $policyIds;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user