update user logs

This commit is contained in:
Pringgosutono
2025-10-21 03:18:05 +07:00
parent 0b79bd665c
commit 8b833e7295
4 changed files with 72 additions and 21 deletions

View File

@ -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">

View File

@ -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)' //
// }
}
]
});
},
};