update user logs
This commit is contained in:
@ -17,6 +17,7 @@ use App\Models\ConfTruckTypes;
|
||||
use App\Models\Vehicles;
|
||||
use App\Models\UserLogs;
|
||||
use Auth;
|
||||
use App\Models\Users;
|
||||
|
||||
class UserLogsController extends Controller
|
||||
{
|
||||
@ -26,9 +27,11 @@ class UserLogsController extends Controller
|
||||
|
||||
public function view_user_logs(Request $req)
|
||||
{
|
||||
$data = [];
|
||||
$users = Users::listUsers();
|
||||
$data = [
|
||||
"users" => $users,
|
||||
];
|
||||
|
||||
|
||||
$log = [
|
||||
"module" => "User Logs",
|
||||
"action" => "View",
|
||||
@ -42,13 +45,16 @@ class UserLogsController extends Controller
|
||||
try {
|
||||
$tgl0 = $req->tgl0;
|
||||
$tgl1 = $req->tgl1;
|
||||
$userId = $req->userId;
|
||||
|
||||
$d = [$tgl0, $tgl1];
|
||||
$d = [$tgl0, $tgl1, $userId, $userId];
|
||||
$list = DB::select("SELECT
|
||||
a.*, b.email
|
||||
FROM t_user_log a
|
||||
join t_users b on a.userId = b.id
|
||||
WHERE a.crt BETWEEN ? AND ?
|
||||
WHERE
|
||||
a.crt BETWEEN ? AND ?
|
||||
and if(? , a.userId = ? , 1=1)
|
||||
order by a.crt desc
|
||||
", $d);
|
||||
|
||||
|
||||
@ -86,8 +86,9 @@
|
||||
($module == 'config_distribution_category' ? 'Config Distribution Category' :
|
||||
($module == 'config_pool' ? 'Config Pool' :
|
||||
($module == 'report_vehicle_trip' ? 'Report Vehicle Trip' :
|
||||
($module == 'report_abnormality' ? 'Report Abnormality' : $module
|
||||
))))))))
|
||||
($module == 'report_abnormality' ? 'Report Abnormality' :
|
||||
($module == 'user_logs' ? 'Config User Activity' : $module
|
||||
)))))))))
|
||||
}}
|
||||
</label>
|
||||
<div class="col-9">
|
||||
@ -145,8 +146,9 @@
|
||||
($module == 'config_distribution_category' ? 'Config Distribution Category' :
|
||||
($module == 'config_pool' ? 'Config Pool' :
|
||||
($module == 'report_vehicle_trip' ? 'Report Vehicle Trip' :
|
||||
($module == 'report_abnormality' ? 'Report Abnormality' : $module
|
||||
))))))))
|
||||
($module == 'report_abnormality' ? 'Report Abnormality' :
|
||||
($module == 'user_logs' ? 'Config User Activity' : $module
|
||||
)))))))))
|
||||
}}
|
||||
</label>
|
||||
<div class="col-9">
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
@extends('app.app')
|
||||
|
||||
@section('title')
|
||||
Vehicles Trip Report
|
||||
User Activity
|
||||
@endsection
|
||||
|
||||
@section('customcss')
|
||||
@ -24,7 +24,7 @@
|
||||
<div class="card-header">
|
||||
<div class="row d-flex align-items-center">
|
||||
<div class="col-3">
|
||||
<p class="card-title text-bold mb-0">User Logs</p>
|
||||
<p class="card-title text-bold mb-0">User Activity</p>
|
||||
</div>
|
||||
<div class="col-auto text-end ps-0">
|
||||
<!-- <button class="btn btn-sm btn-danger">Download</button> -->
|
||||
@ -49,9 +49,23 @@
|
||||
<input class="form-control" id="tgl1" value="{{ date('d-m-Y 23:59') }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="form-group">
|
||||
<label class="text-muted">User</label>
|
||||
<select name="user" class="form-control" id="filterUser">
|
||||
<option value="">-- All --</option>
|
||||
@foreach ($users as $user)
|
||||
<option value="{{ $user->id }}">{{ $user->email }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-1 d-flex align-items-end">
|
||||
<button class="btn btn-primary" id="submitFilter">Submit</button>
|
||||
</div>
|
||||
<div class="col-5 d-flex align-items-end">
|
||||
<button class="btn btn-sm btn-danger ms-auto" id="btnDownloadReport">Download Report</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-responsive p-3">
|
||||
@ -93,8 +107,6 @@
|
||||
|
||||
const Wrapper = {
|
||||
activate: function() {
|
||||
console.log("activate");
|
||||
|
||||
Wrapper.init();
|
||||
Wrapper.event();
|
||||
DTable.activate();
|
||||
@ -115,6 +127,10 @@
|
||||
$('#submitFilter').on('click', function() {
|
||||
DTable.reload();
|
||||
});
|
||||
// Trigger export on external button click
|
||||
$('#btnDownloadReport').on('click', function() {
|
||||
DTable.table.button('.buttons-excel').trigger();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@ -125,7 +141,6 @@
|
||||
DTable.reload();
|
||||
},
|
||||
reload: function() {
|
||||
console.log("DTable.reload");
|
||||
// Abort the last request if it's still running
|
||||
if (DTable.lastAjax) {
|
||||
DTable.lastAjax.abort();
|
||||
@ -155,6 +170,7 @@
|
||||
url: `{{ route('api_user_logs') }}?
|
||||
tgl0=${moment($('#tgl0').val(), "DD-MM-YYYY HH:mm").unix()}
|
||||
&tgl1=${moment($('#tgl1').val(), "DD-MM-YYYY HH:mm").unix()}
|
||||
&userId=${$('#filterUser').val() || ''}
|
||||
`,
|
||||
type: 'GET',
|
||||
success: function(json) {
|
||||
@ -222,6 +238,22 @@
|
||||
},
|
||||
],
|
||||
paging: false,
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
title: () => {
|
||||
return `
|
||||
User Activity Report -
|
||||
${moment($('#tgl0').val(), "DD-MM-YYYY HH:mm").format('DD MMM YYYY HH:mm')}
|
||||
to
|
||||
${moment($('#tgl1').val(), "DD-MM-YYYY HH:mm").format('DD MMM YYYY HH:mm')}`
|
||||
},
|
||||
className: 'd-none', // hide default button
|
||||
// exportOptions: {
|
||||
// columns: ':visible:not(:last-child)' //
|
||||
// }
|
||||
}
|
||||
]
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@ -61,7 +61,14 @@
|
||||
</ul>
|
||||
</li>
|
||||
@endif
|
||||
@if (auth()->user()->can('config_truck_type.view') || auth()->user()->can('config_master_device.view') || auth()->user()->can('config_logs_gps.view'))
|
||||
@if (
|
||||
auth()->user()->can('config_truck_type.view') ||
|
||||
auth()->user()->can('config_master_device.view') ||
|
||||
auth()->user()->can('config_logs_gps.view') ||
|
||||
auth()->user()->can('config_distribution_category.view') ||
|
||||
auth()->user()->can('config_pool.view') ||
|
||||
auth()->user()->can('user_logs.view')
|
||||
)
|
||||
<li class="nav-item dropdown {{ Request::segment(1) == 'config' ? 'active' : '' }}">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="dropdownConfig" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Configuration
|
||||
@ -92,6 +99,17 @@
|
||||
<a class="dropdown-item {{ Request::segment(2) == 'pool' ? 'active' : '' }}" href="{{ route('view_config_pool') }}" title="">Pool</a>
|
||||
</li>
|
||||
@endcan
|
||||
@can('user_logs.view')
|
||||
<li>
|
||||
<a class="dropdown-item {{ Request::segment(1) == 'user_logs' ? 'active' : '' }}" href="{{ route('view_user_logs') }}" title="">User Activity</a>
|
||||
</li>
|
||||
|
||||
<!-- <li class="nav-item {{ Request::segment(1) == 'user_logs' ? 'active' : '' }}">
|
||||
<a class="nav-link d-flex align-items-center text-capitalize" aria-current="page" href="{{ route('view_user_logs') }}">
|
||||
User Logs
|
||||
</a>
|
||||
</li> -->
|
||||
@endcan
|
||||
</ul>
|
||||
</li>
|
||||
@endif
|
||||
@ -116,13 +134,6 @@
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@can('user_logs.view')
|
||||
<li class="nav-item {{ Request::segment(1) == 'user_logs' ? 'active' : '' }}">
|
||||
<a class="nav-link d-flex align-items-center text-capitalize" aria-current="page" href="{{ route('view_user_logs') }}">
|
||||
User Logs
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
@can('role.view')
|
||||
<li class="nav-item {{ Request::segment(1) == 'roles' ? 'active' : '' }}">
|
||||
|
||||
Reference in New Issue
Block a user