update vehicle trips report to include trip duration and distance

This commit is contained in:
wayanrivan
2026-07-07 12:54:42 +07:00
parent 39dbdf1795
commit 07092134e3
2 changed files with 27 additions and 27 deletions

View File

@ -177,13 +177,13 @@ class ReportsController extends Controller
tm.total_mileage, total_trip, tm.total_mileage, total_trip,
vt.name as type_name, vt.name as type_name,
ROW_NUMBER() OVER (PARTITION BY t.id ORDER BY t.start) AS trip_id, ROW_NUMBER() OVER (PARTITION BY t.id ORDER BY t.start) AS trip_id,
tgt.latitude, -- tgt.latitude,
tgt.longitude -- tgt.longitude
FROM trips t FROM trips t
JOIN TotalMileage tm ON t.id = tm.id JOIN TotalMileage tm ON t.id = tm.id
LEFT JOIN t_vehicles tvt ON tvt.id = t.vhc_id LEFT JOIN t_vehicles tvt ON tvt.id = t.vhc_id
LEFT JOIN t_vehicles_cats vt ON vt.id = tvt.cat_id LEFT JOIN t_vehicles_cats vt ON vt.id = tvt.cat_id
LEFT JOIN t_gps_tracks tgt ON t.vhc_id = tgt.vhc_id -- LEFT JOIN t_gps_tracks tgt ON t.vhc_id = tgt.vhc_id
WHERE WHERE
t.start BETWEEN ? AND ? t.start BETWEEN ? AND ?
and (? IS NULL or t.id = ?) and (? IS NULL or t.id = ?)

View File

@ -483,31 +483,11 @@
`; `;
} }
}, },
// {
// data: 'finish',
// render: (data, type, row, meta) => {
// // saat export, hanya tampilkan lokasi tanpa tanggal/jam
// if (type === 'export') {
// return Helper.shortenText(decodeURIComponent(row.finishLoc ||
// 'address'), 255) || "-";
// }
// return `
// ${moment.unix(data + AppState.TIMEFIX).format('DD MMM YYYY HH:mm:ss')}<br>
// ${Helper.shortenText(decodeURIComponent(row.finishLoc || 'address'), 255) || "-"}
// `;
// }
// },
{ {
data: 'finish', data: 'finish',
render: (data, type, row, meta) => { render: (data, type, row, meta) => {
// saat export, cek apakah koordinat finish berdekatan dengan site referensi // saat export, hanya tampilkan lokasi tanpa tanggal/jam
if (type === 'export') { if (type === 'export') {
const nearestSite = findNearestSite(row.finishLat, row
.finishLng); // sesuaikan nama field lat/lng
if (nearestSite) {
return formatSiteLabel(nearestSite);
}
// default: tetap pakai alamat dari database
return Helper.shortenText(decodeURIComponent(row.finishLoc || return Helper.shortenText(decodeURIComponent(row.finishLoc ||
'address'), 255) || "-"; 'address'), 255) || "-";
} }
@ -517,6 +497,26 @@
`; `;
} }
}, },
// {
// data: 'finish',
// render: (data, type, row, meta) => {
// // saat export, cek apakah koordinat finish berdekatan dengan site referensi
// if (type === 'export') {
// const nearestSite = findNearestSite(row.finishLat, row
// .finishLng); // sesuaikan nama field lat/lng
// if (nearestSite) {
// return formatSiteLabel(nearestSite);
// }
// // default: tetap pakai alamat dari database
// return Helper.shortenText(decodeURIComponent(row.finishLoc ||
// 'address'), 255) || "-";
// }
// return `
// ${moment.unix(data + AppState.TIMEFIX).format('DD MMM YYYY HH:mm:ss')}<br>
// ${Helper.shortenText(decodeURIComponent(row.finishLoc || 'address'), 255) || "-"}
// `;
// }
// },
{ {
className: 'text-start', className: 'text-start',
render: function(data, type, row, meta) { render: function(data, type, row, meta) {