MERGE_UAT_BUG_FIXES

This commit is contained in:
Ubuntu 2026-06-25 10:43:04 +05:30
commit 42299b89a1
5 changed files with 294 additions and 1 deletions

View File

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

View File

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

View File

@ -2218,7 +2218,7 @@ body[data-sidebar-size="condensed"] .footer {
<ul class="nav-third-level">
<?php if (
in_array(POS_TEAM_ID, user_team()) // Case 4: Role Any + Must be in POS Team (global guard)
&& (
||(
in_array(get_role_id(), [1, 5]) // Case 1: Role 1 or 5
|| (in_array(get_role_id(), [4]) && in_array(FINANCE_TEAM_ID, user_team())) // Case 2: Role 4 + Finance Team
|| in_array(MANAGEMENT_TEAM_ID, user_team()) // Case 3: Role Any + Management Team

211
get-client-rm-api.md Normal file
View File

@ -0,0 +1,211 @@
# Get Client RM API
Returns Level 1 (Account Manager) and Level 2 (Head) contact details for a client.
**Controller:** `EmployeeRestController::getClientRM`
**Method:** `GET`
---
## Endpoint
```
GET /employeeRest/getClientRM
```
---
## Authentication
**JWT token is required.** This endpoint is available only in the authenticated route group.
| Filter | Description |
|--------|-------------|
| `ratelimit` | Rate limiting |
| `appSignature` | App signature validation |
| `authJWT` | JWT token validation |
### Required Headers
| Header | Required | Description |
|--------|----------|-------------|
| `App-Signature` | Yes | Must match server `APP_SIGNATURE` from `.env` |
| `Authorization` | Yes | JWT token in format `Bearer <token>` |
### Example Headers
```
App-Signature: <your_app_signature>
Authorization: Bearer <jwt_token>
```
---
## Query Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `client_id` | string | Yes | MD5 hash of the client ID (32-character hex string) |
### Example Request
```
GET /employeeRest/getClientRM?client_id=5d41402abc4b2a76b9719d911017c592
```
**Note:** Pass the MD5 hash of the numeric client ID, not the raw client ID.
Example:
```
MD5(123) = 202cb962ac59075b964b07152d234b70
```
```
GET /employeeRest/getClientRM?client_id=202cb962ac59075b964b07152d234b70
```
---
## Success Response
**HTTP Status:** `200`
```json
{
"status": "success",
"code": 200,
"data": {
"level_1": [
{
"first_name": "John",
"email": "john@example.com",
"mobile": "9876543210"
}
],
"level_2": [
{
"first_name": "Jane",
"email": "jane@example.com",
"mobile": "9123456789"
}
]
}
}
```
---
## Response Fields
| Key | Type | Description |
|-----|------|-------------|
| `status` | string | `success` or `failed` |
| `code` | integer | Response code |
| `data.level_1` | array | Account Manager contact list |
| `data.level_2` | array | Head contact list |
| `first_name` | string | RM name |
| `email` | string | RM email |
| `mobile` | string | RM mobile number |
If no RM is assigned for a level, the corresponding array will be empty (`[]`).
---
## Level Mapping
| Response Key | Role | `client_rm.level` in DB |
|--------------|------|-------------------------|
| `level_1` | Account Manager | `3` |
| `level_2` | Head | `1` |
**Notes:**
- Only active records are returned (`client_rm.is_active = 1`).
- Manager (DB level `2`) is not included in this API.
- `level_1` can contain multiple Account Managers.
---
## Error Responses
### Missing `client_id`
**HTTP Status:** `200`
```json
{
"status": "failed",
"code": 400,
"message": "client_id is required"
}
```
### Missing Token
**HTTP Status:** `403`
```json
{
"status": 403,
"message": "Access Forbidden"
}
```
### Invalid or Expired Token
**HTTP Status:** `401`
```json
{
"status": 401,
"message": "Token is Invalid"
}
```
```json
{
"status": 401,
"message": "Token expired"
}
```
### Invalid App Signature
**HTTP Status:** `403`
```json
{
"status": false,
"message": "Forbidden: Invalid App Signature"
}
```
### Server Error
**HTTP Status:** `500`
```json
{
"status": "failed",
"code": 500,
"data": "Error message"
}
```
---
## Route Registration
Defined in `app/Config/Routes.php` (authenticated group only):
```php
$routes->group("employeeRest", ["filter" => ['GlobalPostFileUploadGuard', 'ratelimit', 'appSignature', 'authJWT']], function ($routes) {
$routes->get("getClientRM", "EmployeeRestController::getClientRM");
});
```
---
## Source
Implementation: `app/Controllers/EmployeeRestController.php``getClientRM()`

View File

@ -38,6 +38,13 @@
return false;
}
var name = (el.name || '').toLowerCase();
var id = (el.id || '').toLowerCase();
if (name === 'policy_holder_name' || id === 'policy_holder_name' ||
name === 'family_name[]' || name === 'client_name' || name === 'name') {
return false;
}
var type = (el.type || '').toLowerCase();
if (type === 'file' || type === 'checkbox' || type === 'radio' || type === 'password' || type === 'email' || type === 'url' || type === 'submit' || type === 'button' || type === 'reset') {
return false;