update
This commit is contained in:
@ -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 = ?)
|
||||
|
||||
@ -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,10 +510,8 @@
|
||||
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);
|
||||
@ -497,36 +522,18 @@
|
||||
`;
|
||||
}
|
||||
},
|
||||
// {
|
||||
// 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')}<br>
|
||||
// ${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);
|
||||
@ -558,7 +562,7 @@
|
||||
255
|
||||
) || '-'
|
||||
}
|
||||
`;
|
||||
`;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user