diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 74a6bf4e..e9d2aea9 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -726,6 +726,7 @@ $routes->group("employeeRest", ["filter" => ['GlobalPostFileUploadGuard', 'ratel $routes->get("deleteDependence", "EmployeeRestController::deleteDependence"); $routes->get("getEmployeeAndDependenceByClientId", "EmployeeRestController::getEmployeeAndDependenceByClientId"); $routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy"); + $routes->get("getClientRM", "EmployeeRestController::getClientRM"); $routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy"); $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn"); $routes->get("exportDataByClientPolicyId", "EmployeeRestController::exportDataByClientPolicyId"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index fcf7c9f6..176fba86 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1643,6 +1643,53 @@ class EmployeeRestController extends AdminController } } + public function getClientRM() + { + try { + $client_id = $this->request->getGet('client_id'); + + if (empty($client_id)) { + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'client_id is required'], 200); + } + + $clientRmRecords = $this->clientRMModel + ->select('client_rm.level, user_profiles.first_name, user_profiles.email, user_profiles.mobile') + ->join('user_profiles', 'user_profiles.id = client_rm.user_id') + ->where('md5(client_rm.client_id)', $client_id) + ->where('client_rm.is_active', 1) + ->whereIn('client_rm.level', [1, 3]) + ->findAll(); + + $level_1 = []; + $level_2 = []; + + foreach ($clientRmRecords as $record) { + $user = [ + 'first_name' => $record['first_name'], + 'email' => $record['email'], + 'mobile' => $record['mobile'], + ]; + + if ((int) $record['level'] === 3) { + $level_1[] = $user; + } else { + $level_2[] = $user; + } + } + + return $this->respond([ + 'status' => 'success', + 'code' => 200, + 'data' => [ + 'level_1' => $level_1, + 'level_2' => $level_2, + ], + ], 200); + } catch (\Exception $e) { + return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500); + } + } + public function getAddOnPolicy() { try { @@ -2264,6 +2311,11 @@ class EmployeeRestController extends AdminController client_policy.inception_type as inception_type, client_policy.policy_no as policy_no, client_policy.insurer_id as insurer_id, + client_policy.policy_terms, + insurers.name as insurer_name, + tpa.name as tpa_name, + tpa.short_name as tpa_short_name, + insurers.short_name as insurer_short_name, DATE_FORMAT(client_policy.policy_start_date, '%d-%m-%Y') AS policy_start_date, DATE_FORMAT(client_policy.policy_end_date, '%d-%m-%Y') AS policy_expiry_date, clients.client_logo as client_logo, @@ -2278,6 +2330,8 @@ class EmployeeRestController extends AdminController ", false) ->join('clients', 'clients.id = client_policy.client_id', 'left') ->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left') + ->join('insurers', 'insurers.id = client_policy.insurer_id', 'left') + ->join('tpa', 'tpa.id = client_policy.tpa_id', 'left') ->where('md5(client_policy.client_id)', $this->request->getGet('client_id')) ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id')) ->where('client_policy.is_active', 1) @@ -2316,6 +2370,26 @@ class EmployeeRestController extends AdminController $value['is_ecard_bulk_download'] = 0; $value['is_ecard_bulk_download_for_employee'] = 0; + $terms = json_decode($value['policy_terms'], true) ?? []; + if ($value['policy_type_id'] == 1) { + $policyGroup = 'gpa'; + } elseif (in_array($value['policy_type_id'], [6, 7, 72])) { + $policyGroup = 'other'; + } else { + $policyGroup = 'gmc'; + } + $value['policy_terms'] = isset($terms['enrollment_display_key']) && ! empty($terms['enrollment_display_key']) + ? $terms['enrollment_display_key'] + : $this->policyTermsFiter($terms, $policyGroup); + + $sumInsuredLabel = in_array($value['policy_type_id'], [1, 6, 7]) ? 'Sum Assured' : 'Sum Insured'; + $sumInsuredValue = $terms['sum_insured'] ?? ($terms['sumInsured2'] ?? null); + if ($sumInsuredValue !== null && $sumInsuredValue !== '') { + if (! array_key_exists($sumInsuredLabel, $value['policy_terms'])) { + $value['policy_terms'] = array_merge([$sumInsuredLabel => $sumInsuredValue], $value['policy_terms']); + } + } + array_push($result, $value); } diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 098229d9..25c51f36 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -2218,7 +2218,7 @@ body[data-sidebar-size="condensed"] .footer {