This commit is contained in:
wayanrivan
2026-07-08 17:12:44 +07:00
parent fb0bfed78b
commit 8d90b0d8a4
2 changed files with 71 additions and 68 deletions

View File

@ -167,7 +167,7 @@ class ReportsController extends Controller
// // and if(? , t.pool_code = ? , 1=1) // // and if(? , t.pool_code = ? , 1=1)
// // ", [$from_date, $to_date, $from_date, $to_date, $vid, $vid, $vt, $vt, $poolcode, $poolcode]); // // ", [$from_date, $to_date, $from_date, $to_date, $vid, $vid, $vt, $vt, $poolcode, $poolcode]);
// $sql = // $sql =
// "WITH TotalMileage AS ( // "WITH TotalMileage AS (
// SELECT // SELECT
// id, // id,
// SUM(mileage) AS total_mileage, // SUM(mileage) AS total_mileage,
@ -444,66 +444,66 @@ class ReportsController extends Controller
} }
} }
// public function view_report_trip_detail(Request $req) public function view_report_trip_detail(Request $req)
// { {
// $vid = $req->vid; $vid = $req->vid;
// $tgl0 = $req->tgl0; $tgl0 = $req->tgl0;
// $tgl1 = $req->tgl1; $tgl1 = $req->tgl1;
// $nopol1 = $req->nopol1; $nopol1 = $req->nopol1;
// $d = [$vid, $tgl0, $tgl1]; $d = [$vid, $tgl0, $tgl1];
// $list = DB::select("SELECT $list = DB::select("SELECT
// t.crt_d , t.latitude, t.longitude, t.speed, t.crt_d , t.latitude, t.longitude, t.speed,
// tgta.fulladdress, tgta.fulladdress,
// t.pre_milleage, t.vhc_milleage, fuel_count t.pre_milleage, t.vhc_milleage, fuel_count
// FROM FROM
// t_gps_tracks t t_gps_tracks t
// left join t_gps_tracks_address tgta on tgta.master_id = t.id left join t_gps_tracks_address tgta on tgta.master_id = t.id
// WHERE WHERE
// t.vhc_id = ? t.vhc_id = ?
// and t.latitude IS NOT NULL and t.latitude IS NOT NULL
// AND t.longitude IS NOT NULL AND t.longitude IS NOT NULL
// AND t.action = 'location' AND t.action = 'location'
// AND t.crt_d BETWEEN ? AND ? AND t.crt_d BETWEEN ? AND ?
// ORDER BY t.crt_d asc ORDER BY t.crt_d asc
// ", $d); ", $d);
// $start = [ $start = [
// 'time' => $list[0]->crt_d, 'time' => $list[0]->crt_d,
// 'fulladdress' => urldecode($list[0]->fulladdress), 'fulladdress' => urldecode($list[0]->fulladdress),
// 'mileage' => $list[0]->vhc_milleage, 'mileage' => $list[0]->vhc_milleage,
// ]; ];
// $finish = [ $finish = [
// 'time' => $list[count($list) - 1]->crt_d, 'time' => $list[count($list) - 1]->crt_d,
// 'fulladdress' => urldecode($list[count($list) - 1]->fulladdress), 'fulladdress' => urldecode($list[count($list) - 1]->fulladdress),
// 'mileage' => $list[count($list) - 1]->vhc_milleage, 'mileage' => $list[count($list) - 1]->vhc_milleage,
// ]; ];
// $t0 = Carbon::createFromTimestamp($list[0]->crt_d); $t0 = Carbon::createFromTimestamp($list[0]->crt_d);
// $t1 = Carbon::createFromTimestamp($list[count($list) - 1]->crt_d); $t1 = Carbon::createFromTimestamp($list[count($list) - 1]->crt_d);
// $diff = $t1->diff($t0); $diff = $t1->diff($t0);
// $hours = $diff->h + ($diff->days * 24); // include days converted to hours $hours = $diff->h + ($diff->days * 24); // include days converted to hours
// $minutes = $diff->i; $minutes = $diff->i;
// $duration = "{$hours} hour" . ($hours > 1 ? 's' : '') . " {$minutes} minute" . ($minutes > 1 ? 's' : ''); $duration = "{$hours} hour" . ($hours > 1 ? 's' : '') . " {$minutes} minute" . ($minutes > 1 ? 's' : '');
// $distance = $list[count($list) - 1]->vhc_milleage - $list[0]->vhc_milleage; $distance = $list[count($list) - 1]->vhc_milleage - $list[0]->vhc_milleage;
// $fuel_consumed = $list[count($list) - 1]->fuel_count - $list[0]->fuel_count; $fuel_consumed = $list[count($list) - 1]->fuel_count - $list[0]->fuel_count;
// $data = [ $data = [
// 'nopol1' => $nopol1, 'nopol1' => $nopol1,
// 'vid' => $vid, 'vid' => $vid,
// 'tgl0' => $tgl0, 'tgl0' => $tgl0,
// 'tgl1' => $tgl1, 'tgl1' => $tgl1,
// 'list' => $list, 'list' => $list,
// 'start' => $start, 'start' => $start,
// 'finish' => $finish, 'finish' => $finish,
// 'duration' => $duration, 'duration' => $duration,
// 'distance' => $distance, 'distance' => $distance,
// 'fuel_consumed' => $fuel_consumed, 'fuel_consumed' => $fuel_consumed,
// ]; ];
// // dd($list); // dd($list);
// return view('menu_v1.reports._trip_detail', $data); return view('menu_v1.reports._trip_detail', $data);
// } }
public function view_report_abnormalities(Request $req) public function view_report_abnormalities(Request $req)
{ {

View File

@ -484,6 +484,7 @@
// { // {
// data: 'finish', // data: 'finish',
// render: (data, type, row, meta) => { // render: (data, type, row, meta) => {
// console.log(row)
// // saat export, hanya tampilkan lokasi tanpa tanggal/jam // // saat export, hanya tampilkan lokasi tanpa tanggal/jam
// if (type === 'export') { // if (type === 'export') {
// return Helper.shortenText(decodeURIComponent(row.finishLoc || // return Helper.shortenText(decodeURIComponent(row.finishLoc ||
@ -494,28 +495,30 @@
// ${Helper.shortenText(decodeURIComponent(row.finishLoc || 'address'), 255) || "-"} // ${Helper.shortenText(decodeURIComponent(row.finishLoc || 'address'), 255) || "-"}
// `; // `;
// } // }
// }, // },
{ {
data: 'finish', data: 'finish',
render: (data, type, row) => { render: (data, type, row) => {
console.log(row.fulladdress); // console.log(row.fulladdress);
console.log(row.latitude); // console.log(row.latitude);
console.log(row.longitude); // console.log(row.longitude);
// console.log("End Loc : ",row.endLoc)
console.log('fulll data ',row)
// Saat export Excel // Saat export Excel
if (type === 'export') { if (type === 'export') {
const nearestSite = findNearestSite( // const nearestSite = findNearestSite(
row.latitude, // row.latitude,
row.longitude // row.longitude
); // );
if (nearestSite) { // if (nearestSite) {
return formatSiteLabel(nearestSite); // return formatSiteLabel(nearestSite);
} // }
return Helper.shortenText( return Helper.shortenText(
decodeURIComponent(row.fulladdress || 'address'), decodeURIComponent(row.finishLoc || 'address'),
255 255
) || '-'; ) || '-';
} }