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