MERGE_TEST_HR_AUDIT_LOG

This commit is contained in:
Ubuntu 2025-07-17 10:36:51 +05:30
commit 375ca023d2
16 changed files with 1224 additions and 459 deletions

View File

@ -66,6 +66,7 @@ $routes->group("/user", ["filter" => "authMVC"], function ($routes) {
$routes->get("getuser/(:hash)", "UserController::getuser/$1");
$routes->get("deactive/(:hash)", "UserController::deactive/$1");
$routes->get("rolesandteams", "UserController::getRolesAndTeams");
$routes->get("getUserActivityHistory", "UserController::getUserActivityHistory");
});
$routes->group("/dashboard", ["filter" => "authMVC"], function ($routes) {
@ -360,6 +361,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get('removeInstallments', 'LeadsController::removeInstallments');
$routes->get('viewHrAccessData', 'ClientController::viewHrAccessData');
$routes->post('saveHrAccessData', 'ClientController::saveHrAccessData');
$routes->get('removeLevelContacts', 'ClientController::removeLevelContacts');
});
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
@ -489,10 +491,12 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
$routes->post("employeeRest/saveMpin", "RestAuthenticationController::saveMpin");
$routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMpin");
$routes->post("employeeRest/getPostEmployeeDataForAuth", "RestAuthenticationController::getPostEmployeeDataForAuth");
// $routes->post("logHrActivity", "RestAuthenticationController::logHrActivity");
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->post("logHrActivity", "RestAuthenticationController::logHrActivity");
$routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
$routes->post("storeFireBase", "EmployeeRestController::storeFireBase");
@ -581,6 +585,7 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
$routes->post('getPolicyStartDate','TicketController::getPolicyStartDate');
$routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID");
$routes->post("getMoreInfo","TicketController::getMoreInfo");
$routes->get("getMoreInfo","TicketController::getMoreInfo");
// $routes->post('ticket_messages','TicketController::getTicketMessage');
});
@ -607,4 +612,5 @@ $routes->get('createEnrollmentBatch','ICICILombardController::createEnrollmentBa
$routes->get('getEnrollmentBatchStatus','ICICILombardController::getEnrollmentBatchStatus');
$routes->get('fetchUHIDDetails','ICICILombardController::fetchUHIDDetails');
$routes->get('testTracelog','TestBusinessController::a');
$routes->get('testTracelog','TestBusinessController::a');
$routes->get("claimView", "EmployeeRestController::claimView");

View File

@ -143,7 +143,7 @@ class ClientController extends AdminController
// Perform the query
$builder = $db->table($table);
$isDuplicate = $builder->where($field, $value)->countAllResults() > 0;
$isDuplicate = $builder->where($field, $value)->where('is_active', 1)->countAllResults() > 0;
// Return the result
return $this->response->setJSON(['isDuplicate' => $isDuplicate]);
@ -1171,6 +1171,40 @@ class ClientController extends AdminController
}
}
public function removeLevelContacts()
{
$id = $this->request->getGet('id');
try {
if (empty($id)) {
return $this->respond([
'status' => false,
'message' => 'Invalid ID provided. ID is empty',
'data' => $id
], 400);
}
$updated = $this->levelContactModel->update($id, ['is_active' => 0]);
if ($updated === false) {
return $this->respond([
'status' => false,
'message' => 'Failed to remove contact'
], 500);
}
return $this->respond([
'status' => true,
'message' => 'Contact removed successfully'
]);
} catch (\Exception $e) {
return $this->respond([
'status' => false,
'message' => 'An error occurred: ' . $e->getMessage()
], 500);
}
}
public function createClientPolicy()

View File

@ -2376,41 +2376,46 @@ class EmployeeRestController extends AdminController
$hr_id = $this->request->getGet('hr_id');
$HRAccessData = $this->getHRAccessData($hr_id,'post_enrollment');
if(isset($HRAccessData['allowed_active_policies']))
// print_rr($HRAccessData);die();
if(isset($HRAccessData['allowed_cd']))
{
$policyId = json_decode($HRAccessData['allowed_active_policies'],true);
$allowed_cd = json_decode($HRAccessData['allowed_cd'],true);
}else{
$policyId = [];
$allowed_cd = [];
}
if(count($policyId) == 0){
return $this->respond(['status' => 'failed','code' => (count($policyId) ? 200 : 404),'data' => [] ], 200);
// $allowed_cd = [125];
// print_r($allowed_cd);die();
if(count($allowed_cd) == 0){
return $this->respond(['status' => 'failed','code' => (count($allowed_cd) ? 200 : 404),'data' => [] ], 200);
}
$clientId = $this->request->getGet('client_id');
$clientController = new ClientController;
$result = $clientController->deposit($clientId , $requestFrom = 'rest' , $policyId);
$result = $clientController->deposit($clientId , $requestFrom = 'rest' , []);
// print_rr($result);die();
$data = [];
foreach ($result['clientData'] as $key => $value)
{
$temp['client_id'] = $value->client_id;
$temp['insurer_id'] = $value->insurer_id;
$temp['cd_ac_pk'] = $value->cd_ac_pk;
$temp['insurer_name'] = $value->insurer_name;
$temp['cd_master_account_no'] = $value->cd_master_account_no;
if (isset($result['balances'][$temp['insurer_id']])) {
$balance = $result['balances'][$temp['insurer_id']]->balance;
$temp['balance'] = $balance;
} else {
$temp['balance'] = "N/A";
if( in_array($value->cd_ac_pk, $allowed_cd) )
{
$temp['client_id'] = $value->client_id;
$temp['insurer_id'] = $value->insurer_id;
$temp['cd_ac_pk'] = $value->cd_ac_pk;
$temp['insurer_name'] = $value->insurer_name;
$temp['cd_master_account_no'] = $value->cd_master_account_no;
if (isset($result['balances'][$temp['insurer_id'].'-'.$temp['cd_ac_pk']])) {
$balance = $result['balances'][$temp['insurer_id'].'-'.$temp['cd_ac_pk']]->balance;
$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\HRAccessControlModel;
use App\Models\ClientModel;
use App\Models\UserActivityHistoryModel;
use Firebase\JWT\JWT;
// require_once('../vendor/autoload.php');
@ -39,6 +40,7 @@ class RestAuthenticationController extends AdminController
protected $hrModel;
protected $hrAccessControlModel;
protected $clientModel;
protected $userActivityHistoryModel;
public function __construct()
@ -51,6 +53,7 @@ class RestAuthenticationController extends AdminController
$this->hrModel = new LevelContactModel();
$this->hrAccessControlModel = new HRAccessControlModel();
$this->clientModel = new ClientModel();
$this->userActivityHistoryModel = new UserActivityHistoryModel();
}
@ -210,19 +213,19 @@ class RestAuthenticationController extends AdminController
$client_id = $this->request->getJSON()->client_id ?? null;
$employee_id = $this->request->getJSON()->employee_id ?? null;
// $builder = $this->employeeModel
// ->where('email_corporate', $email)
// ->where('relationship', 'Self')
// ->where('is_active', 1);
$builder = $this->employeeModel
->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
->where('employees.email_corporate', $email)
->where('employees.relationship', 'Self')
->where('employees.is_active', 1)
->whereIn('employees.emp_status', ['active', 'expired'])
->where('EP.is_active', 1)
->whereIn('EP.status', ['active', 'expired']);
->where('email_corporate', $email)
->where('relationship', 'Self')
->where('is_active', 1);
// $builder = $this->employeeModel
// ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
// ->where('employees.email_corporate', $email)
// ->where('employees.relationship', 'Self')
// ->where('employees.is_active', 1)
// ->whereIn('employees.emp_status', ['active', 'expired'])
// ->where('EP.is_active', 1)
// ->whereIn('EP.status', ['active', 'expired']);
if (!empty($client_id)) {
@ -420,10 +423,10 @@ class RestAuthenticationController extends AdminController
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
} else {
return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],200);
return $this->respond(['status' => 'failed','code' => 404,'data' => []],200);
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
return $this->respond(['status' => 'failed','code' => 500,'data' =>[], 'error' => $e->getMessage()],500);
}
}
@ -1231,6 +1234,15 @@ class RestAuthenticationController extends AdminController
], 404);
}
public function logHrActivity()
{
$log_data = $this->request->getJSON();
// print_r($json);die();
$this->userActivityHistoryModel->insert($log_data);
return $this->respond(['status' => 'success','code' => 200,'data' => "logged",],200);
}
}

View File

@ -50,6 +50,7 @@ class TicketController extends BaseController
protected $employeeModel;
protected $clientPolicyModel;
protected $employeePolicyModel;
protected $extraFieldsDisplayForFrontend;
public function __construct()
{
@ -128,6 +129,7 @@ class TicketController extends BaseController
'((APPROVED_DESCRIBTION))' => 'approved_description',
];
$this->extraFields = [
1 => ['non_id_reason'],
10 => ['pay_initiate_date'],
3 => ['raised_date'],
@ -151,87 +153,124 @@ class TicketController extends BaseController
47 => ['cancel_remark'],
53 => ['cancel_remark'],
58 => ['cancel_remark'],
];
2 => [],
6 => [],
12 => [],
15 => [],
16 => [],
17 => [],
18 => [],
19 => [],
21 => [],
22 => [],
23 => [],
25 => [],
26 => [],
27 => [],
28 => [],
29 => [],
31 => [],
32 => [],
33 => [],
35 => [],
36 => [],
37 => [],
38 => [],
39 => [],
41 => [],
42 => [],
43 => [],
45 => [],
46 => [],
49 => [],
50 => [],
51 => [],
52 => [],
55 => [],
56 => [],
57 => [],
60 => []
];
$this->extraFieldsDisplayForFrontend = [
1 => [ 'non_id_reason' => 'Non ID Reason' ],
10 => [ 'pay_initiate_date' => 'Payment Initiated Date' ],
3 => [ 'raised_date' => 'Raised Date' ],
4 => [ 'raised_date' => 'Raised Date' ],
5 => [
'claim_number' => 'Claim Number',
'registration_date' => 'Registration Date'
],
7 => [ 'query_received_date' => 'Query Received Date' ],
8 => [
'denial_reason' => 'Denial Reason',
'denial_date' => 'Denial Date'
],
9 => [
'approved_amount' => 'Approved Amount',
'approved_date' => 'Approved Date',
'approved_letter' => 'Approved Letter',
'approved_description' => 'Approved Description'
],
11 => [
'utr_details' => 'UTR Details',
'settled_date' => 'Settled Date',
'settle_letter' => 'Settle Letter'
],
40 => [
'approved_amount' => 'Approved Amount',
'approved_date' => 'Approved Date',
'approved_letter' => 'Approved Letter',
'approved_description' => 'Approved Description'
],
44 => [
'utr_details' => 'UTR Details',
'settled_date' => 'Settled Date',
'settle_letter' => 'Settle Letter'
],
30 => [
'approved_amount' => 'Approved Amount',
'approved_date' => 'Approved Date',
'approved_letter' => 'Approved Letter',
'approved_description' => 'Approved Description'
],
34 => [
'utr_details' => 'UTR Details',
'settled_date' => 'Settled Date',
'settle_letter' => 'Settle Letter'
],
20 => [
'approved_amount' => 'Approved Amount',
'approved_date' => 'Approved Date',
'approved_letter' => 'Approved Letter',
'approved_description' => 'Approved Description'
],
24 => [
'utr_details' => 'UTR Details',
'settled_date' => 'Settled Date',
'settle_letter' => 'Settle Letter'
],
14 => [
'return_remark' => 'Return Remark',
'awb_no_courier_name' => 'AWB No Courier Name'
],
48 => [
'return_remark' => 'Return Remark',
'awb_no_courier_name' => 'AWB No Courier Name'
],
59 => [
'return_remark' => 'Return Remark',
'awb_no_courier_name' => 'AWB No Courier Name'
],
54 => [
'return_remark' => 'Return Remark',
'awb_no_courier_name' => 'AWB No Courier Name'
],
13 => [ 'cancel_remark' => 'Cancel Remark' ],
47 => [ 'cancel_remark' => 'Cancel Remark' ],
53 => [ 'cancel_remark' => 'Cancel Remark' ],
58 => [ 'cancel_remark' => 'Cancel Remark' ]
];
1 => ['non_id_reason' => 'Non ID Reason'],
10 => ['pay_initiate_date' => 'Payment Initiated Date'],
3 => ['raised_date' => 'Raised Date'],
4 => ['raised_date' => 'Raised Date'],
5 => [
'claim_number' => 'Claim Number',
'registration_date' => 'Registration Date'
],
7 => ['query_received_date' => 'Query Received Date'],
8 => [
'denial_reason' => 'Denial Reason',
'denial_date' => 'Denial Date'
],
9 => [
'approved_amount' => 'Approved Amount',
'approved_date' => 'Approved Date',
'approved_letter' => 'Approved Letter',
'approved_description' => 'Approved Description'
],
11 => [
'utr_details' => 'UTR Details',
'settled_date' => 'Settled Date',
'settle_letter' => 'Settle Letter'
],
40 => [
'approved_amount' => 'Approved Amount',
'approved_date' => 'Approved Date',
'approved_letter' => 'Approved Letter',
'approved_description' => 'Approved Description'
],
44 => [
'utr_details' => 'UTR Details',
'settled_date' => 'Settled Date',
'settle_letter' => 'Settle Letter'
],
30 => [
'approved_amount' => 'Approved Amount',
'approved_date' => 'Approved Date',
'approved_letter' => 'Approved Letter',
'approved_description' => 'Approved Description'
],
34 => [
'utr_details' => 'UTR Details',
'settled_date' => 'Settled Date',
'settle_letter' => 'Settle Letter'
],
20 => [
'approved_amount' => 'Approved Amount',
'approved_date' => 'Approved Date',
'approved_letter' => 'Approved Letter',
'approved_description' => 'Approved Description'
],
24 => [
'utr_details' => 'UTR Details',
'settled_date' => 'Settled Date',
'settle_letter' => 'Settle Letter'
],
14 => [
'return_remark' => 'Return Remark',
'awb_no_courier_name' => 'AWB No Courier Name'
],
48 => [
'return_remark' => 'Return Remark',
'awb_no_courier_name' => 'AWB No Courier Name'
],
59 => [
'return_remark' => 'Return Remark',
'awb_no_courier_name' => 'AWB No Courier Name'
],
54 => [
'return_remark' => 'Return Remark',
'awb_no_courier_name' => 'AWB No Courier Name'
],
13 => ['cancel_remark' => 'Cancel Remark'],
47 => ['cancel_remark' => 'Cancel Remark'],
53 => ['cancel_remark' => 'Cancel Remark'],
58 => ['cancel_remark' => 'Cancel Remark']
];
$this->nonIDReason = [
@ -865,9 +904,10 @@ class TicketController extends BaseController
$ticket_id = $this->request->getPost('ticket_master_id');
$ticket_data = $this->request->getPost();
$ticket_data = $this->formatDateForClaim($ticket_data);
$ticket_data['claim_status_id'] = $this->getLastMatchedStatus($ticket_data);
// print_rr($ticket_data); die;
$old_ticket_data = $this->ticketMasterModel->where('id', $ticket_id)->where('is_active', 1)->first();
$ticket_data['claim_status_id'] = $this->getLastMatchedStatus($ticket_data, $old_ticket_data);
// print_rr($ticket_data); die;
if ($ticket_data) {
$return_value = $this->ticketMasterModel->where('id', $ticket_id)->set($ticket_data)->update();
@ -1646,7 +1686,7 @@ class TicketController extends BaseController
}
}
public function getLastMatchedStatus($incoming_form_values)
public function getLastMatchedStatus($incoming_form_values, $old_ticket_data)
{
if (empty($incoming_form_values) || !isset($incoming_form_values['claim_status_id']) || !isset($incoming_form_values['extra_fields_array_for_validate'])) {
return null;
@ -1657,37 +1697,40 @@ class TicketController extends BaseController
// Use the provided `extra_fields_array_for_validate` from the incoming data
$statusMapping = json_decode($incoming_form_values['extra_fields_array_for_validate']);
foreach ($statusMapping as $status => $requiredFields) {
if($incoming_form_values['claim_status_id'] != $old_ticket_data['claim_status_id']){
foreach ($statusMapping as $status => $requiredFields) {
// Ensure requiredFields is an array
if (!is_array($requiredFields)) {
$requiredFields = [$requiredFields];
if(!empty($requiredFields) && $status != $old_ticket_data['claim_status_id']){
// Ensure requiredFields is an array
if (!is_array($requiredFields)) {
$requiredFields = [$requiredFields];
}
// Check if all required fields exist and are not empty in the incoming form values
$allFieldsMatched = true;
foreach ($requiredFields as $field) {
}
// Check if all required fields exist and are not empty in the incoming form values
$allFieldsMatched = true;
foreach ($requiredFields as $field) {
if(in_array($field, ['approved_description'])){
continue;
}
if(in_array($field, ['approved_description'])){
continue;
}
if (!isset($incoming_form_values[$field]) || empty($incoming_form_values[$field])) {
$allFieldsMatched = false;
break;
if (!isset($incoming_form_values[$field]) || empty($incoming_form_values[$field])) {
$allFieldsMatched = false;
break;
}
}
// Update the last matched status if all fields are validated
if ($allFieldsMatched) {
$lastMatchedStatus = $status;
}
}
}
// Update the last matched status if all fields are validated
if ($allFieldsMatched) {
$lastMatchedStatus = $status;
}
}
if($lastMatchedStatus == 1){
if(!empty($incoming_form_values['tpa_no'])){
$lastMatchedStatus = 2;
if($lastMatchedStatus == 1){
if(!empty($incoming_form_values['tpa_no'])){
$lastMatchedStatus = 2;
}
}
}
@ -1997,11 +2040,11 @@ class TicketController extends BaseController
} else {
// If field is not an array, handle it as a single field
// Check if the field exists in the ticket data
$data_to_send[$claim_status][$f] = ['display_name' => $displayFields[$status['old_value']][$f] ,'display_value' => isset($ticket_data[$f]) ? $ticket_data[$f] : null];
$data_to_send[$claim_status] = ['display_name' => $displayFields[$status['old_value']] ,'display_value' => isset($ticket_data) ? $ticket_data : null];
// Check if the field contains a date and format it
if ($this->isDate($data_to_send[$claim_status][$field])) {
$data_to_send[$claim_status][$f] = ['display_name' => $displayFields[$status['old_value']][$f] ,'display_value' => date('d-m-Y', strtotime($data_to_send[$claim_status][$f]['display_value']))];
// $data_to_send[$claim_status] = ['display_name' => $displayFields[$status['old_value']] ,'display_value' => date('d-m-Y', strtotime($data_to_send[$claim_status]['display_value']))];
}
// $this->myLogger->logme("error", "Data for field {$field}: " . json_encode($data_to_send[$claim_status][$field]));

View File

@ -6,6 +6,9 @@ use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\ClientController;
use App\Models\UserModel;
@ -13,16 +16,22 @@ use App\Models\RoleModel;
use App\Models\TeamModel;
use App\Models\UserTeamsModel;
use App\Helpers\BookStackUserHelper;
use App\Models\AuthHistoryModel;
use App\Models\UserActivityHistoryModel;
class UserController extends AdminController
{
{
use ResponseTrait;
protected $myLogger;
protected $userModel;
protected $roleModel;
protected $teamModel;
protected $userTeamsModel;
protected $bookStack;
protected $authHistoryModel;
protected $userActivityHistoryModel;
public function __construct()
{
@ -34,6 +43,8 @@ class UserController extends AdminController
$this->teamModel = new TeamModel();
$this->userTeamsModel = new UserTeamsModel();
$this->bookStack = new BookStackUserHelper();
$this->authHistoryModel = new AuthHistoryModel();
$this->userActivityHistoryModel = new UserActivityHistoryModel();
}
public function list()
@ -256,4 +267,300 @@ class UserController extends AdminController
$teamData = $this->teamModel->select('id, name')->findAll();
echo json_encode(array("status" => true , 'roleData' => $roleData, 'teamData' => $teamData,));
}
// public function getUserActivityHistory()
// {
// $user_id = $this->request->getVar('user_id');
// $pre_hr_id = $this->request->getVar('pre_hr_id');
// $user_type = $this->request->getVar('user_type');
// // echo $user_id.' - '.$pre_hr_id;
// $field_for_where_condition = 'user_id';
// if($user_id == 0 || $user_id == NULL)
// {
// $field_for_where_condition = 'pre_hr_id';
// $user_id = $pre_hr_id;
// }
// if($field_for_where_condition == "pre_hr_id"){
// //get login history
// $auth_data = $this->authHistoryModel->where('is_active', 1)->where('user_id',$user_id)->where('user_type', $user_type)->findAll();
// }else{
// $preDB = \Config\Database::connect('preDB');
// $auth_data = $preDB->table('auth_history')->where('is_active', 1)->where('user_id',$user_id)->where('user_type', $user_type)->get()->getResultArray();
// }
// //get activity history
// $activity_data = $this->userActivityHistoryModel->where($field_for_where_condition,$user_id)->where('user_type', $user_type)->findAll();
// }
// public function getUserActivityHistory()
// {
// try {
// $client_id = $this->request->getVar('client_id');
// $user_id = $this->request->getVar('user_id');
// $pre_hr_id = $this->request->getVar('pre_hr_id');
// $user_type = $this->request->getVar('user_type');
// $clientController = new ClientController;
// if (empty($client_id)) {
// return $this->respond(['status' => false,'message' => 'Client Id is required'], 400);
// }
// if (empty($user_type)) {
// return $this->respond(['status' => false,'message' => 'User type is required'], 400);
// }
// $field_for_where_condition = 'user_id';
// if (empty($user_id) || $user_id == 0) {
// if (empty($pre_hr_id)) {
// return $this->respond(['status' => false,'message' => 'user_id or pre_hr_id must be provided'], 400);
// }
// $field_for_where_condition = 'pre_hr_id';
// $user_id = $pre_hr_id;
// }
// // Get login/auth history
// if ($field_for_where_condition == 'user_id') {
// $auth_data = $this->authHistoryModel
// ->where('is_active', 1)
// ->where('user_id', $user_id)
// ->where('user_type', $user_type)
// ->orderBy('created_at', 'desc')
// ->findAll();
// // print_r(db_connect()->getLastQuery()); die;
// } else {
// $preDB = \Config\Database::connect('preDB');
// $auth_data = $preDB->table('auth_history')
// ->where('is_active', 1)
// ->where('user_id', $user_id)
// ->where('user_type', $user_type)
// ->orderBy('created_at', 'desc')
// ->get()
// ->getResultArray();
// }
// // Get activity history
// $activity_data = $this->userActivityHistoryModel
// ->where($field_for_where_condition, $user_id)
// ->where('user_type', $user_type)
// ->findAll();
// $merged_data = $this->getMergedUserHistory($auth_data, $activity_data);
// return $this->respond([
// 'status' => true,
// 'message' => 'User history fetched successfully',
// 'auth_history' => $auth_data,
// 'activity_log' => $activity_data,
// 'merged_data' => $merged_data,
// ]);
// } catch (\Exception $e) {
// $this->myLogger->logme("error", ($e->getMessage().' --- '.$e->getLine() . '----' . $e->getTraceAsString()));
// return $this->respond([
// 'status' => false,
// 'message' => 'Error: ' . $e->getMessage()
// ], 500);
// }
// }
public function getUserActivityHistory()
{
try {
$this->myLogger->logme("error", "User activity history fetch initiated.");
$client_id = $this->request->getVar('client_id');
$startDate = $this->request->getVar('startDate');
$endDate = $this->request->getVar('endDate');
$user_type = 'hr';
$clientController = new ClientController;
// Convert to DB format with full time range
$startDateTime = null;
$endDateTime = null;
if (!empty($startDate)) {
$startDateTime = \DateTime::createFromFormat('d-m-Y', $startDate)->format('Y-m-d 00:00:00');
$endDateTime = \DateTime::createFromFormat('d-m-Y', $endDate)->format('Y-m-d 23:59:59');
}
$this->myLogger->logme("error", "Received client_id: " . $client_id);
if (empty($client_id)) {
$this->myLogger->logme("warning", "Client ID is missing.");
return $this->respond(['status' => false, 'message' => 'Client Id is required'], 400);
}
$hr_access_data = $clientController->getHrAccessData($client_id)['hr_access_data'] ?? [];
$this->myLogger->logme("error", "Fetched HR access data: " . json_encode($hr_access_data));
if (empty($hr_access_data)) {
$this->myLogger->logme("error", "No HR access data found for client_id: $client_id");
$html = view('hr_activity_history');
return $this->respond(['status' => true, 'data' => $html, 'list_of_activity_data' => []], 200);
}
$activityMap = [
'export_empdata' => 'Exporting post employee data',
'export_cddata' => 'Exporting cd data',
'export_cdsummary' => 'Exporting cd summary data',
'export_preempdata' => 'Exporting pre employee data',
'import_enrollempdata' => 'Import enrolment file',
];
$list_of_activity_data = [];
foreach ($hr_access_data as $key => $value) {
$this->myLogger->logme("error", "Processing HR user: " . json_encode($value));
$auth_data = [];
$activity_data = [];
$hr_name = $value['hr_name'] ?? '';
$hr_mail = $value['hr_mail'] ?? '';
if (!empty($value['pre_hr_id']) && !empty($value['post_hr_id'])) {
$this->myLogger->logme("error", "Both pre_hr_id and post_hr_id found. Using post DB for user_id: {$value['post_hr_id']}");
// Fetch Auth History
$auth_query = $this->authHistoryModel
->select("DATE_FORMAT(created_at, '%d-%m-%Y %r') AS created_at")
->where('is_active', 1)
->where('user_id', $value['post_hr_id'])
->where('user_type', $user_type);
if (!empty($startDate)) {
$auth_query->where('created_at >=', $startDateTime)
->where('created_at <=', $endDateTime);
}
$auth_data = $auth_query->orderBy('created_at', 'desc')->findAll();
// Fetch User Activity
$activity_query = $this->userActivityHistoryModel
->select("DATE_FORMAT(created_at, '%d-%m-%Y %r') AS created_at, activity")
->where('user_id', $value['post_hr_id'])
->where('user_type', $user_type);
if (!empty($startDate)) {
$activity_query->where('created_at >=', $startDateTime)
->where('created_at <=', $endDateTime);
}
$activity_data = $activity_query->findAll();
} elseif (!empty($value['post_hr_id'])) {
$this->myLogger->logme("error", "Only post_hr_id found. user_id: {$value['post_hr_id']}");
$auth_query = $this->authHistoryModel
->select("DATE_FORMAT(created_at, '%d-%m-%Y %r') AS created_at")
->where('is_active', 1)
->where('user_id', $value['post_hr_id'])
->where('user_type', $user_type);
if (!empty($startDate)) {
$auth_query->where('created_at >=', $startDateTime)
->where('created_at <=', $endDateTime);
}
$auth_data = $auth_query->orderBy('created_at', 'desc')->findAll();
$activity_query = $this->userActivityHistoryModel
->select("DATE_FORMAT(created_at, '%d-%m-%Y %r') AS created_at, activity")
->where('user_id', $value['post_hr_id'])
->where('user_type', $user_type);
if (!empty($startDate)) {
$activity_query->where('created_at >=', $startDateTime)
->where('created_at <=', $endDateTime);
}
$activity_data = $activity_query->findAll();
} elseif (!empty($value['pre_hr_id'])) {
$this->myLogger->logme("error", "Only pre_hr_id found. user_id: {$value['pre_hr_id']}");
$preDB = \Config\Database::connect('preDB');
$auth_query = $preDB->table('auth_history')
->select("DATE_FORMAT(created_at, '%d-%m-%Y %r') AS created_at")
->where('is_active', 1)
->where('user_id', $value['pre_hr_id'])
->where('user_type', $user_type);
if (!empty($startDate)) {
$auth_query->where('created_at >=', $startDateTime)
->where('created_at <=', $endDateTime);
}
$auth_data = $auth_query->orderBy('created_at', 'desc')->get()->getResultArray();
$activity_query = $this->userActivityHistoryModel
->select("DATE_FORMAT(created_at, '%d-%m-%Y %r') AS created_at, activity")
->where('pre_hr_id', $value['pre_hr_id'])
->where('user_type', $user_type);
if (!empty($startDate)) {
$activity_query->where('created_at >=', $startDateTime)
->where('created_at <=', $endDateTime);
}
$activity_data = $activity_query->findAll();
}
foreach ($auth_data as &$entry) {
$entry['user_name'] = $hr_name;
$entry['user_mail'] = $hr_mail;
$entry['activity'] = "Login";
}
foreach ($activity_data as &$entry) {
$entry['user_name'] = $hr_name;
$entry['user_mail'] = $hr_mail;
if (!empty($entry['activity']) && isset($activityMap[$entry['activity']])) {
$entry['activity'] = $activityMap[$entry['activity']];
}
}
$merged_data = array_merge($auth_data, $activity_data);
$list_of_activity_data = array_merge($list_of_activity_data, $merged_data);
$this->myLogger->logme("error", "Merged data count after processing: " . count($list_of_activity_data));
}
usort($list_of_activity_data, function ($a, $b) {
return strtotime($b['created_at']) <=> strtotime($a['created_at']);
});
$this->myLogger->logme("error", "Final sorted list_of_activity_data count: " . count($list_of_activity_data));
$html = view('hr_activity_history', ['data' => $list_of_activity_data]);
return $this->respond([
'status' => true,
'message' => 'User history fetched successfully',
'data' => $html,
'list_of_activity_data' => $list_of_activity_data,
]);
} catch (\Exception $e) {
$this->myLogger->logme("error", $e->getMessage() . ' --- ' . $e->getLine() . ' ---- ' . $e->getTraceAsString());
return $this->respond([
'status' => false,
'message' => 'Error: ' . $e->getMessage()
], 500);
}
}
}

View File

@ -252,7 +252,7 @@ if (!function_exists('check_si')) {
if (!$is_si_found && $slab_value['si'] == $received_si) //match si amount
{
echo 'found - ' . $slab_value['si']. ' - ' . $received_si;
// echo 'found - ' . $slab_value['si']. ' - ' . $received_si;
$is_si_found = true;
}

View File

@ -295,11 +295,23 @@ class ClientPolicyModel extends Model
public function getDepositSummary($clientId, $insurerId, $cd_ac_pk)
{
$subQuery = $this->db->table('cash_deposit')
->select('balance')
->where('client_id', $clientId)
->where('insurer_id', $insurerId)
->where('cd_ac_pk', $cd_ac_pk)
->where('is_active', 1)
->orderBy('id', 'DESC')
->limit(1)
->getCompiledSelect();
// Fetch the sum of credit and debit transactions and calculate the balance
return $this->db->table('cash_deposit')
$data = $this->db->table('cash_deposit')
->select("($subQuery) AS balance", false)
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE 0 END) AS total_credit')
->select('SUM(CASE WHEN transaction_type = "Debit" THEN amount ELSE 0 END) AS total_withdraw')
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
// ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
->select('SUM(CASE WHEN sub_type = 3 THEN amount ELSE 0 END) AS total_refund')
->where('client_id', $clientId)
->where('insurer_id', $insurerId)
@ -307,6 +319,9 @@ class ClientPolicyModel extends Model
->where('cash_deposit.is_active', 1)
->get()
->getRow();
// dd($this->db->getLastQuery());
return $data;
}
// Inside your clientPolicyModel
// Inside your clientPolicyModel
@ -347,7 +362,8 @@ class ClientPolicyModel extends Model
foreach ($depositsummary as $summary) {
$insurerId = $summary->insurer_id;
$balances[$insurerId] = $summary;
$cd_ac_pk = $summary->cd_ac_pk;
$balances[$insurerId . '-'. $cd_ac_pk] = $summary;
}
return $balances;
@ -366,20 +382,35 @@ class ClientPolicyModel extends Model
// ->get()
// ->getResult();
// $sql = "
// SELECT cd.insurer_id, cd.cd_ac_pk, cd.balance
// FROM cash_deposit cd
// INNER JOIN (
// SELECT insurer_id, MAX(id) AS max_id
// FROM cash_deposit
// WHERE client_id = ?
// AND is_active = 1
// GROUP BY insurer_id
// ) latest ON cd.insurer_id = latest.insurer_id AND cd.id = latest.max_id
// ORDER BY cd.id DESC
// ";
$sql = "
SELECT cd.insurer_id, cd.cd_ac_pk, cd.balance
FROM cash_deposit cd
INNER JOIN (
SELECT insurer_id, MAX(id) AS max_id
JOIN cd_master cdm ON cdm.id = cd.cd_ac_pk
JOIN (
SELECT MAX(id) AS max_id
FROM cash_deposit
WHERE client_id = ?
AND is_active = 1
GROUP BY insurer_id
) latest ON cd.insurer_id = latest.insurer_id AND cd.id = latest.max_id
ORDER BY cd.id DESC
WHERE is_active = 1 AND client_id = $id
GROUP BY insurer_id, cd_ac_pk
) latest ON latest.max_id = cd.id
JOIN insurers on cd.insurer_id = insurers.id
WHERE cd.is_active = 1 AND cd.client_id = $id AND cdm.is_active = 1
ORDER BY cd.insurer_id;
";
return $this->db->query($sql, [$id])->getResult();
return $this->db->query($sql)->getResult();
}

View File

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

View File

@ -580,12 +580,12 @@ $('body').on('click', '.btnBranchEdit', function() {
console.log(branch_form_action);
});
$("#remove_btn").click(function() {
$("#name").val('');
$("#email").val('');
$("#mobile").val('');
$("#designation").val('');
})
// $("#remove_btn").click(function() {
// $("#name").val('');
// $("#email").val('');
// $("#mobile").val('');
// $("#designation").val('');
// })
// Initialize the contact count
function appendContactHtml(contact = false, reset = false) {
@ -644,21 +644,68 @@ function appendContactHtml(contact = false, reset = false) {
}
// function removeContact(button) {
// var uniqueId = button.id.split("_")[0];
// var contactSection = document.getElementById(uniqueId);
// if (contactSection) {
// contactSection.parentNode.removeChild(contactSection);
// contactCount--;
// if (contactCount < 3) {
// var addButton = document.querySelector('.ac');
// if (addButton) {
// addButton.style.display = 'block';
// }
// }
// }
// }
function removeContact(button) {
var uniqueId = button.id.split("_")[0];
console.log('uniqueId', uniqueId);
var contactSection = document.getElementById(uniqueId);
console.log('contactSection', contactSection);
if (contactSection) {
contactSection.parentNode.removeChild(contactSection);
contactCount--;
confirmActionSweertAlert("Do you want to remove this contact?", "Yes, Proceed!", "No, Cancel").then((confirmed) => {
if(confirmed){
if (contactSection) {
if (contactCount < 3) {
var addButton = document.querySelector('.ac');
if (addButton) {
addButton.style.display = 'block';
let unique_param = uniqueId + '_branch_table_pk';
console.log('unique_param', unique_param);
let other_id = $('#' + unique_param).val();
console.log('other_id', other_id);
contactSection.parentNode.removeChild(contactSection);
contactCount--;
if (contactCount < 3) {
var addButton = document.querySelector('.ac');
if (addButton) {
addButton.style.display = 'block';
}
}
if(other_id){
removeLevelContacts(other_id);
}
}else{
$("#name").val('');
$("#email").val('');
$("#mobile").val('');
$("#designation").val('');
let first_id = $('#branch_table_pk').val();
console.log('first_id', first_id);
if(first_id){
removeLevelContacts(first_id);
}
}
}
}
});
}
function storeButtonId(id) {
@ -839,6 +886,30 @@ function getContactsData() {
return contacts;
}
function removeLevelContacts(id){
let url = '<?= base_url('util/removeLevelContacts') ?>';
let requestData = {
id: id,
};
// Send AJAX request
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status == true) {
toastr.success(response.message, 'SUCCESS');
} else {
toastr.warning(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
});
}
</script>
<script>

View File

@ -38,9 +38,10 @@
<td>
<?php
$insurerId = $value->insurer_id;
$cd_ac_pk = $value->cd_ac_pk;
// Check if the balance information exists for the insurer
if (isset($balances[$insurerId])) {
$balance = $balances[$insurerId]->balance;
if (isset($balances[$insurerId . '-'. $cd_ac_pk])) {
$balance = $balances[$insurerId . '-'. $cd_ac_pk]->balance;
echo $balance;
} else {
echo "N/A"; // Display "Not Available" if balance information is not present

View File

@ -34,224 +34,224 @@ body {
</style>
<style>
body {
background-color: #f8f9fa;
font-size: 14px;
}
<style>
body {
background-color: #f8f9fa;
font-size: 14px;
}
.container-fluid {
padding: 12px;
}
.container-fluid {
padding: 12px;
}
.user-card {
background: white;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(77, 77, 77, 0.3);
margin-bottom: 12px;
overflow: hidden;
transition: all 0.3s ease;
}
.user-card {
background: white;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(77, 77, 77, 0.3);
margin-bottom: 12px;
overflow: hidden;
transition: all 0.3s ease;
}
.user-card:hover {
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.user-card:hover {
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.card-header {
background: #d6d6d6;
color: white;
padding: 12px 18px;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
transition: background 0.3s ease;
}
.card-header {
background: #d6d6d6;
color: white;
padding: 12px 18px;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
transition: background 0.3s ease;
}
.card-header:hover {
background: #b4bec5;
}
.card-header:hover {
background: #b4bec5;
}
.user-info h5 {
margin-bottom: 2px;
font-size: 1.1em;
color: #121212;
}
.user-info h5 {
margin-bottom: 2px;
font-size: 1.1em;
color: #121212;
}
.user-email {
font-size: 0.85em;
opacity: 0.9;
margin: 0;
color:rgb(56, 55, 55);
}
.user-email {
font-size: 0.85em;
opacity: 0.9;
margin: 0;
color:rgb(56, 55, 55);
}
.accordion-icon {
font-size: 1.2em;
transition: transform 0.3s ease;
color: #121212;
}
.accordion-icon {
font-size: 1.2em;
transition: transform 0.3s ease;
color: #121212;
}
.accordion-icon.active {
transform: rotate(180deg);
}
.accordion-icon.active {
transform: rotate(180deg);
}
.card-content {
max-height: 0;
overflow: hidden;
transition: max-height 0.4s ease;
background: white;
}
.card-content {
max-height: 0;
overflow: hidden;
transition: max-height 0.4s ease;
background: white;
}
.card-content.active {
max-height: 500px;
overflow-y: auto;
}
.card-content.active {
max-height: 500px;
overflow-y: auto;
}
.content-inner {
padding: 18px;
}
.content-inner {
padding: 18px;
}
.section {
background: #d6dce1;
border-radius: 6px;
padding: 12px;
border: 1px solid #e9ecef;
margin-bottom: 12px;
transition: all 0.3s ease;
}
.section {
background: #d6dce1;
border-radius: 6px;
padding: 12px;
border: 1px solid #e9ecef;
margin-bottom: 12px;
transition: all 0.3s ease;
}
.section:hover {
border-color: #667eea;
box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}
.section:hover {
border-color: #667eea;
box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}
.section-title {
font-weight: 600;
margin-bottom: 8px;
color: #121212;
font-size: 0.95em;
display: flex;
align-items: center;
}
.section-title {
font-weight: 600;
margin-bottom: 8px;
color: #121212;
font-size: 0.95em;
display: flex;
align-items: center;
}
.main-checkbox {
margin-right: 8px;
transform: scale(1.1);
cursor: pointer;
}
.main-checkbox {
margin-right: 8px;
transform: scale(1.1);
cursor: pointer;
}
.checkbox-group {
margin-left: 24px;
transition: all 0.3s ease;
max-height: 225px;
overflow-y: auto;
padding-right: 8px;
overflow-x: hidden;
}
.checkbox-group {
margin-left: 24px;
transition: all 0.3s ease;
max-height: 225px;
overflow-y: auto;
padding-right: 8px;
overflow-x: hidden;
}
.checkbox-group::-webkit-scrollbar {
width: 4px;
}
.checkbox-group::-webkit-scrollbar {
width: 4px;
}
.checkbox-group::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 2px;
}
.checkbox-group::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 2px;
}
.checkbox-group::-webkit-scrollbar-thumb {
background: #667eea;
border-radius: 2px;
}
.checkbox-group::-webkit-scrollbar-thumb {
background: #667eea;
border-radius: 2px;
}
.checkbox-group::-webkit-scrollbar-thumb:hover {
background: #5a6fd8;
}
.checkbox-group::-webkit-scrollbar-thumb:hover {
background: #5a6fd8;
}
.checkbox-item {
display: flex;
align-items: center;
padding: 4px 8px;
border-radius: 4px;
transition: background 0.2s ease;
/* margin-bottom: 3px; */
margin-bottom: -7px;
}
.checkbox-item {
display: flex;
align-items: center;
padding: 4px 8px;
border-radius: 4px;
transition: background 0.2s ease;
/* margin-bottom: 3px; */
margin-bottom: -7px;
}
.checkbox-item:hover {
background: rgba(102, 126, 234, 0.1);
}
.checkbox-item:hover {
background: rgba(102, 126, 234, 0.1);
}
.checkbox-item input[type="checkbox"] {
transform: scale(1.05);
cursor: pointer;
margin-right: 6px;
}
.checkbox-item input[type="checkbox"] {
transform: scale(1.05);
cursor: pointer;
margin-right: 6px;
}
.checkbox-item label {
cursor: pointer;
user-select: none;
margin: 0;
font-size: 0.9em;
}
.checkbox-item label {
cursor: pointer;
user-select: none;
margin: 0;
font-size: 0.9em;
}
.hidden {
opacity: 0;
max-height: 0 !important;
overflow: hidden;
margin: 0;
padding: 0;
}
.hidden {
opacity: 0;
max-height: 0 !important;
overflow: hidden;
margin: 0;
padding: 0;
}
.policy-number {
font-family: monospace;
font-size: 0.8em;
color: #6c757d;
}
.policy-number {
font-family: monospace;
font-size: 0.8em;
color: #6c757d;
}
.submit-container {
background: white;
padding: 18px;
border-radius: 8px;
/* box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); */
margin-top: 20px;
text-align: right;
}
.submit-container {
background: white;
padding: 18px;
border-radius: 8px;
/* box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); */
margin-top: 20px;
text-align: right;
}
/* .btn-submit {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border: none;
padding: 10px 30px;
font-weight: 600;
border-radius: 25px;
transition: all 0.3s ease;
}
/* .btn-submit {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border: none;
padding: 10px 30px;
font-weight: 600;
border-radius: 25px;
transition: all 0.3s ease;
}
.btn-submit:hover {
background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
transform: translateY(-2px);
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
} */
.btn-submit:hover {
background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
transform: translateY(-2px);
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
} */
.output-container {
background: #f8f9fa;
border: 1px solid #dee2e6;
border-radius: 8px;
padding: 15px;
margin-top: 20px;
display: none;
}
.output-container {
background: #f8f9fa;
border: 1px solid #dee2e6;
border-radius: 8px;
padding: 15px;
margin-top: 20px;
display: none;
}
.output-table {
font-family: monospace;
font-size: 0.85em;
white-space: pre-wrap;
background: white;
padding: 10px;
border-radius: 4px;
border: 1px solid #dee2e6;
}
</style>
.output-table {
font-family: monospace;
font-size: 0.85em;
white-space: pre-wrap;
background: white;
padding: 10px;
border-radius: 4px;
border: 1px solid #dee2e6;
}
</style>
@ -314,6 +314,12 @@ body {
<span class="d-none d-sm-inline-block">HR Access Controll</span>
</a>
</li>
<li class="nav-item">
<a href="#hr-activity-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="hr_activity_tab" onclick="appendHrActivityHistoryHtml(this)">
<span class="mr-1"><i class="mdi mdi-book-open-page-variant"></i></span>
<span class="d-none d-sm-inline-block">HR Activity</span>
</a>
</li>
<!-- <li class="nav-item">
<a href="#api-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="api_tab">
<span class="mdi mdi-api"></span>
@ -340,6 +346,17 @@ body {
</div>
</div>
<div class="tab-pane fade" id="hr-activity-tab">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body" id="hr_activity_history_append_area" style="position: relative;bottom: 50px;">
</div>
</div>
</div> <!-- end col -->
</div>
</div>
<?php include("client_api.php"); ?>
<?php // include('client_others_tab.php'); ?>
<?php include('notification.php'); ?>
@ -358,6 +375,7 @@ body {
<script>
let hrAccessControlHtmlAppended = false;
let hrActivityHistoryHtmlAppended = false;
function client_kyc_docs() {
var check_client_id = $('#general_PrimaryKey');
@ -416,7 +434,6 @@ body {
}
function client_notification() {
var check_client_id = $('#general_PrimaryKey');
@ -432,14 +449,11 @@ body {
}
document.getElementById("kyc_tab").addEventListener("click", function(event) {
event.preventDefault();
client_kyc_docs();
});
document.getElementById("RM_tab").addEventListener("click", function(event) {
event.preventDefault();
client_relationship_manager();
@ -460,6 +474,7 @@ body {
client_notification();
});
//HR Access Controll
function appendHrAccessControllHtml(input){
console.log(input.id);
let client_id = $('#general_PrimaryKey').val();
@ -490,11 +505,55 @@ body {
}
}
//HR Activity History
function appendHrActivityHistoryHtml(input, submit = false){
console.log(input.id);
let client_id = $('#general_PrimaryKey').val();
let startDate = $('#startDate').val();
let endDate = $('#endDate').val();
console.log('client_id ', client_id);
console.log('startDate ', startDate);
console.log('endDate ', endDate);
if(submit){
hrActivityHistoryHtmlAppended = false;
}
let url = '<?= base_url('user/getUserActivityHistory') ?>';
let requestData = {client_id : client_id, startDate : startDate, endDate : endDate};
if(hrActivityHistoryHtmlAppended == false){
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
$('#hr_activity_history_append_area').empty();
$('#hr_activity_history_append_area').append(response.data)
hrActivityHistoryHtmlAppended = true;
} else {
console.log(response.message, 'WARNING');
hrActivityHistoryHtmlAppended = false;
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
hrActivityHistoryHtmlAppended = false;
});
}else{
console.log('Already HTML appended');
}
}
</script>
<script>
function toggleAccordion(header) {
if (event.target.classList.contains('fa-info-circle') ||
event.target.parentElement.classList.contains('fa-info-circle')) {
getHrActivityHistory();
return; // Do nothing if click was on the info icon
}
const card = header.parentElement;
const content = card.querySelector('.card-content');
const icon = header.querySelector('.accordion-icon i');
@ -544,78 +603,38 @@ body {
return Array.from(checkboxes).map(cb => parseInt(cb.value));
}
// function submitForm(event) {
// event.preventDefault();
function getHrActivityHistory()
{
console.log(event.target.dataset.id);//return;
let ids = event.target.dataset.id.split('-');
console.log('ids', ids)
let client_id = $('#general_PrimaryKey').val();
// let url = '<?= base_url('user/getUserActivityHistory?user_id=') ?>' + event.target.dataset.id.split('-')[0] + '&pre_hr_id=' + event.target.dataset.id.split('-')[1];
let url = '<?= base_url('user/getUserActivityHistory') ?>';
console.log(url);
let user_type = "hr";
// const formData = new FormData(document.getElementById('insuranceForm'));
// const users = [];
let requestData = {user_id : ids[1], pre_hr_id : ids[0], user_type : user_type, client_id : client_id};
console.log('requestData', requestData);
// // Process User 1
// const user1 = {
// pk: formData.get('user1_pk'),
// pre_hr_id: formData.get('user1_pre_hr_id'),
// post_hr_id: formData.get('user1_post_hr_id'),
// allowed_modules: getCheckedValues('user1_modules'),
// allowed_pre_policies: getCheckedValues('user1_pre_policies'),
// allowed_active_policies: getCheckedValues('user1_active_policies'),
// allowed_cd: getCheckedValues('user1_cd'),
// allowed_claims: getCheckedValues('user1_claims')
// };
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
// // Process User 2
// const user2 = {
// pk: formData.get('user2_pk'),
// pre_hr_id: formData.get('user2_pre_hr_id'),
// post_hr_id: formData.get('user2_post_hr_id'),
// allowed_modules: getCheckedValues('user2_modules'),
// allowed_pre_policies: getCheckedValues('user2_pre_policies'),
// allowed_active_policies: getCheckedValues('user2_active_policies'),
// allowed_cd: getCheckedValues('user2_cd'),
// allowed_claims: getCheckedValues('user2_claims')
// };
// users.push(user1, user2);
// // Generate JSON format
// const jsonOutput = users.map(user => {
// const modules = user.allowed_modules.length > 0 ? `[${user.allowed_modules.join(',')}]` : '[]';
// const prePolicies = user.allowed_pre_policies.length > 0 ? `[${user.allowed_pre_policies.join(',')}]` : '[]';
// const activePolicies = user.allowed_active_policies.length > 0 ? `[${user.allowed_active_policies.join(',')}]` : '[]';
// const cdPolicies = user.allowed_cd.length > 0 ? `[${user.allowed_cd.join(',')}]` : '[]';
// const claims = user.allowed_claims.length > 0 ? `[${user.allowed_claims.join(',')}]` : '[]';
// return {
// pk: parseInt(user.pk) || 0,
// pre_hr_id: user.pre_hr_id || "",
// post_hr_id: user.post_hr_id || "",
// allowed_modules: modules,
// allowed_pre_policies: prePolicies,
// allowed_active_policies: activePolicies,
// allowed_cd: cdPolicies,
// allowed_claims: claims
// };
// });
// const output = JSON.stringify(jsonOutput, null, 1);
// // Display the output (you can modify this part based on your needs)
// console.log(output);
// // Optional: Display in a textarea or pre element
// const outputElement = document.getElementById('output');
// if (outputElement) {
// outputElement.textContent = output;
// }
// // Optional: Copy to clipboard
// if (navigator.clipboard) {
// navigator.clipboard.writeText(output).then(() => {
// console.log('Output copied to clipboard');
// }).catch(err => {
// console.error('Failed to copy to clipboard:', err);
// });
// }
// }
if (response.status === true) {
toastr.success(response.message, 'SUCCESS');
} else {
console.error(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('--- AJAX Error Details ---');
console.error('Status Code:', xhr.status);
console.error('Status Text:', xhr.statusText);
console.error('Response Text:', xhr.responseText);
console.error('XHR Object:', xhr);
console.error('jQuery Status:', status);
console.error('Thrown Error:', error);
});
}
function submitForm(event) {
event.preventDefault();
@ -705,22 +724,6 @@ body {
return Array.from(checkboxes).map(cb => cb.value);
}
// $(document).on('change', '.select-all', function () {
// let type = $(this).data('type');
// let user = $(this).data('user');
// let group = $(this).data('group');
// let selector = '.policy-checkbox[data-user="' + user + '"][data-group="' + group + '"]';
// if (type === 'active') {
// selector += '.active';
// } else if (type === 'inactive') {
// selector += '.inactive';
// }
// $(selector).prop('checked', this.checked);
// });
$(document).on('change', '.select-all', function () {
let $this = $(this);
let type = $this.data('type');
@ -765,6 +768,103 @@ body {
console.log('--- END ---');
});
//----------------------------------------------------------------------------------------------------------------------
// function submitForm(event) {
// event.preventDefault();
// const formData = new FormData(document.getElementById('insuranceForm'));
// const users = [];
// // Process User 1
// const user1 = {
// pk: formData.get('user1_pk'),
// pre_hr_id: formData.get('user1_pre_hr_id'),
// post_hr_id: formData.get('user1_post_hr_id'),
// allowed_modules: getCheckedValues('user1_modules'),
// allowed_pre_policies: getCheckedValues('user1_pre_policies'),
// allowed_active_policies: getCheckedValues('user1_active_policies'),
// allowed_cd: getCheckedValues('user1_cd'),
// allowed_claims: getCheckedValues('user1_claims')
// };
// // Process User 2
// const user2 = {
// pk: formData.get('user2_pk'),
// pre_hr_id: formData.get('user2_pre_hr_id'),
// post_hr_id: formData.get('user2_post_hr_id'),
// allowed_modules: getCheckedValues('user2_modules'),
// allowed_pre_policies: getCheckedValues('user2_pre_policies'),
// allowed_active_policies: getCheckedValues('user2_active_policies'),
// allowed_cd: getCheckedValues('user2_cd'),
// allowed_claims: getCheckedValues('user2_claims')
// };
// users.push(user1, user2);
// // Generate JSON format
// const jsonOutput = users.map(user => {
// const modules = user.allowed_modules.length > 0 ? `[${user.allowed_modules.join(',')}]` : '[]';
// const prePolicies = user.allowed_pre_policies.length > 0 ? `[${user.allowed_pre_policies.join(',')}]` : '[]';
// const activePolicies = user.allowed_active_policies.length > 0 ? `[${user.allowed_active_policies.join(',')}]` : '[]';
// const cdPolicies = user.allowed_cd.length > 0 ? `[${user.allowed_cd.join(',')}]` : '[]';
// const claims = user.allowed_claims.length > 0 ? `[${user.allowed_claims.join(',')}]` : '[]';
// return {
// pk: parseInt(user.pk) || 0,
// pre_hr_id: user.pre_hr_id || "",
// post_hr_id: user.post_hr_id || "",
// allowed_modules: modules,
// allowed_pre_policies: prePolicies,
// allowed_active_policies: activePolicies,
// allowed_cd: cdPolicies,
// allowed_claims: claims
// };
// });
// const output = JSON.stringify(jsonOutput, null, 1);
// // Display the output (you can modify this part based on your needs)
// console.log(output);
// // Optional: Display in a textarea or pre element
// const outputElement = document.getElementById('output');
// if (outputElement) {
// outputElement.textContent = output;
// }
// // Optional: Copy to clipboard
// if (navigator.clipboard) {
// navigator.clipboard.writeText(output).then(() => {
// console.log('Output copied to clipboard');
// }).catch(err => {
// console.error('Failed to copy to clipboard:', err);
// });
// }
// }
//----------------------------------------------------------------------------------------------------------------------
// $(document).on('change', '.select-all', function () {
// let type = $(this).data('type');
// let user = $(this).data('user');
// let group = $(this).data('group');
// let selector = '.policy-checkbox[data-user="' + user + '"][data-group="' + group + '"]';
// if (type === 'active') {
// selector += '.active';
// } else if (type === 'inactive') {
// selector += '.inactive';
// }
// $(selector).prop('checked', this.checked);
// });
//----------------------------------------------------------------------------------------------------------------------
// $(document).on('change', '.post-select-all', function () {
// let $this = $(this);

View File

@ -18,7 +18,9 @@
<div class="card-header" onclick="toggleAccordion(this)">
<div class="user-info">
<h5 class="mb-0"><?= $value['hr_name'] ?></h5>
<h5 class="mb-0"><?= $value['hr_name'] ?>
<!-- <i class="fa fa-info-circle" aria-hidden="true" data-id="<?= (!empty($value['pre_hr_id']) ? $value['pre_hr_id'] : 0) . '-' . (!empty($value['post_hr_id']) ? $value['post_hr_id'] : 0) ?>"></i> -->
</h5>
<p class="user-email"><?= $value['hr_mail'] ?></p>
</div>
<div class="accordion-icon">

View File

@ -0,0 +1,120 @@
<style>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
/* .col-12 {
max-width: 98% !important;
} */
/* .dataTables_filter {
position: absolute;
margin-left: -25px;
} */
/* .right-align-input {
text-align: right;
} */
</style>
<div class="row" style="position: relative;left: 250px;top: 55px;">
<div class="form-group col-md-3" id="date_div">
<!-- <label>ActivityDate<span class="text-danger"></span></label> -->
<div id="reportrange" class="form-control" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
<i class="fa fa-calendar"></i>&nbsp;
<span></span> <i class="fa fa-caret-down"></i>
</div>
<input type="hidden" id="startDate">
<input type="hidden" id="endDate">
</div>
<div class="form-group col-md-3">
<button type="button" class="btn btn-primary" onclick="appendHrActivityHistoryHtml(this, true)"> submit </button>
</div>
</div>
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>S. No</th>
<th>Timestamp</th>
<th>HR Name</th>
<th>HR Mail</th>
<th>Activity</th>
</tr>
</thead>
<tbody>
<?php if (isset($data) && !empty($data)) { ?>
<?php foreach ($data as $index => $row) { ?>
<tr>
<td><?= $index + 1 ?></td>
<td><?php echo $row['created_at']; ?></td>
<td><?php echo $row['user_name']; ?></td>
<td><?php echo $row['user_mail']; ?></td>
<td><?php echo $row['activity']; ?></td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<script>
$(document).ready(function () {
var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-2'f><'col-sm-2'>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-3'i><'col-sm-2'l><'col-sm-7'p>>",
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true,
pageLength: 25,
ordering: false
});
} else {
console.error("Table not found.");
}
// Daterangepicker setup
const params = new URLSearchParams(window.location.search);
const startDateParam = params.get('start_date') || moment().subtract(29, 'days').format('DD-MM-YYYY');
const endDateParam = params.get('end_date') || moment().format('DD-MM-YYYY');
const start = moment(startDateParam, 'DD-MM-YYYY');
const end = moment(endDateParam, 'DD-MM-YYYY');
function cb(start, end) {
$('#reportrange span').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY'));
$('#startDate').val(start.format('DD-MM-YYYY'));
$('#endDate').val(end.format('DD-MM-YYYY'));
}
$('#reportrange').daterangepicker({
startDate: start,
endDate: end,
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
}
}, cb);
cb(start, end);
});
</script>

View File

@ -1168,7 +1168,7 @@
$("#infoIcon").click(function() {
var ticket_id = $('#ticket_master_id').val();
getDataForInfo(ticket_id, function(data) {
console.log("data: ", data);
console.log("claims history data response : ", data);
if (data && Object.keys(data).length) {
// openModal();
var myModal = new bootstrap.Modal(document.getElementById('moreInfoModal'));
@ -1214,7 +1214,11 @@
// Iterate over each status in the data
for (let status in data) {
if (data.hasOwnProperty(status)) {
let length = Object.keys(data[status]).length;
console.log('length', length);
if (data.hasOwnProperty(status) && length > 0) {
// Create the status subheading
var statusHeading = document.createElement('h5');
statusHeading.textContent = status;
@ -1233,7 +1237,8 @@
// Create a label for the field
var fieldLabel = document.createElement('label');
fieldLabel.textContent = field.replace(/_/g, ' ').toUpperCase(); // Convert underscores to spaces and capitalize
// fieldLabel.textContent = field.replace(/_/g, ' ').toUpperCase(); // Convert underscores to spaces and capitalize
fieldLabel.textContent = field.display_name; // Convert underscores to spaces and capitalize
fieldContainer.appendChild(fieldLabel);
// Create either an input field or a textarea based on the field name
@ -1242,13 +1247,13 @@
// Create a textarea for 'approved_letter'
fieldInput = document.createElement('textarea');
fieldInput.classList.add('form-control');
fieldInput.textContent = data[status][field]; // Set the value to the field content
fieldInput.textContent = data[status][field].display_value; // Set the value to the field content
} else {
// Create an input field for other fields
fieldInput = document.createElement('input');
fieldInput.type = 'text';
fieldInput.classList.add('form-control');
fieldInput.value = data[status][field];
fieldInput.value = data[status][field].display_value;
}
fieldInput.setAttribute('readonly', 'readonly'); // Set field as readonly

View File

@ -932,7 +932,15 @@
// Iterate over each status in the data
for (let status in data) {
if (data.hasOwnProperty(status)) {
console.log('status', status)
console.log('data[status]', data[status])
console.log('data[status].length', data[status].length)
let length = Object.keys(data[status]).length;
console.log('length', length);
if (data.hasOwnProperty(status) && length > 0) {
// Create the status subheading
var statusHeading = document.createElement('h5');
statusHeading.textContent = status;
@ -951,7 +959,8 @@
// Create a label for the field
var fieldLabel = document.createElement('label');
fieldLabel.textContent = field.replace(/_/g, ' ').toUpperCase(); // Convert underscores to spaces and capitalize
// fieldLabel.textContent = field.replace(/_/g, ' ').toUpperCase(); // Convert underscores to spaces and capitalize
fieldLabel.textContent = field.display_name;
fieldContainer.appendChild(fieldLabel);
// Create either an input field or a textarea based on the field name
@ -960,13 +969,13 @@
// Create a textarea for 'approved_letter'
fieldInput = document.createElement('textarea');
fieldInput.classList.add('form-control');
fieldInput.textContent = data[status][field]; // Set the value to the field content
fieldInput.textContent = data[status][field].display_value; // Set the value to the field content
} else {
// Create an input field for other fields
fieldInput = document.createElement('input');
fieldInput.type = 'text';
fieldInput.classList.add('form-control');
fieldInput.value = data[status][field];
fieldInput.value = data[status][field].display_value;
}
fieldInput.setAttribute('readonly', 'readonly'); // Set field as readonly