update vehicle trips report to include trip duration and distance

This commit is contained in:
wayanrivan
2026-07-07 12:46:36 +07:00
parent 67cff7d667
commit 39dbdf1795
2 changed files with 174 additions and 85 deletions

View File

@ -176,11 +176,14 @@ class ReportsController extends Controller
t.*,
tm.total_mileage, total_trip,
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.longitude
FROM trips t
JOIN TotalMileage tm ON t.id = tm.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_gps_tracks tgt ON t.vhc_id = tgt.vhc_id
WHERE
t.start BETWEEN ? AND ?
and (? IS NULL or t.id = ?)