update & fix

This commit is contained in:
Pringgosutono
2025-09-11 10:34:45 +07:00
parent 5d585a6e26
commit bc92ed5234
2 changed files with 17 additions and 43 deletions

View File

@ -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'){