FEAT_HR_AUDITLOG
This commit is contained in:
parent
634f65ec96
commit
e31a9bae60
@ -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) {
|
||||
@ -489,6 +490,7 @@ $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) {
|
||||
|
||||
@ -1236,9 +1236,11 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
public function logHrActivity()
|
||||
{
|
||||
$json = $this->request->getJSON();
|
||||
print_r($json);die();
|
||||
// $this->userActivityHistoryModel->insert();
|
||||
$log_data = $this->request->getJSON();
|
||||
// print_r($json);die();
|
||||
$this->userActivityHistoryModel->insert($log_data);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => "logged",],200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -13,6 +13,8 @@ use App\Models\RoleModel;
|
||||
use App\Models\TeamModel;
|
||||
use App\Models\UserTeamsModel;
|
||||
use App\Helpers\BookStackUserHelper;
|
||||
use App\Helpers\AuthHistoryModel;
|
||||
use App\Models\UserActivityHistoryModel;
|
||||
|
||||
|
||||
class UserController extends AdminController
|
||||
@ -34,6 +36,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 +260,25 @@ 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');
|
||||
// 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;
|
||||
}
|
||||
|
||||
//get login history
|
||||
$auth_data = $this->authHistoryModel->where($field_for_where_condition,$user_id);
|
||||
|
||||
//get activity history
|
||||
$activity_data = $this->userActivityHistoryModel->where();
|
||||
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@ class UserActivityHistoryModel extends Model
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'user_id',
|
||||
'pre_hr_id',
|
||||
'user_type',
|
||||
'misc_data',
|
||||
'activity'
|
||||
|
||||
@ -495,6 +495,11 @@ body {
|
||||
<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,6 +549,28 @@ body {
|
||||
return Array.from(checkboxes).map(cb => parseInt(cb.value));
|
||||
}
|
||||
|
||||
function getHrActivityHistory()
|
||||
{
|
||||
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];
|
||||
console.log(url);
|
||||
|
||||
sendAjaxRequestForGlobal(url, 'GET', function(response) {
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status === true) {
|
||||
$('#hr_access_append_area').empty();
|
||||
$('#hr_access_append_area').append(response.data)
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
} else {
|
||||
console.error(response.message, 'WARNING');
|
||||
}
|
||||
}, function(xhr, status, error) {
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
});
|
||||
}
|
||||
|
||||
// function submitForm(event) {
|
||||
// event.preventDefault();
|
||||
|
||||
|
||||
@ -18,7 +18,8 @@
|
||||
|
||||
<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="<?= $value['pre_hr_id'].'-'.$value['post_hr_id'] ?>"></i>
|
||||
</h5>
|
||||
<p class="user-email"><?= $value['hr_mail'] ?></p>
|
||||
</div>
|
||||
<div class="accordion-icon">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user