diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php
index b1df9a8..388e0fc 100644
--- a/app/Http/Controllers/ReportsController.php
+++ b/app/Http/Controllers/ReportsController.php
@@ -178,10 +178,6 @@ class ReportsController extends Controller
)
SELECT
t.*,
- ttll.start_latitude,
- ttll.start_longitude,
- ttll.finish_latitude,
- ttll.finish_longitude,
tm.total_mileage,
tm.total_trip,
vt.name AS type_name,
@@ -193,7 +189,6 @@ class ReportsController extends Controller
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_trips_latitude_longitude ttll ON t.id = ttll.tripsid
WHERE
t.start BETWEEN ? AND ?
AND (? IS NULL OR t.id = ?)
diff --git a/resources/views/menu_v1/reports/vehicle_trips.blade.php b/resources/views/menu_v1/reports/vehicle_trips.blade.php
index b5027e4..5e64c4a 100644
--- a/resources/views/menu_v1/reports/vehicle_trips.blade.php
+++ b/resources/views/menu_v1/reports/vehicle_trips.blade.php
@@ -25,8 +25,8 @@
@if ($user_role == \App\Models\Users::ROLE_VENDOR || $user_role == \App\Models\Users::ROLE_ADMIN)
@can('vehicle.create')
+
+ -->
@endcan
{{--
@@ -129,73 +129,73 @@
+
+ | 24-679 |
+ 24-679 |
+ 26 |
+ 442.3 |
+
+
+ | 24-682 |
+ 24-682 |
+ 28 |
+ 312.7 |
+
+
+ | 24-877 |
+ 24-877 |
+ 15 |
+ 276.4 |
+
+
+ | A.16-347 |
+ A.16-347 |
+ 37 |
+ 543.2 |
+
+
+ | AL2025-B21 |
+ AL2025-B21 |
+ 18 |
+ 295.4 |
+
+
+ | B.16-542 |
+ B.16-542 |
+ 32 |
+ 478.2 |
+
+
+ | B.24-264 |
+ B.24-264 |
+ 24 |
+ 188.4 |
+
+
+ | B.24-274 |
+ B.24-274 |
+ 33 |
+ 440.1 |
+
+
+ | Ford Ranger |
+ 26-199 |
+ 30 |
+ 631.4 |
+
+
+ | Nissan AD |
+ B.10-517 |
+ 27 |
+ 375.9 |
+
+
+ | Triton |
+ A.29-127 |
+ 26 |
+ 508.2 |
+
+ -->
@@ -207,17 +207,17 @@
-->
@endsection
@@ -321,6 +321,30 @@
// Radius toleransi "berdekatan" dalam meter — sesuaikan sesuai kebutuhan
const SITE_PROXIMITY_RADIUS_METERS = 500;
+ // Helper untuk parse string "lat, long" menjadi { lat, lng }
+ function parseLatLong(latLongStr) {
+ if (!latLongStr || typeof latLongStr !== 'string') {
+ return {
+ lat: null,
+ lng: null
+ };
+ }
+
+ const parts = latLongStr.split(',').map(part => parseFloat(part.trim()));
+
+ if (parts.length !== 2 || isNaN(parts[0]) || isNaN(parts[1])) {
+ return {
+ lat: null,
+ lng: null
+ };
+ }
+
+ return {
+ lat: parts[0],
+ lng: parts[1]
+ };
+ }
+
// Hitung jarak antara 2 koordinat (formula Haversine), hasil dalam meter
function getDistanceMeters(lat1, lon1, lat2, lon2) {
const R = 6371000; // radius bumi (meter)
@@ -470,12 +494,15 @@
{
data: 'start',
render: (data, type, row, meta) => {
+ // Parse start_lat_long -> { lat, lng }
+ const {
+ lat: startLat,
+ lng: startLng
+ } = parseLatLong(row.start_lat_long);
+
// saat export, hanya tampilkan lokasi tanpa tanggal/jam
if (type === 'export') {
- const nearestSite = findNearestSite(
- row.start_latitude,
- row.start_longitude
- );
+ const nearestSite = findNearestSite(startLat, startLng);
if (nearestSite) {
return formatSiteLabel(nearestSite);
@@ -483,50 +510,30 @@
return Helper.shortenText(decodeURIComponent(row.startLoc ||
'address'), 255) || "-";
}
- const nearestSite = findNearestSite(
- row.start_latitude,
- row.start_longitude
- );
+
+ const nearestSite = findNearestSite(startLat, startLng);
if (nearestSite) {
return formatSiteLabel(nearestSite);
}
return `
- ${moment.unix(data + AppState.TIMEFIX).format('DD MMM YYYY HH:mm:ss')}
- ${Helper.shortenText(decodeURIComponent(row.startLoc || 'address'), 255) || "-"}
- `;
+ ${moment.unix(data + AppState.TIMEFIX).format('DD MMM YYYY HH:mm:ss')}
+ ${Helper.shortenText(decodeURIComponent(row.startLoc || 'address'), 255) || "-"}
+ `;
}
},
- // {
- // data: 'finish',
- // render: (data, type, row, meta) => {
- // console.log(row)
- // // 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')}
- // ${Helper.shortenText(decodeURIComponent(row.finishLoc || 'address'), 255) || "-"}
- // `;
- // }
- // },
{
data: 'finish',
render: (data, type, row) => {
- // console.log(row.fulladdress);
- // console.log(row.latitude);
- // console.log(row.longitude);
- // console.log("End Loc : ",row.endLoc)
+ // Parse finish_lat_long -> { lat, lng }
+ const {
+ lat: finishLat,
+ lng: finishLng
+ } = parseLatLong(row.finish_lat_long);
// Saat export Excel
if (type === 'export') {
-
- const nearestSite = findNearestSite(
- row.finish_latitude,
- row.finish_longitude
- );
+ const nearestSite = findNearestSite(finishLat, finishLng);
if (nearestSite) {
return formatSiteLabel(nearestSite);
@@ -538,10 +545,7 @@
) || '-';
}
- const nearestSite = findNearestSite(
- row.finish_latitude,
- row.finish_longitude
- );
+ const nearestSite = findNearestSite(finishLat, finishLng);
if (nearestSite) {
return formatSiteLabel(nearestSite);
@@ -549,16 +553,16 @@
// Tampilan di tabel
return `
- ${moment.unix(data + AppState.TIMEFIX)
- .format('DD MMM YYYY HH:mm:ss')}
-
- ${
- Helper.shortenText(
- decodeURIComponent(row.finishLoc || 'address'),
- 255
- ) || '-'
- }
- `;
+ ${moment.unix(data + AppState.TIMEFIX)
+ .format('DD MMM YYYY HH:mm:ss')}
+
+ ${
+ Helper.shortenText(
+ decodeURIComponent(row.finishLoc || 'address'),
+ 255
+ ) || '-'
+ }
+`;
}
},
{