update
This commit is contained in:
@ -444,66 +444,66 @@ class ReportsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
// public function view_report_trip_detail(Request $req)
|
||||
// {
|
||||
// $vid = $req->vid;
|
||||
// $tgl0 = $req->tgl0;
|
||||
// $tgl1 = $req->tgl1;
|
||||
// $nopol1 = $req->nopol1;
|
||||
public function view_report_trip_detail(Request $req)
|
||||
{
|
||||
$vid = $req->vid;
|
||||
$tgl0 = $req->tgl0;
|
||||
$tgl1 = $req->tgl1;
|
||||
$nopol1 = $req->nopol1;
|
||||
|
||||
// $d = [$vid, $tgl0, $tgl1];
|
||||
// $list = DB::select("SELECT
|
||||
// t.crt_d , t.latitude, t.longitude, t.speed,
|
||||
// tgta.fulladdress,
|
||||
// t.pre_milleage, t.vhc_milleage, fuel_count
|
||||
// FROM
|
||||
// t_gps_tracks t
|
||||
// left 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_d BETWEEN ? AND ?
|
||||
// ORDER BY t.crt_d asc
|
||||
// ", $d);
|
||||
$d = [$vid, $tgl0, $tgl1];
|
||||
$list = DB::select("SELECT
|
||||
t.crt_d , t.latitude, t.longitude, t.speed,
|
||||
tgta.fulladdress,
|
||||
t.pre_milleage, t.vhc_milleage, fuel_count
|
||||
FROM
|
||||
t_gps_tracks t
|
||||
left 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_d BETWEEN ? AND ?
|
||||
ORDER BY t.crt_d asc
|
||||
", $d);
|
||||
|
||||
// $start = [
|
||||
// 'time' => $list[0]->crt_d,
|
||||
// 'fulladdress' => urldecode($list[0]->fulladdress),
|
||||
// 'mileage' => $list[0]->vhc_milleage,
|
||||
// ];
|
||||
// $finish = [
|
||||
// 'time' => $list[count($list) - 1]->crt_d,
|
||||
// 'fulladdress' => urldecode($list[count($list) - 1]->fulladdress),
|
||||
// 'mileage' => $list[count($list) - 1]->vhc_milleage,
|
||||
// ];
|
||||
$start = [
|
||||
'time' => $list[0]->crt_d,
|
||||
'fulladdress' => urldecode($list[0]->fulladdress),
|
||||
'mileage' => $list[0]->vhc_milleage,
|
||||
];
|
||||
$finish = [
|
||||
'time' => $list[count($list) - 1]->crt_d,
|
||||
'fulladdress' => urldecode($list[count($list) - 1]->fulladdress),
|
||||
'mileage' => $list[count($list) - 1]->vhc_milleage,
|
||||
];
|
||||
|
||||
// $t0 = Carbon::createFromTimestamp($list[0]->crt_d);
|
||||
// $t1 = Carbon::createFromTimestamp($list[count($list) - 1]->crt_d);
|
||||
// $diff = $t1->diff($t0);
|
||||
// $hours = $diff->h + ($diff->days * 24); // include days converted to hours
|
||||
// $minutes = $diff->i;
|
||||
// $duration = "{$hours} hour" . ($hours > 1 ? 's' : '') . " {$minutes} minute" . ($minutes > 1 ? 's' : '');
|
||||
$t0 = Carbon::createFromTimestamp($list[0]->crt_d);
|
||||
$t1 = Carbon::createFromTimestamp($list[count($list) - 1]->crt_d);
|
||||
$diff = $t1->diff($t0);
|
||||
$hours = $diff->h + ($diff->days * 24); // include days converted to hours
|
||||
$minutes = $diff->i;
|
||||
$duration = "{$hours} hour" . ($hours > 1 ? 's' : '') . " {$minutes} minute" . ($minutes > 1 ? 's' : '');
|
||||
|
||||
// $distance = $list[count($list) - 1]->vhc_milleage - $list[0]->vhc_milleage;
|
||||
// $fuel_consumed = $list[count($list) - 1]->fuel_count - $list[0]->fuel_count;
|
||||
$distance = $list[count($list) - 1]->vhc_milleage - $list[0]->vhc_milleage;
|
||||
$fuel_consumed = $list[count($list) - 1]->fuel_count - $list[0]->fuel_count;
|
||||
|
||||
// $data = [
|
||||
// 'nopol1' => $nopol1,
|
||||
// 'vid' => $vid,
|
||||
// 'tgl0' => $tgl0,
|
||||
// 'tgl1' => $tgl1,
|
||||
// 'list' => $list,
|
||||
// 'start' => $start,
|
||||
// 'finish' => $finish,
|
||||
// 'duration' => $duration,
|
||||
// 'distance' => $distance,
|
||||
// 'fuel_consumed' => $fuel_consumed,
|
||||
// ];
|
||||
// // dd($list);
|
||||
// return view('menu_v1.reports._trip_detail', $data);
|
||||
// }
|
||||
$data = [
|
||||
'nopol1' => $nopol1,
|
||||
'vid' => $vid,
|
||||
'tgl0' => $tgl0,
|
||||
'tgl1' => $tgl1,
|
||||
'list' => $list,
|
||||
'start' => $start,
|
||||
'finish' => $finish,
|
||||
'duration' => $duration,
|
||||
'distance' => $distance,
|
||||
'fuel_consumed' => $fuel_consumed,
|
||||
];
|
||||
// dd($list);
|
||||
return view('menu_v1.reports._trip_detail', $data);
|
||||
}
|
||||
|
||||
public function view_report_abnormalities(Request $req)
|
||||
{
|
||||
|
||||
@ -484,6 +484,7 @@
|
||||
// {
|
||||
// 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 ||
|
||||
@ -498,24 +499,26 @@
|
||||
{
|
||||
data: 'finish',
|
||||
render: (data, type, row) => {
|
||||
console.log(row.fulladdress);
|
||||
console.log(row.latitude);
|
||||
console.log(row.longitude);
|
||||
// console.log(row.fulladdress);
|
||||
// console.log(row.latitude);
|
||||
// console.log(row.longitude);
|
||||
// console.log("End Loc : ",row.endLoc)
|
||||
console.log('fulll data ',row)
|
||||
|
||||
// Saat export Excel
|
||||
if (type === 'export') {
|
||||
|
||||
const nearestSite = findNearestSite(
|
||||
row.latitude,
|
||||
row.longitude
|
||||
);
|
||||
// const nearestSite = findNearestSite(
|
||||
// row.latitude,
|
||||
// row.longitude
|
||||
// );
|
||||
|
||||
if (nearestSite) {
|
||||
return formatSiteLabel(nearestSite);
|
||||
}
|
||||
// if (nearestSite) {
|
||||
// return formatSiteLabel(nearestSite);
|
||||
// }
|
||||
|
||||
return Helper.shortenText(
|
||||
decodeURIComponent(row.fulladdress || 'address'),
|
||||
decodeURIComponent(row.finishLoc || 'address'),
|
||||
255
|
||||
) || '-';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user