update & fix
This commit is contained in:
@ -56,8 +56,7 @@ class ReportsController extends Controller
|
||||
// $to_date = 1756745940;
|
||||
|
||||
try {
|
||||
$q = "
|
||||
WITH trips AS (
|
||||
$list = DB::select("WITH trips AS (
|
||||
SELECT
|
||||
t.*,
|
||||
-- mark the start of a trip when ignition=4 and previous ignition <> 4
|
||||
@ -109,10 +108,7 @@ class ReportsController extends Controller
|
||||
FROM agg agg
|
||||
join t_vehicles_detail tvd on tvd.vid = agg.id
|
||||
ORDER BY agg.id, trip_id
|
||||
";
|
||||
$d = [$from_date, $to_date, $vid, $vid];
|
||||
|
||||
$list = DB::select($q, $d);
|
||||
", [$from_date, $to_date, $vid, $vid]);
|
||||
|
||||
// // RETURN 1 - LIST
|
||||
// if($req->type != 'report'){
|
||||
@ -200,8 +196,8 @@ class ReportsController extends Controller
|
||||
$tgl1 = $req->tgl1;
|
||||
$nopol1 = $req->nopol1;
|
||||
|
||||
$q = "
|
||||
select
|
||||
$d = [$vid, $tgl0, $tgl1];
|
||||
$list = DB::select("SELECT
|
||||
t.crt_s , t.latitude, t.longitude, t.speed,
|
||||
tgta.fulladdress,
|
||||
t.pre_milleage, t.vhc_milleage
|
||||
@ -215,9 +211,7 @@ class ReportsController extends Controller
|
||||
AND t.action = 'location'
|
||||
AND t.crt_s BETWEEN ? AND ?
|
||||
ORDER BY t.crt_s asc
|
||||
";
|
||||
$d = [$vid, $tgl0, $tgl1];
|
||||
$list = DB::select($q, $d);
|
||||
", $d);
|
||||
|
||||
$start = [
|
||||
'time' => date('d-m-Y H:i:s', $list[0]->crt_s),
|
||||
@ -244,25 +238,6 @@ class ReportsController extends Controller
|
||||
$polyline[] = [$item->latitude, $item->longitude];
|
||||
}
|
||||
|
||||
// $q0 = "
|
||||
// select
|
||||
// t.crt_s , t.latitude, t.longitude, t.speed,
|
||||
// tgta.fulladdress,
|
||||
// t.pre_milleage, t.vhc_milleage
|
||||
// FROM
|
||||
// t_gps_tracks t
|
||||
// join t_gps_tracks_address tgta on tgta.master_id = t.id
|
||||
// WHERE
|
||||
// t.vhc_id = ?
|
||||
// and t.latitude IS NOT NULL
|
||||
// AND t.longitude IS NOT NULL
|
||||
// AND t.action = 'location'
|
||||
// AND t.crt_s BETWEEN ? AND ?
|
||||
// ORDER BY t.crt_s asc
|
||||
// ";
|
||||
// $d = [$vid, $tgl0, $tgl1];
|
||||
|
||||
|
||||
$data = [
|
||||
'nopol1' => $nopol1,
|
||||
'vid' => $vid,
|
||||
@ -310,8 +285,7 @@ class ReportsController extends Controller
|
||||
$vid = $req->input('vid');
|
||||
|
||||
try {
|
||||
$q = "
|
||||
select
|
||||
$list = DB::select("SELECT
|
||||
tv.name, tv.nopol1,
|
||||
t.crt_s, t.speed, tgta.fulladdress,
|
||||
tvd.speed_limit, tvd.pool_code, tvd.dc_code
|
||||
@ -328,10 +302,7 @@ class ReportsController extends Controller
|
||||
-- and t.speed > tvd.speed_limit
|
||||
having t.speed >= tvd.speed_limit
|
||||
ORDER BY t.crt_s
|
||||
";
|
||||
$d = [$from_date, $to_date, $vid, $vid];
|
||||
|
||||
$list = DB::select($q, $d);
|
||||
", [$from_date, $to_date, $vid, $vid]);
|
||||
|
||||
// // RETURN 1 - LIST
|
||||
// if($req->type != 'report'){
|
||||
|
||||
@ -100,12 +100,12 @@
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
setTimeout(function () {
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
}, 1000);
|
||||
setTimeout(() => {
|
||||
map.invalidateSize(); // force Leaflet to recalc
|
||||
map.fitBounds(polyline.getBounds());
|
||||
}, 200);
|
||||
|
||||
const linesData = (@json($list));
|
||||
console.log(linesData);
|
||||
|
||||
// 1) Initialize map
|
||||
const map = L.map("leafMap").setView([-8.90507, 125.9945732], 10)
|
||||
@ -115,8 +115,10 @@
|
||||
maxZoom: 20,
|
||||
}).addTo(map)
|
||||
|
||||
// // 3) Coordinates (Lat, Lng) for polyline
|
||||
const points = linesData.map((point) => [point.latitude, point.longitude])
|
||||
// // // 3) Coordinates (Lat, Lng) for polyline
|
||||
const points = linesData
|
||||
.filter(p => p.latitude && p.longitude)
|
||||
.map((point) => [point.latitude, point.longitude])
|
||||
|
||||
// // 4) Add polyline
|
||||
const polyline = L.polyline(points, {
|
||||
@ -145,6 +147,7 @@
|
||||
// 5) Auto-fit map to polyline bounds
|
||||
map.fitBounds(polyline.getBounds())
|
||||
|
||||
|
||||
console.log("Points:", points)
|
||||
console.log("Bounds:", polyline.getBounds())
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user