Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
VENKATESHWARAN 2025-07-15 11:15:05 +05:30
commit 45091a1c3a
4 changed files with 109 additions and 48 deletions

View File

@ -6274,45 +6274,74 @@ class ClientController extends AdminController
} }
} else { } else {
foreach ($hrAccessTableData as $access) { // First create a map of HR data by post_hr_id for quick lookup
foreach ($merged as $hr) { $hrMap = [];
if ($hr['post_hr_id'] == $access['post_hr_id']) { foreach ($merged as $hr) {
$hrMap[$hr['post_hr_id']] = $hr;
$allowed_modules = json_decode($access['allowed_modules'], true) ?? null; }
if ($allowed_modules == null) {
$allowed_pre_modules = null; // Process access data first
$allowed_post_modules = null; foreach ($hrAccessTableData as $access) {
} else { $post_hr_id = $access['post_hr_id'];
// Check if this HR exists in our merged data
if (isset($hrMap[$post_hr_id])) {
$hr = $hrMap[$post_hr_id];
$temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
// Parse allowed modules
$allowed_modules = json_decode($access['allowed_modules'], true) ?? null;
$allowed_pre_modules = $allowed_modules['pre'] ?? []; $allowed_pre_modules = $allowed_modules['pre'] ?? [];
$allowed_post_modules = $allowed_modules['post'] ?? []; $allowed_post_modules = $allowed_modules['post'] ?? [];
$result[$temp_arr_key] = [
'hr_access_table_pk' => $access['id'] ?? null,
'post_client_id' => $access['post_client_id'] ?? null,
'pre_hr_id' => $hr['pre_hr_id'] ?? null,
'post_hr_id' => $hr['post_hr_id'] ?? null,
'allowed_pre_modules' => $allowed_pre_modules,
'allowed_post_modules' => $allowed_post_modules,
'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [],
'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [],
'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [],
'hr_name' => $hr['hr_name'],
'hr_mobile' => $hr['hr_mobile'],
'hr_mail' => $hr['hr_mail']
];
// Remove from map so we know it's been processed
unset($hrMap[$post_hr_id]);
} }
}
$result[] = [
'hr_access_table_pk' => $access['id'] ?? null, // Now process any remaining HRs that didn't have access records
'post_client_id' => $access['post_client_id'] ?? null, foreach ($hrMap as $hr) {
$temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
$result[$temp_arr_key] = [
'hr_access_table_pk' => null,
'post_client_id' => $client_id ?? null,
'pre_hr_id' => $hr['pre_hr_id'] ?? null, 'pre_hr_id' => $hr['pre_hr_id'] ?? null,
'post_hr_id' => $hr['post_hr_id'] ?? null, 'post_hr_id' => $hr['post_hr_id'] ?? null,
'allowed_pre_modules' => $allowed_pre_modules, 'allowed_pre_modules' => [],
'allowed_post_modules' => $allowed_post_modules, 'allowed_post_modules' => [],
'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [], 'allowed_pre_policies' => [],
'allowed_active_policies' => json_decode($access['allowed_active_policies']) ?? [], 'allowed_active_policies' => [],
'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [], 'allowed_cd' => [],
'hr_name' => $hr['hr_name'], 'hr_name' => $hr['hr_name'] ?? null,
'hr_mobile' => $hr['hr_mobile'], 'hr_mobile' => $hr['hr_mobile'] ?? null,
'hr_mail' => $hr['hr_mail'] 'hr_mail' => $hr['hr_mail'] ?? null,
]; ];
break;
} }
}
}
} }
$resultData['hr_access_data'] = $result; $resultData['hr_access_data'] = array_values($result);
$resultData['pre_policy_data'] = $data['pre_policy_data']; $resultData['pre_policy_data'] = $data['pre_policy_data'];
$resultData['post_policy_data'] = $data['post_policy_data']; $resultData['post_policy_data'] = $data['post_policy_data'];
$resultData['post_cd_data'] = $data['post_cd_data']; $resultData['post_cd_data'] = $data['post_cd_data'];
// echo '**********************************************';
// dd($resultData); // print_rr($resultData);die();
return $resultData; return $resultData;
} }

View File

@ -2376,41 +2376,45 @@ class EmployeeRestController extends AdminController
$hr_id = $this->request->getGet('hr_id'); $hr_id = $this->request->getGet('hr_id');
$HRAccessData = $this->getHRAccessData($hr_id,'post_enrollment'); $HRAccessData = $this->getHRAccessData($hr_id,'post_enrollment');
// print_rr($HRAccessData);die();
if(isset($HRAccessData['allowed_active_policies'])) if(isset($HRAccessData['allowed_cd']))
{ {
$policyId = json_decode($HRAccessData['allowed_active_policies'],true); $allowed_cd = json_decode($HRAccessData['allowed_cd'],true);
}else{ }else{
$policyId = []; $allowed_cd = [];
} }
// $allowed_cd = [125];
if(count($policyId) == 0){ // print_r($allowed_cd);die();
return $this->respond(['status' => 'failed','code' => (count($policyId) ? 200 : 404),'data' => [] ], 200); if(count($allowed_cd) == 0){
return $this->respond(['status' => 'failed','code' => (count($allowed_cd) ? 200 : 404),'data' => [] ], 200);
} }
$clientId = $this->request->getGet('client_id'); $clientId = $this->request->getGet('client_id');
$clientController = new ClientController; $clientController = new ClientController;
$result = $clientController->deposit($clientId , $requestFrom = 'rest' , $policyId); $result = $clientController->deposit($clientId , $requestFrom = 'rest' , []);
// print_rr($result);die();
$data = []; $data = [];
foreach ($result['clientData'] as $key => $value) foreach ($result['clientData'] as $key => $value)
{ {
$temp['client_id'] = $value->client_id; if( in_array($value->cd_ac_pk, $allowed_cd) )
$temp['insurer_id'] = $value->insurer_id; {
$temp['cd_ac_pk'] = $value->cd_ac_pk; $temp['client_id'] = $value->client_id;
$temp['insurer_name'] = $value->insurer_name; $temp['insurer_id'] = $value->insurer_id;
$temp['cd_master_account_no'] = $value->cd_master_account_no; $temp['cd_ac_pk'] = $value->cd_ac_pk;
if (isset($result['balances'][$temp['insurer_id']])) { $temp['insurer_name'] = $value->insurer_name;
$balance = $result['balances'][$temp['insurer_id']]->balance; $temp['cd_master_account_no'] = $value->cd_master_account_no;
$temp['balance'] = $balance; if (isset($result['balances'][$temp['insurer_id']])) {
} else { $balance = $result['balances'][$temp['insurer_id']]->balance;
$temp['balance'] = "N/A"; $temp['balance'] = $balance;
} else {
$temp['balance'] = "N/A";
}
array_push($data,$temp);
} }
array_push($data,$temp);
} }

View File

@ -23,6 +23,7 @@ use App\Models\AuthHistoryModel;
use App\Models\LevelContactModel; use App\Models\LevelContactModel;
use App\Models\HRAccessControlModel; use App\Models\HRAccessControlModel;
use App\Models\ClientModel; use App\Models\ClientModel;
use App\Models\UserActivityHistoryModel;
use Firebase\JWT\JWT; use Firebase\JWT\JWT;
// require_once('../vendor/autoload.php'); // require_once('../vendor/autoload.php');
@ -39,6 +40,7 @@ class RestAuthenticationController extends AdminController
protected $hrModel; protected $hrModel;
protected $hrAccessControlModel; protected $hrAccessControlModel;
protected $clientModel; protected $clientModel;
protected $userActivityHistoryModel;
public function __construct() public function __construct()
@ -51,6 +53,7 @@ class RestAuthenticationController extends AdminController
$this->hrModel = new LevelContactModel(); $this->hrModel = new LevelContactModel();
$this->hrAccessControlModel = new HRAccessControlModel(); $this->hrAccessControlModel = new HRAccessControlModel();
$this->clientModel = new ClientModel(); $this->clientModel = new ClientModel();
$this->userActivityHistoryModel = new UserActivityHistoryModel();
} }
@ -1231,6 +1234,13 @@ class RestAuthenticationController extends AdminController
], 404); ], 404);
} }
public function logHrActivity()
{
$json = $this->request->getJSON();
print_r($json);die();
// $this->userActivityHistoryModel->insert();
}
} }

View File

@ -0,0 +1,18 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class UserActivityHistoryModel extends Model
{
protected $table = 'user_activity_history';
protected $primaryKey = 'id';
protected $allowedFields = [
'user_id',
'user_type',
'misc_data',
'activity'
];
}