update report
This commit is contained in:
@ -78,7 +78,7 @@
|
||||
<tr class="">
|
||||
<!-- <th class="">Vehicle ID</th> -->
|
||||
<!-- <th class="text-center">Action</th> -->
|
||||
<th class="">Vehicle Name</th>
|
||||
<!-- <th class="">Vehicle Name</th> -->
|
||||
<th class="">License Plate Number</th>
|
||||
<th class="">Time</th>
|
||||
<th class="">Speed (kph)</th>
|
||||
@ -116,8 +116,7 @@
|
||||
activate: function() {
|
||||
Wrapper.init();
|
||||
Wrapper.event();
|
||||
DTable.activate();
|
||||
|
||||
// DTable.activate();
|
||||
},
|
||||
init: ()=>{
|
||||
$('#tgl0, #tgl1').datetimepicker({
|
||||
@ -193,10 +192,10 @@
|
||||
deferRender: true,
|
||||
columns: [
|
||||
// { data: 'id', visible: false }, // vhc_id
|
||||
{
|
||||
data: 'name',
|
||||
className: 'text-start text-nowrap',
|
||||
},
|
||||
// {
|
||||
// data: 'name',
|
||||
// className: 'text-start text-nowrap',
|
||||
// },
|
||||
{
|
||||
data: 'nopol1',
|
||||
className: 'text-start',
|
||||
@ -220,7 +219,13 @@
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
title: `Abnormality Report - ${moment(safeVal('#tgl0')).format('DD MMM YYYY')} to ${moment(safeVal('#tgl1')).format('DD MMM YYYY')}`,
|
||||
title: () => {
|
||||
return `
|
||||
Vehicle Trip 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(:first-child)' // 🔹 exclude first column
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
<div class="form-group">
|
||||
<label class="text-muted">From</label>
|
||||
<!-- default today -->
|
||||
<!-- <input type="date" class="form-control" id="tgl0" value="{{ date('Y-m-d') }}"> -->
|
||||
<!-- <input class="form-control" id="tgl0" value="25-08-2025 00:00"> -->
|
||||
<input class="form-control" id="tgl0" value="{{ date('d-m-Y 00:00') }}">
|
||||
</div>
|
||||
</div>
|
||||
@ -77,8 +77,6 @@
|
||||
<thead>
|
||||
<tr class="">
|
||||
<th class="">Vehicle ID</th>
|
||||
<!-- <th class="text-center">Action</th> -->
|
||||
<th class="">Vehicle Name</th>
|
||||
<th class="">License Plate Number</th>
|
||||
<th class="">Number of Trip</th>
|
||||
<th class="">Total Mileage (km)</th>
|
||||
@ -187,8 +185,7 @@
|
||||
activate: function() {
|
||||
Wrapper.init();
|
||||
Wrapper.event();
|
||||
DTable.activate();
|
||||
|
||||
// DTable.activate();
|
||||
},
|
||||
init: ()=>{
|
||||
$('#tgl0, #tgl1').datetimepicker({
|
||||
@ -227,10 +224,6 @@
|
||||
return;
|
||||
}
|
||||
|
||||
let mileageSum = {};
|
||||
let tripCount = {};
|
||||
|
||||
|
||||
DTable.table = $('#tVehicleTrips').DataTable({
|
||||
searching: false, // 🔹 remove search box
|
||||
ordering: false, // 🔹 disable sorting for all columns
|
||||
@ -254,17 +247,6 @@
|
||||
&vid=${$('#filterNopol').val() || ''}`,
|
||||
type: 'GET',
|
||||
success: function(json) {
|
||||
// Precompute totals by vhc_id
|
||||
|
||||
json.data.forEach(row => {
|
||||
const id = row.id; // vhc_id
|
||||
if (!mileageSum[id]) {
|
||||
mileageSum[id] = 0;
|
||||
tripCount[id] = 0;
|
||||
}
|
||||
mileageSum[id] += parseFloat(row.milleage || 0);
|
||||
tripCount[id] += 1;
|
||||
});
|
||||
callback(json);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
@ -280,13 +262,6 @@
|
||||
deferRender: true,
|
||||
columns: [
|
||||
{ data: 'id', visible: false }, // vhc_id
|
||||
{
|
||||
data: 'name',
|
||||
className: 'text-start text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: 'nopol1',
|
||||
className: 'text-start',
|
||||
@ -294,8 +269,8 @@
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{ data: "id", className: 'text-end'},
|
||||
{ data: "id", className: 'text-end'},
|
||||
{ data: "total_trip", className: 'text-end'},
|
||||
{ data: "total_mileage", className: 'text-end', render: (data, type, row, meta) => parseFloat(data).toFixed(2)},
|
||||
{ data: "trip_id", className: 'text-end'},
|
||||
{
|
||||
data: 'start',
|
||||
@ -318,7 +293,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'milleage',
|
||||
data: 'mileage',
|
||||
className: 'text-end', render: function(data, type, row, meta) {
|
||||
return (data === null) ? '0' : parseFloat(data).toFixed(2);
|
||||
}
|
||||
@ -346,17 +321,7 @@
|
||||
$(rows).eq(i).find('td:eq(0)').attr('rowspan', rowspanCount);
|
||||
$(rows).eq(i).find('td:eq(1)').attr('rowspan', rowspanCount);
|
||||
$(rows).eq(i).find('td:eq(2)').attr('rowspan', rowspanCount);
|
||||
$(rows).eq(i).find('td:eq(3)').attr('rowspan', rowspanCount);
|
||||
|
||||
// fill trip count
|
||||
$(rows).eq(i).find('td:eq(2)')
|
||||
.attr('rowspan', rowspanCount)
|
||||
.text(tripCount[group]);
|
||||
|
||||
// fill mileage sum
|
||||
$(rows).eq(i).find('td:eq(3)')
|
||||
.attr('rowspan', rowspanCount)
|
||||
.text(mileageSum[group].toFixed(2));
|
||||
// $(rows).eq(i).find('td:eq(3)').attr('rowspan', rowspanCount);
|
||||
|
||||
last = group;
|
||||
} else {
|
||||
@ -364,17 +329,23 @@
|
||||
$(rows).eq(i).find('td:eq(0)').remove();
|
||||
$(rows).eq(i).find('td:eq(0)').remove();
|
||||
$(rows).eq(i).find('td:eq(0)').remove();
|
||||
$(rows).eq(i).find('td:eq(0)').remove();
|
||||
// $(rows).eq(i).find('td:eq(0)').remove();
|
||||
}
|
||||
});
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
title: `Vehicle Trip Report - ${moment(safeVal('#tgl0')).format('DD MMM YYYY')} to ${moment(safeVal('#tgl1')).format('DD MMM YYYY')}`,
|
||||
title: () => {
|
||||
return `
|
||||
Vehicle Trip 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(:first-child)' // 🔹 exclude first column
|
||||
columns: ':visible' // 🔹 exclude first column
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user