FIX_ONBORDING RV
This commit is contained in:
parent
4c95db69ea
commit
90c53d8b02
@ -584,6 +584,7 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->post('getPolicyStartDate','TicketController::getPolicyStartDate');
|
$routes->post('getPolicyStartDate','TicketController::getPolicyStartDate');
|
||||||
$routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID");
|
$routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID");
|
||||||
$routes->post("getMoreInfo","TicketController::getMoreInfo");
|
$routes->post("getMoreInfo","TicketController::getMoreInfo");
|
||||||
|
$routes->get("getMoreInfo","TicketController::getMoreInfo");
|
||||||
// $routes->post('ticket_messages','TicketController::getTicketMessage');
|
// $routes->post('ticket_messages','TicketController::getTicketMessage');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -611,3 +612,4 @@ $routes->get('getEnrollmentBatchStatus','ICICILombardController::getEnrollmentBa
|
|||||||
$routes->get('fetchUHIDDetails','ICICILombardController::fetchUHIDDetails');
|
$routes->get('fetchUHIDDetails','ICICILombardController::fetchUHIDDetails');
|
||||||
|
|
||||||
$routes->get('testTracelog','TestBusinessController::a');
|
$routes->get('testTracelog','TestBusinessController::a');
|
||||||
|
$routes->get("claimView", "EmployeeRestController::claimView");
|
||||||
|
|||||||
@ -6,6 +6,7 @@ use CodeIgniter\HTTP\IncomingRequest;
|
|||||||
use CodeIgniter\HTTP\RequestInterface;
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use CodeIgniter\API\ResponseTrait;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\UserModel;
|
use App\Models\UserModel;
|
||||||
@ -19,6 +20,8 @@ use App\Models\UserActivityHistoryModel;
|
|||||||
|
|
||||||
class UserController extends AdminController
|
class UserController extends AdminController
|
||||||
{
|
{
|
||||||
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $myLogger;
|
protected $myLogger;
|
||||||
protected $userModel;
|
protected $userModel;
|
||||||
protected $roleModel;
|
protected $roleModel;
|
||||||
@ -264,23 +267,121 @@ class UserController extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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()
|
public function getUserActivityHistory()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$user_id = $this->request->getVar('user_id');
|
$user_id = $this->request->getVar('user_id');
|
||||||
$pre_hr_id = $this->request->getVar('pre_hr_id');
|
$pre_hr_id = $this->request->getVar('pre_hr_id');
|
||||||
// echo $user_id.' - '.$pre_hr_id;
|
$user_type = $this->request->getVar('user_type');
|
||||||
|
|
||||||
|
if (empty($user_type)) {
|
||||||
|
return $this->respond(['status' => false,'message' => 'User type is required'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
$field_for_where_condition = 'user_id';
|
$field_for_where_condition = 'user_id';
|
||||||
if($user_id == 0 || $user_id == NULL)
|
|
||||||
{
|
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';
|
$field_for_where_condition = 'pre_hr_id';
|
||||||
$user_id = $pre_hr_id;
|
$user_id = $pre_hr_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get login history
|
// Get login/auth history
|
||||||
$auth_data = $this->authHistoryModel->where($field_for_where_condition,$user_id);
|
if ($field_for_where_condition == 'pre_hr_id') {
|
||||||
|
$auth_data = $this->authHistoryModel
|
||||||
|
->where('is_active', 1)
|
||||||
|
->where('user_id', $user_id)
|
||||||
|
->where('user_type', $user_type)
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->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)
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->get()
|
||||||
|
->getResultArray();
|
||||||
|
}
|
||||||
|
|
||||||
//get activity history
|
// Get activity history
|
||||||
$activity_data = $this->userActivityHistoryModel->where();
|
$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 getMergedUserHistory($auth_data, $activity_data)
|
||||||
|
{
|
||||||
|
// Tag each entry with its source
|
||||||
|
foreach ($auth_data as &$entry) {
|
||||||
|
$entry['source'] = 'auth';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($activity_data as &$entry) {
|
||||||
|
$entry['source'] = 'activity';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge both arrays
|
||||||
|
$merged = array_merge($auth_data, $activity_data);
|
||||||
|
|
||||||
|
// Sort by 'created_at' descending
|
||||||
|
usort($merged, function ($a, $b) {
|
||||||
|
return strtotime($b['created_at']) <=> strtotime($a['created_at']);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $merged;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -552,22 +552,32 @@ body {
|
|||||||
function getHrActivityHistory()
|
function getHrActivityHistory()
|
||||||
{
|
{
|
||||||
console.log(event.target.dataset.id);//return;
|
console.log(event.target.dataset.id);//return;
|
||||||
let url = '<?= base_url('user/getUserActivityHistory?user_id=') ?>' + event.target.dataset.id.split('-')[0] + '&pre_hr_id=' + event.target.dataset.id.split('-')[1];
|
let ids = event.target.dataset.id.split('-');
|
||||||
|
console.log('ids', ids)
|
||||||
|
// 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);
|
console.log(url);
|
||||||
|
let user_type = "hr";
|
||||||
|
|
||||||
sendAjaxRequestForGlobal(url, 'GET', function(response) {
|
let requestData = {user_id : ids[0], pre_hr_id : ids[1], user_type : user_type};
|
||||||
|
console.log('requestData', requestData);
|
||||||
|
|
||||||
|
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||||
console.log('Data fetched successfully:', response);
|
console.log('Data fetched successfully:', response);
|
||||||
|
|
||||||
if (response.status === true) {
|
if (response.status === true) {
|
||||||
$('#hr_access_append_area').empty();
|
|
||||||
$('#hr_access_append_area').append(response.data)
|
|
||||||
toastr.success(response.message, 'SUCCESS');
|
toastr.success(response.message, 'SUCCESS');
|
||||||
} else {
|
} else {
|
||||||
console.error(response.message, 'WARNING');
|
console.error(response.message, 'WARNING');
|
||||||
}
|
}
|
||||||
}, function(xhr, status, error) {
|
}, function(xhr, status, error) {
|
||||||
console.error('Error fetching data:', error);
|
console.error('--- AJAX Error Details ---');
|
||||||
console.error(xhr.responseText);
|
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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,8 @@
|
|||||||
|
|
||||||
<div class="card-header" onclick="toggleAccordion(this)">
|
<div class="card-header" onclick="toggleAccordion(this)">
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<h5 class="mb-0"><?= $value['hr_name'] ?> <i class="fa fa-info-circle" aria-hidden="true" data-id="<?= $value['pre_hr_id'].'-'.$value['post_hr_id'] ?>"></i>
|
<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>
|
</h5>
|
||||||
<p class="user-email"><?= $value['hr_mail'] ?></p>
|
<p class="user-email"><?= $value['hr_mail'] ?></p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user