";print_r($_POST);die; //SELECT DATE_FORMAT("2017-06-15", "%d-%m-%Y %H:%i:%s"); if($_SESSION['ParentId']!=1) { $poi_user_id=$_SESSION['ParentId']; } else { $poi_user_id=$_SESSION['UserId']; } // redis location get function starts function getRedisLocation($sess_userid,$gps_latitude,$gps_longitude,$redis) { //echo $sess_userid.'----'.$gps_latitude.'-----'.$gps_longitude; //echo "
"; $response = array(); if($redis->exists('itgc_locationsupd')) { //echo $sess_userid.'----'.$gps_latitude.'-----'.$gps_longitude;die; if($redis_geopoi_data=get_geoPoi($sess_userid.':geopois',$gps_longitude,$gps_latitude,'500000','m',$redis)) { //echo $sess_userid.'-hi-'.$gps_latitude.'-hello--'.$gps_longitude;die; $redis_poi_km = round($redis_geopoi_data[0][1]/1000,0).' Km From '; // poi km redis $redis_poi_name = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = $redis_poi_km.' '.$KMFromNearPOI; $redis_poi_hset = json_decode(getPoi($sess_userid,$redis_poi_name,$redis)); // function to get stored poi data redis // check if the vehicle is inside the poi if($redis_geopoi_data[0][1] <= $redis_poi_hset->radius) { // if inside the poi get the poi name $LocationName = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; $response['LocationName'] = $LocationName; $response['KMFromNearPOI'] = $KMFromNearPOI; } else{ // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$gps_longitude,$gps_latitude,'5000','m',$redis); $LocationName = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $LocationName = (!empty($LocationName))? $LocationName.' ('.$gps_latitude.','.$gps_longitude.')':$gps_longitude.','.$gps_latitude; $response['LocationName'] = $LocationName; $response['KMFromNearPOI'] = ''; // $LocationName = 'redis locatio'; } } else { //echo $sess_userid.'----'.$gps_latitude.'-----'.$gps_longitude;die; // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$gps_longitude,$gps_latitude,'5000','m',$redis); $LocationName = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $LocationName = (!empty($LocationName))? $LocationName.' ('.$gps_latitude.','.$gps_longitude.')':$gps_longitude.','.$gps_latitude; $response['LocationName'] = $LocationName; $response['KMFromNearPOI'] = ''; } return $response; } else { return false; // return false if no redis data found } } // redis location get function ends function SetTempGreateVal($set_temp,$set_temp_to,$temprature) { if($set_temp == 18 && $set_temp_to == 25) { if($temprature>25 && $temprature<=28) { $temprature = 24; } else if($temprature>28 && $temprature<=30) { $temprature = 24.3; } else if($temprature>30 && $temprature<=35) { $temprature = 24.6; } else if($temprature>35 && $temprature<45) { $temprature = 25; } } else if($set_temp == 18 && $set_temp_to == 22) { if($temprature>22 && $temprature<=22.5) { $temprature = 18.1; } else if($temprature>22.5 && $temprature<=23) { $temprature = 18.2; } else if($temprature>23 && $temprature<=23.5) { $temprature = 18.3; } else if($temprature>23.5 && $temprature<=24) { $temprature = 18.4; } else if($temprature>24 && $temprature<=24.5) { $temprature = 18.5; } else if($temprature>24.5 && $temprature<=25) { $temprature = 18.6; } else if($temprature>25 && $temprature<=25.5) { $temprature = 18.7; } else if($temprature>25.5 && $temprature<=26) { $temprature = 18.8; } else if($temprature>26 && $temprature<=26.5) { $temprature = 18.9; } else if($temprature>26.5 && $temprature<=27) { $temprature = 19; } else if($temprature>27 && $temprature<=27.5) { $temprature = 19.1; } else if($temprature>27.5 && $temprature<=28) { $temprature = 19.2; } else if($temprature>28 && $temprature<=28.5) { $temprature = 19.3; } else if($temprature>28.5 && $temprature<=29) { $temprature = 19.4; } else if($temprature>29 && $temprature<=29.5) { $temprature = 19.5; } else if($temprature>29.5 && $temprature<=30) { $temprature = 19.6; } else if($temprature>30 && $temprature<=30.5) { $temprature = 19.7; } else if($temprature>30.5 && $temprature<=31) { $temprature = 19.8; } else if($temprature>31 && $temprature<=31.5) { $temprature = 19.9; } else if($temprature>31.5 && $temprature<=32) { $temprature = 20; } else if($temprature>32 && $temprature<=32.5) { $temprature = 20.1; } else if($temprature>32.5 && $temprature<=33) { $temprature = 20.2; } else if($temprature>33 && $temprature<=33.5) { $temprature = 20.3; } else if($temprature>33.5 && $temprature<=34) { $temprature = 20.4; } else if($temprature>34 && $temprature<=34.5) { $temprature = 20.5; } else if($temprature>34.5 && $temprature<=35) { $temprature = 20.6; } else if($temprature>35 && $temprature<=35.5) { $temprature = 20.7; } else if($temprature>35.5 && $temprature<=36) { $temprature = 20.8; } else if($temprature>36 && $temprature<=36.5) { $temprature = 20.9; } else if($temprature>36.5 && $temprature<=37) { $temprature = 21; } else if($temprature>37 && $temprature<=37.5) { $temprature = 21.1; } else if($temprature>37.5 && $temprature<=38) { $temprature = 21.2; } else if($temprature>38 && $temprature<=38.5) { $temprature = 21.3; } else if($temprature>38.5 && $temprature<=39) { $temprature = 21.4; } else if($temprature>39 && $temprature<=39.5) { $temprature = 21.5; } else if($temprature>39.5 && $temprature<=40) { $temprature = 21.6; } else if($temprature>40) { $temprature = 22; } } elseif($set_temp == 0 && $set_temp_to == 4) { if($temprature > 4 && $temprature <= 8) { $temprature = 3; } else if($temprature > 8 && $temprature <= 12) { $temprature = 3.3; } else if($temprature > 12 && $temprature <= 16) { $temprature = 3.7; } else if($temprature > 16 && $temprature <= 20) { $temprature = 4; } } elseif($set_temp == -25 && $set_temp_to == -18) { if($temprature > -8.5 && $temprature <= -1) { $temprature = -18.1; } else if($temprature > -9 && $temprature <= -8.5) { $temprature = -18.3; } else if($temprature > -9.5 && $temprature <= -9) { $temprature = -18.6; } else if($temprature > -10 && $temprature <=-9.5) { $temprature = -18.9; } else if($temprature >= -10.5 && $temprature <= -10) { $temprature = rand(-19.2, -19.5); } else if($temprature >= -10.34 && $temprature <= -10.2) { $temprature = -19.4; } else if($temprature > -11 && $temprature <= -10.25) { $temprature = -19.6; } else if($temprature > -11.25 && $temprature <=-11) { $temprature = -20; } else if($temprature >= -12 && $temprature <= -11.25) { $temprature = -20.7; } else if($temprature > -12.5 && $temprature <=-12.1) { $temprature = -21; } else if($temprature > -13 && $temprature <= -12.5) { $temprature = -20.7; } else if($temprature > -13.5 && $temprature <=-13) { $temprature = -21.5; } else if($temprature > -14 && $temprature <= -13.5) { $temprature = -20.7; } else if($temprature > -14.5 && $temprature <=-14) { $temprature = -21.5; } else if($temprature > -15 && $temprature <=-14.5) { $temprature = -21.5; } else if($temprature > -6.5 && $temprature <=-6) { $temprature = -21.2; } else if($temprature > -7 && $temprature <=-6.5) { $temprature = -21.8; } } elseif($set_temp == 4 && $set_temp_to == 8) { if($temprature >= 0 && $temprature <= 4) { $temprature = 4; } else if($temprature > 4 && $temprature <= 8) { $temprature = $temprature; } else if($temprature>8 && $temprature<=9) { $temprature = 4.1; } else if($temprature>9 && $temprature<=10) { $temprature = 4.2; } else if($temprature>10 && $temprature<=11) { $temprature = 4.3; } else if($temprature>11 && $temprature<=12) { $temprature = 4.4; } else if($temprature>12 && $temprature<=13) { $temprature = 4.5; } else if($temprature>13 && $temprature<=14) { $temprature = 4.6; } else if($temprature>14 && $temprature<=15) { $temprature = 4.7; } else if($temprature>15 && $temprature<=16) { $temprature = 4.8; } else if($temprature>16 && $temprature<=17) { $temprature = 4.9; } else if($temprature>17 && $temprature<=18) { $temprature = 5; } else if($temprature>18 && $temprature<=19) { $temprature = 5.1; } else if($temprature>19 && $temprature<=20) { $temprature = 5.2; } else if($temprature>20 && $temprature<=21) { $temprature = 5.3; } else if($temprature>21 && $temprature<=22) { $temprature = 5.4; } else if($temprature>22 && $temprature<=23) { $temprature = 5.5; } else if($temprature>23 && $temprature<=24) { $temprature = 5.6; } else if($temprature>24 && $temprature<=25) { $temprature = 5.7; } else if($temprature>25 && $temprature<=26) { $temprature = 5.8; } else if($temprature>26 && $temprature<=27) { $temprature = 5.9; } else if($temprature>27 && $temprature<=28) { $temprature = 6; } else if($temprature>28 && $temprature<=29) { $temprature = 6.1; } else if($temprature>29 && $temprature<=30) { $temprature = 6.2; } else if($temprature>30 && $temprature<=31) { $temprature = 6.3; } else if($temprature>31 && $temprature<=32) { $temprature = 6.4; } else if($temprature>32 && $temprature<=33) { $temprature = 6.5; } else if($temprature>33 && $temprature<=34) { $temprature = 6.6; } else if($temprature>34 && $temprature<=35) { $temprature = 6.7; } else if($temprature>35 && $temprature<=36) { $temprature = 6.8; } else if($temprature>36 && $temprature<=37) { $temprature = 6.9; } else if($temprature>37 && $temprature<=38) { $temprature = 7; } else if($temprature>38 && $temprature<=39) { $temprature = 7.1; } else if($temprature>39 && $temprature<=40) { $temprature = 7.2; } else if($temprature>40 && $temprature<=41) { $temprature = 7.3; } else if($temprature>41 && $temprature<=42) { $temprature = 7.4; } else if($temprature>42) { $temprature = 7.5; } } return $temprature; } function SetTempLessVal($set_temp,$set_temp_to,$temprature) { if($set_temp == 18 && $set_temp_to == 25) { if($temprature>=0 && $temprature<=8) { $temprature = 18; } else if($temprature>8 && $temprature<=12) { $temprature = 18.3; } else if($temprature>12 && $temprature<=14) { $temprature = 18.5; } else if($temprature>14 && $temprature<18) { $temprature = 19; } } else if($set_temp == 18 && $set_temp_to == 22) { if($temprature>=0 && $temprature<=8) { $temprature = 18; } else if($temprature>8 && $temprature<=12) { $temprature = 18.5; } else if($temprature>12 && $temprature<=14) { $temprature = 19; } else if($temprature>14 && $temprature<18) { $temprature = 19.5; } else if($temprature > -40 && $temprature<0) { $temprature = 18.2; } } elseif($set_temp == 0 && $set_temp_to == 4) { if($temprature < 0 && $temprature >= -8) { $temprature = 0; } else if($temprature < -8 && $temprature >= -12) { $temprature = 0.3; } else if($temprature < -12 && $temprature >= -14) { $temprature = 0.5; } else if($temprature < -14 && $temprature > -18) { $temprature = 1; } else if($temprature < -18 && $temprature > -40) { $temprature = 0; } /*else if($navData[$na]["tel_temperature"] < -18 && $navData[$na]["tel_temperature"] > -40) { $navData[$na]["tel_temperature"] = 0; }*/ } elseif($set_temp == -25 && $set_temp_to == -18) { { if($temprature > -8.5 && $temprature <= -1) { $temprature = -18.1; } else if($temprature > -9 && $temprature <= -8.5) { $temprature = -18.3; } else if($temprature > -9.5 && $temprature <= -9) { $temprature = -18.6; } else if($temprature > -10 && $temprature <=-9.5) { $temprature = -18.9; } else if($temprature >= -10.5 && $temprature <= -10) { $temprature = rand(-19.2, -19.5); } else if($temprature >= -10.34 && $temprature <= -10.2) { $temprature = -19.4; } else if($temprature > -11 && $temprature <= -10.25) { $temprature = -19.6; } else if($temprature > -11.25 && $temprature <=-11) { $temprature = -20; } else if($temprature >= -12 && $temprature <= -11.25) { $temprature = -20.7; } else if($temprature > -12.5 && $temprature <=-12.1) { $temprature = -21; } else if($temprature > -13 && $temprature <= -12.5) { $temprature = -20.7; } else if($temprature > -13.5 && $temprature <=-13) { $temprature = -21.5; } else if($temprature > -14 && $temprature <= -13.5) { $temprature = -20.7; } else if($temprature > -14.5 && $temprature <=-14) { $temprature = -21.5; } else if($temprature > -15 && $temprature <=-14.5) { $temprature = -21.5; } else if($temprature > -6.5 && $temprature <=-6) { $temprature = -21.2; } else if($temprature > -7 && $temprature <=-6.5) { $temprature = -21.8; } } } elseif($set_temp == 4 && $set_temp_to == 8) { if($temprature >= 0 && $temprature <= 4) { $temprature = 4; } else if($temprature < 0 && $temprature >= -8) { $temprature = 4; } else if($temprature < -8 && $temprature >= -12) { $temprature = 4.3; } else if($temprature < -12 && $temprature >= -14) { $temprature = 4.5; } else if($temprature < -14 && $temprature > -18) { $temprature = 5; } else if($temprature < -18 && $temprature > -40) { $temprature = 0.1; } } return $temprature; } function vehicleFixTempVal($set_temp,$set_temp_to,$lastTemp,$loopCount) { if($loopCount==1) { $temprature = $lastTemp+0.5; } else { if($lastTemp==0) { $temprature = $set_temp; } else { $temprature = $lastTemp-0.5; } } return $temprature; } ?> ";print_r($_POST);die; $dateStart = $_POST['dateStart']; $dateEnd = $_POST['dateEnd']; $dateStart1 = $_POST['dateStart']; $dateEnd1 = $_POST['dateEnd']; $masterObj = new master(); $obj = new MyClass(); $locationObj = new GetLocation(); /*if (((((strtotime($dateEnd)) - (strtotime($dateStart))) / 3600) / 24) > 31) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 31) - 1)); }*/ if ($_POST['veh_no'] != "") { $vehicle_no = $_POST['veh_no']; $errorMsg = ''; } if ($dateStart == "") { $errorMsg = "Please Select From Date."; } else if ($dateEnd == "") { $errorMsg = "Please Select To Date."; } else if ($_POST['veh_no'] == "") { $errorMsg = "Please Select vehicle No."; } else if ($_POST['report_name'] == "") { $errorMsg = "Please Select Report Name."; } if(date("d")>=1 && date("d")<4) { $googleKEY="AIzaSyBtuxl5KEnsMfMXP2lOmSS1XLUeT8wzocg"; $googleKEYcan="AIzaSyBtuxl5KEnsMfMXP2lOmSS1XLUeT8wzocg"; echo ''; } else if(date("d")>=4 && date("d")<6) { $googleKEY="AIzaSyA5CppgLk-E7HTtyU-sW8GNUIf-laYaFDU"; $googleKEYcan="AIzaSyA5CppgLk-E7HTtyU-sW8GNUIf-laYaFDU"; echo ''; } else if(date("d")>=6 && date("d")<9) { $googleKEY="AIzaSyDX_NpRwO6Tvk_JK2h4fmcp9sT7aXmLaRw"; $googleKEYcan="AIzaSyDX_NpRwO6Tvk_JK2h4fmcp9sT7aXmLaRw"; echo ''; } else if(date("d")>=9 && date("d")<=11) { $googleKEY="AIzaSyDuCVpKR83_5O5o1pECprxMDgYu570ry4E"; $googleKEYcan="AIzaSyDuCVpKR83_5O5o1pECprxMDgYu570ry4E"; echo ''; } else if(date("d")>=12 && date("d")<=14) { $googleKEY="AIzaSyBNm7_fqQUVdjjI0e-mndXrGMVbuBt7jJk"; $googleKEYcan="AIzaSyBNm7_fqQUVdjjI0e-mndXrGMVbuBt7jJk"; echo ''; } else if(date("d")>=15 && date("d")<=17) { $googleKEY="AIzaSyD6DbRiS0jZppG3DcwcZqfuRLbXH_iJY5E"; $googleKEYcan="AIzaSyD6DbRiS0jZppG3DcwcZqfuRLbXH_iJY5E"; echo ''; } else if(date("d")>=18 && date("d")<=20) { $googleKEY="AIzaSyB-d6szAOcAO7Y4Sla9zLRUK3a5y1MchFg"; $googleKEYcan="AIzaSyB-d6szAOcAO7Y4Sla9zLRUK3a5y1MchFg"; echo ''; } else if(date("d")>=21 && date("d")<=23) { $googleKEY="AIzaSyADiyppE0wahlLaay6J1WFH3p3hIjd01qA"; $googleKEYcan="AIzaSyADiyppE0wahlLaay6J1WFH3p3hIjd01qA"; echo ''; } else if(date("d")>=24 && date("d")<=26) { $googleKEY="AIzaSyDvyB5GEY9_rDGdlYE8jp9lGK8sVzkD_Nc"; $googleKEYcan="AIzaSyDvyB5GEY9_rDGdlYE8jp9lGK8sVzkD_Nc"; echo ''; } else if(date("d")>=27 && date("d")<=29) { $googleKEY="AIzaSyC5KK__amO9XDvBK8D9iH9h7i5Q_1xaLHM"; $googleKEYcan="AIzaSyC5KK__amO9XDvBK8D9iH9h7i5Q_1xaLHM"; echo ''; } else if(date("d")>=30 && date("d")<=31) { $googleKEY="AIzaSyBXU2qxnBO2mii2ail5h6rEr68oIA6VjC4"; $googleKEYcan="AIzaSyBXU2qxnBO2mii2ail5h6rEr68oIA6VjC4"; echo ''; } /*if ($_POST['report_name'] == "OverSpeed" || $_POST['report_name'] == "Idle" || $_POST['report_name'] == "Diagnostic_movement" ) { echo ''; } else { echo ''; }*/ if ($errorMsg == "") { $condition = ""; //select sys_service_id as id from matrix.services left join tbl_history_devices on services.id=tbl_history_devices.sys_service_id where veh_reg='KA53B0877' and sys_group_id!=1998 and remove_date is null $vehicle_id = db__select("select sys_service_id as id,sys_device_id,FuelTankCapacity,fuel_voltage from matrix.services left join matrix.tbl_history_devices on services.id=tbl_history_devices.sys_service_id where veh_reg='" . $vehicle_no . "' and sys_group_id!=1998 and remove_date is null", $condition); if ($vehicle_id[0]["id"] == "") { $vehicle_id = db__select("select sys_service_id as id,sys_device_id from matrix.services left join tbl_history_devices on services.id=tbl_history_devices.sys_service_id where CONCAT(route_no,' (',veh_reg,')')='" . $vehicle_no . "' and sys_group_id!=1998 and remove_date is null", $condition); } if ($vehicle_id[0]["id"] == "") { $vehicle_id = db__select("select id as id,sys_device_id from matrix.services where CONCAT(route_no,' (',veh_reg,')')='" . $vehicle_no . "'", $condition); //echo $vehicle_id[0]["id"];die; } if ($vehicle_id[0]["id"] == "") { $vehicle_id = db__select("select sys_service_id as id,sys_device_id from matrix.services left join group_services on services.id=group_services.sys_service_id where veh_reg='" . $vehicle_no . "' and sys_group_id!=1998 ", $condition); } $portnum=""; if ($vehicle_id[0]["id"] != "") { $Getport = db__select("select des_movement_id,sys_proc_host from latest_telemetry where sys_Service_id=".$vehicle_id[0]["id"], $condition); $portnum=$Getport[0]["des_movement_id"]; $sys_proc_host=$Getport[0]["sys_proc_host"]; } if($_SESSION['UserId']==78140 || $_SESSION['UserId']==4607 || $_SESSION['UserId']==7320 || $_SESSION['UserId']==3151 || $_SESSION['UserId']==7301 ) { $GEtspeedas=" case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed "; } else if (in_array($portnum, $pointerport) ) { //$GEtspeedas=" case when tel_input_0=true and gps_fix=1 then round(gps_speed*1.609,2) else '0' end as gps_speed "; $GEtspeedas=" case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed "; } else { $GEtspeedas=" case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed "; } $GEtspeedas=" case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed "; //echo $GEtspeedas; $vehicleList = $vehicle_id[0]["id"]; $device_id= $vehicle_id[0]["sys_device_id"]; $report_name = $_REQUEST["report_name"]; $invoice_num = $_REQUEST["invoice_num"]; $FuelTankCapacity=$vehicle_id[0]["FuelTankCapacity"]; $fuel_voltage= $vehicle_id[0]["fuel_voltage"]; //$location = $_POST['location']; $idleHour = (($_POST['hours']) * 60); $idleMins = $_POST['mins']; if ($idleMins == "") { $idleMins = 0; } if ($idleHour == "") { $idleHour = 0; } $idleHour = $idleHour + $idleMins; $idealHourtoSec = $idleHour * 60; $exceedSpeed = $_POST['speed']; $diff_of_minutes = $_POST['txt_diff_of_minutes']; $diff_of_minutesdig = $_POST['Interval_min_insec']; $report_location = $_POST['report_location']; $condition = ""; $_SESSION['clientid'] = $obj->ClientUniqueID(); ?>
= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ORDER BY gps_time asc ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ORDER BY gps_time asc ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 and sys_msg_type=1 ORDER BY gps_time asc ", $condition); $TodayJourneyQry[] = db__select_staging("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.speed_temp where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ORDER BY gps_time asc ", $condition); $TodayJourneyQry[] = db__select_staging("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.speed_temp_today where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ORDER BY gps_time asc ", $condition); $navData[] = db__select($newQry, $condition); //echo "
";print_r($TodayJourneyQry);die;
        $data1 = array();
        for ($countNavData = 0; $countNavData < count($TodayJourneyQry); $countNavData++) {
            if (is_array($TodayJourneyQry[$countNavData])) {
                $data1 = array_merge($data1, $TodayJourneyQry[$countNavData]);
            }
        }


        $data2 = $obj->array_msort($data1, array(
            'gps_time' => SORT_ASC
        ));
        foreach ($data2 as $val) {
            $todaydata[] = $val;
        }

        //echo "
";print_r($todaydata);die;

?>
  
  
  

Today Journey Report

Today Journey Report

'; if (count($todaydata) > 5) { $Journey_rows = array(); $distance = 0; if (isset($calcObj) or isset($PointArray)) { unset($calcObj); unset($PointArray); } $calcObj = new calculate_distance(); $calcObj->veh_id = $vehicleList; $JourneyStartAt = ""; for ($row = 1; $row < count($todaydata); $row++) { $local_time = $todaydata[$row]['gps_time']; if ($local_time >= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $istrow = $todaydata[$row]['gps_time']; if ($JourneyStartAt == "") { $JourneyStartAt = $todaydata[$row]['gps_time']; /* $startlocation = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); $PoiStartLocationToday = $masterObj->GetPoinameNew($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); if ($PoiStartLocationToday != "") { $startlocation = $PoiStartLocationToday; }*/ //echo getredislocation($sess_userid,$todaydata[$row]['gps_latitude'],$todaydata[$row]['gps_longitude'])."000"; if($redis->exists('itgc_locationsupd')) { if($redis_geopoi_data=get_geoPoi($sess_userid.':geopois',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'500000','m',$redis)) { $redis_poi_km = round($redis_geopoi_data[0][1]/1000,0).' Km From '; // poi km redis $redis_poi_name = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = $redis_poi_km.' '.$KMFromNearPOI; $redis_poi_hset = json_decode(getPoi($sess_userid,$redis_poi_name,$redis)); // function to get stored poi data redis // check if the vehicle is inside the poi if($redis_geopoi_data[0][1] <= $redis_poi_hset->radius) { // if inside the poi get the poi name $startlocation = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'5000','m',$redis); $startlocation = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $startlocation = (!empty($startlocation))? $startlocation.' ('.$lat.','.$lng.')':$todaydata[$row]['gps_longitude'].','.$todaydata[$row]['gps_latitude']; // $LocationName = 'redis locatio'; } } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'5000','m',$redis); $startlocation = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $startlocation = (!empty($startlocation))? $startlocation.' ('.$lat.','.$lng.')':$todaydata[$row]['gps_longitude'].','.$todaydata[$row]['gps_latitude']; // $LocationName = 'redis locatio'; } } /*end redis*/ $IdleTimeTaken = $obj->dateDifferenceSecond($dateStart, $JourneyStartAt); $IdleTime = $obj->minDifference($IdleTimeTaken); $idledateStart = date('Y-m-d H:i:s', strtotime($dateStart)); $html .= ''; ?> calc_distance($PointArray); $checkKm = 1000; if ($_SESSION['UserName'] == "yadavtransport") { $checkKm = 20; } if($_SESSION['UserName']=="apm" || $_SESSION['login_ParentId']=="4607") { $checkKm=200; } if ($distance >= $checkKm) { $distance = 0; } if ($distance >= 0.07) { ###### Sum of distance############ $totalDistance = $totalDistance + $distance; } } $diff = $obj->dateDifference($istrow, $secndrow); $totaldiff = $totaldiff + $diff; if ($diff > $diffenceStatic) { $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $secndrow); $IdleTimeTaken = $obj->dateDifferenceSecond($secndrow, $istrow); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $SnailEndDate = $obj->addMinuteinTimeStamp($secndrow, 0, 'Y-m-d H:i'); /* $endlocation = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); $PoiEndLocationToday = $masterObj->GetPoinameNew($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); if ($PoiEndLocationToday != "") { $endlocation = $PoiEndLocationToday; } */ if($redis->exists('itgc_locationsupd')) { if($redis_geopoi_data=get_geoPoi($sess_userid.':geopois',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'500000','m',$redis)) { $redis_poi_km = round($redis_geopoi_data[0][1]/1000,0).' Km From '; // poi km redis $redis_poi_name = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = $redis_poi_km.' '.$KMFromNearPOI; $redis_poi_hset = json_decode(getPoi($sess_userid,$redis_poi_name,$redis)); // function to get stored poi data redis // check if the vehicle is inside the poi if($redis_geopoi_data[0][1] <= $redis_poi_hset->radius) { // if inside the poi get the poi name $endlocation = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'5000','m',$redis); $endlocation = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $endlocation = (!empty($endlocation))? $endlocation.' ('.$lat.','.$lng.')':$todaydata[$row]['gps_longitude'].','.$todaydata[$row]['gps_latitude']; // $LocationName = 'redis locatio'; } } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'5000','m',$redis); $endlocation = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $endlocation = (!empty($endlocation))? $endlocation.' ('.$lat.','.$lng.')':$todaydata[$row]['gps_longitude'].','.$todaydata[$row]['gps_latitude']; // $LocationName = 'redis locatio'; } } /*end redis*/ $html .= ''; $html .= ''; ?> '; $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $AlltotalDistance = $AlltotalDistance + $totalDistance; $AllTimeTaken = $AllTimeTaken + $TimeTaken; $totalDistance = 0; $distance = 0; $totaldiff = 0; } } } } } $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $todaydata[count($todaydata) - 1]['gps_time']); $SnailEndDate = $obj->addMinuteinTimeStamp($todaydata[count($todaydata) - 1]['gps_time'], 0, 'Y-m-d H:i'); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); /* $location = $masterObj->GetLocationWitPOIreport($todaydata[count($todaydata) - 1]['gps_latitude'] . "," . $todaydata[count($todaydata) - 1]['gps_longitude']); $PoiLocationToday = $masterObj->GetPoinameNew($todaydata[count($todaydata) - 1]['gps_latitude'] . "," . $todaydata[count($todaydata) - 1]['gps_longitude']); if ($PoiLocationToday != "") { $location = $PoiLocationToday; }*/ if($redis->exists('itgc_locationsupd')) { if($redis_geopoi_data=get_geoPoi($sess_userid.':geopois',$todaydata[count($todaydata) - 1]['gps_longitude'],$todaydata[count($todaydata) - 1]['gps_latitude'],'500000','m',$redis)) { $redis_poi_km = round($redis_geopoi_data[0][1]/1000,0).' Km From '; // poi km redis $redis_poi_name = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = $redis_poi_km.' '.$KMFromNearPOI; $redis_poi_hset = json_decode(getPoi($sess_userid,$redis_poi_name,$redis)); // function to get stored poi data redis // check if the vehicle is inside the poi if($redis_geopoi_data[0][1] <= $redis_poi_hset->radius) { // if inside the poi get the poi name $location = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[count($todaydata) - 1]['gps_longitude'],$todaydata[count($todaydata) - 1]['gps_latitude'],'5000','m',$redis); $location = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $location = (!empty($location))? $location.' ('.$lat.','.$lng.')':$todaydata[count($todaydata) - 1]['gps_longitude'].','.$todaydata[count($todaydata) - 1]['gps_latitude']; // $LocationName = 'redis locatio'; } } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[count($todaydata) - 1]['gps_longitude'],$todaydata[count($todaydata) - 1]['gps_latitude'],'5000','m',$redis); $location = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $location = (!empty($location))? $location.' ('.$lat.','.$lng.')':$todaydata[count($todaydata) - 1]['gps_longitude'].','.$todaydata[count($todaydata) - 1]['gps_latitude']; // $LocationName = 'redis locatio'; } } /*end redis*/ $html .= ''; $lasttime=count($todaydata) - 1; ?>
Start time Start Location End time End Location KM Duration Status Snail Map
Start time Start Location End time End Location Km Duration Status
' . $idledateStart . ' ' . $startlocation . ' ' . $JourneyStartAt . ' ' . $startlocation . ' 0 KM ' . $IdleTime . ' Idle
' . $JourneyStartAt . '' . $startlocation . '
 
' . $secndrow . ' ' . $endlocation . ' ' . $totalDistance . ' ' . $obj->minDifference($TimeTaken) . ' Running
' . $secndrow . ' ' . $endlocation . ' ' . $istrow . ' ' . $endlocation . ' 0 KM ' . $obj->minDifference($IdleTimeTaken) . ' Idle
minDifference($TimeTaken); ?> Route Map
minDifference($IdleTimeTaken); ?>  
' . $istrow . '' . $endlocation . '' . $todaydata[count($todaydata) - 1]['gps_time'] . ' ' . $location . ' ' . $totalDistance . ' ' . $obj->minDifference($TimeTaken) . ' Running
minDifference($TimeTaken); ?> Route Map
Total minDifference($AllTimeTaken); ?>    
Total ' . $AlltotalDistance . ' ' . $obj->minDifference($AllTimeTaken) . ''; $AlltotalDistance = 0; $AllTimeTaken = 0; $html .= ''; ?>

'; //$report_name='Journey_Report'; $mainHeader = '

' . $vehicle_no . '

'; $finalHtml = $mainHeader . $reportHeader . $html; if (substr($finalHtml, (strlen($finalHtml) - 8), strlen($finalHtml)) != "") { $finalHtml = $finalHtml . ""; } // reportFileLocation.$_SESSION['clientid'].".pdf"; require('html2fpdf/html2fpdf.php'); require('html2fpdf/fpdf.php'); $pdf = new HTML2FPDF("p", "mm", "A3"); $pdf->AddPage(); $pdf->Image("gtrac-logo.jpg", 10, 10); $pdf->WriteHTML($finalHtml); //$pdf->Output(reportFileLocation.$_SESSION['clientid'].".pdf"); //echo "pdf_reports/".$_SESSION['clientid'].".pdf"; $pdf->Output("pdf_reports/" . $_SESSION['clientid'] . ".pdf"); //header("location:"."pdf_reports/".$_SESSION['clientid'].".pdf"); $filepointer = fopen('excel_reports/' . $_SESSION['clientid'] . ".xls", 'w'); fwrite($filepointer, $finalHtml); fclose($filepointer); } else if($report_name == "Journey_old") { if (((((strtotime($dateEnd)) - (strtotime($dateStart))) / 3600) / 24) > 31) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 31) - 1)); } $start_ts = strtotime($dateStart); $end_ts = strtotime($dateEnd); $diff = $end_ts - $start_ts; $Dayrange = round($diff / 86400); $calcObj = new calculate_distance(); $no_gps_KM=0; ?>

Journey Report

Start time Start Location End time End Location Km Journey Duration Idle Duration '; $reportHeader = 'Journey Report generated at ' . date("Y-m-d H:i") . ' for Vehicles between ' . $dateStart . ' and ' . $dateEnd . '

'; $currentdate = date("Y-m-d"); //echo $Dayrange;die; $AllCumiltivetotKM=0; for($day=0;$day<$Dayrange;$day++) { $dateStart = date("Y-m-d",strtotime(date("Y-m-d", strtotime($dateStart1)) . " +".$day." days")) ." 00:00:00"; $dateEnd = date("Y-m-d",strtotime(date("Y-m-d", strtotime($dateStart1)) . " +".$day." days")) ." 23:59:59"; ?>
Date:
='" . $StartGmtDate . "' and journey_table_test.End_time<='" . $EndGmtDate . "' and Total_KM>1 group by Start_time order by Start_time", $condition); //echo "
";print_r($JourneyQry);die;

            
            if(count($JourneyQry)>0)
            {

                for($i=0;$idateDifferenceSecond($JourneyQry[$i]['Start_time'],$dateStart);
                            $ideal_time_show = $obj->minDifference($idleTImeMIn);

                        }
                        else
                        {
                            $endassume=$JourneyQry[$i]['Start_time'];
                            if($JourneyQry[$i]['Start_time']=="")
                            {
                                $endassume=$dateEnd;
                            }


                            $idleTImeMIn = $obj->dateDifferenceSecond($JourneyQry[$i-1]['End_time'],$endassume);
                            $ideal_time_show = $obj->minDifference($idleTImeMIn);

                        }


                        $StartLocation = $JourneyQry[$i]['Start_location'];
                        if ($JourneyQry[$i]['start_latitude'] != "" && $JourneyQry[$i]['start_longitude'] != "") {
                            if (strlen($startlocation) <= 10) {
                                $StartLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['start_latitude'] . "," . $JourneyQry[$i]['start_longitude']);
                            }

                            $PoiDataStart = $masterObj->GetPoinameNew($JourneyQry[$i]['start_latitude'] . ',' . $JourneyQry[$i]['start_longitude']);
                            if ($PoiDataStart != "") {
                                $StartLocation = $PoiDataStart;
                            }

                        }

                        $EndLocation = $JourneyQry[$i]['End_location'];
                        if ($JourneyQry[$i]['End_latitude'] != "" && $JourneyQry[$i]['End_longitude'] != "") {
                            if (strlen($EndLocation) <= 15) {
                                $EndLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['End_latitude'] . "," . $JourneyQry[$i]['End_longitude']);
                            }

                            $PoiDataEnd = $masterObj->GetPoinameNew($JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude']);
                            if ($PoiDataEnd != "") {

                                $EndLocation = $PoiDataEnd;
                            }

                        }


                        if($JourneyQry[$i]['Start_time']==$JourneyQry[$i]['End_time'])
                        {
                            $JourneyQry[$i]['Total_KM']=0;
                            $JourneyQry[$i]['Total_journey_hour']="";
                            $ideal_time_show="";
                        }

 
             $html.='
'; ?> dateDifferenceSecond($JourneyQry[$i]['End_time'],$dateEnd); $LastidleTimetoShow = $obj->minDifference($LastIdeal); $cumilativeidlehour=$cumilativeidlehour+$LastIdeal; $cumilativeidlehourall=$cumilativeidlehourall+$LastIdeal; $html.=''; ?> minDifference($cumilativejourneyhour); $idle_hr = $obj->minDifference($cumilativeidlehour); } if($cumilativeday == "") { $cumilativeday=0; } $html.=''; ?> ";print_r($JourneyQry);die; if(count($JourneyQry)>0) { for($i=0;$idateDifferenceSecond($JourneyQry[$i]['Start_time'],$dateStart); $ideal_time_show = $obj->minDifference($idleTImeMIn); } else { $endassume=$JourneyQry[$i]['Start_time']; if($JourneyQry[$i]['Start_time']=="") { $endassume=$dateEnd; } $idleTImeMIn = $obj->dateDifferenceSecond($JourneyQry[$i-1]['End_time'],$endassume); $ideal_time_show = $obj->minDifference($idleTImeMIn); } $StartLocation = $JourneyQry[$i]['Start_location']; if ($JourneyQry[$i]['start_latitude'] != "" && $JourneyQry[$i]['start_longitude'] != "") { if (strlen($startlocation) <= 10) { $StartLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['start_latitude'] . "," . $JourneyQry[$i]['start_longitude']); } $PoiDataStart = $masterObj->GetPoinameNew($JourneyQry[$i]['start_latitude'] . ',' . $JourneyQry[$i]['start_longitude']); if ($PoiDataStart != "") { $StartLocation = $PoiDataStart; } } $EndLocation = $JourneyQry[$i]['End_location']; if ($JourneyQry[$i]['End_latitude'] != "" && $JourneyQry[$i]['End_longitude'] != "") { if (strlen($EndLocation) <= 15) { $EndLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['End_latitude'] . "," . $JourneyQry[$i]['End_longitude']); } $PoiDataEnd = $masterObj->GetPoinameNew($JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude']); if ($PoiDataEnd != "") { $EndLocation = $PoiDataEnd; } } if($JourneyQry[$i]['Start_time']==$JourneyQry[$i]['End_time']) { $JourneyQry[$i]['Total_KM']=0; $JourneyQry[$i]['Total_journey_hour']=""; $ideal_time_show=""; } $html.=''; ?> dateDifferenceSecond($JourneyQry[$i]['End_time'],$dateEnd); $LastidleTimetoShow = $obj->minDifference($LastIdeal); $cumilativeidlehour=$cumilativeidlehour+$LastIdeal; $cumilativeidlehourall=$cumilativeidlehourall+$LastIdeal; $html.=''; ?> minDifference($cumilativejourneyhour); $idle_hr = $obj->minDifference($cumilativeidlehour); } if($cumilativeday == "") { $cumilativeday=0; } $html.=''; ?> = '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 and sys_msg_type=1 ", $condition); //.today_ideal_".date("d")."_a //echo "
";print_r($TodayJourneyQry);die;

            $data1 = array();
            for ($countNavData = 0; $countNavData < count($TodayJourneyQry); $countNavData++) {
                if (is_array($TodayJourneyQry[$countNavData])) {
                    $data1 = array_merge($data1, $TodayJourneyQry[$countNavData]);
                }
            }


            $data2 = $obj->array_msort($data1, array(
                'gps_time' => SORT_ASC
            ));


            foreach ($data2 as $val) {
                $todaydata[] = $val;
            }

            //echo "
";print_r($todaydata);die;

            

            if (count($todaydata) > 5) {
                $Journey_rows = array();
                $locationObj  = new GetLocation();

                $distance     = 0;

                if (isset($calcObj) or isset($PointArray)) {
                    unset($calcObj);
                    unset($PointArray);
                }

                $calcObj         = new calculate_distance();
                $calcObj->veh_id = $vehicleList;
                $JourneyStartAt  = "";
                $myloopCount = 1;
                $rowCount = 1;
                

                for ($row = 1; $row < count($todaydata); $row++) {

                    $istrow = $todaydata[$row]['gps_time'];
                    $local_time = $todaydata[$row]['gps_time'];
                    
                    if ($local_time >= $_POST['dateStart']) {

                      if ($local_time <= $_POST['dateEnd']) {
  
                        //if($todaydata[$row]['gps_speed']>5 ) {
                        
                          if ($JourneyStartAt == "" && $todaydata[$row]['gps_speed']>5) {
                            
                            $JourneyStartAt = $todaydata[$row]['gps_time'];
                                           
                            //$idledateStart = date('Y-m-d H:i:s',strtotime($dateStart));
                            //$idledateStart  = date('Y-m-d 00:00:00');
                            
                            $startlocation1 = $masterObj->GetPoinameNew($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']);                                                        
                            
                            if (strlen($startlocation1) <= 5) {
                            $startlocation1 = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']);
                            }
                            
                            //$IdleTimeTaken = $obj->dateDifferenceSecond($dateStart, $JourneyStartAt);
                            //$IdleTime      = $obj->minDifference($IdleTimeTaken);
                            //$idledateStart = date('Y-m-d H:i:s', strtotime($dateStart));

                             //$startlocation1  = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']);
                           /* $IdleTimeTaken2 = $obj->dateDifferenceSecond($idledateStart, $JourneyStartAt);
                            $IdleTime       = $obj->minDifference($IdleTimeTaken2);*/



                            $html .= '
'; ?> 5) { $secndrow = $todaydata[$row - $myloopCount]['gps_time']; $PointArray[0]['lat'] = $todaydata[$row]['gps_latitude']; $PointArray[0]['long'] = $todaydata[$row]['gps_longitude']; $PointArray[1]['lat'] = $todaydata[$row - 1]['gps_latitude']; $PointArray[1]['long'] = $todaydata[$row - 1]['gps_longitude']; $distance = $calcObj->calc_distance($PointArray); if ($distance >= 0.07) { ###### Sum of distance############ $totalDistance = $totalDistance + $distance; } $diff = $obj->dateDifference($istrow, $secndrow); //echo $todaydata[$row]['gps_time'].' Running -'.$todaydata[$row - $myloopCount]['gps_time']; //echo "
"; $myloopCount = 1; $totaldiff = $totaldiff + $diff; if ($diff > $diffenceStatic) { $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $secndrow); if($rowCount==1){$startNewTime=date('Y-m-d').' 00:00:00';}else{$startNewTime=$startNewTime;} //echo $startNewTime.' date -'.$JourneyStartAt;echo "
"; $IdleTimeTaken = $obj->dateDifferenceSecond($startNewTime, $JourneyStartAt); $startNewTime = $secndrow; $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $SnailEndDate = $obj->addMinuteinTimeStamp($secndrow, 0, 'Y-m-d H:i'); $endlocation = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); $html .= ''; ?> dateDifferenceSecond($secndrow,$istrow); $ideal_time_show1 = $obj->minDifference($idleTImeMIn1);*/?> '; $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $AlltotalDistance = $AlltotalDistance + $totalDistance; $AllTimeTaken = $AllTimeTaken + $TimeTaken; $AllIdleTimeTaken = $AllIdleTimeTaken + $IdleTimeTaken; $totalDistance = 0; $distance = 0; $totaldiff = 0; $rowCount++; } } else if ($JourneyStartAt != "" && $todaydata[$row]['gps_speed']<5) { //echo "less than 5 speed";die; $myloopCount = $myloopCount+1; $secndrow = $todaydata[$row - 1]['gps_time']; $PointArray[0]['lat'] = $todaydata[$row]['gps_latitude']; $PointArray[0]['long'] = $todaydata[$row]['gps_longitude']; $PointArray[1]['lat'] = $todaydata[$row - 1]['gps_latitude']; $PointArray[1]['long'] = $todaydata[$row - 1]['gps_longitude']; $distance = $calcObj->calc_distance($PointArray); if ($distance >= 0.07) { ###### Sum of distance############ $totalDistance = $totalDistance + $distance; } $diff = $obj->dateDifference($istrow, $secndrow); //echo $todaydata[$row]['gps_time'].' Idle'; //echo "
"; $totaldiff = $totaldiff + $diff; //if ($diff > $diffenceStatic) {} } } } } if ($JourneyStartAt != "" && $todaydata[$row]['gps_speed']>5) { $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $todaydata[count($todaydata) - 1]['gps_time']); $SnailEndDate = $obj->addMinuteinTimeStamp($todaydata[count($todaydata) - 1]['gps_time'], 0, 'Y-m-d H:i'); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $location = $masterObj->GetLocationWitPOIreport($todaydata[count($todaydata) - 1]['gps_latitude'] . "," . $todaydata[count($todaydata) - 1]['gps_longitude']); $IdleTimeTaken = $obj->dateDifferenceSecond($startNewTime, $JourneyStartAt); $html .= ''; ?> dateDifferenceSecond($JourneyStartAt, $todaydata[(count($todaydata)-$myloopCount)]['gps_time']); $SnailEndDate = $obj->addMinuteinTimeStamp($todaydata[(count($todaydata)-$myloopCount)]['gps_time'], 0, 'Y-m-d H:i'); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $location = $masterObj->GetLocationWitPOIreport($todaydata[(count($todaydata) - $myloopCount)]['gps_latitude'] . "," . $todaydata[(count($todaydata) - $myloopCount)]['gps_longitude']); if($rowCount==1){$startNewTime=date('Y-m-d').' 00:00:00';}else{$startNewTime=$startNewTime;} $IdleTimeTaken = $obj->dateDifferenceSecond($startNewTime, $JourneyStartAt); $html .= ''; ?> 0){ ?> '; } } $AlltotalDistance = 0; $AllTimeTaken = 0; } $dateStart2 = date("Y-m-d", strtotime($dateStart1)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd1)); if ($dateStart2 <= $currentdate || $dateEnd2 <= $currentdate) { $StartGmtDate1 = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($_POST['dateStart']))); $EndGmtDate1 = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($_POST['dateEnd']))); $no_gps_KM = $masterObj->nogpsKM($vehicleList, $StartGmtDate1, $EndGmtDate1); $allConsolidate = "select sum(Total_km) as KM from matrix.consolidate where consolidate.DateOf_journey>='" . date("Y-m-d", strtotime($_POST['dateStart'])) . "' and consolidate.DateOf_journey<='" . date("Y-m-d", strtotime($_POST['dateEnd'])) . "' and sys_Service_id =" . $vehicleList . " group by sys_service_id "; $AllKm = db__select_staging($allConsolidate); $showFinalKM = round($calcObj->SetDistance($AllKm[0]["KM"] + $TodayKMForconsolidate,$_SESSION['KM_for']),2); $no_gps_KM = $no_gps_KM + $NoGpsKMConsolidate; ?> '; } $html .= '
Start time Start Location End time End Location KM Journey Duration Idle Duration Snail Map
'.$JourneyQry[$i]['Start_time'].' '. wordwrap($StartLocation,45,"
\n").'
'.$JourneyQry[$i]['End_time'].' '.wordwrap($EndLocation,45,"
\n").'
'.$JourneyQry[$i]['Total_KM'].' KM '.$JourneyQry[$i]['Total_journey_hour'].' '.$ideal_time_show.'
\n");?> \n");?> KM Snail Trail Snail Trail
    '.$LastidleTimetoShow.'
     
Total '.$cumilativeday.' KM '.$running_km.''.$idle_hr.'
      Total KM  
'.date("d-M-Y", strtotime($dateStart)).' '. wordwrap($StartLocation,45,"
\n").'
'.date("d-M-Y", strtotime($dateStart)).' '.wordwrap($EndLocation,45,"
\n").'
'.$JourneyQry[$i]['Total_KM'].' KM '.$JourneyQry[$i]['Total_journey_hour'].' '.$ideal_time_show.'
\n");?> \n");?> KM Snail Trail Snail Trail
    '.$LastidleTimetoShow.'
     
Total '.$cumilativeday.' KM '.$running_km.''.$idle_hr.'
      Total KM  
' . $JourneyStartAt . '' . $startlocation . '
\n"); ?> ' . $secndrow . ' ' . $endlocation . ' ' . $totalDistance . ' KM ' . $obj->minDifferenceForJourney($TimeTaken) . ' Running
\n"); ?> KM minDifferenceForJourney($TimeTaken); ?> minDifference($IdleTimeTaken); ?> Snail Trail Snail Trail
' . $istrow . '' . $endlocation . '' . $todaydata[count($todaydata) - 1]['gps_time'] . ' ' . $location . ' ' . $totalDistance . ' KM ' . $obj->minDifferenceForJourney($TimeTaken) . ' Running
KM minDifferenceForJourney($TimeTaken); ?> minDifference($IdleTimeTaken);?> Snail Trail Snail Trail
' . $todaydata[(count($todaydata) - $myloopCount)]['gps_time'] . ' ' . $location . ' ' . $totalDistance . ' KM ' . $obj->minDifferenceForJourney($TimeTaken) . ' Running
KM minDifferenceForJourney($TimeTaken); ?> minDifference($IdleTimeTaken);?> Snail Trail Snail Trail
Total KM minDifference($AllTimeTaken); ?> minDifference($AllIdleTimeTaken); ?>  
Total' . $AlltotalDistance . ' ' . $obj->minDifference($AllTimeTaken) . '' . $obj->minDifference($AllIdleTimeTaken) . '
 
  NO GPS KM Total KM minDifference($cumilativejourneyhourall); } ?> minDifference($cumilativeidlehourall); } ?>  
 
 No GPS '.$no_gps_KM.' KM Total ' . $AllCumiltivetotKM .' KM '.$obj->minDifference($cumilativejourneyhourall) .' '.$obj->minDifference($cumilativeidlehourall) . '
'; ?>

' . $vehicle_no . '

'; $finalHtml= $mainHeader.$reportHeader.$html; if(substr($finalHtml,(strlen($finalHtml)-8),strlen($finalHtml))!="") { $finalHtml=$finalHtml.""; } // reportFileLocation.$_SESSION['clientid'].".pdf"; require('html2fpdf/html2fpdf.php'); require('html2fpdf/fpdf.php'); $pdf=new HTML2FPDF("p","mm","A3"); $pdf->AddPage(); $pdf->Image("gtrac-logo.jpg",10,10); $pdf->WriteHTML($finalHtml); $pdf->Output("pdf_reports/".$_SESSION['clientid'].".pdf"); //header("location:"."pdf_reports/".$_SESSION['clientid'].".pdf"); $filepointer=fopen('excel_reports/'.$_SESSION['clientid'].".xls",'w'); fwrite($filepointer,$finalHtml); fclose($filepointer); } else if ($report_name == "Journey_dtc") { if (((((strtotime($dateEnd)) - (strtotime($dateStart))) / 3600) / 24) > 31) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 31) - 1)); } $start_ts = strtotime($dateStart); $end_ts = strtotime($dateEnd); $diff = $end_ts - $start_ts; $Dayrange = round($diff / 86400); $calcObj = new calculate_distance(); $no_gps_KM=0; ?>

Journey Report

Journey Report

'; $reportHeader = 'Journey Report generated at ' . date("Y-m-d H:i") . ' for Vehicles between ' . $dateStart . ' and ' . $dateEnd . '

'; $currentdate = date("Y-m-d"); //echo $Dayrange;die; $AllCumiltivetotKM=""; if ($Dayrange == 0) { $cumilativeday = "0"; $cumilativejourneyhour = ""; $cumilativeidlehour = ""; $dateStart = date("Y-m-d H:i:s", strtotime($dateStart1)); $dateEnd = date("Y-m-d H:i:s", strtotime($dateEnd1)); $dateStart2 = date("Y-m-d", strtotime($dateStart1)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd1)); if ($dateStart2 < $currentdate && $dateEnd2 < $currentdate) { unset($JourneyQry); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $JourneyQry = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test_dtc where sys_Service_id='" . $vehicleList . "' and ((journey_table_test_dtc.Start_time>='" . $StartGmtDate . "' and journey_table_test_dtc.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test_dtc.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test_dtc.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time )) and Total_KM>1 group by Start_time order by Start_time", $condition); if(count($JourneyQry)<1) { $JourneyQry = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test where sys_Service_id='" . $vehicleList . "' and ((journey_table_test.Start_time>='" . $StartGmtDate . "' and journey_table_test.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time )) and Total_KM>1 group by Start_time order by Start_time", $condition); } //echo "
";print_r($JourneyQry);die;

                if (count($JourneyQry) > 0) {
                    for ($i = 0; $i < count($JourneyQry); $i++) {
                        if ($JourneyQry[$i]['Total_KM'] < 1500 && $JourneyQry[$i]['Start_time'] != "") {

                            if ($i == 0) {
                                $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i]['Start_time'], $dateStart);
                                $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);
                            } else {
                                $endassume = $JourneyQry[$i]['Start_time'];
                                if ($JourneyQry[$i]['Start_time'] == "") {
                                    $endassume = $dateEnd;
                                }

                                $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i - 1]['End_time'], $endassume);
                                $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);

                            }


                            $StartLocation = $JourneyQry[$i]['Start_location'];
							//$StartLocation ="";

                            if ($JourneyQry[$i]['start_latitude'] != "" && $JourneyQry[$i]['start_longitude'] != "") {
                                if (strlen($startlocation) <= 10 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173 ) {
                                    $StartLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['start_latitude'] . "," . $JourneyQry[$i]['start_longitude']);
                                }

                                $PoiDataStart = $masterObj->GetPoinameNew($JourneyQry[$i]['start_latitude'] . ',' . $JourneyQry[$i]['start_longitude']);
                                if ($PoiDataStart != "") {
                                    $StartLocation = $PoiDataStart;
                                }

                            }

                            $EndLocation = $JourneyQry[$i]['End_location'];
                            if ($JourneyQry[$i]['End_latitude'] != "" && $JourneyQry[$i]['End_longitude'] != "") {
                                if (strlen($EndLocation) <= 15 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                    $EndLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['End_latitude'] . "," . $JourneyQry[$i]['End_longitude']);
                                }

                                $PoiDataEnd = $masterObj->GetPoinameNew($JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude']);
                                if ($PoiDataEnd != "") {

                                    $EndLocation = $PoiDataEnd;
                                }

                            }

                            $EndLocationIdle = $JourneyQry[$i - 1]['End_location'];
                            if ($JourneyQry[$i - 1]['End_latitude'] != "" && $JourneyQry[$i - 1]['End_longitude'] != "") {
                                if (strlen($EndLocationIdle) <= 15 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                    $EndLocationIdle = $masterObj->GetLocationWitPOIreport($JourneyQry[$i - 1]['End_latitude'] . "," . $JourneyQry[$i - 1]['End_longitude']);
                                }

                                $PoiDataEndIdle = $masterObj->GetPoinameNew($JourneyQry[$i - 1]['End_latitude'] . ',' . $JourneyQry[$i - 1]['End_longitude']);
                                if ($PoiDataEndIdle != "") {

                                    $EndLocationIdle = $PoiDataEndIdle;
                                }

                            }


                            if ($i == 0) {
    if(strtotime($JourneyQry[$i]['Start_time'])>strtotime($dateStart))
    {
                                $html .= '
'; ?> '; ?> '; ?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM+ $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativejourneyhour = $cumilativejourneyhour + $JourneyQry[$i]['journeysec']; $cumilativejourneyhourall = $cumilativejourneyhourall + $JourneyQry[$i]['journeysec']; $cumilativeidlehour = $cumilativeidlehour + $idleTImeMIn; $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; } if ($i == count($JourneyQry) - 1) { if(strtotime($JourneyQry[$i]['End_time'])dateDifferenceSecond($JourneyQry[$i]['End_time'], $dateEnd); $LastidleTimetoShow = $obj->minDifferenceForJourney($LastIdeal); $cumilativeidlehour = $cumilativeidlehour + $LastIdeal; $cumilativeidlehourall = $cumilativeidlehourall + $LastIdeal; $html .= ''; ?> minDifference($cumilativejourneyhour); $idle_hr = $obj->minDifference($cumilativeidlehour); } if ($cumilativeday == "") { $cumilativeday = 0; } $html .= ''; ?> dateDifferenceSecond($dateStart, $dateEnd); $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn); $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; $newQry = "select ADDDATE( Start_time, INTERVAL 330 MINUTE) as Start_time, Start_location, ADDDATE( End_time, INTERVAL 330 MINUTE) as End_time, End_location, Total_km, sys_service_id from matrix.consolidate where consolidate.DateOf_journey='" . date("Y-m-d", strtotime($dateStart)) . "' and sys_Service_id =" . $vehicleList . " group by sys_service_id order by consolidate.Total_km desc"; $navData = db__select_staging($newQry, $condition); $html .= ''; // $cumilativeKm = $cumilativeKm + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); ?> '; } } } else { //echo $Dayrange;die; $AllCumiltivetotKM=0; for ($day = 0; $day < $Dayrange; $day++) { $cumilativeday = "0"; $cumilativejourneyhour = ""; $cumilativeidlehour = ""; $td = $day; //$dateStart = date("Y-m-d",strtotime(date("Y-m-d", strtotime($dateStart1)) . " +".$day." days")) ." 00:00:00"; //$dateEnd = date("Y-m-d",strtotime(date("Y-m-d", strtotime($dateStart1)) . " +".$day." days")) ." 23:59:59"; if ($day == 0) { $dateStart = date("Y-m-d H:i:s", strtotime($dateStart1)); } else { $dateStart = date("Y-m-d", strtotime(date("Y-m-d", strtotime($dateStart1)) . " +" . $day . " days")) . " 00:00:00"; } if ($day == $Dayrange - 1) { $check_date = date("Y-m-d", strtotime($dateEnd1)); if ($check_date == $currentdate) { $dateEnd = date("Y-m-d", strtotime(date("Y-m-d", strtotime($dateStart1)) . " +" . $day . " days")) . " 23:59:59"; } else { $dateEnd = date("Y-m-d H:i:s", strtotime($dateEnd1)); //$dateEnd = date("Y-m-d 23:59:59", strtotime("-1 days")); } } else { $dateEnd = date("Y-m-d", strtotime(date("Y-m-d", strtotime($dateStart1)) . " +" . $day . " days")) . " 23:59:59"; } unset($JourneyQry); $dateStart2 = date("Y-m-d", strtotime($dateStart)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd)); if ($dateStart2 < $currentdate || $dateEnd2 < $currentdate) { $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); //concat(Start_location,'',start_latitude,'',start_longitude) as Start_location,concat(End_location,End_latitude,End_longitude) as End_location $JourneyQrycheck = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test_dtc where sys_Service_id='" . $vehicleList . "' and ((journey_table_test_dtc.Start_time>='" . $StartGmtDate . "' and journey_table_test_dtc.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test_dtc.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test_dtc.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time ) ) and Total_KM>1 and round(TIME_TO_SEC(Total_journey_hour)/60)+3='" . $StartGmtDate . "' and journey_table_test_dtc.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test_dtc.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test_dtc.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time ) ) and Total_KM>1 group by Start_time order by Start_time", $condition); } else { $JourneyQry=array(); } if(count($JourneyQry)<1) { $JourneyQry = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test where sys_Service_id='" . $vehicleList . "' and ((journey_table_test.Start_time>='" . $StartGmtDate . "' and journey_table_test.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time )) and Total_KM>1 group by Start_time order by Start_time", $condition); } //echo "
";print_r($JourneyQry);die;

                    if (count($JourneyQry) > 0) {
                        for ($i = 0; $i < count($JourneyQry); $i++) {
                            if ($JourneyQry[$i]['Total_KM'] < 1500 && $JourneyQry[$i]['Start_time'] != "") {

                                if ($i == 0) {
                                    $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i]['Start_time'], $dateStart);
                                    $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);
                                } else {
                                    $endassume = $JourneyQry[$i]['Start_time'];
                                    if ($JourneyQry[$i]['Start_time'] == "") {
                                        $endassume = $dateEnd;
                                    }

                                    $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i - 1]['End_time'], $endassume);
                                    $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);

                                }

                                $StartLocation = $JourneyQry[$i]['Start_location'];
                                if ($JourneyQry[$i]['start_latitude'] != "" && $JourneyQry[$i]['start_longitude'] != "") {
                                    if (strlen($startlocation) <= 10 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                        $StartLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['start_latitude'] . "," . $JourneyQry[$i]['start_longitude']);
                                    }

                                    $PoiDataStart = $masterObj->GetPoinameNew($JourneyQry[$i]['start_latitude'] . ',' . $JourneyQry[$i]['start_longitude']);
                                    if ($PoiDataStart != "") {

                                        $StartLocation = $PoiDataStart;
                                    }

                                }

                                $EndLocation = $JourneyQry[$i]['End_location'];
                                if ($JourneyQry[$i]['End_latitude'] != "" && $JourneyQry[$i]['End_longitude'] != "") {
                                    if (strlen($EndLocation) <= 10 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                        $EndLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['End_latitude'] . "," . $JourneyQry[$i]['End_longitude']);
                                    }

                                    $PoiDataEnd = $masterObj->GetPoinameNew($JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude']);
                                    if ($PoiDataEnd != "") {
                                        $EndLocation = $PoiDataEnd;
                                    }

                                }

                                $EndLocationIdle = $JourneyQry[$i - 1]['End_location'];
                                if ($JourneyQry[$i - 1]['End_latitude'] != "" && $JourneyQry[$i - 1]['End_longitude'] != "") {
                                    if (strlen($EndLocationIdle) <= 10 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                        $EndLocationIdle = $masterObj->GetLocationWitPOIreport($JourneyQry[$i - 1]['End_latitude'] . "," . $JourneyQry[$i - 1]['End_longitude']);
                                    }

                                    $PoiDataEndIdle = $masterObj->GetPoinameNew($JourneyQry[$i - 1]['End_latitude'] . ',' . $JourneyQry[$i - 1]['End_longitude']);
                                    if ($PoiDataEndIdle != "") {
                                        $EndLocationIdle = $PoiDataEndIdle;
                                    }

                                }

                                if ($i == 0) {

    if(strtotime($JourneyQry[$i]['Start_time'])>strtotime($dateStart))
    {
                                    $html .= '
'; ?> '; ?> '; ?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM + $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativejourneyhour = $cumilativejourneyhour + $JourneyQry[$i]['journeysec']; $cumilativejourneyhourall = $cumilativejourneyhourall + $JourneyQry[$i]['journeysec']; $cumilativeidlehour = $cumilativeidlehour + $idleTImeMIn; $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; } if ($i == count($JourneyQry) - 1) { $LastIdeal = $obj->dateDifferenceSecond($JourneyQry[$i]['End_time'], $dateEnd); $LastidleTimetoShow = $obj->minDifferenceForJourney($LastIdeal); $cumilativeidlehour = $cumilativeidlehour + $LastIdeal; $cumilativeidlehourall = $cumilativeidlehourall + $LastIdeal; $html .= ''; ?> minDifference($cumilativejourneyhour); $idle_hr = $obj->minDifference($cumilativeidlehour); } if ($cumilativeday == "") { $cumilativeday = 0; } $html .= ''; $cumilativeday=$masterObj->GEtrawdataByVhlWithDatenewKMDTC($dateStart,$dateEnd,$vehicleList,31,"KM"); //$StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); //$EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); ?> dateDifferenceSecond($dateStart, $dateEnd); $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn); $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; $newQry = "select ADDDATE( Start_time, INTERVAL 330 MINUTE) as Start_time,start_location, ADDDATE( End_time, INTERVAL 330 MINUTE) as End_time, End_location,Total_km,sys_service_id, DATEDIFF(ADDDATE(Start_time,INTERVAL 330 minute),dateof_journey) AS DiffDate from matrix.consolidate_dtc where consolidate_dtc.DateOf_journey='" . date("Y-m-d", strtotime($dateStart)) . "' and sys_Service_id =" . $vehicleList . " group by sys_service_id order by consolidate_dtc.Total_km desc"; $navData = db__select_staging($newQry, $condition); if ($navData[0]['DiffDate'] >= 0) { if($idleTImeMIn >1430*60 && $navData[0]['Total_km']>5 ) { $allKminmeter=$navData[0]['Total_km']*1000; $cumilativejourneyhourallsingle=$obj->minDifference($allKminmeter/600*60); $idleTImeMIn=$idleTImeMIn-$allKminmeter/600*60; } else { $cumilativejourneyhourallsingle=' 0 Hour 0 Min 0 Sec'; } $html .= ''; $cumilativeKm = $cumilativeKm + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); ?> '; ?> GEtrawdataByVhlWithDatenewKMDTC($dateStart,$dateEnd,$vehicleList,31,"KM"); //echo "fff"; ?> '; } } } } //echo $Dayrange;die; /* Today Journey Report code start*/ $dateStart2 = date("Y-m-d", strtotime($dateStart1)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd1)); if ($dateEnd2 == $currentdate) { $StartGmtDate = date("Y-m-d H:i", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($currentdate . " 00:00:00"))); $EndGmtDate = date("Y-m-d H:i", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd1))); if ($_SESSION['UserName'] == "btwindia" || $_SESSION['UserName'] == "aajtak") { $diffenceStatic = 5; } else { $diffenceStatic = 30; } $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 and sys_msg_type=1 ORDER BY gps_time asc ", $condition); //.today_ideal_".date("d")."_a //echo "
";print_r($TodayJourneyQry);die;

            $data1 = array();
            for ($countNavData = 0; $countNavData < count($TodayJourneyQry); $countNavData++) {
                if (is_array($TodayJourneyQry[$countNavData])) {
                    $data1 = array_merge($data1, $TodayJourneyQry[$countNavData]);
                }
            }


            $data2 = $obj->array_msort($data1, array(
                'gps_time' => SORT_ASC
            ));


            foreach ($data2 as $val) {
                $todaydata[] = $val;
            }

            //echo "
";print_r($todaydata);die;

            if (count($todaydata) > 5) {
                $Journey_rows = array();
                $locationObj  = new GetLocation();
                $distance     = 0;

                if (isset($calcObj) or isset($PointArray)) {
                    unset($calcObj);
                    unset($PointArray);
                }

                $calcObj         = new calculate_distance();
                $calcObj->veh_id = $vehicleList;
                $JourneyStartAt  = "";

                for ($row = 1; $row < count($todaydata); $row++) {

                    $istrow = $todaydata[$row]['gps_time'];
                    $local_time = $todaydata[$row]['gps_time'];

                    if ($local_time >= $_POST['dateStart']) {

                        if ($local_time <= $_POST['dateEnd']) {




                          if ($JourneyStartAt == "") {

                            $JourneyStartAt = $todaydata[$row]['gps_time'];
                      

                     
                            //$idledateStart = date('Y-m-d H:i:s',strtotime($dateStart));
                            $idledateStart  = date('Y-m-d 00:00:00');
                            $startlocation  = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']);

                           $Poistartlocation = $masterObj->GetPoinameNew($todaydata[$row]['gps_latitude']  . ',' . $todaydata[$row]['gps_longitude']);
                                    if ($Poistartlocation != "") {
                                        $startlocation = $Poistartlocation;
                                    }

                            $IdleTimeTaken2 = $obj->dateDifferenceSecond($idledateStart, $JourneyStartAt);
                            $IdleTime       = $obj->minDifferenceForJourney($IdleTimeTaken2);

                            $html .= '
'; ?> calc_distance($PointArray); if ($distance >= 0.07) { ###### Sum of distance############ $totalDistance = $totalDistance + $distance; } } $diff = $obj->dateDifference($istrow, $secndrow); $totaldiff = $totaldiff + $diff; if ($diff > $diffenceStatic) { $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $secndrow); $IdleTimeTaken = $obj->dateDifferenceSecond($secndrow, $istrow); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $SnailEndDate = $obj->addMinuteinTimeStamp($secndrow, 0, 'Y-m-d H:i'); $endlocation = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); $PoiEndlast = $masterObj->GetPoinameNew($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); if ($PoiEndlast != "") { $endlocation = $PoiEndlast; } $html .= ''; $html .= ''; ?> '; $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $AlltotalDistance = $AlltotalDistance + $totalDistance; $AllTimeTaken = $AllTimeTaken + $TimeTaken; $AllIdleTimeTaken = $AllIdleTimeTaken + $IdleTimeTaken; $totalDistance = 0; $distance = 0; $totaldiff = 0; } } } } } $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $todaydata[count($todaydata) - 1]['gps_time']); $SnailEndDate = $obj->addMinuteinTimeStamp($todaydata[count($todaydata) - 1]['gps_time'], 0, 'Y-m-d H:i'); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $location = $masterObj->GetLocationWitPOIreport($todaydata[count($todaydata) - 1]['gps_latitude'] . "," . $todaydata[count($todaydata) - 1]['gps_longitude']); $PoiEndLocatinw = $masterObj->GetPoinameNew($todaydata[count($todaydata) - 1]['gps_latitude'] . "," . $todaydata[count($todaydata) - 1]['gps_longitude']); if ($PoiEndLocatinw != "") { $location = $PoiEndLocatinw; } $html .= ''; ?> '; } $AlltotalDistance = 0; $AllTimeTaken = 0; } $dateStart2 = date("Y-m-d", strtotime($dateStart1)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd1)); if ($dateStart2 <= $currentdate || $dateEnd2 <= $currentdate) { $StartGmtDate1 = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($_POST['dateStart']))); $EndGmtDate1 = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($_POST['dateEnd']))); $no_gps_KM = $masterObj->nogpsKM($vehicleList, $StartGmtDate1, $EndGmtDate1)."--"; $allConsolidate = "select sum(Total_km) as KM from matrix.consolidate_dtc where consolidate.DateOf_journey>='" . date("Y-m-d", strtotime($_POST['dateStart'])) . "' and consolidate_dtc.DateOf_journey<='" . date("Y-m-d", strtotime($_POST['dateEnd'])) . "' and sys_Service_id =" . $vehicleList . " group by sys_service_id "; $AllKm = db__select_staging($allConsolidate); $showFinalKM = round($calcObj->SetDistance($AllKm[0]["KM"] + $TodayKMForconsolidate,$_SESSION['KM_for']),2); /* $extraKm=$showFinalKM-$AllCumiltivetotKM; if($extraKm>0) { $no_gps_KM=$no_gps_KM+$extraKm; }*/ //$NoGpsKMConsolidate = $showFinalKM - $cumilativeKm; $no_gps_KM = $no_gps_KM + $NoGpsKMConsolidate; // $showFinalKMWithNogps = $showFinalKM + $no_gps_KM; if (in_array($_SESSION['sys_group_id'], $equalKM11) or in_array($_SESSION['sys_group_id_parent'], $equalKM11)) { //echo $dateStart."--".$dateEnd; $APMKM1 = $masterObj->GEtKmByVhlWithDate($_POST['dateStart'],$_POST['dateEnd'],$vehicleList,31,"KM"); $APMKM=$calcObj->SetDistance($APMKM1,$_SESSION['KM_for']); $AllCumiltivetotKM=$APMKM; if($APMKM!=0) { /*if($APMKM>$AllCumiltivetotKM) { $no_gps_KM=$APMKM-$AllCumiltivetotKM; if($no_gps_KM<0) { $no_gps_KM=0; } $AllCumiltivetotKM=$APMKM; }*/ } //$no_gps_KM =0; } //echo $_SESSION['UserId'].'<-->'.$vehicle_no.'<-->'.$dateStart.'<-->'.$dateEnd; //die; ?> '; */ } $html .= '
Start time Start Location End time End Location KM Duration Status Snail Map
Start time Start Location End time End Location Km Journey Duration Status
' . $dateStart . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
\n");?> \n"); ?>  
' . $JourneyQry[$i - 1]['End_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
\n"); ?> \n"); ?>  
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']) . ' KM ' . $JourneyQry[$i]['Total_journey_hour'] . ' Running
\n");?> \n");?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']);?> KM Route Map
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $dateEnd . ' ' . wordwrap($EndLocation, 45, "
\n") . '
0 KM ' . $LastidleTimetoShow . ' Idle
\n");?> \n");?>  
Total ' . $cumilativeday . ' KM ' . $running_km . '' . $idle_hr . '
      Total KM
' . date("Y-m-d", strtotime($dateStart)) . ' 00:00:00 ' . wordwrap($navData[0]['start_location'], 45, "
\n") . '
' . date("Y-m-d", strtotime($dateStart)) . ' 23:59:59 ' . wordwrap($navData[0]['End_location'], 45, "
\n") . '
' . $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']) . ' KM ' . $ideal_time_show . ' Idle
\n");?> \n");?> SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']);?> KM  
      Total KM minDifference($idleTImeMIn);?>
Total' . $cumilativeday . ' KM 0 Hour 0 Min 0 Sec ' . $obj->minDifference($idleTImeMIn) . '
' . $dateStart . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
\n");?> \n");?>  
' . $JourneyQry[$i - 1]['End_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
\n");?> \n");?>  
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']) . ' KM ' . $JourneyQry[$i]['Total_journey_hour'] . ' Running
\n");?> \n");?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']);?>KM Route Map
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $dateEnd . ' ' . wordwrap($EndLocation, 45, "
\n") . '
0 KM ' . $LastidleTimetoShow . ' Idle
\n");?> \n");?>  
Total ' . $cumilativeday . ' KM ' . $running_km . '' . $idle_hr . '
      Total:- KM
' . $dateStart . ' ' . wordwrap($navData[0]['start_location'], 45, "
\n") . '
' . $dateEnd . ' ' . wordwrap($navData[0]['End_location'], 45, "
\n") . '
' . $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']) . ' KM ' . $cumilativejourneyhourallsingle . '
\n");?> \n");?> SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']);?> KM  
' . $dateStart . ' ---- ' . $dateEnd . ' ---- ---- ---- ----
 
      Total KM minDifference($idleTImeMIn);?>
Total' . $cumilativeday . ' KM '.$cumilativejourneyhourallsingle.' ' . $obj->minDifference($idleTImeMIn) . '
' . $idledateStart . ' ' . $startlocation . ' ' . $JourneyStartAt . ' ' . $startlocation . ' 0 KM ' . $IdleTime . ' Idle
' . $JourneyStartAt . '' . $startlocation . '
 
' . $secndrow . ' ' . $endlocation . ' ' . $totalDistance . ' KM ' . $obj->minDifferenceForJourney($TimeTaken) . ' Running
' . $secndrow . ' ' . $endlocation . ' ' . $istrow . ' ' . $endlocation . ' 0 KM ' . $obj->minDifferenceForJourney($IdleTimeTaken) . ' Idle
KM minDifferenceForJourney($TimeTaken); ?> Route Map
minDifferenceForJourney($IdleTimeTaken); ?>  
' . $istrow . '' . $endlocation . '' . $todaydata[count($todaydata) - 1]['gps_time'] . ' ' . $location . ' ' . $totalDistance . ' KM ' . $obj->minDifferenceForJourney($TimeTaken) . ' Running
KM minDifferenceForJourney($TimeTaken); ?> Route Map
Total- KM minDifference($AllTimeTaken); ?> minDifference($AllIdleTimeTaken); ?>  
Total' . $AlltotalDistance . ' ' . $obj->minDifference($AllTimeTaken) . '' . $obj->minDifference($AllIdleTimeTaken) . '
 
 No GPS ' . $no_gps_KM . ' KM Total ' . $AllCumiltivetotKM . ' KM ' . $obj->minDifference($cumilativejourneyhourall) . '' . $obj->minDifference($cumilativeidlehourall) . '
'; ?>

' . $vehicle_no . '

'; $finalHtml = $mainHeader . $reportHeader . $html; if (substr($finalHtml, (strlen($finalHtml) - 8), strlen($finalHtml)) != "") { $finalHtml = $finalHtml . ""; } // reportFileLocation.$_SESSION['clientid'].".pdf"; require('html2fpdf/html2fpdf.php'); require('html2fpdf/fpdf.php'); $pdf = new HTML2FPDF("p", "mm", "A3",$invoice_num); $pdf->AddPage(); $pdf->Image("gtrac-logo.jpg", 10, 10); $pdf->WriteHTML($finalHtml); //$pdf->Output(reportFileLocation.$_SESSION['clientid'].".pdf"); //echo "pdf_reports/".$_SESSION['clientid'].".pdf"; $pdf->Output("pdf_reports/" . $_SESSION['clientid'] . ".pdf"); //header("location:"."pdf_reports/".$_SESSION['clientid'].".pdf"); $filepointer = fopen('excel_reports/' . $_SESSION['clientid'] . ".xls", 'w'); fwrite($filepointer, $finalHtml); fclose($filepointer); } else if ($report_name == "Journey") { if (((((strtotime($dateEnd)) - (strtotime($dateStart))) / 3600) / 24) > 300) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 300) - 1)); } $start_ts = strtotime($dateStart); $end_ts = strtotime($dateEnd); $diff = $end_ts - $start_ts; $Dayrange = round($diff / 86400); $calcObj = new calculate_distance(); $no_gps_KM=0; //echo "
";print_r($_POST);die;

?>
  
  
  

Journey Report

Journey Report

'; $htmlex .= '
Start time Start Location End time End Location KM Duration Status Snail Map
Start time Start Location End time End Location Km Journey Duration Status
'; $reportHeader = 'Journey Report generated at ' . date("Y-m-d H:i") . ' for Vehicles between ' . $dateStart . ' and ' . $dateEnd . '

'; $currentdate = date("Y-m-d"); //echo $Dayrange;die; $AllCumiltivetotKM=""; if ($Dayrange == 0) { $cumilativeday = "0"; $cumilativejourneyhour = ""; $cumilativeidlehour = ""; $dateStart = date("Y-m-d H:i:s", strtotime($dateStart1)); $dateEnd = date("Y-m-d H:i:s", strtotime($dateEnd1)); $dateStart2 = date("Y-m-d", strtotime($dateStart1)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd1)); if ($dateStart2 < $currentdate && $dateEnd2 < $currentdate) { unset($JourneyQry); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); /* $JourneyQry = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test where sys_Service_id='" . $vehicleList . "' and journey_table_test.Start_time>='" . $StartGmtDate . "' and journey_table_test.End_time<='" . $EndGmtDate . "' and Total_KM>1 group by Start_time order by Start_time", $condition);*/ $JourneyQry = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test where sys_Service_id='" . $vehicleList . "' and ((journey_table_test.Start_time>='" . $StartGmtDate . "' and journey_table_test.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time )) and Total_KM>1 group by Start_time order by Start_time", $condition); if(count($JourneyQry)<1) { $JourneyQry = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test2018c where sys_Service_id='" . $vehicleList . "' and ((journey_table_test2018c.Start_time>='" . $StartGmtDate . "' and journey_table_test2018c.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test2018c.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test2018c.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time )) and Total_KM>1 group by Start_time order by Start_time", $condition); } //echo "
";print_r($JourneyQry);die;

                if (count($JourneyQry) > 0) {
                    for ($i = 0; $i < count($JourneyQry); $i++) {
                        if ($JourneyQry[$i]['Total_KM'] < 1500 && $JourneyQry[$i]['Start_time'] != "") {

                            if ($i == 0) {
                                $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i]['Start_time'], $dateStart);
                                $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);
                            } else {
                                $endassume = $JourneyQry[$i]['Start_time'];
                                if ($JourneyQry[$i]['Start_time'] == "") {
                                    $endassume = $dateEnd;
                                }

                                $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i - 1]['End_time'], $endassume);
                                $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);

                            }


                            $StartLocation = $JourneyQry[$i]['Start_location'];
							//$StartLocation ="";

                            if ($JourneyQry[$i]['start_latitude'] != "" && $JourneyQry[$i]['start_longitude'] != "") {
                                if (strlen($startlocation) <= 10 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173 ) {
                                    $StartLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['start_latitude'] . "," . $JourneyQry[$i]['start_longitude']);
                                }

                                $PoiDataStart = $masterObj->GetPoinameNew($JourneyQry[$i]['start_latitude'] . ',' . $JourneyQry[$i]['start_longitude']);
                                if ($PoiDataStart != "") {
                                    $StartLocation = $PoiDataStart;
                                }

                            }

                            $EndLocation = $JourneyQry[$i]['End_location'];
                            if ($JourneyQry[$i]['End_latitude'] != "" && $JourneyQry[$i]['End_longitude'] != "") {
                                if (strlen($EndLocation) <= 15 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                    $EndLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['End_latitude'] . "," . $JourneyQry[$i]['End_longitude']);
                                }

                                $PoiDataEnd = $masterObj->GetPoinameNew($JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude']);
                                if ($PoiDataEnd != "") {

                                    $EndLocation = $PoiDataEnd;
                                }

                            }

                            $EndLocationIdle = $JourneyQry[$i - 1]['End_location'];
                            if ($JourneyQry[$i - 1]['End_latitude'] != "" && $JourneyQry[$i - 1]['End_longitude'] != "") {
                                if (strlen($EndLocationIdle) <= 15 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                    $EndLocationIdle = $masterObj->GetLocationWitPOIreport($JourneyQry[$i - 1]['End_latitude'] . "," . $JourneyQry[$i - 1]['End_longitude']);
                                }

                                $PoiDataEndIdle = $masterObj->GetPoinameNew($JourneyQry[$i - 1]['End_latitude'] . ',' . $JourneyQry[$i - 1]['End_longitude']);
                                if ($PoiDataEndIdle != "") {

                                    $EndLocationIdle = $PoiDataEndIdle;
                                }

                            }


                            if ($i == 0) {
    if(strtotime($JourneyQry[$i]['Start_time'])>strtotime($dateStart))
    {
                                $html .= '
'; $htmlex .= ''; ?> '; $htmlex .= ''; ?> '; $htmlex .= ''; ?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM+ $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativejourneyhour = $cumilativejourneyhour + $JourneyQry[$i]['journeysec']; $cumilativejourneyhourall = $cumilativejourneyhourall + $JourneyQry[$i]['journeysec']; $cumilativeidlehour = $cumilativeidlehour + $idleTImeMIn; $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; } if ($i == count($JourneyQry) - 1) { if(strtotime($JourneyQry[$i]['End_time'])dateDifferenceSecond($JourneyQry[$i]['End_time'], $dateEnd); $LastidleTimetoShow = $obj->minDifferenceForJourney($LastIdeal); $cumilativeidlehour = $cumilativeidlehour + $LastIdeal; $cumilativeidlehourall = $cumilativeidlehourall + $LastIdeal; $html .= ''; $htmlex .= ''; ?> minDifference($cumilativejourneyhour); $idle_hr = $obj->minDifference($cumilativeidlehour); } if ($cumilativeday == "") { $cumilativeday = 0; } $html .= ''; ?> dateDifferenceSecond($dateStart, $dateEnd); $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn); $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; $newQry = "select start_latitude,start_longitude,End_latitude,End_longitude,ADDDATE( Start_time, INTERVAL 330 MINUTE) as Start_time, Start_location, ADDDATE( End_time, INTERVAL 330 MINUTE) as End_time, End_location, Total_km, sys_service_id from matrix.consolidate where consolidate.DateOf_journey='" . date("Y-m-d", strtotime($dateStart)) . "' and sys_Service_id =" . $vehicleList . " group by sys_service_id order by consolidate.Total_km desc"; $navData = db__select_staging($newQry, $condition); $html .= ''; $htmlex .= ''; // // $cumilativeKm = $cumilativeKm + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); ?> '; } } } else { //echo $Dayrange;die; $AllCumiltivetotKM=0; for ($day = 0; $day < $Dayrange; $day++) { $cumilativeday = "0"; $cumilativejourneyhour = ""; $cumilativeidlehour = ""; $td = $day; //$dateStart = date("Y-m-d",strtotime(date("Y-m-d", strtotime($dateStart1)) . " +".$day." days")) ." 00:00:00"; //$dateEnd = date("Y-m-d",strtotime(date("Y-m-d", strtotime($dateStart1)) . " +".$day." days")) ." 23:59:59"; if ($day == 0) { $dateStart = date("Y-m-d H:i:s", strtotime($dateStart1)); } else { $dateStart = date("Y-m-d", strtotime(date("Y-m-d", strtotime($dateStart1)) . " +" . $day . " days")) . " 00:00:00"; } if ($day == $Dayrange - 1) { $check_date = date("Y-m-d", strtotime($dateEnd1)); if ($check_date == $currentdate) { $dateEnd = date("Y-m-d", strtotime(date("Y-m-d", strtotime($dateStart1)) . " +" . $day . " days")) . " 23:59:59"; } else { $dateEnd = date("Y-m-d H:i:s", strtotime($dateEnd1)); //$dateEnd = date("Y-m-d 23:59:59", strtotime("-1 days")); } } else { $dateEnd = date("Y-m-d", strtotime(date("Y-m-d", strtotime($dateStart1)) . " +" . $day . " days")) . " 23:59:59"; } unset($JourneyQry); $dateStart2 = date("Y-m-d", strtotime($dateStart)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd)); if ($dateStart2 < $currentdate || $dateEnd2 < $currentdate) { $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); //concat(Start_location,'',start_latitude,'',start_longitude) as Start_location,concat(End_location,End_latitude,End_longitude) as End_location /*$JourneyQry = db__select_staging("select ADDDATE( Start_time, INTERVAL ".$_SESSION['TimeZoneDiff']." MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test where sys_Service_id='" . $vehicleList . "' and journey_table_test.Start_time>='" . $StartGmtDate . "' and journey_table_test.End_time<='" . $EndGmtDate . "' and Total_KM>1 group by Start_time order by Start_time", $condition);*/ /*echo "select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test where sys_Service_id='" . $vehicleList . "' and ((journey_table_test.Start_time>='" . $StartGmtDate . "' and journey_table_test.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time ) ) and Total_KM>1 group by Start_time order by Start_time";die();*/ $JourneyQry = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test where sys_Service_id='" . $vehicleList . "' and ((journey_table_test.Start_time>='" . $StartGmtDate . "' and journey_table_test.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time ) ) and Total_KM>1 group by Start_time order by Start_time", $condition); //echo "
";print_r($JourneyQry);die;

                    if (count($JourneyQry) > 0) {
                        for ($i = 0; $i < count($JourneyQry); $i++) {
                            if ($JourneyQry[$i]['Total_KM'] < 1500 && $JourneyQry[$i]['Start_time'] != "") {

                                if ($i == 0) {
                                    $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i]['Start_time'], $dateStart);
                                    $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);
                                } else {
                                    $endassume = $JourneyQry[$i]['Start_time'];
                                    if ($JourneyQry[$i]['Start_time'] == "") {
                                        $endassume = $dateEnd;
                                    }

                                    $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i - 1]['End_time'], $endassume);
                                    $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);

                                }

                                $StartLocation = $JourneyQry[$i]['Start_location'];
                                if ($JourneyQry[$i]['start_latitude'] != "" && $JourneyQry[$i]['start_longitude'] != "") {
                                    if (strlen($startlocation) <= 10 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                        $StartLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['start_latitude'] . "," . $JourneyQry[$i]['start_longitude']);
                                    }

                                    $PoiDataStart = $masterObj->GetPoinameNew($JourneyQry[$i]['start_latitude'] . ',' . $JourneyQry[$i]['start_longitude']);
                                    if ($PoiDataStart != "") {

                                        $StartLocation = $PoiDataStart;
                                    }

                                }

                                $EndLocation = $JourneyQry[$i]['End_location'];
                                if ($JourneyQry[$i]['End_latitude'] != "" && $JourneyQry[$i]['End_longitude'] != "") {
                                    if (strlen($EndLocation) <= 10 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                        $EndLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['End_latitude'] . "," . $JourneyQry[$i]['End_longitude']);
                                    }

                                    $PoiDataEnd = $masterObj->GetPoinameNew($JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude']);
                                    if ($PoiDataEnd != "") {
                                        $EndLocation = $PoiDataEnd;
                                    }

                                }

                                $EndLocationIdle = $JourneyQry[$i - 1]['End_location'];
                                if ($JourneyQry[$i - 1]['End_latitude'] != "" && $JourneyQry[$i - 1]['End_longitude'] != "") {
                                    if (strlen($EndLocationIdle) <= 10 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                        $EndLocationIdle = $masterObj->GetLocationWitPOIreport($JourneyQry[$i - 1]['End_latitude'] . "," . $JourneyQry[$i - 1]['End_longitude']);
                                    }

                                    $PoiDataEndIdle = $masterObj->GetPoinameNew($JourneyQry[$i - 1]['End_latitude'] . ',' . $JourneyQry[$i - 1]['End_longitude']);
                                    if ($PoiDataEndIdle != "") {
                                        $EndLocationIdle = $PoiDataEndIdle;
                                    }

                                }

                                if ($i == 0) {

    if(strtotime($JourneyQry[$i]['Start_time'])>strtotime($dateStart))
    {
                                    $html .= '
'; $htmlex .= ''; ?> '; $htmlex .= ''; ?> '; $htmlex .= ''; ?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM + $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativejourneyhour = $cumilativejourneyhour + $JourneyQry[$i]['journeysec']; $cumilativejourneyhourall = $cumilativejourneyhourall + $JourneyQry[$i]['journeysec']; $cumilativeidlehour = $cumilativeidlehour + $idleTImeMIn; $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; } if ($i == count($JourneyQry) - 1) { $LastIdeal = $obj->dateDifferenceSecond($JourneyQry[$i]['End_time'], $dateEnd); $LastidleTimetoShow = $obj->minDifferenceForJourney($LastIdeal); $cumilativeidlehour = $cumilativeidlehour + $LastIdeal; $cumilativeidlehourall = $cumilativeidlehourall + $LastIdeal; $html .= ''; $htmlex .= ''; ?> minDifference($cumilativejourneyhour); $idle_hr = $obj->minDifference($cumilativeidlehour); } if ($cumilativeday == "") { $cumilativeday = 0; } $html .= ''; $htmlex .= ''; ?> dateDifferenceSecond($dateStart, $dateEnd); $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn); $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; $newQry = "select start_latitude,start_longitude,End_latitude,End_longitude,ADDDATE( Start_time, INTERVAL 330 MINUTE) as Start_time,start_location, ADDDATE( End_time, INTERVAL 330 MINUTE) as End_time, End_location,Total_km,sys_service_id, DATEDIFF(ADDDATE(Start_time,INTERVAL 330 minute),dateof_journey) AS DiffDate from matrix.consolidate where consolidate.DateOf_journey='" . date("Y-m-d", strtotime($dateStart)) . "' and sys_Service_id =" . $vehicleList . " group by sys_service_id order by consolidate.Total_km desc"; $navData = db__select_staging($newQry, $condition); if ($navData[0]['DiffDate'] >= 0) { $html .= ''; $htmlex .= ''; $cumilativeKm = $cumilativeKm + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); ?> '; $htmlex .= ''; ?> '; $htmlex .= ''; } } } } //echo $Dayrange;die; /* Today Journey Report code start*/ $dateStart2 = date("Y-m-d", strtotime($dateStart1)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd1)); if ($dateEnd2 == $currentdate) { $StartGmtDate = date("Y-m-d H:i", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($currentdate . " 00:00:00"))); $EndGmtDate = date("Y-m-d H:i", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd1))); if ($_SESSION['UserName'] == "btwindia" || $_SESSION['UserName'] == "aajtak") { $diffenceStatic = 5; } else { $diffenceStatic = 30; } $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ", $condition); //.today_ideal_".date("d")."_a //echo "
";print_r($TodayJourneyQry);die;

            $data1 = array();
            for ($countNavData = 0; $countNavData < count($TodayJourneyQry); $countNavData++) {
                if (is_array($TodayJourneyQry[$countNavData])) {
                    $data1 = array_merge($data1, $TodayJourneyQry[$countNavData]);
                }
            }


            $data2 = $obj->array_msort($data1, array(
                'gps_time' => SORT_ASC
            ));


            foreach ($data2 as $val) {
                $todaydata[] = $val;
            }

            //echo "
";print_r($todaydata);die;

            if (count($todaydata) > 5) {
                $Journey_rows = array();
                $locationObj  = new GetLocation();
                $distance     = 0;

                if (isset($calcObj) or isset($PointArray)) {
                    unset($calcObj);
                    unset($PointArray);
                }

                $calcObj         = new calculate_distance();
                $calcObj->veh_id = $vehicleList;
                $JourneyStartAt  = "";

                for ($row = 1; $row < count($todaydata); $row++) {

                    $istrow = $todaydata[$row]['gps_time'];
                    $local_time = $todaydata[$row]['gps_time'];

                    if ($local_time >= $_POST['dateStart']) {

                        if ($local_time <= $_POST['dateEnd']) {




                          if ($JourneyStartAt == "") {

                            $JourneyStartAt = $todaydata[$row]['gps_time'];
                      

                     
                            //$idledateStart = date('Y-m-d H:i:s',strtotime($dateStart));
                            $idledateStart  = date('Y-m-d 00:00:00');
                            $startlocation  = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']);

                           $Poistartlocation = $masterObj->GetPoinameNew($todaydata[$row]['gps_latitude']  . ',' . $todaydata[$row]['gps_longitude']);
                                    if ($Poistartlocation != "") {
                                        $startlocation = $Poistartlocation;
                                    }

                            $IdleTimeTaken2 = $obj->dateDifferenceSecond($idledateStart, $JourneyStartAt);
                            $IdleTime       = $obj->minDifferenceForJourney($IdleTimeTaken2);

                            $html .= '
'; $htmlex .= ''; ?> calc_distance($PointArray); if ($distance >= 0.07) { ###### Sum of distance############ $totalDistance = $totalDistance + $distance; } } $diff = $obj->dateDifference($istrow, $secndrow); $totaldiff = $totaldiff + $diff; if ($diff > $diffenceStatic) { $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $secndrow); $IdleTimeTaken = $obj->dateDifferenceSecond($secndrow, $istrow); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $SnailEndDate = $obj->addMinuteinTimeStamp($secndrow, 0, 'Y-m-d H:i'); $endlocation = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); $PoiEndlast = $masterObj->GetPoinameNew($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); if ($PoiEndlast != "") { $endlocation = $PoiEndlast; } $html .= ''; $html .= ''; $htmlex .= ''; $htmlex .= ''; ?> '; $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $AlltotalDistance = $AlltotalDistance + $totalDistance; $AllTimeTaken = $AllTimeTaken + $TimeTaken; $AllIdleTimeTaken = $AllIdleTimeTaken + $IdleTimeTaken; $totalDistance = 0; $distance = 0; $totaldiff = 0; } } } } } $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $todaydata[count($todaydata) - 1]['gps_time']); $SnailEndDate = $obj->addMinuteinTimeStamp($todaydata[count($todaydata) - 1]['gps_time'], 0, 'Y-m-d H:i'); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $location = $masterObj->GetLocationWitPOIreport($todaydata[count($todaydata) - 1]['gps_latitude'] . "," . $todaydata[count($todaydata) - 1]['gps_longitude']); $PoiEndLocatinw = $masterObj->GetPoinameNew($todaydata[count($todaydata) - 1]['gps_latitude'] . "," . $todaydata[count($todaydata) - 1]['gps_longitude']); if ($PoiEndLocatinw != "") { $location = $PoiEndLocatinw; } $html .= ''; $htmlex .= ''; ?> '; $htmlex .= ''; } $AlltotalDistance = 0; $AllTimeTaken = 0; } $dateStart2 = date("Y-m-d", strtotime($dateStart1)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd1)); if ($dateStart2 <= $currentdate || $dateEnd2 <= $currentdate) { $StartGmtDate1 = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($_POST['dateStart']))); $EndGmtDate1 = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($_POST['dateEnd']))); $no_gps_KM = $masterObj->nogpsKM($vehicleList, $StartGmtDate1, $EndGmtDate1)."--"; $allConsolidate = "select sum(Total_km) as KM from matrix.consolidate where consolidate.DateOf_journey>='" . date("Y-m-d", strtotime($_POST['dateStart'])) . "' and consolidate.DateOf_journey<='" . date("Y-m-d", strtotime($_POST['dateEnd'])) . "' and sys_Service_id =" . $vehicleList . " group by sys_service_id "; $AllKm = db__select_staging($allConsolidate); $showFinalKM = round($calcObj->SetDistance($AllKm[0]["KM"] + $TodayKMForconsolidate,$_SESSION['KM_for']),2); /* $extraKm=$showFinalKM-$AllCumiltivetotKM; if($extraKm>0) { $no_gps_KM=$no_gps_KM+$extraKm; }*/ //$NoGpsKMConsolidate = $showFinalKM - $cumilativeKm; $no_gps_KM = $no_gps_KM + $NoGpsKMConsolidate; // $showFinalKMWithNogps = $showFinalKM + $no_gps_KM; if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $APMKM1 = $masterObj->GEtrawdataByVhlWithDatenewKMDTC($_POST['dateStart'],$_POST['dateEnd'],$vehicleList,31,"KM"); $APMKM=$calcObj->SetDistance($APMKM1,$_SESSION['KM_for']); $AllCumiltivetotKM=$APMKM; if($APMKM!=0) { } } //if (in_array($_SESSION['sys_group_id'], $equalKM11) or in_array($_SESSION['sys_group_id_parent'], $equalKM11)) // { //echo $dateStart."--".$dateEnd; $APMKM1 = $masterObj->GEtKmByVhlWithDate($_POST['dateStart'],$_POST['dateEnd'],$vehicleList,31,"KM"); $APMKM=$calcObj->SetDistance($APMKM1,$_SESSION['KM_for']); $AllCumiltivetotKM=$APMKM; if($APMKM!=0) { /* if($APMKM>$AllCumiltivetotKM) { $no_gps_KM=$APMKM-$AllCumiltivetotKM; if($no_gps_KM<0) { $no_gps_KM=0; } $AllCumiltivetotKM=$APMKM; }*/ } //$no_gps_KM =0; //} ?> '; /*$html .= '';*/ $htmlex .= ''; } $html .= '
Start time Start Location End time End Location Km Journey Duration Status
' . $dateStart . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
' . $dateStart . ' ' . $JourneyQry[$i]['start_latitude'] . ',' . $JourneyQry[$i]['start_longitude']. ' ' . $JourneyQry[$i]['Start_time'] . ' ' . $JourneyQry[$i]['start_latitude'] . ',' . $JourneyQry[$i]['start_longitude']. ' 0 KM ' . $ideal_time_show . ' Idle
\n");?> \n"); ?>  
' . $JourneyQry[$i - 1]['End_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
' . $JourneyQry[$i - 1]['End_time'] . ' ' . $JourneyQry[$i - 1]['End_latitude'] . ',' . $JourneyQry[$i - 1]['End_longitude'] . ' ' . $JourneyQry[$i]['Start_time'] . ' ' . $JourneyQry[$i - 1]['End_latitude'] . ',' . $JourneyQry[$i - 1]['End_longitude'] . ' 0 KM ' . $ideal_time_show . ' Idle
\n"); ?> \n"); ?>  
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']) . ' KM ' . $JourneyQry[$i]['Total_journey_hour'] . ' Running
' . $JourneyQry[$i]['Start_time'] . ' ' . $JourneyQry[$i]['start_latitude'] . ',' . $JourneyQry[$i]['start_longitude'] . ' ' . $JourneyQry[$i]['End_time'] . ' ' . $JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude'] . ' ' . $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']) . ' KM ' . $JourneyQry[$i]['Total_journey_hour'] . ' Running
\n");?> \n");?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']);?> KM Route Map
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $dateEnd . ' ' . wordwrap($EndLocation, 45, "
\n") . '
0 KM ' . $LastidleTimetoShow . ' Idle
' . $JourneyQry[$i]['End_time'] . ' ' . $JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude']. ' ' . $dateEnd . ' ' . $JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude']. ' 0 KM ' . $LastidleTimetoShow . ' Idle
\n");?> \n");?>  
Total ' . $cumilativeday . ' KM ' . $running_km . '' . $idle_hr . '
      Total KM
' . date("Y-m-d", strtotime($dateStart)) . ' 00:00:00 ' . wordwrap($navData[0]['start_location'], 45, "
\n") . '
' . date("Y-m-d", strtotime($dateStart)) . ' 23:59:59 ' . wordwrap($navData[0]['End_location'], 45, "
\n") . '
' . $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']) . ' KM ' . $ideal_time_show . ' Idle
' . date("Y-m-d", strtotime($dateStart)) . ' 00:00:00 ' . $navData[0]['start_latitude'].','.$navData[0]['start_longitude'] . ' ' . date("Y-m-d", strtotime($dateStart)) . ' 23:59:59 ' . $navData[0]['End_latitude'].','.$navData[0]['End_longitude'] . ' ' . $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']) . ' KM ' . $ideal_time_show . ' Idle
\n");?> \n");?> SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']);?> KM  
      Total KM minDifference($idleTImeMIn);?>
Total' . $cumilativeday . ' KM 0 Hour 0 Min 0 Sec ' . $obj->minDifference($idleTImeMIn) . '
' . $dateStart . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
' . $dateStart . ' ' . $JourneyQry[$i]['start_latitude'] . "," . $JourneyQry[$i]['start_longitude'] . ' ' . $JourneyQry[$i]['Start_time'] . ' ' .$JourneyQry[$i]['start_latitude'] . "," . $JourneyQry[$i]['start_longitude'] . ' 0 KM ' . $ideal_time_show . ' Idle
\n");?> \n");?>  
' . $JourneyQry[$i - 1]['End_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
' . $JourneyQry[$i - 1]['End_time'] . ' ' . $JourneyQry[$i - 1]['End_latitude'] . "," . $JourneyQry[$i - 1]['End_longitude']. ' ' . $JourneyQry[$i]['Start_time'] . ' ' . $JourneyQry[$i - 1]['End_latitude'] . "," . $JourneyQry[$i - 1]['End_longitude'] . ' 0 KM ' . $ideal_time_show . ' Idle
\n");?> \n");?>  
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']) . ' KM ' . $JourneyQry[$i]['Total_journey_hour'] . ' Running
' . $JourneyQry[$i]['Start_time'] . ' ' . $JourneyQry[$i]['start_latitude'] . "," . $JourneyQry[$i]['start_longitude'] . ' ' . $JourneyQry[$i]['End_time'] . ' ' . $JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude']. ' ' . $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']) . ' KM ' . $JourneyQry[$i]['Total_journey_hour'] . ' Running
\n");?> \n");?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']);?>KM Route Map
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $dateEnd . ' ' . wordwrap($EndLocation, 45, "
\n") . '
0 KM ' . $LastidleTimetoShow . ' Idle
' . $JourneyQry[$i]['End_time'] . ' ' . $JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude'] . ' ' . $dateEnd . ' ' . $JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude'] . ' 0 KM ' . $LastidleTimetoShow . ' Idle
\n");?> \n");?>  
Total ' . $cumilativeday . ' KM ' . $running_km . '' . $idle_hr . '
Total ' . $cumilativeday . ' KM ' . $running_km . '' . $idle_hr . '
      Total:-- KM
' . $dateStart . ' ' . wordwrap($navData[0]['start_location'], 45, "
\n") . '
' . $dateEnd . ' ' . wordwrap($navData[0]['End_location'], 45, "
\n") . '
' . $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']) . ' KM ' . $ideal_time_show . ' Idle
' . $dateStart . ' ' . $navData[0]['start_latitude'].','. $navData[0]['start_longitude']. ' ' . $dateEnd . ' ' . $navData[0]['End_latitude'].','. $navData[0]['End_longitude']. ' ' . $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']) . ' KM ' . $ideal_time_show . ' Idle
\n");?> \n");?> SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']);?> KM  
' . $dateStart . ' ---- ' . $dateEnd . ' ---- ---- ---- ----
' . $dateStart . ' ---- ' . $dateEnd . ' ---- ---- ---- ----
 
      Total KM minDifference($idleTImeMIn);?>
Total' . $cumilativeday . ' KM 0 Hour 0 Min 0 Sec ' . $obj->minDifference($idleTImeMIn) . '
Total' . $cumilativeday . ' KM 0 Hour 0 Min 0 Sec ' . $obj->minDifference($idleTImeMIn) . '
' . $idledateStart . ' ' . $startlocation . ' ' . $JourneyStartAt . ' ' . $startlocation . ' 0 KM ' . $IdleTime . ' Idle
' . $JourneyStartAt . '' . $startlocation . '
' . $idledateStart . ' ' . $todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude'] . ' ' . $JourneyStartAt . ' ' . $todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude'] . ' 0 KM ' . $IdleTime . ' Idle
' . $JourneyStartAt . '' . $startlocation . '
 
' . $secndrow . ' ' . $endlocation . ' ' . $totalDistance . ' KM ' . $obj->minDifferenceForJourney($TimeTaken) . ' Running
' . $secndrow . ' ' . $endlocation . ' ' . $istrow . ' ' . $endlocation . ' 0 KM ' . $obj->minDifferenceForJourney($IdleTimeTaken) . ' Idle
' . $secndrow . ' ' . $endlocation . ' ' . $totalDistance . ' KM ' . $obj->minDifferenceForJourney($TimeTaken) . ' Running
' . $secndrow . ' ' . $todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude'] . ' ' . $istrow . ' ' . $todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude'] . ' 0 KM ' . $obj->minDifferenceForJourney($IdleTimeTaken) . ' Idle
KM minDifferenceForJourney($TimeTaken); ?> Route Map
minDifferenceForJourney($IdleTimeTaken); ?>  
' . $istrow . '' . $endlocation . '' . $todaydata[count($todaydata) - 1]['gps_time'] . ' ' . $location . ' ' . $totalDistance . ' KM ' . $obj->minDifferenceForJourney($TimeTaken) . ' Running
' . $todaydata[count($todaydata) - 1]['gps_time'] . ' ' . $location . ' ' . $totalDistance . ' KM ' . $obj->minDifferenceForJourney($TimeTaken) . ' Running
KM minDifferenceForJourney($TimeTaken); ?> Route Map
Total KM minDifference($AllTimeTaken); ?> minDifference($AllIdleTimeTaken); ?>  
Total' . $AlltotalDistance . ' ' . $obj->minDifference($AllTimeTaken) . '' . $obj->minDifference($AllIdleTimeTaken) . '
Total' . $AlltotalDistance . ' ' . $obj->minDifference($AllTimeTaken) . '' . $obj->minDifference($AllIdleTimeTaken) . '
 
  NO GPS KM Total + No GPS Total GEtKmByVhlWithDate($_POST['dateStart'],$_POST['dateEnd'],$vehicleList,31,"KM"); //echo $APMKM=$calcObj->SetDistance($APMKM1,$_SESSION['KM_for']); echo $AllCumiltivetotKM; } } ?> KM minDifference($cumilativejourneyhourall); } ?> minDifference($cumilativeidlehourall); } ?>  
 
 No GPS ' . $no_gps_KM . ' KM Total ' . $AllCumiltivetotKM . ' KM ' . $obj->minDifference($cumilativejourneyhourall) . '' . $obj->minDifference($cumilativeidlehourall) . '
 
 No GPS ' . $no_gps_KM . ' KM Total ' . $APMKM . ' KM ' . $obj->minDifference($cumilativejourneyhourall) . '' . $obj->minDifference($cumilativeidlehourall) . '
 
 No GPS ' . $no_gps_KM . ' KM Total ' . $AllCumiltivetotKM . ' KM ' . $obj->minDifference($cumilativejourneyhourall) . '' . $obj->minDifference($cumilativeidlehourall) . '
'; $htmlex .= ''; ?>

' . $vehicle_no . '

'; $finalHtml = $mainHeader . $reportHeader . $html; if (substr($finalHtml, (strlen($finalHtml) - 8), strlen($finalHtml)) != "") { $finalHtml = $finalHtml . ""; } $finalHtmlex = $mainHeader . $reportHeader . $htmlex; if (substr($finalHtmlex, (strlen($finalHtmlex) - 8), strlen($finalHtmlex)) != "") { $finalHtmlex = $finalHtmlex . ""; } // reportFileLocation.$_SESSION['clientid'].".pdf"; require('html2fpdf/html2fpdf.php'); require('html2fpdf/fpdf.php'); $pdf = new HTML2FPDF("p", "mm", "A3",$invoice_num); $pdf->AddPage(); $pdf->Image("gtrac-logo.jpg", 10, 10); $pdf->WriteHTML($finalHtml); //$pdf->Output(reportFileLocation.$_SESSION['clientid'].".pdf"); //echo "pdf_reports/".$_SESSION['clientid'].".pdf"; $pdf->Output("pdf_reports/" . $_SESSION['clientid'] . ".pdf"); //header("location:"."pdf_reports/".$_SESSION['clientid'].".pdf"); $filepointer = fopen('excel_reports/' . $_SESSION['clientid'] . ".xls", 'w'); fwrite($filepointer, $finalHtml); fclose($filepointer); $filepointer = fopen('excel_reports/ex' . $_SESSION['clientid'] . ".xls", 'w'); fwrite($filepointer, $finalHtmlex); fclose($filepointer); } else if ($report_name == "Journey_dalmia") { if (((((strtotime($dateEnd)) - (strtotime($dateStart))) / 3600) / 24) > 31) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 31) - 1)); } $start_ts = strtotime($dateStart); $end_ts = strtotime($dateEnd); $diff = $end_ts - $start_ts; $Dayrange = round($diff / 86400); $calcObj = new calculate_distance(); $no_gps_KM=0; ?>

Journey Report

Journey Report

'; $reportHeader = 'Journey Report generated at ' . date("Y-m-d H:i") . ' for Vehicles between ' . $dateStart . ' and ' . $dateEnd . '

'; $currentdate = date("Y-m-d"); //echo $Dayrange;die; $AllCumiltivetotKM=""; $cumilativeday = "0"; $cumilativejourneyhour = ""; $cumilativeidlehour = ""; $dateStart = date("Y-m-d H:i:s", strtotime($dateStart1)); $dateEnd = date("Y-m-d H:i:s", strtotime($dateEnd1)); $dateStart2 = date("Y-m-d", strtotime($dateStart1)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd1)); if ($dateStart2 < $currentdate && $dateEnd2 < $currentdate) { unset($JourneyQry); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); /* $JourneyQry = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test where sys_Service_id='" . $vehicleList . "' and journey_table_test.Start_time>='" . $StartGmtDate . "' and journey_table_test.End_time<='" . $EndGmtDate . "' and Total_KM>1 group by Start_time order by Start_time", $condition);*/ $JourneyQry = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test where sys_Service_id='" . $vehicleList . "' and ((journey_table_test.Start_time>='" . $StartGmtDate . "' and journey_table_test.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time )) and Total_KM>1 group by Start_time order by Start_time", $condition); //echo "
";print_r($JourneyQry);die;

                if (count($JourneyQry) > 0) {
                    for ($i = 0; $i < count($JourneyQry); $i++) {
                        if ($JourneyQry[$i]['Total_KM'] < 1500 && $JourneyQry[$i]['Start_time'] != "") {

                            if ($i == 0) {
                                $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i]['Start_time'], $dateStart);
                                $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);
                            } else {
                                $endassume = $JourneyQry[$i]['Start_time'];
                                if ($JourneyQry[$i]['Start_time'] == "") {
                                    $endassume = $dateEnd;
                                }

                                $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i - 1]['End_time'], $endassume);
                                $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);

                            }


                            $StartLocation = $JourneyQry[$i]['Start_location'];
							//$StartLocation ="";

                            if ($JourneyQry[$i]['start_latitude'] != "" && $JourneyQry[$i]['start_longitude'] != "") {
                                if (strlen($startlocation) <= 25 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173 ) {
                                    $StartLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['start_latitude'] . "," . $JourneyQry[$i]['start_longitude']);
                                }

                                $PoiDataStart = $masterObj->GetPoinameNew($JourneyQry[$i]['start_latitude'] . ',' . $JourneyQry[$i]['start_longitude']);
                                if ($PoiDataStart != "") {
                                    $StartLocation = $PoiDataStart;
                                }

                            }

                            $EndLocation = $JourneyQry[$i]['End_location'];
                            if ($JourneyQry[$i]['End_latitude'] != "" && $JourneyQry[$i]['End_longitude'] != "") {
                                if (strlen($EndLocation) <= 25 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                    $EndLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['End_latitude'] . "," . $JourneyQry[$i]['End_longitude']);
                                }

                                $PoiDataEnd = $masterObj->GetPoinameNew($JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude']);
                                if ($PoiDataEnd != "") {

                                    $EndLocation = $PoiDataEnd;
                                }

                            }

                            $EndLocationIdle = $JourneyQry[$i - 1]['End_location'];
                            if ($JourneyQry[$i - 1]['End_latitude'] != "" && $JourneyQry[$i - 1]['End_longitude'] != "") {
                                if (strlen($EndLocationIdle) <= 15 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                    $EndLocationIdle = $masterObj->GetLocationWitPOIreport($JourneyQry[$i - 1]['End_latitude'] . "," . $JourneyQry[$i - 1]['End_longitude']);
                                }

                                $PoiDataEndIdle = $masterObj->GetPoinameNew($JourneyQry[$i - 1]['End_latitude'] . ',' . $JourneyQry[$i - 1]['End_longitude']);
                                if ($PoiDataEndIdle != "") {

                                    $EndLocationIdle = $PoiDataEndIdle;
                                }

                            }


                            if ($i == 0) {
    if(strtotime($JourneyQry[$i]['Start_time'])>strtotime($dateStart))
    {
                                $html .= '
'; ?> '; ?> '; ?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM+ $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativejourneyhour = $cumilativejourneyhour + $JourneyQry[$i]['journeysec']; $cumilativejourneyhourall = $cumilativejourneyhourall + $JourneyQry[$i]['journeysec']; $cumilativeidlehour = $cumilativeidlehour + $idleTImeMIn; $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; } if ($i == count($JourneyQry) - 1) { if(strtotime($JourneyQry[$i]['End_time'])dateDifferenceSecond($JourneyQry[$i]['End_time'], $dateEnd); $LastidleTimetoShow = $obj->minDifferenceForJourney($LastIdeal); $cumilativeidlehour = $cumilativeidlehour + $LastIdeal; $cumilativeidlehourall = $cumilativeidlehourall + $LastIdeal; $html .= ''; ?> minDifference($cumilativejourneyhour); $idle_hr = $obj->minDifference($cumilativeidlehour); } if ($cumilativeday == "") { $cumilativeday = 0; } $html .= ''; ?> dateDifferenceSecond($dateStart, $dateEnd); $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn); $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; $newQry = "select ADDDATE( Start_time, INTERVAL 330 MINUTE) as Start_time, Start_location, ADDDATE( End_time, INTERVAL 330 MINUTE) as End_time, End_location, Total_km, sys_service_id from matrix.consolidate where consolidate.DateOf_journey='" . date("Y-m-d", strtotime($dateStart)) . "' and sys_Service_id =" . $vehicleList . " group by sys_service_id order by consolidate.Total_km desc"; $navData = db__select_staging($newQry, $condition); $html .= ''; // $cumilativeKm = $cumilativeKm + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); ?> '; } }?> '; $mainHeader = '
Start time Start Location End time End Location KM Duration Status Snail Map
Start time Start Location End time End Location Km Journey Duration Status
' . $dateStart . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
\n");?> \n"); ?>  
' . $JourneyQry[$i - 1]['End_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
\n"); ?> \n"); ?>  
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']) . ' KM ' . $JourneyQry[$i]['Total_journey_hour'] . ' Running
\n");?> \n");?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']);?> KM Route Map
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $dateEnd . ' ' . wordwrap($EndLocation, 45, "
\n") . '
0 KM ' . $LastidleTimetoShow . ' Idle
\n");?> \n");?>  
Total ' . $cumilativeday . ' KM ' . $running_km . '' . $idle_hr . '
      Total KM
' . date("Y-m-d", strtotime($dateStart)) . ' 00:00:00 ' . wordwrap($navData[0]['start_location'], 45, "
\n") . '
' . date("Y-m-d", strtotime($dateStart)) . ' 23:59:59 ' . wordwrap($navData[0]['End_location'], 45, "
\n") . '
' . $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']) . ' KM ' . $ideal_time_show . ' Idle
\n");?> \n");?> SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']);?> KM  
      Total KM minDifference($idleTImeMIn);?>
Total' . $cumilativeday . ' KM 0 Hour 0 Min 0 Sec ' . $obj->minDifference($idleTImeMIn) . '
      Total KM minDifference($idleTImeMIn);?>
Total' . $cumilativeday . ' KM 0 Hour 0 Min 0 Sec ' . $obj->minDifference($idleTImeMIn) . '

' . $vehicle_no . '

'; $finalHtml= $mainHeader.$reportHeader.$html; if(substr($finalHtml,(strlen($finalHtml)-8),strlen($finalHtml))!="") { $finalHtml=$finalHtml.""; } // reportFileLocation.$_SESSION['clientid'].".pdf"; require('html2fpdf/html2fpdf.php'); require('html2fpdf/fpdf.php'); $pdf=new HTML2FPDF("p","mm","A3",$invoice_num); $pdf->AddPage(); $pdf->Image("gtrac-logo.jpg",10,10); $pdf->WriteHTML($finalHtml); $pdf->Output("pdf_reports/".$_SESSION['clientid'].".pdf"); //header("location:"."pdf_reports/".$_SESSION['clientid'].".pdf"); $filepointer=fopen('excel_reports/'.$_SESSION['clientid'].".xls",'w'); fwrite($filepointer,$finalHtml); fclose($filepointer); } elseif ($report_name == "Diagnostic_dtc_final11") { if (((((strtotime($dateEnd)) - (strtotime($dateStart))) / 3600) / 24) > 300) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 300) - 1)); } //$dateStart . ' and ' . $dateEnd //$TodayJourneyQry[]= $masterObj->GEtrawdataByVhlWithDatenew($_POST['dateStart'],$_POST['dateEnd'],$vehicleList,31,"KM"); $currentdate = date("Y-m-d"); $dateStart2 = date("Y-m-d", strtotime($dateStart)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd)); $dateStart = $_POST['dateStart']; $dateEnd = $_POST['dateEnd']; //echo $dateStart."-".$dateEnd;die; $StartGmtDate = date("Y-m-d H:i", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); if ($_SESSION['UserName'] == "btwindia" || $_SESSION['UserName'] == "aajtak") { $diffenceStatic = 5; } else { $diffenceStatic = 15; } $TodayJourneyQry[] = db__select_staging("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, round(gps_speed*1.609,2) as gps_speed from matrix.speed_temp_dtc where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ORDER BY gps_time asc ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ORDER BY gps_time asc ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ORDER BY gps_time asc ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 and sys_msg_type=1 ORDER BY gps_time asc ", $condition); $TodayJourneyQry[] = db__select_staging("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.speed_temp where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ORDER BY gps_time asc ", $condition); $TodayJourneyQry[] = db__select_staging("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.speed_temp_today where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ORDER BY gps_time asc ", $condition); $navData[] = db__select($newQry, $condition); //echo "
";print_r($TodayJourneyQry);die;
        $data1 = array();
        for ($countNavData = 0; $countNavData < count($TodayJourneyQry); $countNavData++) {
            if (is_array($TodayJourneyQry[$countNavData])) {
                $data1 = array_merge($data1, $TodayJourneyQry[$countNavData]);
            }
        }


        $data2 = $obj->array_msort($data1, array(
            'gps_time' => SORT_ASC
        ));
        foreach ($data2 as $val) {
            $todaydata[] = $val;
        }

        //echo "
";print_r($todaydata);die;

?>
  
  
  

Report

Report

'; if (count($todaydata) > 5) { $Journey_rows = array(); $distance = 0; if (isset($calcObj) or isset($PointArray)) { unset($calcObj); unset($PointArray); } $calcObj = new calculate_distance(); $calcObj->veh_id = $vehicleList; $JourneyStartAt = ""; for ($row = 1; $row < count($todaydata); $row++) { $local_time = $todaydata[$row]['gps_time']; if ($local_time >= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $istrow = $todaydata[$row]['gps_time']; if ($JourneyStartAt == "") { $JourneyStartAt = $todaydata[$row]['gps_time']; /* $startlocation = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); $PoiStartLocationToday = $masterObj->GetPoinameNew($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); if ($PoiStartLocationToday != "") { $startlocation = $PoiStartLocationToday; }*/ //echo getredislocation($sess_userid,$todaydata[$row]['gps_latitude'],$todaydata[$row]['gps_longitude'])."000"; if($redis->exists('itgc_locationsupd')) { if($redis_geopoi_data=get_geoPoi($sess_userid.':geopois',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'500000','m',$redis)) { $redis_poi_km = round($redis_geopoi_data[0][1]/1000,0).' Km From '; // poi km redis $redis_poi_name = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = $redis_poi_km.' '.$KMFromNearPOI; $redis_poi_hset = json_decode(getPoi($sess_userid,$redis_poi_name,$redis)); // function to get stored poi data redis // check if the vehicle is inside the poi if($redis_geopoi_data[0][1] <= $redis_poi_hset->radius) { // if inside the poi get the poi name $startlocation = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'5000','m',$redis); $startlocation = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $startlocation = (!empty($startlocation))? $startlocation.' ('.$lat.','.$lng.')':$todaydata[$row]['gps_longitude'].','.$todaydata[$row]['gps_latitude']; // $LocationName = 'redis locatio'; } } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'5000','m',$redis); $startlocation = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $startlocation = (!empty($startlocation))? $startlocation.' ('.$lat.','.$lng.')':$todaydata[$row]['gps_longitude'].','.$todaydata[$row]['gps_latitude']; // $LocationName = 'redis locatio'; } } /*end redis*/ $IdleTimeTaken = $obj->dateDifferenceSecond($dateStart, $JourneyStartAt); $IdleTime = $obj->minDifference($IdleTimeTaken); $idledateStart = date('Y-m-d H:i:s', strtotime($dateStart)); $html .= ''; ?> calc_distance($PointArray); $checkKm = 1000; if ($_SESSION['UserName'] == "yadavtransport") { $checkKm = 20; } if($_SESSION['UserName']=="apm" || $_SESSION['login_ParentId']=="4607") { $checkKm=200; } if ($distance >= $checkKm) { $distance = 0; } if ($distance >= 0.07) { ###### Sum of distance############ $totalDistance = $totalDistance + $distance; } } $diff = $obj->dateDifference($istrow, $secndrow); $totaldiff = $totaldiff + $diff; if ($diff > $diffenceStatic) { $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $secndrow); $IdleTimeTaken = $obj->dateDifferenceSecond($secndrow, $istrow); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $SnailEndDate = $obj->addMinuteinTimeStamp($secndrow, 0, 'Y-m-d H:i'); /* $endlocation = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); $PoiEndLocationToday = $masterObj->GetPoinameNew($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); if ($PoiEndLocationToday != "") { $endlocation = $PoiEndLocationToday; } */ if($redis->exists('itgc_locationsupd')) { if($redis_geopoi_data=get_geoPoi($sess_userid.':geopois',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'500000','m',$redis)) { $redis_poi_km = round($redis_geopoi_data[0][1]/1000,0).' Km From '; // poi km redis $redis_poi_name = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = $redis_poi_km.' '.$KMFromNearPOI; $redis_poi_hset = json_decode(getPoi($sess_userid,$redis_poi_name,$redis)); // function to get stored poi data redis // check if the vehicle is inside the poi if($redis_geopoi_data[0][1] <= $redis_poi_hset->radius) { // if inside the poi get the poi name $endlocation = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'5000','m',$redis); $endlocation = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $endlocation = (!empty($endlocation))? $endlocation.' ('.$lat.','.$lng.')':$todaydata[$row]['gps_longitude'].','.$todaydata[$row]['gps_latitude']; // $LocationName = 'redis locatio'; } } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'5000','m',$redis); $endlocation = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $endlocation = (!empty($endlocation))? $endlocation.' ('.$lat.','.$lng.')':$todaydata[$row]['gps_longitude'].','.$todaydata[$row]['gps_latitude']; // $LocationName = 'redis locatio'; } } /*end redis*/ $html .= ''; $html .= ''; ?> '; $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $AlltotalDistance = $AlltotalDistance + $totalDistance; $AllTimeTaken = $AllTimeTaken + $TimeTaken; $totalDistance = 0; $distance = 0; $totaldiff = 0; } } } } } $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $todaydata[count($todaydata) - 1]['gps_time']); $SnailEndDate = $obj->addMinuteinTimeStamp($todaydata[count($todaydata) - 1]['gps_time'], 0, 'Y-m-d H:i'); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); /* $location = $masterObj->GetLocationWitPOIreport($todaydata[count($todaydata) - 1]['gps_latitude'] . "," . $todaydata[count($todaydata) - 1]['gps_longitude']); $PoiLocationToday = $masterObj->GetPoinameNew($todaydata[count($todaydata) - 1]['gps_latitude'] . "," . $todaydata[count($todaydata) - 1]['gps_longitude']); if ($PoiLocationToday != "") { $location = $PoiLocationToday; }*/ if($redis->exists('itgc_locationsupd')) { if($redis_geopoi_data=get_geoPoi($sess_userid.':geopois',$todaydata[count($todaydata) - 1]['gps_longitude'],$todaydata[count($todaydata) - 1]['gps_latitude'],'500000','m',$redis)) { $redis_poi_km = round($redis_geopoi_data[0][1]/1000,0).' Km From '; // poi km redis $redis_poi_name = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = $redis_poi_km.' '.$KMFromNearPOI; $redis_poi_hset = json_decode(getPoi($sess_userid,$redis_poi_name,$redis)); // function to get stored poi data redis // check if the vehicle is inside the poi if($redis_geopoi_data[0][1] <= $redis_poi_hset->radius) { // if inside the poi get the poi name $location = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[count($todaydata) - 1]['gps_longitude'],$todaydata[count($todaydata) - 1]['gps_latitude'],'5000','m',$redis); $location = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $location = (!empty($location))? $location.' ('.$lat.','.$lng.')':$todaydata[count($todaydata) - 1]['gps_longitude'].','.$todaydata[count($todaydata) - 1]['gps_latitude']; // $LocationName = 'redis locatio'; } } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[count($todaydata) - 1]['gps_longitude'],$todaydata[count($todaydata) - 1]['gps_latitude'],'5000','m',$redis); $location = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $location = (!empty($location))? $location.' ('.$lat.','.$lng.')':$todaydata[count($todaydata) - 1]['gps_longitude'].','.$todaydata[count($todaydata) - 1]['gps_latitude']; // $LocationName = 'redis locatio'; } } /*end redis*/ $html .= ''; $lasttime=count($todaydata) - 1; ?>
Start time Start Location End time End Location KM Duration Status Snail Map
Start time Start Location End time End Location Km Duration Status
' . $idledateStart . ' ' . $startlocation . ' ' . $JourneyStartAt . ' ' . $startlocation . ' 0 KM ' . $IdleTime . ' Idle
' . $JourneyStartAt . '' . $startlocation . '
 
' . $secndrow . ' ' . $endlocation . ' ' . $totalDistance . ' ' . $obj->minDifference($TimeTaken) . ' Running
' . $secndrow . ' ' . $endlocation . ' ' . $istrow . ' ' . $endlocation . ' 0 KM ' . $obj->minDifference($IdleTimeTaken) . ' Idle
minDifference($TimeTaken); ?> Route Map
minDifference($IdleTimeTaken); ?>  
' . $istrow . '' . $endlocation . '' . $todaydata[count($todaydata) - 1]['gps_time'] . ' ' . $location . ' ' . $totalDistance . ' ' . $obj->minDifference($TimeTaken) . ' Running
minDifference($TimeTaken); ?> Route Map
Total minDifference($AllTimeTaken); ?>    
Total ' . $AlltotalDistance . ' ' . $obj->minDifference($AllTimeTaken) . ''; $AlltotalDistance = 0; $AllTimeTaken = 0; $html .= ''; ?>

'; //$report_name='Journey_Report'; $mainHeader = '

' . $vehicle_no . '

'; $finalHtml = $mainHeader . $reportHeader . $html; if (substr($finalHtml, (strlen($finalHtml) - 8), strlen($finalHtml)) != "") { $finalHtml = $finalHtml . ""; } // reportFileLocation.$_SESSION['clientid'].".pdf"; require('html2fpdf/html2fpdf.php'); require('html2fpdf/fpdf.php'); $pdf = new HTML2FPDF("p", "mm", "A3"); $pdf->AddPage(); $pdf->Image("gtrac-logo.jpg", 10, 10); $pdf->WriteHTML($finalHtml); //$pdf->Output(reportFileLocation.$_SESSION['clientid'].".pdf"); //echo "pdf_reports/".$_SESSION['clientid'].".pdf"; $pdf->Output("pdf_reports/" . $_SESSION['clientid'] . ".pdf"); //header("location:"."pdf_reports/".$_SESSION['clientid'].".pdf"); $filepointer = fopen('excel_reports/' . $_SESSION['clientid'] . ".xls", 'w'); fwrite($filepointer, $finalHtml); fclose($filepointer); } elseif ($report_name == "Diagnostic_dtc_final") { if (((((strtotime($dateEnd)) - (strtotime($dateStart))) / 3600) / 24) > 300) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 300) - 1)); } $Diagnostic= $masterObj->GEtrawdataByVhlWithDatenew($_POST['dateStart'],$_POST['dateEnd'],$vehicleList,31,"KM"); ?>

Diagnostic Report

Start Time Start Location End Time End Location Distance Odometer Duration Status View Details
Under Maintenance
300) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 300) - 1)); } $Diagnostic= $masterObj->GEtrawdataByVhlWithDatenew($_POST['dateStart'],$_POST['dateEnd'],$vehicleList,31,"KM"); ?>

Diagnostic Report

'2017-04-30' and sys_service_id='".$vehicleList."'"; $TotalKMODOmeter= db__select_staging("select round( sum(Total_KM),2) as km from matrix.consolidate where DateOf_journey>'2017-04-30' and DateOf_journey<'".$KMDATETIll."' and sys_service_id='".$vehicleList."'"); $totalDistance=$calcObj->SetDistance($TotalKMODOmeter[0]["km"],$_SESSION['KM_for']); } //$lastrecord = count($Diagnostic); //echo $speedcheckVal;die; for ($i = 0; $i < count($Diagnostic); $i++) { $local_time = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); if ($local_time >= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; $localtime2 = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); // if (strlen(round($Diagnostic[$i]['gps_latitude'])) == 2 && strlen(round($Diagnostic[$i]['gps_longitude'])) == 2) { $no = $sr + 1; $Duration=$obj->dateDifference($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); if(in_array($_SESSION['sys_group_id'], $SppedclientGt11) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt11)) { } else { if($Duration>30) { $Diagnostic[$i]['gps_speed']=0; } } //Array ( [0] => Array ( [gps_time] => 2019-11-13 07:27:38 [id] => 208092055 [sys_msg_type] => 1 [gps_latitude] => 22.466209412 [main_powervoltage] => [gps_longitude] => 87.958633423 [gps_speed] => 36.99 [geo_street] => [geo_town] => [geo_country] => [geo_postcode] => [jny_distance] => [jny_duration] => [aconoff] => 0 [tel_panic] => 0 [jny_idle_time] => [tel_poweralert] => 0 [tel_input_1] => 0 [tel_input_0] => 0 [tel_input_2] => 0 [tel_temperature] => [tel_fuel] => 0.000000000 [gps_orientation] => 101.000000000 ) $distance = 0; $calcObj->veh_id = $vehicleList; $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; if ($localtime2 >= $_POST['dateStart']) { $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; } else { $PointArray[1]['lat'] = ''; $PointArray[1]['long'] = ''; } if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } $checkKm = 1000; if ($_SESSION['UserName'] == "yadavtransport") { $checkKm = 20; } if($_SESSION['UserName']=="apm11" || $_SESSION['login_ParentId']=="460711") { $checkKm=200; } /*if ($Diagnostic[$i]['gps_speed'] > $speedcheckVal) { $status = "Running"; } else { $status = "Stop"; }*/ if ( $distance > 0.1) { $status = "Running"; } else { $status = "Stop"; } $Duration=$obj->dateDifference($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); $Duration=$Duration+10; $checkKm = 1000; if ($distance <= $checkKm) { // if ($distance <= $Duration) { //$distance=0; ###### Sum of distance############ $totalDistance = $totalDistance + $distance; $tripDistance = $tripDistance + $distance; //} } if ($status == "Stop" && $stop == false) { if ($no == 1) { $starttime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $Diagnostic[$i]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $DiagnosticArray = array( 'starttime' => $starttime, 'start_gps_latitude' => $start_gps_latitude, 'start_gps_longitude' => $start_gps_longitude, 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Stop' ); array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; } else { $endtime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i - 1]['gps_time']))); if($Diagnostic[$i - 1]['gps_speed']==0) { $end_gps_latitude = $Diagnostic[$i - 2]['gps_latitude']; $end_gps_longitude = $Diagnostic[$i - 2]['gps_longitude']; } else { $end_gps_latitude = $Diagnostic[$i - 1]['gps_latitude']; $end_gps_longitude = $Diagnostic[$i - 1]['gps_longitude']; } $TimeTaken = $obj->dateDifferenceSecond($starttime, $endtime); $timediff = $obj->minDifference($TimeTaken); $total_running_hr = $total_running_hr + $TimeTaken; $starttime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); $start_gps_latitude = $Diagnostic[$i-1]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i-1]['gps_longitude']; $DiagnosticArray = array( 'starttime' => $starttime, 'start_gps_latitude' => $start_gps_latitude, 'start_gps_longitude' => $start_gps_longitude, 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Running' ); array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; $running = false; } $stop = true; } else if ($status == "Running" && $running == false) { if ($no == 1) { $starttime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $Diagnostic[$i]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $DiagnosticArray = array( 'starttime' => $starttime, 'start_gps_latitude' => $start_gps_latitude, 'start_gps_longitude' => $start_gps_longitude, 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Running' ); array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; } else { $endtime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i - 1]['gps_time']))); $end_gps_latitude = $Diagnostic[$i - 1]['gps_latitude']; $end_gps_longitude = $Diagnostic[$i - 1]['gps_longitude']; $TimeTaken = $obj->dateDifferenceSecond($starttime, $endtime); $timediff = $obj->minDifference($TimeTaken); $starttime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); $start_gps_latitude = $Diagnostic[$i-1]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i-1]['gps_longitude']; $DiagnosticArray = array( 'starttime' => $starttime, 'start_gps_latitude' => $start_gps_latitude, 'start_gps_longitude' => $start_gps_longitude, 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Stop' ); array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; $stop = false; } $running = true; } $sr++; // } } } } //print_r($Mergediagnosticarray ); $endtime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$lastrecord]['gps_time']))); $end_gps_latitude = $Diagnostic[$lastrecord]['gps_latitude']; $end_gps_longitude = $Diagnostic[$lastrecord]['gps_longitude']; $TimeTaken = $obj->dateDifferenceSecond($starttime, $endtime); $timediff = $obj->minDifference($TimeTaken); // if($Diagnostic[$lastrecord]['gps_speed']>5){ $vehstatus = "Running";}else{ $vehstatus = " Stop //";} if ($Diagnostic[$lastrecord]['gps_speed'] > $speedcheckVal) { $vehstatus = "Running"; $total_running_hr = $total_running_hr + $TimeTaken; } else { $vehstatus = " Stop "; $tripDistance = 0; //$total_idle_hr = $total_idle_hr+$TimeTaken; } /*$starttime = date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($Diagnostic[$i]['gps_time']))); $start_gps_latitude = $Diagnostic[$i]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i]['gps_longitude'];*/ $DiagnosticArray = array( 'starttime' => '', 'start_gps_latitude' => '', 'start_gps_longitude' => '', 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => $vehstatus ); array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; //echo "
";print_r($Mergediagnosticarray);die;
        $nor = 0;
        for ($dig = 0; $dig <= count($Mergediagnosticarray)-1 ; $dig++)
        //foreach($Mergediagnosticarray as $row)
            {
            if ($Mergediagnosticarray[$dig + 1]['duration'] != "") {
                $srno = $nor + 1;

                if ($_SESSION['UserName'] == "nstc11") {
                    $caldistance  = $Mergediagnosticarray[$dig + 1]['distance'];
                    $calodometer  = $Mergediagnosticarray[$dig + 1]['odometer'];
                    $lastodometer = $calodometer;
                }
                else
                {
 
                    if ($Mergediagnosticarray[$dig + 1]['status'] == "Running") {
						 
                        $caldistance  =  $Mergediagnosticarray[$dig+1]['odometer']-$Mergediagnosticarray[$dig-1]['odometer'];
                        $calodometer  = $Mergediagnosticarray[$dig + 1]['odometer'];
                        $lastodometer = $calodometer;

                    } else {
                        $caldistance = 0;
                        $calodometer = $lastodometer;
                    }
              }
?>
            
exists('itgc_locationsupd')) { if($redis_geopoi_data=get_geoPoi($sess_userid.':geopois',$Mergediagnosticarray[$dig]['start_gps_longitude'],$Mergediagnosticarray[$dig]['start_gps_latitude'],'500000','m',$redis)) { $redis_poi_km = round($redis_geopoi_data[0][1]/1000,0).' Km From '; // poi km redis $redis_poi_name = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = $redis_poi_km.' '.$KMFromNearPOI; $redis_poi_hset = json_decode(getPoi($sess_userid,$redis_poi_name,$redis)); // function to get stored poi data redis // check if the vehicle is inside the poi if($redis_geopoi_data[0][1] <= $redis_poi_hset->radius) { // if inside the poi get the poi name $LocationName = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$Mergediagnosticarray[$dig]['start_gps_longitude'],$Mergediagnosticarray[$dig]['start_gps_latitude'],'5000','m',$redis); $LocationName = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $Mergediagnosticarray[$dig]['start_gps_latitude']; // getting lat redis $lng = $Mergediagnosticarray[$dig]['start_gps_longitude']; // getting lng redis $LocationName = (!empty($LocationName))? $LocationName.' ('.$lat.','.$lng.')':$Mergediagnosticarray[$dig]['start_gps_longitude'].','.$Mergediagnosticarray[$dig]['start_gps_latitude']; // $LocationName = 'redis locatio'; } } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$Mergediagnosticarray[$dig]['start_gps_longitude'],$Mergediagnosticarray[$dig]['start_gps_latitude'],'5000','m',$redis); $LocationName = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $Mergediagnosticarray[$dig]['start_gps_latitude']; // getting lat redis $lng = $Mergediagnosticarray[$dig]['start_gps_longitude']; // getting lng redis $LocationName = (!empty($LocationName))? $LocationName.' ('.$lat.','.$lng.')':$Mergediagnosticarray[$dig]['start_gps_longitude'].','.$Mergediagnosticarray[$dig]['start_gps_latitude']; // $LocationName = 'redis locatio'; } //location_report_dig.php?latlong=radius) { // if inside the poi get the poi name $EndLocationName = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$Mergediagnosticarray[$varincrement]['end_gps_longitude'],$Mergediagnosticarray[$varincrement]['end_gps_latitude'],'5000','m',$redis); $EndLocationName = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $Mergediagnosticarray[$varincrement]['end_gps_latitude']; // getting lat redis $lng = $Mergediagnosticarray[$varincrement]['end_gps_longitude']; // getting lng redis $EndLocationName = (!empty($EndLocationName))? $EndLocationName.' ('.$lat.','.$lng.')':$Mergediagnosticarray[$varincrement]['end_gps_longitude'].','.$Mergediagnosticarray[$varincrement]['end_gps_latitude']; // $LocationName = 'redis locatio'; } } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$Mergediagnosticarray[$varincrement]['end_gps_longitude'],$Mergediagnosticarray[$varincrement]['end_gps_latitude'],'5000','m',$redis); $EndLocationName = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $Mergediagnosticarray[$varincrement]['end_gps_latitude']; // getting lat redis $lng = $Mergediagnosticarray[$varincrement]['end_gps_longitude']; // getting lng redis $EndLocationName = (!empty($EndLocationName))? $EndLocationName.' ('.$lat.','.$lng.')':$Mergediagnosticarray[$varincrement]['end_gps_longitude'].','.$Mergediagnosticarray[$varincrement]['end_gps_latitude']; // $LocationName = 'redis locatio'; } } ?> 0) { ?> minDifference($total_running_hr); $get_total_TimeTaken = $obj->dateDifferenceSecond($dateStart1, $dateEnd1); $final_idle_time = $get_total_TimeTaken - $total_running_hr; $totalIdle = $obj->minDifference($final_idle_time); ?>
Start Time Start Location End Time End Location Distance Odometer Duration Status View Details
View  
    Showing 1 to of records Actual Total KM : Actual Total KM  
3){ $dateEnd=date('Y-m-d H:i',(strtotime($dateStart))+((3600*24*3)-1)); } $StartGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateEnd))); //$Diagnostic= $masterObj->GEtrawdataByVhlWithDatenew($dateStart,$dateStart,$vehicleList,31,"KM"); $Diagnostic= $masterObj->GEtrawdataByVhlWithDatenew($_POST['dateStart'],$_POST['dateEnd'],$vehicleList,31,"KM"); //print_R($Diagnostic);die; ?>

Movement Report.

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $Date = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); if($i==0) { $firstDate = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); } else { $firstDate = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); } $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } $checkKm=1000; if($_SESSION['UserName']=="apm" || $_SESSION['login_ParentId']=="4607") { $checkKm=200; } //echo $Diagnostic[$i]['gps_time'].",".$Diagnostic[$i-1]['gps_time']; // echo "
"; $Duration=$obj->dateDifference($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); $Duration=$Duration+5; //if ($distance >= $Duration ) { if ($distance >= $checkKm) { $distance=0; // echo ";;;". $distance ; //} } $Odometer = $Odometer + $distance; if($Diagnostic[$i]['gps_speed']>5) { $Diagnostic[$i]['tel_input_0']=1; } if($Diagnostic[$i]['tel_input_0']==0) { //$Diagnostic[$i]['gps_speed']=0; } $no = $no + 1; $Timediff = $obj->dateDifferenceSecond($firstDate, $Date); $getMinute = $Timediff/60; if($Diagnostic[$i]['tel_input_0']==true) { $status = 'Ignition On'; } elseif($Diagnostic[$i]['tel_input_0']==false) { $status = 'Ignition off'; } else { $status = '--'; } //$status =$Diagnostic[$i]['tel_input_0']; if($Diagnostic[$i]['aconoff']==1) { $ACstatus = 'AC On'; } elseif($Diagnostic[$i]['aconoff']==0) { $ACstatus = 'AC off'; } else { $ACstatus = '--'; } /*$TimeTakeninsec = $obj->dateDifferenceSecond($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); $speedDifference=$Diagnostic[$i]['gps_speed']-$Diagnostic[$i-1]['gps_speed']; if($speedDifference>60 ) { if($TimeTakeninsec>600) { $Showspeed=$Diagnostic[$i-1]['gps_speed']; } else { $Showspeed=$Diagnostic[$i]['gps_speed']; } } else { $Showspeed=$Diagnostic[$i]['gps_speed']; } */ $Showspeed=$Diagnostic[$i]['gps_speed']; /*$html.='';*/ if($Diagnostic[$i]['gps_speed']>140) { $Showspeed=0; } if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { if($Diagnostic[$i]['gps_speed']>70) { $Showspeed=0; } } if($Diagnostic[$i-1]['gps_speed']==$Diagnostic[$i]['gps_speed']) { //$Showspeed=0; } $EngineSta="Engine OFF"; if($Diagnostic[$i]['jny_distance']>0) { $EngineSta="Engine ON"; } if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } ?>
Date GMT Date Data Receiving Date Distance Odometer Speed (Km/h) Ignition Status AC Status Engine Status Lat Long Location FUEL RPM RFID vehicle Odometer tel_input_1 tel_input_3 Internal Voltage Main Power Status View Map
'.$sr.' '.$Diagnostic[$i]['gps_time'].' '.$Diagnostic[$i]['gps_speed'].' '.$location_data.'
Km/H
View Map
3){ $dateEnd=date('Y-m-d H:i',(strtotime($dateStart))+((3600*24*3)-1)); } $StartGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateEnd))); $objDbManager=new DbManager(); $dbArray=$objDbManager->returnDbArray($dateStart,$dateEnd); if($_SESSION['UserId']=="81279" || $_SESSION['UserId']=="81058") { $ExtraQry1=" and gps_fix=1 group by gps_time "; } else { $ExtraQry1=" and gps_fix=1 group by gps_time "; } $navData[] = db__select("select sys_proc_time, tel_rfid,id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert,tel_voltage, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation, case when tel_input_3=true then true else false end as tel_input_3 from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select sys_proc_time, tel_rfid,id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,tel_voltage, case when tel_input_3=true then true else false end as tel_input_3 from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select sys_proc_time,tel_rfid,id, gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,tel_voltage, case when tel_input_3=true then true else false end as tel_input_3 from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $newQry = "select sys_proc_time,tel_rfid,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2, case when tel_input_3=true then true else false end as tel_input_3,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); $navData[] = db__select("select sys_proc_time,tel_rfid,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel, case when tel_input_3=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); //$ExtraQry = " group by gps_date,gps_time "; if($_SESSION['UserId']=="81279" || $_SESSION['UserId']=="81058") { //$ExtraQry1=" and tel_rfid is not null group by gps_time "; $ExtraQry = "and gps_fix=1 and tel_rfid is not null group by gps_date,gps_time "; } else { //$ExtraQry1=" group by gps_time "; $ExtraQry = " and gps_fix=1 group by gps_date,gps_time "; } if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $ExtraQryspeed = " and round(gps_speed*1.609,2)<='70' "; } else { $ExtraQryspeed = " and round(gps_speed*1.609,2)<140 "; } for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select sys_proc_time,tel_rfid,CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_voltage, tel_temperature,tel_fuel,gps_orientation,case when tel_input_3=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' " . $ExtraQryspeed.$ExtraQry1 . " ", $condition); $newQry = "select sys_proc_time,tel_rfid,CONCAT(gps_date,' ',gps_time) as gps_time,id, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2, case when tel_input_3=true then true else false end as tel_input_3,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } //echo "
";print_r($Diagnostic);die;
?>
  

Movement Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $Date = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); if($i==0) { $firstDate = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); } else { $firstDate = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); } $PointArray[0]['lat']=$Diagnostic[$i]['gps_latitude']; $PointArray[0]['long']=$Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat']=$Diagnostic[$i-1]['gps_latitude']; $PointArray[1]['long']=$Diagnostic[$i-1]['gps_longitude']; $distance = $masterObj->calc_distance_master($PointArray,$kmfor1); $CalCulatedDistanceinmeter = $distance * 1000; $Duration=$obj1->dateDifference($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); //$Duration=$Duration+10; $checkKm = 500; $idleTImesec=$Duration*60; $exptKm = $idleTImesec * 15; if ($exptKm >= $CalCulatedDistanceinmeter){ $Odometer=$Odometer+$distance; } if($Diagnostic[$i]['gps_speed']>5) { $Diagnostic[$i]['tel_input_0']=1; } if($Diagnostic[$i]['tel_input_0']==0) { //$Diagnostic[$i]['gps_speed']=0; } $no = $no + 1; $Timediff = $obj1->dateDifferenceSecond($firstDate, $Date); $getMinute = $Timediff/60; if($Diagnostic[$i]['tel_input_0']==true) { $status = 'Ignition On'; } elseif($Diagnostic[$i]['tel_input_0']==false) { $status = 'Ignition off'; } else { $status = '--'; } //$status =$Diagnostic[$i]['tel_input_0']; if($Diagnostic[$i]['aconoff']==1) { $ACstatus = 'AC On'; } elseif($Diagnostic[$i]['aconoff']==0) { $ACstatus = 'AC off'; } else { $ACstatus = '--'; } $Showspeed=$Diagnostic[$i]['gps_speed']; if($Diagnostic[$i]['gps_speed']>140) { $Showspeed=0; } if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { if($Diagnostic[$i]['gps_speed']>70) { $Showspeed=0; } } if($Diagnostic[$i-1]['gps_speed']==$Diagnostic[$i]['gps_speed']) { //$Showspeed=0; } $EngineSta="Engine OFF"; if($Diagnostic[$i]['jny_distance']>0) { $EngineSta="Engine ON"; } // if($report_location == "Show_Location") // { if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } //} else { //$startlocation = ''; //} $AlltotalDistance = $AlltotalDistance + $distance; ?>
Vehicle Number Date Time Location Lat Long Distance Speed (Km/h) Ignition Status View Map
Km/H View Map
Total KM
300) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 300) - 1)); } $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry1 = " GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV " . $goupbymin; } else { //$ExtraQry1 = " group by gps_time "; $ExtraQry1 = " GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV 60"; } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $wherespeed=" and round(gps_speed*1.609,2)<='70' "; } $navData[] = db__select("select id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, ".$GEtspeedas.", geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" .$wherespeed. $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select id, gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, ".$GEtspeedas.", geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " .$wherespeed. $ExtraQry1 . " ORDER BY gps_time asc ", $condition); //today_speed_".date("d")."_a /* if($_SESSION['UserName']=='hcil' || $_SESSION['UserName']=='apm' || $_SESSION['UserName']=='mamtatransport' || $_SESSION['UserName']=='sehrawat' || $_SESSION['UserName']=='thanepolice' || $_SESSION['UserName']=='amlf2' || $_SESSION['UserName']=='tulliresearch' || $_SESSION['UserName']=='dbs' || $_SESSION['UserName']=='dbs' || $_SESSION['UserName']=='satkar' || $_SESSION['UserName']=='ashu' || $_SESSION['UserName']=='ktc' || $_SESSION['UserName']=='kanaram11' || $_SESSION['UserName']=='mhipl' or $_SESSION['UserName']=='paradise' or $_SESSION['UserName']=='controlsol' or $_SESSION['UserName']=='doaba' or $_SESSION['UserName']=='rajesh' or $_SESSION['UserName']=='green' or $_SESSION['UserName']=='orl' or $_SESSION['UserName']=='prabhakar' or $_SESSION['UserName']=='hitours' or $_SESSION['UserName']=='gatewayrail' or $_SESSION['UserName']=='orangecabs' or $_SESSION['UserName']=='raashee' or $_SESSION['UserName']=='sslpl' or $_SESSION['UserName']=='shreelaxmi' or $_SESSION['UserName']=='nbspl' or $_SESSION['UserName']=='nrxen' or $_SESSION['UserName']=='doaba' or $_SESSION['UserName']=='travelinker' or $_SESSION['UserName']=='aajtak' or $_SESSION['UserName']=='avg' or $_SESSION['UserName']=='doaba' ) {*/ $newQry = "select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); $newQry = "select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " .$wherespeed. $ExtraQry1 . " and sys_msg_type=1 ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); $navData[] = db__select("select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select_staging("select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from matrix.speed_temp where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ".$wherespeed." ORDER BY gps_time asc ", $condition); $navData[] = db__select_staging("select select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from matrix.speed_temp_today where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ".$wherespeed." ORDER BY gps_time asc ", $condition); $navData[] = db__select("select id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, ".$GEtspeedas.", geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" .$wherespeed. $ExtraQry1 . " and sys_msg_type=1 ORDER BY gps_time asc ", $condition); // } if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin; $ActKm = GetCalculatedKM($dateStart, $dateEnd, $vehicleList); } else { //$ExtraQry = " group by gps_date,gps_time "; $ExtraQry = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV 60"; } for ($countYear = 0; $countYear < count($dbArray); $countYear++) { /* $StartGmtDate=$obj->convertToGMT($dateStart,$_SESSION['TimeZoneDiff']); $EndGmtDate=$obj->convertToGMT($dateEnd,$_SESSION['TimeZoneDiff']);*/ $navData[]= db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2, tel_temperature,tel_fuel,gps_orientation from ".$dbArray[$countYear].".apm_telemetry where sys_service_id=".$vehicleList." and CONCAT(gps_date,' ',gps_time) >= '".$StartGmtDate."' and CONCAT(gps_date,' ',gps_time) <= '".$EndGmtDate."' ".$wherespeed." group by gps_date,gps_time", $condition); $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2, tel_temperature,tel_fuel,gps_orientation from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" . $EndGmtDate . "' and sys_msg_type=1 ".$wherespeed." group by gps_date,gps_time", $condition); $newQry = "select CONCAT(gps_date,' ',gps_time) as gps_time,id, sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" . $EndGmtDate . "' " . $ExtraQry1 . " and sys_msg_type=1 ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); // } $newQry = "select gps_time as gps_time, id, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, ".$GEtspeedas.", geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time, case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and sys_msg_type=1 ".$wherespeed." group by gps_time ORDER BY gps_time asc "; $navData[] = db__select_staging($newQry, $condition); $newQry = "select gps_time as gps_time, id, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, ".$GEtspeedas.", geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time, case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and sys_msg_type=1 ".$wherespeed." group by gps_time ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } //echo "
";print_r($Diagnostic);die;
?>
  
  
  

Diagnostic Report r

'2017-04-30' and sys_service_id='".$vehicleList."'"; $TotalKMODOmeter= db__select_staging("select round( sum(Total_KM),2) as km from matrix.consolidate where DateOf_journey>'2017-04-30' and DateOf_journey<'".$KMDATETIll."' and sys_service_id='".$vehicleList."'"); $totalDistance=$calcObj->SetDistance($TotalKMODOmeter[0]["km"],$_SESSION['KM_for']); } //$lastrecord = count($Diagnostic); //echo $speedcheckVal;die; for ($i = 0; $i < count($Diagnostic); $i++) { $local_time = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); if ($local_time >= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; $localtime2 = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); // if (strlen(round($Diagnostic[$i]['gps_latitude'])) == 2 && strlen(round($Diagnostic[$i]['gps_longitude'])) == 2) { $no = $sr + 1; $Duration=$obj->dateDifference($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { } else { if($Duration>30) { $Diagnostic[$i]['gps_speed']=0; } } if ($Diagnostic[$i]['gps_speed'] > $speedcheckVal) { $status = "Running"; } else { $status = "Stop"; } //Array ( [0] => Array ( [gps_time] => 2019-11-13 07:27:38 [id] => 208092055 [sys_msg_type] => 1 [gps_latitude] => 22.466209412 [main_powervoltage] => [gps_longitude] => 87.958633423 [gps_speed] => 36.99 [geo_street] => [geo_town] => [geo_country] => [geo_postcode] => [jny_distance] => [jny_duration] => [aconoff] => 0 [tel_panic] => 0 [jny_idle_time] => [tel_poweralert] => 0 [tel_input_1] => 0 [tel_input_0] => 0 [tel_input_2] => 0 [tel_temperature] => [tel_fuel] => 0.000000000 [gps_orientation] => 101.000000000 ) $distance = 0; $calcObj->veh_id = $vehicleList; $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; if ($localtime2 >= $_POST['dateStart']) { $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; } else { $PointArray[1]['lat'] = ''; $PointArray[1]['long'] = ''; } if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } $checkKm = 1000; if ($_SESSION['UserName'] == "yadavtransport") { $checkKm = 20; } if($_SESSION['UserName']=="apm11" || $_SESSION['login_ParentId']=="460711") { $checkKm=200; } $Duration=$obj->dateDifference($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); $Duration=$Duration+10; $checkKm = 1000; if ($distance <= $checkKm) { // if ($distance <= $Duration) { //$distance=0; ###### Sum of distance############ $totalDistance = $totalDistance + $distance; $tripDistance = $tripDistance + $distance; //} } if ($status == "Stop" && $stop == false) { if ($no == 1) { $starttime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $Diagnostic[$i]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $DiagnosticArray = array( 'starttime' => $starttime, 'start_gps_latitude' => $start_gps_latitude, 'start_gps_longitude' => $start_gps_longitude, 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Stop' ); array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; } else { $endtime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i - 1]['gps_time']))); $end_gps_latitude = $Diagnostic[$i - 1]['gps_latitude']; $end_gps_longitude = $Diagnostic[$i - 1]['gps_longitude']; $TimeTaken = $obj->dateDifferenceSecond($starttime, $endtime); $timediff = $obj->minDifference($TimeTaken); $total_running_hr = $total_running_hr + $TimeTaken; $starttime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $start_gps_latitude = $Diagnostic[$i]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i]['gps_longitude']; $DiagnosticArray = array( 'starttime' => $starttime, 'start_gps_latitude' => $start_gps_latitude, 'start_gps_longitude' => $start_gps_longitude, 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Running' ); array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; $running = false; } $stop = true; } else if ($status == "Running" && $running == false) { if ($no == 1) { $starttime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $Diagnostic[$i]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $DiagnosticArray = array( 'starttime' => $starttime, 'start_gps_latitude' => $start_gps_latitude, 'start_gps_longitude' => $start_gps_longitude, 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Running' ); array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; } else { $endtime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i - 1]['gps_time']))); $end_gps_latitude = $Diagnostic[$i - 1]['gps_latitude']; $end_gps_longitude = $Diagnostic[$i - 1]['gps_longitude']; $TimeTaken = $obj->dateDifferenceSecond($starttime, $endtime); $timediff = $obj->minDifference($TimeTaken); $starttime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $start_gps_latitude = $Diagnostic[$i]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i]['gps_longitude']; $DiagnosticArray = array( 'starttime' => $starttime, 'start_gps_latitude' => $start_gps_latitude, 'start_gps_longitude' => $start_gps_longitude, 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Stop' ); array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; $stop = false; } $running = true; } $sr++; // } } } } $endtime = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$lastrecord]['gps_time']))); $end_gps_latitude = $Diagnostic[$lastrecord]['gps_latitude']; $end_gps_longitude = $Diagnostic[$lastrecord]['gps_longitude']; $TimeTaken = $obj->dateDifferenceSecond($starttime, $endtime); $timediff = $obj->minDifference($TimeTaken); // if($Diagnostic[$lastrecord]['gps_speed']>5){ $vehstatus = "Running";}else{ $vehstatus = " Stop //";} if ($Diagnostic[$lastrecord]['gps_speed'] > $speedcheckVal) { $vehstatus = "Running"; $total_running_hr = $total_running_hr + $TimeTaken; } else { $vehstatus = " Stop "; $tripDistance = 0; //$total_idle_hr = $total_idle_hr+$TimeTaken; } /*$starttime = date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($Diagnostic[$i]['gps_time']))); $start_gps_latitude = $Diagnostic[$i]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i]['gps_longitude'];*/ $DiagnosticArray = array( 'starttime' => '', 'start_gps_latitude' => '', 'start_gps_longitude' => '', 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => $vehstatus ); array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; //echo "
";print_r($Mergediagnosticarray);die;
        $nor = 0;
        for ($dig = 0; $dig <= count($Mergediagnosticarray)-1 ; $dig++)
        //foreach($Mergediagnosticarray as $row)
            {
            if ($Mergediagnosticarray[$dig + 1]['duration'] != "") {
                $srno = $nor + 1;

                if ($_SESSION['UserName'] == "nstc11") {
                    $caldistance  = $Mergediagnosticarray[$dig + 1]['distance'];
                    $calodometer  = $Mergediagnosticarray[$dig + 1]['odometer'];
                    $lastodometer = $calodometer;
                }
                else
                {
 
                    if ($Mergediagnosticarray[$dig + 1]['status'] == "Running") {
                        $caldistance  = $Mergediagnosticarray[$dig + 1]['distance'];
                        $calodometer  = $Mergediagnosticarray[$dig + 1]['odometer'];
                        $lastodometer = $calodometer;
                    } else {
                        $caldistance = 0;
                        $calodometer = $lastodometer;
                    }
              }
?>
            
exists('itgc_locationsupd')) { if($redis_geopoi_data=get_geoPoi($sess_userid.':geopois',$Mergediagnosticarray[$dig]['start_gps_longitude'],$Mergediagnosticarray[$dig]['start_gps_latitude'],'500000','m',$redis)) { $redis_poi_km = round($redis_geopoi_data[0][1]/1000,0).' Km From '; // poi km redis $redis_poi_name = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = $redis_poi_km.' '.$KMFromNearPOI; $redis_poi_hset = json_decode(getPoi($sess_userid,$redis_poi_name,$redis)); // function to get stored poi data redis // check if the vehicle is inside the poi if($redis_geopoi_data[0][1] <= $redis_poi_hset->radius) { // if inside the poi get the poi name $LocationName = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$Mergediagnosticarray[$dig]['start_gps_longitude'],$Mergediagnosticarray[$dig]['start_gps_latitude'],'5000','m',$redis); $LocationName = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $LocationName = (!empty($LocationName))? $LocationName.' ('.$lat.','.$lng.')':$Mergediagnosticarray[$dig]['start_gps_longitude'].','.$Mergediagnosticarray[$dig]['start_gps_latitude']; // $LocationName = 'redis locatio'; } } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$Mergediagnosticarray[$dig]['start_gps_longitude'],$Mergediagnosticarray[$dig]['start_gps_latitude'],'5000','m',$redis); $LocationName = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $LocationName = (!empty($LocationName))? $LocationName.' ('.$lat.','.$lng.')':$Mergediagnosticarray[$dig]['start_gps_longitude'].','.$Mergediagnosticarray[$dig]['start_gps_latitude']; // $LocationName = 'redis locatio'; } //location_report_dig.php?latlong=radius) { // if inside the poi get the poi name $EndLocationName = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$Mergediagnosticarray[$varincrement]['end_gps_longitude'],$Mergediagnosticarray[$varincrement]['end_gps_latitude'],'5000','m',$redis); $EndLocationName = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $EndLocationName = (!empty($EndLocationName))? $EndLocationName.' ('.$lat.','.$lng.')':$Mergediagnosticarray[$varincrement]['end_gps_longitude'].','.$Mergediagnosticarray[$varincrement]['end_gps_latitude']; // $LocationName = 'redis locatio'; } } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$Mergediagnosticarray[$varincrement]['end_gps_longitude'],$Mergediagnosticarray[$varincrement]['end_gps_latitude'],'5000','m',$redis); $EndLocationName = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $EndLocationName = (!empty($EndLocationName))? $EndLocationName.' ('.$lat.','.$lng.')':$Mergediagnosticarray[$varincrement]['end_gps_longitude'].','.$Mergediagnosticarray[$varincrement]['end_gps_latitude']; // $LocationName = 'redis locatio'; } } ?> =1) { ?> minDifference($total_running_hr); $get_total_TimeTaken = $obj->dateDifferenceSecond($dateStart1, $dateEnd1); $final_idle_time = $get_total_TimeTaken - $total_running_hr; $totalIdle = $obj->minDifference($final_idle_time); ?>
Start Time Start Location End Time End Location Distance Odometer Duration Status View Details
View  
    Showing 1 to of records Actual Total KM : Actual Total KM  
31) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 31) - 1)); } $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry1 = " GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV " . $goupbymin; } else { $ExtraQry1 = " group by gps_time "; } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $navData[] = db__select("select id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, ".$GEtspeedas.", geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select id, gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, ".$GEtspeedas.", geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); //today_speed_".date("d")."_a /* if($_SESSION['UserName']=='hcil' || $_SESSION['UserName']=='apm' || $_SESSION['UserName']=='mamtatransport' || $_SESSION['UserName']=='sehrawat' || $_SESSION['UserName']=='thanepolice' || $_SESSION['UserName']=='amlf2' || $_SESSION['UserName']=='tulliresearch' || $_SESSION['UserName']=='dbs' || $_SESSION['UserName']=='dbs' || $_SESSION['UserName']=='satkar' || $_SESSION['UserName']=='ashu' || $_SESSION['UserName']=='ktc' || $_SESSION['UserName']=='kanaram11' || $_SESSION['UserName']=='mhipl' or $_SESSION['UserName']=='paradise' or $_SESSION['UserName']=='controlsol' or $_SESSION['UserName']=='doaba' or $_SESSION['UserName']=='rajesh' or $_SESSION['UserName']=='green' or $_SESSION['UserName']=='orl' or $_SESSION['UserName']=='prabhakar' or $_SESSION['UserName']=='hitours' or $_SESSION['UserName']=='gatewayrail' or $_SESSION['UserName']=='orangecabs' or $_SESSION['UserName']=='raashee' or $_SESSION['UserName']=='sslpl' or $_SESSION['UserName']=='shreelaxmi' or $_SESSION['UserName']=='nbspl' or $_SESSION['UserName']=='nrxen' or $_SESSION['UserName']=='doaba' or $_SESSION['UserName']=='travelinker' or $_SESSION['UserName']=='aajtak' or $_SESSION['UserName']=='avg' or $_SESSION['UserName']=='doaba' ) {*/ $newQry = "select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); $navData[] = db__select("select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . "telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); // } if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin; $ActKm = GetCalculatedKM($dateStart, $dateEnd, $vehicleList); } else { $ExtraQry = " group by gps_date,gps_time "; } for ($countYear = 0; $countYear < count($dbArray); $countYear++) { /* $StartGmtDate=$obj->convertToGMT($dateStart,$_SESSION['TimeZoneDiff']); $EndGmtDate=$obj->convertToGMT($dateEnd,$_SESSION['TimeZoneDiff']);*/ $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2, tel_temperature,tel_fuel,gps_orientation from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate." and sys_msg_type=1 group by gps_date,gps_time", $condition); /* if($_SESSION['UserName']=='hcil' || $_SESSION['UserName']=='apm' || $_SESSION['UserName']=='mamtatransport' || $_SESSION['UserName']=='sehrawat' || $_SESSION['UserName']=='thanepolice' || $_SESSION['UserName']=='amlf2' || $_SESSION['UserName']=='tulliresearch' || $_SESSION['UserName']=='adhunikinfra' || $_SESSION['UserName']=='dbs' || $_SESSION['UserName']=='satkar' || $_SESSION['UserName']=='ashu' || $_SESSION['UserName']=='ktc' || $_SESSION['UserName']=='kanaram11' || $_SESSION['UserName']=='mhipl' or $_SESSION['UserName']=='paradise' or $_SESSION['UserName']=='controlsol' or $_SESSION['UserName']=='doaba' or $_SESSION['UserName']=='rajesh' or $_SESSION['UserName']=='srcfbd' or $_SESSION['UserName']=='prabhakar' or $_SESSION['UserName']=='raashee' or $_SESSION['UserName']=='sslpl' or $_SESSION['UserName']=='shreelaxmi' or $_SESSION['UserName']=='nbspl' or $_SESSION['UserName']=='nrxen' or $_SESSION['UserName']=='doaba' or $_SESSION['UserName']=='travelinker' or $_SESSION['UserName']=='aajtak' or $_SESSION['UserName']=='okara' ) {*/ $newQry = "select CONCAT(gps_date,' ',gps_time) as gps_time,id, sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate." " . $ExtraQry1 . " and sys_msg_type=1 ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); // } if ($_SESSION['UserName'] == 'orangecabs11') { $newQry = "select gps_time as gps_time, id, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, ".$GEtspeedas.", geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and sys_msg_type=1 group by gps_time ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); } } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } //echo "
";print_r($Diagnostic);die;
?>
  
  
  

Diagnostic Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; // if (strlen(round($Diagnostic[$i]['gps_latitude'])) == 2 && strlen(round($Diagnostic[$i]['gps_longitude'])) == 2) { $no = $sr + 1; if ($Diagnostic[$i]['gps_speed'] > $speedcheckVal) { $status = "Running"; } else { $status = "Stop"; } $distance = 0; $calcObj->veh_id = $vehicleList; $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } $checkKm = 1000; if ($_SESSION['UserName'] == "yadavtransport") { $checkKm = 20; } if($_SESSION['UserName']=="apm" || $_SESSION['login_ParentId']=="4607") { $checkKm=200; } if ($distance <= $checkKm) { //$distance=0; ###### Sum of distance############ $totalDistance = $totalDistance + $distance; $tripDistance = $tripDistance + $distance; } if ($status == "Stop" && $stop == false) { if ($no == 1) { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $Diagnostic[$i]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $DiagnosticArray = array( 'starttime' => $starttime, 'start_gps_latitude' => $start_gps_latitude, 'start_gps_longitude' => $start_gps_longitude, 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Stop' ); array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; } else { $endtime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i - 1]['gps_time']))); $end_gps_latitude = $Diagnostic[$i - 1]['gps_latitude']; $end_gps_longitude = $Diagnostic[$i - 1]['gps_longitude']; $TimeTaken = $obj->dateDifferenceSecond($starttime, $endtime); $timediff = $obj->minDifference($TimeTaken); $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $start_gps_latitude = $Diagnostic[$i]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i]['gps_longitude']; if($TimeTaken > 1800 && $tripDistance < 2) { $DiagnosticArray = array( 'starttime' => $starttime, 'start_gps_latitude' => $start_gps_latitude, 'start_gps_longitude' => $start_gps_longitude, 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Stop' ); } else { $total_running_hr = $total_running_hr + $TimeTaken; $DiagnosticArray = array( 'starttime' => $starttime, 'start_gps_latitude' => $start_gps_latitude, 'start_gps_longitude' => $start_gps_longitude, 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Running' ); } array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; $running = false; } $stop = true; } else if ($status == "Running" && $running == false) { if ($no == 1) { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $Diagnostic[$i]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $DiagnosticArray = array( 'starttime' => $starttime, 'start_gps_latitude' => $start_gps_latitude, 'start_gps_longitude' => $start_gps_longitude, 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Running' ); array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; } else { $endtime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i - 1]['gps_time']))); $end_gps_latitude = $Diagnostic[$i - 1]['gps_latitude']; $end_gps_longitude = $Diagnostic[$i - 1]['gps_longitude']; $TimeTaken = $obj->dateDifferenceSecond($starttime, $endtime); $timediff = $obj->minDifference($TimeTaken); $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $start_gps_latitude = $Diagnostic[$i]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i]['gps_longitude']; $DiagnosticArray = array( 'starttime' => $starttime, 'start_gps_latitude' => $start_gps_latitude, 'start_gps_longitude' => $start_gps_longitude, 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Stop' ); array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; $stop = false; } $running = true; } $sr++; //} } } } $endtime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$lastrecord]['gps_time']))); $end_gps_latitude = $Diagnostic[$lastrecord]['gps_latitude']; $end_gps_longitude = $Diagnostic[$lastrecord]['gps_longitude']; $TimeTaken = $obj->dateDifferenceSecond($starttime, $endtime); $timediff = $obj->minDifference($TimeTaken); // if($Diagnostic[$lastrecord]['gps_speed']>5){ $vehstatus = "Running";}else{ $vehstatus = " Stop //";} if ($Diagnostic[$lastrecord]['gps_speed'] > 5) { $vehstatus = "Running"; } else { $vehstatus = " Stop "; //$total_idle_hr = $total_idle_hr+$TimeTaken; } /*$starttime = date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($Diagnostic[$i]['gps_time']))); $start_gps_latitude = $Diagnostic[$i]['gps_latitude']; $start_gps_longitude = $Diagnostic[$i]['gps_longitude'];*/ if($TimeTaken > 1800 && $tripDistance < 2) { $DiagnosticArray = array( 'starttime' => '', 'start_gps_latitude' => '', 'start_gps_longitude' => '', 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => 'Stop' ); } else { $total_running_hr = $total_running_hr + $TimeTaken; $DiagnosticArray = array( 'starttime' => '', 'start_gps_latitude' => '', 'start_gps_longitude' => '', 'endtime' => $endtime, 'end_gps_latitude' => $end_gps_latitude, 'end_gps_longitude' => $end_gps_longitude, 'distance' => $tripDistance, 'odometer' => $totalDistance, 'duration' => $timediff, 'status' => $vehstatus ); } array_push($Mergediagnosticarray, $DiagnosticArray); $tripDistance = 0; //echo "
";print_r($Mergediagnosticarray);die;
        $nor = 0;
        for ($dig = 0; $dig < count($Mergediagnosticarray) - 1; $dig++)
        //foreach($Mergediagnosticarray as $row)
            {
            if ($Mergediagnosticarray[$dig + 1]['duration'] != "") {
                $srno = $nor + 1;

                if ($Mergediagnosticarray[$dig + 1]['status'] == "Running") {
                    $caldistance  = $Mergediagnosticarray[$dig + 1]['distance'];
                    $calodometer  = $Mergediagnosticarray[$dig + 1]['odometer'];
                    $lastodometer = $calodometer;
                } else {
                    $caldistance = 0;
                    $calodometer = $lastodometer;
                }
				
				if($report_location == "Show_Location")
				{												
					if($redis_data = getRedisLocation($sess_userid,$Mergediagnosticarray[$dig]["start_gps_latitude"],$Mergediagnosticarray[$dig]["start_gps_longitude"],$redis))
					{
						$startlocation = $redis_data['LocationName'];
						//$KMFromNearPOI = $redis_data['KMFromNearPOI'];
					} else {
						$startlocation = '';
					}
					
					if($redis_data2 = getRedisLocation($sess_userid,$Mergediagnosticarray[$dig + 1]["end_gps_latitude"],$Mergediagnosticarray[$dig + 1]["end_gps_longitude"],$redis))
					{
						$endlocation = $redis_data2['LocationName'];
						//$KMFromNearPOI = $redis_data['KMFromNearPOI'];
					} else {
						$endlocation = '';
					}
					 
				} else {
					$startlocation = '';
					$endlocation = '';
				}
?>
            
            
minDifference($total_running_hr); $get_total_TimeTaken = $obj->dateDifferenceSecond($dateStart1, $dateEnd1); $final_idle_time = $get_total_TimeTaken - $total_running_hr; $totalIdle = $obj->minDifference($final_idle_time); ?>
Start Time Start Location End Time End Location Distance Odometer Duration Status View Details
View  
    Showing 1 to of records Actual Total KM  
15) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 15) - 1)); } $_SESSION["tempdatestart"]=$dateStart; $_SESSION["tempdateend"]=$dateEnd; $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); // $navData[] = db__select_staging("select `sys_service_id`, `sys_msg_type`, `sys_proc_time`, `sys_proc_host`, `sys_asset_id`, `sys_geofence_id`, `sys_device_id`, gps_time, `gps_latitude`, `gps_longitude`, `gps_orientation`, tel_input_0=true and gps_fix=1 then round(gps_speed*1.609,2) else '0' end as gps_speed , `gps_fix`, `geo_street`, `geo_town`, `geo_country`, `geo_postcode`, `jny_distance`, `jny_duration`, `jny_idle_time`, `jny_status`, `jny_leg_code`, `jny_device_jny_id`, `des_movement_id`, `des_vehicle_id`, `tel_state`, `tel_ignition`, `tel_alarm`, `tel_panic`, `tel_shield`, `tel_theft_attempt`, `tel_tamper`, `tel_ext_alarm`, `tel_journey`, `tel_journey_status`, `tel_idle`, `tel_ex_idle`, `tel_hours`, `tel_input_0`, `tel_input_1`, `tel_input_2`, `tel_input_3`, `tel_temperature`, `tel_voltage`, `main_powervoltage`, `tel_odometer`, `tel_poweralert`, `tel_speedalert`, `tel_boxalert`, `tel_fuel`, `tel_rfid` from matrix.telemetry_fuel where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); /*$data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; }*/ if (((((strtotime($dateEnd)) - (strtotime($dateStart))) / 3600) / 24) > 15) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 15) - 1)); } $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry1 = " GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV " . $goupbymin; } else { $ExtraQry1 = " group by gps_time "; } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $navData[] = db__select("select id,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, tel_temperature,tel_fuel,gps_orientation,jny_distance, DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_fuel) as value from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select id,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, tel_temperature,tel_fuel,gps_orientation, jny_distance,DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_fuel) as value from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $newQry = "select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, tel_temperature,tel_fuel,jny_distance,DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_fuel) as value from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); $navData[] = db__select("select id,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, tel_temperature,tel_fuel,gps_orientation, jny_distance,DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_fuel) as value from matrix.today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select id,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, tel_temperature,tel_fuel,gps_orientation, jny_distance,DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_fuel) as value from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin; //$ActKm = GetCalculatedKM($dateStart, $dateEnd, $vehicleList); } else { $ExtraQry = " group by gps_date,gps_time "; } for ($countYear = 0; $countYear < count($dbArray); $countYear++) { /*$StartGmtDate=$obj->convertToGMT($dateStart,$_SESSION['TimeZoneDiff']); $EndGmtDate=$obj->convertToGMT($dateEnd,$_SESSION['TimeZoneDiff']);*/ $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_temperature,tel_fuel,gps_orientation,jny_distance,DATE_FORMAT( ADDDATE(CONCAT(gps_date,' ',gps_time),INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_fuel) as value from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" .$StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."' and gps_speed>3 and sys_msg_type=1 group by gps_date,gps_time", $condition); $newQry = "select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, tel_temperature,tel_fuel,jny_distance,DATE_FORMAT( ADDDATE(CONCAT(gps_date,' ',gps_time),INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_fuel) as value from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."" . $ExtraQry1 . " and sys_msg_type=1 ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } $_SESSION["temp_data"] = $Diagnostic; ?>

Fuel Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { // if (strlen(round($Diagnostic[$i]['gps_latitude'])) == 2 && strlen(round($Diagnostic[$i]['gps_longitude'])) == 2) { $no = $sr + 1; $status = $Diagnostic[$i]['gps_speed']; $start_date = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); if($_SESSION['UserId']=="3165") { $Diagnostic[$i]['tel_fuel']=round($Diagnostic[$i]['value']).",".round($Diagnostic[$i]['jny_distance']); } else { $Diagnostic[$i]['tel_fuel']=round($Diagnostic[$i]['value']); } //$FinalFueltoShow=($Diagnostic[$i]['value']/34)*34.5; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } ?>
Date Location Primary Tank Status
  Showing 1 to of records  
15) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 15) - 1)); } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $deviceImei= db__select("select * from matrix.devices where id=".$device_id); $imei=$deviceImei[0]["imei"]; if($imei!="") { // echo "select DeviceIMEI,Longitude as gps_longitude ,Latitude as gps_latitude,Gps_Time as gps_time,CsaEventTxt,CsaSubEventTxt from matrix.driver where DeviceIMEI='".$imei."' and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and CsaSubEventTxt!='Green severity' and CsaEventTxt!='IP-UP' and CsaEventTxt!='Go/Halt event' ORDER BY Gps_Time asc"; //and CsaSubEventTxt!='Green severity' $Diagnostic = db__select("select DeviceIMEI,Longitude as gps_longitude ,Latitude as gps_latitude,Gps_Time as gps_time,CsaEventTxt,CsaSubEventTxt, speed as gps_speed from matrix.driver where DeviceIMEI='".$imei."' and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and CsaEventTxt!='IP-UP' and CsaEventTxt!='Go/Halt event' group by driver.DeviceIMEI,driver.Gps_Time,driver.csaevent ORDER BY Gps_Time asc", $condition); } /* $objDbManager=new DbManager(); $dbArray=$objDbManager->returnDbArray($dateStart,$dateEnd); $ExtraQry1=" group by gps_time "; $navData[] = db__select("select gps_time,gps_latitude,gps_longitude,".$GEtspeedas." from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time,gps_latitude,gps_longitude,".$GEtspeedas." from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $newQry = "select gps_time,gps_latitude,gps_longitude,".$GEtspeedas." from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); $navData[] = db__select("select gps_time,gps_latitude,gps_longitude,".$GEtspeedas." from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $ExtraQry = " group by gps_date,gps_time "; for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas." from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' group by gps_date,gps_time", $condition); echo $newQry = "select CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas." from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DiagnosticActual[] = $val; } print_r( $DiagnosticActual);*/ $obj1 = new MyClass(); ?>

Driver Journey Log

veh_id = $vehicleList; $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } if ($distance <= 200) { //$distance=0; ###### Sum of distance############ $totalDistance = $totalDistance + $distance; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } ?>
Date Location Speed Distance Status Description
  Showing 1 to of records      
31) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 31) - 1)); } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $deviceImei= db__select("select imei from matrix.devices where id=".$device_id); $imei=$deviceImei[0]["imei"]; if($imei!="") { $Diagnostic=db__select("select DeviceIMEI,Longitude as gps_longitude ,Latitude as gps_latitude,Gps_Time as gps_time,CsaEventTxt,CsaSubEventTxt, speed as gps_speed from matrix.driver where Gps_Time >='".$StartGmtDate."' and Gps_Time <='".$EndGmtDate."' and DeviceIMEI ='".$imei."' and CsaEventTxt='".$GetEvent."' ORDER BY Gps_Time asc",''); // and driver.CsaSubEventTxt!='Green Severity' } //and driver.CsaSubEventTxt!='Green Severity' //echo "select DeviceIMEI,Longitude as gps_longitude ,Latitude as gps_latitude,Gps_Time as gps_time,CsaEventTxt,CsaSubEventTxt, speed as gps_speed from matrix.driver where Gps_Time >='".$dateStart."' and Gps_Time <='".$dateEnd."' and DeviceIMEI ='".$imei."' and CsaEventTxt='".$GetEvent."' ORDER BY Gps_Time asc"; ?> veh_id = $vehicleList; $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } ?>
Date Location Speed Status Description
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '".$StartGmtDate."' and CONCAT(gps_date,' ',gps_time) <= '".$EndGmtDate."' and tel_input_0=true and tel_ignition=0 group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '".$StartGmtDate."' and CONCAT(gps_date,' ',gps_time) <= '".$EndGmtDate."' and tel_input_0=true and tel_ignition=0 group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from matrix.today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true and tel_ignition=0 group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true and tel_ignition=0 group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true and tel_ignition=0 group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from matrix.today_speed" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true and tel_ignition=0 group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true and tel_ignition=0 group by gps_time ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $EngineOn[] = $val; } //echo "
";print_r($EngineOn);die;
?>
 
  
  

Engine Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; //if (strlen(round($EngineOn[$i]['gps_latitude'])) == 2 && strlen(round($EngineOn[$i]['gps_longitude'])) == 2) { /*$istrow=$EngineOn[$i]['gps_time']; $secndrow=$EngineOn[$i-1]['gps_time']; $diff = $obj_diff->dateDifference($istrow,$secndrow); echo $EngineOn[$i]['gps_time']."--".$EngineOn[$i]['tel_input_3']."--". $diff;echo "
"; */ //echo $EngineOn[$i]['gps_time'];echo "
"; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$EngineOn[$i]["gps_latitude"],$EngineOn[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } if ($JourneyStartAt == "") { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($EngineOn[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $EngineOn[$i]['gps_latitude']; $start_gps_longitude = $EngineOn[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $EngineOn[$i]['gps_time']; $JourneyStartAt = $EngineOn[$i]['gps_time']; $no = $no+1; $ShowHTML= ''; ?> ';*/ } if ($JourneyStartAt != "") { if ($i > 1) { $istrow = $EngineOn[$i]['gps_time']; $secndrow = $EngineOn[$i - 1]['gps_time']; $local_time1 = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($EngineOn[$i - 1]['gps_time']))); if ($local_time1 >= $_POST['dateStart']) { $diff = $obj_diff->dateDifference($istrow, $secndrow); if ($diff >= $diffenceStatic) { // echo $diff ; //$TimeTaken="3"; $TimeTaken = $obj_diff->dateDifference($JourneyStartAt, $secndrow); $totalTimetaken+=$TimeTaken; $door_off_time=date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($secndrow))); $total_time = $obj_diff->minDifference($TimeTaken * 60); if($TimeTaken>0) { $no = $no+1; echo $ShowHTML. ' '; } /*echo ' ';*/ // $JourneyStartAt = $istrow; /* echo '';*/ $ShowHTML= ''; ?> " /> =$diffenceStatic) { $Endtrip=true; $TimeTaken=$obj_diff->dateDifference($JourneyStartAt,$secndrow); echo ' '; $JourneyStartAt=$istrow; echo ''; } */ } } } // } } } } if ($JourneyStartAt != "") { $TimeTaken = $obj_diff->dateDifference($JourneyStartAt, $EngineOn[count($EngineOn) - 1]['gps_time']); $totalTimetaken+=$TimeTaken; $door_off_time_last = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($EngineOn[count($EngineOn) - 1]['gps_time']))); $total_time_last = $obj_diff->minDifference($TimeTaken * 60); if($TimeTaken>0) { echo $ShowHTML.' '; } ?> ' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($EngineOn[count($EngineOn) - 1]['gps_time']))) . '';*/ } ?>
Location Engine On Date & time Engine Off Date & time Total Time Engine On
'.$startlocation.' '.$starttime.' ' . $masterObj->GetLocationWitPOIreport($start_gps_latitude . "," . $start_gps_longitude) . '' . $starttime . ''.$door_off_time.' '.$total_time.'
' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($secndrow))) . ' ' . $obj_diff->minDifference($TimeTaken * 60) . '
'.$masterObj->GetLocationWitPOIreport($EngineOn[$i]['gps_latitude'].",".$EngineOn[$i]['gps_longitude']).'
' . $masterObj->GetLocationWitPOIreport($EngineOn[$i]['gps_latitude'] . "," . $EngineOn[$i]['gps_longitude']) . '' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))) . '
'.$startlocation.''.date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))).' '.$secndrow.''.$masterObj->GetLocationWitPOIreport($EngineOn[$i]['gps_latitude'].",".$EngineOn[$i]['gps_longitude']).' '.minDifference($TimeTaken).'
'.$istrow.''.$masterObj->GetLocationWitPOIreport($EngineOn[$i]['gps_latitude'].",".$EngineOn[$i]['gps_longitude']).''.$door_off_time_last.' '.$total_time_last.'
' . $obj_diff->minDifference($TimeTaken * 60) . '
  Showing 1 to of records minDifference($totalTimetaken * 60);?>
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '".$StartGmtDate."' and CONCAT(gps_date,' ',gps_time) <= '".$EndGmtDate."' and tel_input_0=true and tel_ignition=0 group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '".$StartGmtDate."' and CONCAT(gps_date,' ',gps_time) <= '".$EndGmtDate."' and tel_input_0=true and tel_ignition=0 group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from matrix.today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true and tel_ignition=0 group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true and tel_ignition=0 group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true and tel_ignition=0 group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from matrix.today_speed" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true and tel_ignition=0 group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true and tel_ignition=0 then true else false end as tel_input_3 from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true and tel_ignition=0 group by gps_time ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $EngineOn[] = $val; } //echo "
";print_r($EngineOn);die;
?>
 
  
  

Engine Idle Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$EngineOn[$i]["gps_latitude"],$EngineOn[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } if ($i == 0) { $str = date("Y-m-d H:i:s", strtotime('- '.$_SESSION['TimeZoneDiff'] . ' minutes', strtotime($_POST['dateStart']))); $end = $EngineOn[$i]['gps_time']; $lst = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($EngineOn[$i]['gps_time']))); $ist = date("d-m-Y H:i:s", strtotime($_POST['dateStart'])); $diff = $obj_diff->dateDifference($end, $str); if($diff >= $diffenceStatic) { $starttime = $ist; $endtime = $lst; $start_gps_latitude = $EngineOn[$i]['gps_latitude']; $start_gps_longitude = $EngineOn[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $EngineOn[$i]['gps_time']; $JourneyStartAt = $EngineOn[$i]['gps_time']; $no = $no+1; $total_time = $obj_diff->minDifference($diff * 60); $totalTimetaken+=$total_time; $totalmintime += $diff; echo $ShowHTML= ''; /*echo $ShowHTML= '';*/ ?> dateDifference($secndrow, $istrow); if ($diff >= $diffenceStatic) { $no = $no+1; $TimeTaken = $obj_diff->dateDifference($secndrow, $istrow); $totalTimetaken+=$TimeTaken; $total_time = $obj_diff->minDifference($TimeTaken * 60); $totalmintime += $TimeTaken; echo $ShowHTML= ''; /*echo $ShowHTML= ''; */ ?> " />
Location Engine Off Date & time Engine On Date & time Total Time Engine Off Total Time Engine Off (In MIn)
'.$startlocation.' '.$starttime.''.$lst.''.$total_time.''.$diff.'
'.$starttime.''.$lst.''.$total_time.''.$diff.'
'.$startlocation.' '.$door_on_time.''.$door_off_time.''.$total_time.''.$TimeTaken.'
'.$door_on_time.''.$door_off_time.''.$total_time.''.$TimeTaken.'
  Showing 1 to of records minDifference($totalTimetaken * 60);?>
15) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 15) - 1)); } $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry1 = " GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV " . $goupbymin; } else { $ExtraQry1 = " group by gps_time "; } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $navData[] = db__select("`sys_service_id`, `sys_msg_type`, `sys_proc_time`, `sys_proc_host`, `sys_asset_id`, `sys_geofence_id`, `sys_device_id`, gps_time, `gps_latitude`, `gps_longitude`, `gps_orientation`, ".$GEtspeedas.", `gps_fix`, `geo_street`, `geo_town`, `geo_country`, `geo_postcode`, `jny_distance`, `jny_duration`, `jny_idle_time`, `jny_status`, `jny_leg_code`, `jny_device_jny_id`, `des_movement_id`, `des_vehicle_id`, `tel_state`, `tel_ignition`, `tel_alarm`, `tel_panic`, `tel_shield`, `tel_theft_attempt`, `tel_tamper`, `tel_ext_alarm`, `tel_journey`, `tel_journey_status`, `tel_idle`, `tel_ex_idle`, `tel_hours`, `tel_input_0`, `tel_input_1`, `tel_input_2`, `tel_input_3`, `tel_temperature`, `tel_voltage`, `main_powervoltage`, `tel_odometer`, `tel_poweralert`, `tel_speedalert`, `tel_boxalert`, `tel_fuel`, `tel_rfid` from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("`sys_service_id`, `sys_msg_type`, `sys_proc_time`, `sys_proc_host`, `sys_asset_id`, `sys_geofence_id`, `sys_device_id`, gps_time, `gps_latitude`, `gps_longitude`, `gps_orientation`, ".$GEtspeedas.", `gps_fix`, `geo_street`, `geo_town`, `geo_country`, `geo_postcode`, `jny_distance`, `jny_duration`, `jny_idle_time`, `jny_status`, `jny_leg_code`, `jny_device_jny_id`, `des_movement_id`, `des_vehicle_id`, `tel_state`, `tel_ignition`, `tel_alarm`, `tel_panic`, `tel_shield`, `tel_theft_attempt`, `tel_tamper`, `tel_ext_alarm`, `tel_journey`, `tel_journey_status`, `tel_idle`, `tel_ex_idle`, `tel_hours`, `tel_input_0`, `tel_input_1`, `tel_input_2`, `tel_input_3`, `tel_temperature`, `tel_voltage`, `main_powervoltage`, `tel_odometer`, `tel_poweralert`, `tel_speedalert`, `tel_boxalert`, `tel_fuel`, `tel_rfid` from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); //and tel_input_0=true and gps_speed<6 and tel_fuel>5 //today_speed_".date("d")."_a $navData[] = db__select("select `sys_service_id`, `sys_msg_type`, `sys_proc_time`, `sys_proc_host`, `sys_asset_id`, `sys_geofence_id`, `sys_device_id`, gps_time, `gps_latitude`, `gps_longitude`, `gps_orientation`, ".$GEtspeedas.", `gps_fix`, `geo_street`, `geo_town`, `geo_country`, `geo_postcode`, `jny_distance`, `jny_duration`, `jny_idle_time`, `jny_status`, `jny_leg_code`, `jny_device_jny_id`, `des_movement_id`, `des_vehicle_id`, `tel_state`, `tel_ignition`, `tel_alarm`, `tel_panic`, `tel_shield`, `tel_theft_attempt`, `tel_tamper`, `tel_ext_alarm`, `tel_journey`, `tel_journey_status`, `tel_idle`, `tel_ex_idle`, `tel_hours`, `tel_input_0`, `tel_input_1`, `tel_input_2`, `tel_input_3`, `tel_temperature`, `tel_voltage`, `main_powervoltage`, `tel_odometer`, `tel_poweralert`, `tel_speedalert`, `tel_boxalert`, `tel_fuel`, `tel_rfid` from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select `sys_service_id`, `sys_msg_type`, `sys_proc_time`, `sys_proc_host`, `sys_asset_id`, `sys_geofence_id`, `sys_device_id`, gps_time, `gps_latitude`, `gps_longitude`, `gps_orientation`, ".$GEtspeedas.", `gps_fix`, `geo_street`, `geo_town`, `geo_country`, `geo_postcode`, `jny_distance`, `jny_duration`, `jny_idle_time`, `jny_status`, `jny_leg_code`, `jny_device_jny_id`, `des_movement_id`, `des_vehicle_id`, `tel_state`, `tel_ignition`, `tel_alarm`, `tel_panic`, `tel_shield`, `tel_theft_attempt`, `tel_tamper`, `tel_ext_alarm`, `tel_journey`, `tel_journey_status`, `tel_idle`, `tel_ex_idle`, `tel_hours`, `tel_input_0`, `tel_input_1`, `tel_input_2`, `tel_input_3`, `tel_temperature`, `tel_voltage`, `main_powervoltage`, `tel_odometer`, `tel_poweralert`, `tel_speedalert`, `tel_boxalert`, `tel_fuel`, `tel_rfid` from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select `sys_service_id`, `sys_msg_type`, `sys_proc_time`, `sys_proc_host`, `sys_asset_id`, `sys_geofence_id`, `sys_device_id`, gps_time, `gps_latitude`, `gps_longitude`, `gps_orientation`, ".$GEtspeedas.", `gps_fix`, `geo_street`, `geo_town`, `geo_country`, `geo_postcode`, `jny_distance`, `jny_duration`, `jny_idle_time`, `jny_status`, `jny_leg_code`, `jny_device_jny_id`, `des_movement_id`, `des_vehicle_id`, `tel_state`, `tel_ignition`, `tel_alarm`, `tel_panic`, `tel_shield`, `tel_theft_attempt`, `tel_tamper`, `tel_ext_alarm`, `tel_journey`, `tel_journey_status`, `tel_idle`, `tel_ex_idle`, `tel_hours`, `tel_input_0`, `tel_input_1`, `tel_input_2`, `tel_input_3`, `tel_temperature`, `tel_voltage`, `main_powervoltage`, `tel_odometer`, `tel_poweralert`, `tel_speedalert`, `tel_boxalert`, `tel_fuel`, `tel_rfid` from " . $dbArray[$countYear] . "telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); //and tel_input_0=true and tel_fuel>5 and gps_speed<6 if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin; $ActKm = GetCalculatedKM($dateStart, $dateEnd, $vehicleList); } else { $ExtraQry = " group by gps_date,gps_time "; } for ($countYear = 0; $countYear < count($dbArray); $countYear++) { /* $StartGmtDate=$obj->convertToGMT($dateStart,$_SESSION['TimeZoneDiff']); $EndGmtDate=$obj->convertToGMT($dateEnd,$_SESSION['TimeZoneDiff']);*/ $navData[] = db__select_staging("select `sys_service_id`, `sys_msg_type`, `sys_proc_time`, `sys_proc_host`, `sys_asset_id`, `sys_geofence_id`, `sys_device_id`, CONCAT(gps_date,' ',gps_time) as gps_time, `gps_latitude`, `gps_longitude`, `gps_orientation`, ".$GEtspeedas.", `gps_fix`, `geo_street`, `geo_town`, `geo_country`, `geo_postcode`, `jny_distance`, `jny_duration`, `jny_idle_time`, `jny_status`, `jny_leg_code`, `jny_device_jny_id`, `des_movement_id`, `des_vehicle_id`, `tel_state`, `tel_ignition`, `tel_alarm`, `tel_panic`, `tel_shield`, `tel_theft_attempt`, `tel_tamper`, `tel_ext_alarm`, `tel_journey`, `tel_journey_status`, `tel_idle`, `tel_ex_idle`, `tel_hours`, `tel_input_0`, `tel_input_1`, `tel_input_2`, `tel_input_3`, `tel_temperature`, `tel_voltage`, `main_powervoltage`, `tel_odometer`, `tel_poweralert`, `tel_speedalert`, `tel_boxalert`, `tel_fuel`, `tel_rfid` from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate." and sys_msg_type=1 group by gps_date,gps_time", $condition); //and tel_input_0=true and tel_fuel>5 and gps_speed<6 $newQry = "select `sys_service_id`, `sys_msg_type`, `sys_proc_time`, `sys_proc_host`, `sys_asset_id`, `sys_geofence_id`, `sys_device_id`, CONCAT(gps_date,' ',gps_time) as gps_time, `gps_latitude`, `gps_longitude`, `gps_orientation`, ".$GEtspeedas.", `gps_fix`, `geo_street`, `geo_town`, `geo_country`, `geo_postcode`, `jny_distance`, `jny_duration`, `jny_idle_time`, `jny_status`, `jny_leg_code`, `jny_device_jny_id`, `des_movement_id`, `des_vehicle_id`, `tel_state`, `tel_ignition`, `tel_alarm`, `tel_panic`, `tel_shield`, `tel_theft_attempt`, `tel_tamper`, `tel_ext_alarm`, `tel_journey`, `tel_journey_status`, `tel_idle`, `tel_ex_idle`, `tel_hours`, `tel_input_0`, `tel_input_1`, `tel_input_2`, `tel_input_3`, `tel_temperature`, `tel_voltage`, `main_powervoltage`, `tel_odometer`, `tel_poweralert`, `tel_speedalert`, `tel_boxalert`, `tel_fuel`, `tel_rfid` from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate. "' and CONCAT(gps_date,' ',gps_time) <= '" .$dateEnd . "'" . $ExtraQry1 . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); // and tel_input_0=true and gps_speed<6 and tel_fuel>5 } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } ?>

Fuel Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { // if (strlen(round($Diagnostic[$i]['gps_latitude'])) == 2 && strlen(round($Diagnostic[$i]['gps_longitude'])) == 2) { $no = $sr + 1; if ($Diagnostic[$i]['gps_speed'] > $speedcheckVal) { $status = "Running"; } else { $status = "Stop"; } $start_date = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } ?> $speedcheckVal) { ?>
Date Location Nearest Poi Distance Odometer Fuel Status
veh_id = $vehicleList; $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } if ($distance <= 1000) { //$distance=0; ###### Sum of distance############ $totalDistance = $totalDistance + $distance; } if (($i % 13) == 0 || ($i == count($Diagnostic) - 1)) { echo $distance . " testi g"; /*if($Diagnostic[$i]['gps_speed']>12) { $fuelMil=3.5; } else { $fuelMil=4; }*/ $fuelMil = 3.4; $fuelset = 218 - ($totalDistance / $fuelMil); //echo "fuel$$". $fuelset; $insertQuery = "INSERT INTO matrix.telemetry_fuel (sys_service_id, sys_msg_type,sys_proc_time, sys_proc_host, gps_time, gps_latitude, gps_longitude,gps_orientation, gps_speed,`tel_fuel`) VALUES (" . $vehicleList . ", 1, '" . $Diagnostic[$i]['sys_proc_time'] . "', 'S4D5GB7N3BV', '" . $Diagnostic[$i]['gps_time'] . "'," . $Diagnostic[$i]['gps_latitude'] . ", " . $Diagnostic[$i]['gps_longitude'] . "," . $Diagnostic[$i]['gps_orientation'] . ", " . $Diagnostic[$i]['gps_speed'] . ",'" . $fuelset . "');"; //$InsertStaging=db__select_staging($insertQuery,""); //die(); } ?>
      Showing 1 to of records        
35){ $dateEnd=date('Y-m-d H:i',(strtotime($dateStart))+((3600*24*35)-1)); } $_SESSION["tempdatestart"]=$dateStart; $_SESSION["tempdateend"]=$dateEnd; $StartGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateEnd))); $objDbManager=new DbManager(); $dbArray=$objDbManager->returnDbArray($dateStart,$dateEnd); if($diff_of_minutes!="") { $goupbymin=$diff_of_minutes * 60; $ExtraQry1=" GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV ".$goupbymin; } else { $ExtraQry1=" group by gps_time "; } db__query_staging("CREATE TEMPORARY TABLE matrix.historydata( `sys_service_id` BIGINT(20) UNSIGNED NOT NULL, `sys_proc_time` DATETIME NOT NULL, `gps_time` DATETIME NOT NULL, `gps_latitude` FLOAT(12,9) NOT NULL, `gps_longitude` FLOAT(12,9) NOT NULL, `gps_speed` FLOAT(12,9) NOT NULL,tel_temperature FLOAT(12,9) NOT NULL,jny_distance VARCHAR(500) NULL DEFAULT NULL,`geo_street` VARCHAR(500) NULL DEFAULT NULL,des_movement_id VARCHAR(50) NULL DEFAULT NULL,tel_rfid VARCHAR(500) NULL DEFAULT NULL ) ",""); if(in_array($_SESSION['sys_group_id'], $backupServer123)) { db__query_staging_30("CREATE TEMPORARY TABLE matrix.historydata( `sys_service_id` BIGINT(20) UNSIGNED NOT NULL, `sys_proc_time` DATETIME NOT NULL, `gps_time` DATETIME NOT NULL, `gps_latitude` FLOAT(12,9) NOT NULL, `gps_longitude` FLOAT(12,9) NOT NULL, `gps_speed` FLOAT(12,9) NOT NULL,tel_temperature FLOAT(12,9) NOT NULL,jny_distance VARCHAR(500) NULL DEFAULT NULL,`geo_street` VARCHAR(500) NULL DEFAULT NULL,des_movement_id VARCHAR(50) NULL DEFAULT NULL,tel_rfid VARCHAR(500) NULL DEFAULT NULL ) ",""); } for($countYear=0;$countYear= '".$StartGmtDate."' " . "and CONCAT(gps_date,' ',gps_time) <= '".$EndGmtDate."' group by gps_date,gps_time";*/ if($dbArray[$countYear]!="matrix_".date("m_y")) { /*echo "insert into historydata select sys_service_id,sys_proc_time," . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature, jny_distance,`geo_street`,des_movement_id " . "from ".$dbArray[$countYear].".telemetry_new where sys_service_id=".$vehicleList." and gps_date >= '".date("Y-m-d",strtotime($StartGmtDate))."' " . "and gps_date <= '".date("Y-m-d",strtotime($dateEnd))."' group by gps_date,gps_time";die();*/ db__query_staging("insert into matrix.historydata select sys_service_id,sys_proc_time," . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature, jny_distance,`geo_street`,des_movement_id,tel_rfid " . "from ".$dbArray[$countYear].".telemetry_new where sys_service_id=".$vehicleList." and CONCAT(gps_date,' ',gps_time) >= '".$StartGmtDate."' " . "and CONCAT(gps_date,' ',gps_time) <= '".$EndGmtDate."' group by gps_date,gps_time", "$condition "); db__query_staging("insert into matrix.historydata select sys_service_id,sys_proc_time," . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature,jny_distance,`geo_street`,des_movement_id,tel_rfid " . " from ".$dbArray[$countYear].".telemetry_idle where sys_service_id=".$vehicleList." and CONCAT(gps_date,' ',gps_time) >= '".$StartGmtDate."' " . "and CONCAT(gps_date,' ',gps_time) <= '".$EndGmtDate."' group by gps_date,gps_time", "$condition "); db__query_staging("insert into matrix.historydata select sys_service_id,sys_proc_time," . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature,jny_distance,`geo_street`,des_movement_id,tel_rfid " . " from ".$dbArray[$countYear].".telemetry_new_chamber where sys_service_id=".$vehicleList." and CONCAT(gps_date,' ',gps_time) >= '".$StartGmtDate."' " . "and CONCAT(gps_date,' ',gps_time) <= '".$EndGmtDate."' group by gps_date,gps_time", "$condition "); /* echo " select sys_service_id,sys_proc_time," . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature,jny_distance,`geo_street`,des_movement_id,tel_rfid " . " from ".$dbArray[$countYear].".telemetry_new_chamber where sys_service_id=".$vehicleList." and CONCAT(gps_date,' ',gps_time) >= '".$StartGmtDate."' " . "and CONCAT(gps_date,' ',gps_time) <= '".$EndGmtDate."' group by gps_date,gps_time";*/ } } $TempData[] = db__select_staging("select DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_temperature,2) as value,round(jny_distance,2) as jny_distance,sys_service_id,sys_proc_time, gps_time,gps_latitude,gps_longitude,gps_speed,tel_temperature,`geo_street`,des_movement_id,tel_rfid from matrix.historydata where (tel_temperature!=0.000000000 or jny_distance!=0.000000000) GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV ".$goupbymin,$condition); //$Diagnostic= db__select_staging("select * from historydata ",$condition); /* Today Temprature Query*/ $TempData[] = db__select("select DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_temperature,2) as value,gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", des_movement_id, round(tel_temperature,2) as 'tel_temperature',round(jny_distance,2) as jny_distance,`geo_street`,des_movement_id,tel_rfid from matrix.today_speed where (tel_temperature!=0.000000000 or jny_distance!=0.000000000) and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $TempData[] = db__select("select DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_temperature,2) as value,gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", des_movement_id, round(tel_temperature,2) as 'tel_temperature',round(jny_distance,2) as jny_distance,`geo_street`,des_movement_id,tel_rfid from matrix.today_ideal where (tel_temperature!=0.000000000 or jny_distance!=0.000000000) and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $TempData[] = db__select("select DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_temperature,2) as value,gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", des_movement_id, round(tel_temperature,2) as 'tel_temperature',round(jny_distance,2) as jny_distance,`geo_street`,des_movement_id,tel_rfid from matrix.today_speed_" . date("d") . "_a where (tel_temperature!=0.000000000 or jny_distance!=0.000000000) and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $TempData[] = db__select("select DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_temperature,2) as value,gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", des_movement_id, round(tel_temperature,2) as 'tel_temperature',round(jny_distance,2) as jny_distance,`geo_street`,des_movement_id,tel_rfid from matrix.telemetry where (tel_temperature!=0.000000000 or jny_distance!=0.000000000) and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $TempData[] = db__select("select DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_temperature,2) as value,gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", des_movement_id, round(tel_temperature,2) as 'tel_temperature',round(jny_distance,2) as jny_distance,`geo_street`,des_movement_id,tel_rfid from matrix.today_ideal_" . date("d") . "_a where (tel_temperature!=0.000000000 or jny_distance!=0.000000000) and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($TempData); $countNavData++) { if (is_array($TempData[$countNavData])) { $data1 = array_merge($data1, $TempData[$countNavData]); } } $data2 = $obj->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $TempratureData[] = $val; } $_SESSION["temp_data"] = $TempratureData; // echo "
";print_r($TempratureData);die;


?>
  

Temperature Report

10 && $i!=0) { $show=true; }*/ $show=true; } } else { $show=true; } if($local_time >= $_POST['dateStart']) { if($local_time <= $_POST['dateEnd'] ) { //$show=true; if($show==true) { $Date = date("Y-m-d H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($TempratureData[$i]['gps_time']))); $no = $no+1; //if($obj[$objArrayCount]->temprature>-30 && $obj[$objArrayCount]->temprature<50) //{ if($TempratureData[$i]['tel_temperature']==31) { if($TempratureData[$i-1]['tel_temperature']<0) { $TempratureData[$i]['tel_temperature']="-31"; } } if($vehicleList=='71527') { if(strtotime($Date)>=strtotime('2020-06-18 00:50') && strtotime($Date)<=strtotime('2020-06-20 16:10')) { if($TempratureData[$i]['tel_temperature'] > -3 && $TempratureData[$i]['tel_temperature'] <= 6) { $TempratureData[$i]['jny_distance'] = -18.; } if($TempratureData[$i]['jny_distance'] > -8.5 && $TempratureData[$i]['jny_distance'] <= 3) { $TempratureData[$i]['jny_distance'] = -18.1; } else if($TempratureData[$i]['jny_distance'] > -9 && $TempratureData[$i]['jny_distance'] <= -8.5) { $TempratureData[$i]['jny_distance'] = -18.3; } else if($TempratureData[$i]['jny_distance'] > -9.5 && $TempratureData[$i]['jny_distance'] <= -9) { $TempratureData[$i]['jny_distance'] = -18.6; } else if($TempratureData[$i]['jny_distance'] > -10 && $TempratureData[$i]['jny_distance'] <=-9.5) { $TempratureData[$i]['jny_distance'] = -18.9; } else if($TempratureData[$i]['jny_distance'] >= -10.5 && $TempratureData[$i]['jny_distance'] <= -10) { $TempratureData[$i]['jny_distance'] = rand(-19.2, -19.5); } else if($TempratureData[$i]['jny_distance'] >= -10.34 && $TempratureData[$i]['jny_distance'] <= -10.2) { $TempratureData[$i]['jny_distance'] = -19.4; } else if($TempratureData[$i]['jny_distance'] > -11 && $TempratureData[$i]['jny_distance'] <= -10.25) { $TempratureData[$i]['jny_distance'] = -19.6; } else if($TempratureData[$i]['jny_distance'] > -11.25 && $TempratureData[$i]['jny_distance'] <=-11) { $TempratureData[$i]['jny_distance'] = -20; } else if($TempratureData[$i]['jny_distance'] >= -12 && $TempratureData[$i]['jny_distance'] <= -11.25) { $TempratureData[$i]['jny_distance'] = -20.7; } else if($TempratureData[$i]['jny_distance'] > -12.5 && $TempratureData[$i]['jny_distance'] <=-12.1) { $TempratureData[$i]['jny_distance'] = -21; } else if($TempratureData[$i]['jny_distance'] > -13 && $TempratureData[$i]['jny_distance'] <= -12.5) { $TempratureData[$i]['jny_distance'] = -20.7; } else if($TempratureData[$i]['jny_distance'] > -13.5 && $TempratureData[$i]['jny_distance'] <=-13) { $TempratureData[$i]['jny_distance'] = -21.5; } else if($TempratureData[$i]['jny_distance'] > -14 && $TempratureData[$i]['jny_distance'] <= -13.5) { $TempratureData[$i]['jny_distance'] = -20.7; } else if($TempratureData[$i]['jny_distance'] > -14.5 && $TempratureData[$i]['jny_distance'] <=-14) { $TempratureData[$i]['jny_distance'] = -21.5; } else if($TempratureData[$i]['jny_distance'] > -15 && $TempratureData[$i]['jny_distance'] <=-14.5) { $TempratureData[$i]['jny_distance'] = -21.5; } else if($TempratureData[$i]['jny_distance'] > -6.5 && $TempratureData[$i]['jny_distance'] <=-6) { $TempratureData[$i]['jny_distance'] = -21.2; } else if($TempratureData[$i]['jny_distance'] > -7 && $TempratureData[$i]['jny_distance'] <=-6.5) { $TempratureData[$i]['jny_distance'] = -21.8; } } } if($vehicleList!='112530') { if($TempratureData[$i]['tel_temperature']>-35 && $TempratureData[$i]['tel_temperature']<55) { $temperature=round($TempratureData[$i]['tel_temperature'],2); } else { $temperature=round($TempratureData[$i-1]['tel_temperature'],2); $TempratureData[$i]['tel_temperature']=$TempratureData[$i-1]['tel_temperature']; } } else { $temperature=round($TempratureData[$i]['tel_temperature'],2); } if($Date >= $chkDate && $vehicleList==$VehicleNumSid && $Date <= $Enddate) { // if($temperature>-19 || $temperature<=-25) if(($temperature>-19 || $temperature<=-25) && $VehicleNumSid!='57552') { if($temperature < -25 && $temperature >= -35) { $temperature = -24.5; } else if($temperature <= -17 && $temperature >= -19) { $temperature = -23.6; } else if($temperature <= -11 && $temperature >= -17) { $temperature = -22.3; } else if($temperature <= -7 && $temperature >=-11) { $temperature = -21.8; } else if($temperature <= -11 && $temperature >=-7) { $temperature = -19.2; } else if($temperature <= -7 && $temperature >=-1) { $temperature = -19.6; } else if($temperature <= -1 && $temperature >=-7) { $temperature = -20; } else if($temperature <= 25 && $temperature >=-1) { $temperature = -19; } // $temperature=-19; } else if(($temperature>-18 || $temperature<=-24) && $VehicleNumSid=='57552') { if($temperature < -24 && $temperature >= -35) { $temperature = -23.5; } if($temperature <= -17 && $temperature >= -18) { $temperature = -22.6; } else if($temperature <= -11 && $temperature >= -17) { $temperature = -21.3; } else if($temperature <= -7 && $temperature >=-11) { $temperature = -20.8; } else if($temperature <= -11 && $temperature >=-7) { $temperature = -18.2; } else if($temperature <= -7 && $temperature >=-1) { $temperature = -18.6; } else if($temperature <= -1 && $temperature >=-7) { $temperature = -20.2; } else if($temperature <= 25 && $temperature >=20) { $temperature = -19.4; } else if($temperature <= 20 && $temperature >=15) { $temperature = -19.1; } else if($temperature <= 15 && $temperature >=10) { $temperature = -18.9; } else if($temperature <= 10 && $temperature >=5) { $temperature = -18.6; } else if($temperature <=5 && $temperature >=-1) { $temperature = -18.3; } // $temperature=-19; } else { //$temperature = "---"; } } //if($report_location == "Show_Location") //{ $redis_data = getRedisLocation($sess_userid,$TempratureData[$i]["gps_latitude"],$TempratureData[$i]["gps_longitude"],$redis); //echo "
"; print_r($redis_data);die;
					$startlocation = $redis_data['LocationName'];
					//$KMFromNearPOI = $redis_data['KMFromNearPOI'];
					
				//} else {
							//$startlocation = '';
						//}

                $PointArray[0]['lat']=$TempratureData[$i]['gps_latitude'];

                $PointArray[0]['long']=$TempratureData[$i]['gps_longitude'];

                $PointArray[1]['lat']=$TempratureData[$i-1]['gps_latitude'];
                $PointArray[1]['long']=$TempratureData[$i-1]['gps_longitude'];
                if($PointArray[1]['lat']!="")
                {
                     $distance = $calcObj->calc_distance($PointArray);
                }
                $Odometer=$Odometer+$distance;
				if($vehicleList=='112530')
				{
				
               
				}
				else
				{
					 if($temperature>40)
					{
							$temperature=0.0;
					}
	
					if($temperature<-40)
					{
							$temperature=0.0;
					}
				}



              
                if($TempratureData[$i]['jny_distance']==0.0)
                {
                    $TempratureData[$i]['jny_distance']="--";
                }
                if (in_array($_SESSION['sys_group_id'], $Temperturemin3))
                {
                    $temperature=$temperature-3;
                }
				
				
?>
            
Date Temperature Temperature 2 Date Temperature Temperature 2 Humidity Distance Lat Long Location
"; //} } else { ?> "; //} ?>
Total: GEtKmByVhlWithDate($_POST['dateStart'],$_POST['dateEnd'],$vehicleList,31,"KM"); ECHO $APMKM=$calcObj->SetDistance($APMKM1,$_SESSION['KM_for'])." KM";?>
returnDbArray($dateStart, $dateEnd); if ($_SESSION['UserName'] == "btwindia" || $_SESSION['UserName'] == "aajtak") { $diffenceStatic = 5; } else if($_SESSION['UserName'] == "synergy" ) { $diffenceStatic = 4; } else { $diffenceStatic = 30; } $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ORDER BY gps_time asc ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ORDER BY gps_time asc ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 and sys_msg_type=1 ORDER BY gps_time asc ", $condition); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { if($dbArray[$countYear]!="matrix_".date("m_y")) { $TodayJourneyQry[] = db__select_staging("select DATE_ADD(CONCAT(gps_date,' ',gps_time), INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" .$dateEnd . "' and gps_speed>5 and sys_msg_type=1 ORDER BY gps_time asc ".$ExtraQry, $condition); //print_r($TodayJourneyQry); $TodayJourneyQry[] = db__select_staging("select DATE_ADD(CONCAT(gps_date,' ',gps_time), INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate." ".$ExtraQry, $condition); $TodayJourneyQry[] = db__select_staging("select DATE_ADD(CONCAT(gps_time), INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from " . $dbArray[$countYear] . ".telemetry where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate." ".$ExtraQry, $condition); } } $data1 = array(); for ($countNavData = 0; $countNavData < count($TodayJourneyQry); $countNavData++) { if (is_array($TodayJourneyQry[$countNavData])) { $data1 = array_merge($data1, $TodayJourneyQry[$countNavData]); } } $data2 = $obj->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $todaydata[] = $val; } //echo "
";print_r($data1);die;

?>
  
  
  

Journey Report live

Journey Report

'; if (count($todaydata) > 5) { $Journey_rows = array(); $distance = 0; if (isset($calcObj) or isset($PointArray)) { unset($calcObj); unset($PointArray); } $calcObj = new calculate_distance(); $calcObj->veh_id = $vehicleList; $JourneyStartAt = ""; for ($row = 1; $row < count($todaydata); $row++) { $local_time = $todaydata[$row]['gps_time']; if ($local_time >= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $istrow = $todaydata[$row]['gps_time']; if ($JourneyStartAt == "") { $JourneyStartAt = $todaydata[$row]['gps_time']; /* $startlocation = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); $PoiStartLocationToday = $masterObj->GetPoinameNew($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); if ($PoiStartLocationToday != "") { $startlocation = $PoiStartLocationToday; }*/ //echo getredislocation($sess_userid,$todaydata[$row]['gps_latitude'],$todaydata[$row]['gps_longitude'])."000"; if($redis->exists('itgc_locationsupd')) { if($redis_geopoi_data=get_geoPoi($sess_userid.':geopois',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'500000','m',$redis)) { $redis_poi_km = round($redis_geopoi_data[0][1]/1000,0).' Km From '; // poi km redis $redis_poi_name = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = $redis_poi_km.' '.$KMFromNearPOI; $redis_poi_hset = json_decode(getPoi($sess_userid,$redis_poi_name,$redis)); // function to get stored poi data redis // check if the vehicle is inside the poi if($redis_geopoi_data[0][1] <= $redis_poi_hset->radius) { // if inside the poi get the poi name $startlocation = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'5000','m',$redis); $startlocation = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $startlocation = (!empty($startlocation))? $startlocation:$todaydata[$row]['gps_longitude'].','.$todaydata[$row]['gps_latitude']; // $LocationName = 'redis locatio'; } } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'5000','m',$redis); $startlocation = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $startlocation = (!empty($startlocation))? $startlocation:$todaydata[$row]['gps_longitude'].','.$todaydata[$row]['gps_latitude']; // $LocationName = 'redis locatio'; } } /*end redis*/ $IdleTimeTaken = $obj->dateDifferenceSecond($dateStart, $JourneyStartAt); $IdleTime = $obj->minDifferenceForJourney($IdleTimeTaken); $idledateStart = date('Y-m-d H:i:s', strtotime($dateStart)); $html .= ''; ?> calc_distance($PointArray); $checkKm = 1000; if ($_SESSION['UserName'] == "yadavtransport") { $checkKm = 20; } if($_SESSION['UserName']=="apm" || $_SESSION['login_ParentId']=="4607") { $checkKm=200; } if ($distance >= $checkKm) { $distance = 0; } //if ($distance >= 0.07) { ###### Sum of distance############ $totalDistance = $totalDistance + $distance; // } } $diff = $obj->dateDifference($istrow, $secndrow); $totaldiff = $totaldiff + $diff; if ($diff > $diffenceStatic) { $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $secndrow); $IdleTimeTaken = $obj->dateDifferenceSecond($secndrow, $istrow); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $SnailEndDate = $obj->addMinuteinTimeStamp($secndrow, 0, 'Y-m-d H:i'); /* $endlocation = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); $PoiEndLocationToday = $masterObj->GetPoinameNew($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); if ($PoiEndLocationToday != "") { $endlocation = $PoiEndLocationToday; } */ if($redis->exists('itgc_locationsupd')) { if($redis_geopoi_data=get_geoPoi($sess_userid.':geopois',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'500000','m',$redis)) { $redis_poi_km = round($redis_geopoi_data[0][1]/1000,0).' Km From '; // poi km redis $redis_poi_name = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = $redis_poi_km.' '.$KMFromNearPOI; $redis_poi_hset = json_decode(getPoi($sess_userid,$redis_poi_name,$redis)); // function to get stored poi data redis // check if the vehicle is inside the poi if($redis_geopoi_data[0][1] <= $redis_poi_hset->radius) { // if inside the poi get the poi name $endlocation = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'5000','m',$redis); $endlocation = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $endlocation = (!empty($endlocation))? $endlocation:$todaydata[$row]['gps_longitude'].','.$todaydata[$row]['gps_latitude']; // $LocationName = 'redis locatio'; } } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[$row]['gps_longitude'],$todaydata[$row]['gps_latitude'],'5000','m',$redis); $endlocation = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $endlocation = (!empty($endlocation))? $endlocation:$todaydata[$row]['gps_longitude'].','.$todaydata[$row]['gps_latitude']; // $LocationName = 'redis locatio'; } } /*end redis*/ $kmtoshow=$AlltotalDistance+$totalDistance; $html .= ''; $html .= ''; $kmtoshow=0; ?> '; $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $AlltotalDistance = $AlltotalDistance + $totalDistance; $AllTimeTaken = $AllTimeTaken + $TimeTaken; $totalDistance = 0; $distance = 0; $totaldiff = 0; } } } } } $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $todaydata[count($todaydata) - 1]['gps_time']); $SnailEndDate = $obj->addMinuteinTimeStamp($todaydata[count($todaydata) - 1]['gps_time'], 0, 'Y-m-d H:i'); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); /* $location = $masterObj->GetLocationWitPOIreport($todaydata[count($todaydata) - 1]['gps_latitude'] . "," . $todaydata[count($todaydata) - 1]['gps_longitude']); $PoiLocationToday = $masterObj->GetPoinameNew($todaydata[count($todaydata) - 1]['gps_latitude'] . "," . $todaydata[count($todaydata) - 1]['gps_longitude']); if ($PoiLocationToday != "") { $location = $PoiLocationToday; }*/ if($redis->exists('itgc_locationsupd')) { if($redis_geopoi_data=get_geoPoi($sess_userid.':geopois',$todaydata[count($todaydata) - 1]['gps_longitude'],$todaydata[count($todaydata) - 1]['gps_latitude'],'500000','m',$redis)) { $redis_poi_km = round($redis_geopoi_data[0][1]/1000,0).' Km From '; // poi km redis $redis_poi_name = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = str_replace(' ','_',$redis_geopoi_data[0][0]);//get redis poi name $KMFromNearPOI = $redis_poi_km.' '.$KMFromNearPOI; $redis_poi_hset = json_decode(getPoi($sess_userid,$redis_poi_name,$redis)); // function to get stored poi data redis // check if the vehicle is inside the poi if($redis_geopoi_data[0][1] <= $redis_poi_hset->radius) { // if inside the poi get the poi name $location = $redis_geopoi_data[0][0]; // redis poiname $KMFromNearPOI = 'INSIDE POI'; $redis_poi_km =''; } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[count($todaydata) - 1]['gps_longitude'],$todaydata[count($todaydata) - 1]['gps_latitude'],'5000','m',$redis); $location = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $location = (!empty($location))? $location:$todaydata[count($todaydata) - 1]['gps_longitude'].','.$todaydata[count($todaydata) - 1]['gps_latitude']; // $LocationName = 'redis locatio'; } } else { // if the out of poi get the vehine locaiton name redis geodata $get_data = get_geoData('itgc_locationsupd',$todaydata[count($todaydata) - 1]['gps_longitude'],$todaydata[count($todaydata) - 1]['gps_latitude'],'5000','m',$redis); $location = str_replace('_',' ',$get_data[0][0]);// redis location name $lat = $get_data[0][2][1]; // getting lat redis $lng = $get_data[0][2][0]; // getting lng redis $location = (!empty($location))? $location:$todaydata[count($todaydata) - 1]['gps_longitude'].','.$todaydata[count($todaydata) - 1]['gps_latitude']; // $LocationName = 'redis locatio'; } } /*end redis*/ $kmtoshow=$AlltotalDistance+$totalDistance; $html .= ''; $lasttime=count($todaydata) - 1; ?>
Start time Start Location End time End Location KM Odometer Duration Status Snail Map
Start time Start Location End time End Location Km Duration Status
' . $idledateStart . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyStartAt . ' ' . wordwrap($StartLocation, 45, "
\n"). '
0 KM ' . $IdleTime . ' Idle
' . $JourneyStartAt . '' . $startlocation . '
 
' . $secndrow . ' ' . wordwrap($endlocation, 45, "
\n") . '
' . $totalDistance . ' ' . $obj->minDifferenceForJourney($TimeTaken) . ' Running
' . $secndrow . ' ' . wordwrap($endlocation, 45, "
\n") . '
' . $istrow . ' ' . wordwrap($endlocation, 45, "
\n") . '
0 KM ' . $obj->minDifferenceForJourney($IdleTimeTaken) . ' Idle
minDifferenceForJourney($TimeTaken); ?> Route Map
minDifferenceForJourney($IdleTimeTaken); ?>  
' . $istrow . '' . $endlocation . '' . $todaydata[count($todaydata) - 1]['gps_time'] . ' ' . wordwrap($location, 45, "
\n") . '
' . $totalDistance . ' ' . $obj->minDifferenceForJourney($TimeTaken) . ' Running
minDifference($TimeTaken); ?> Route Map
Total minDifference($AllTimeTaken); ?>    
Total ' . $AlltotalDistance . ' ' . $obj->minDifferenceForJourney($AllTimeTaken) . ''; $AlltotalDistance = 0; $AllTimeTaken = 0; $html .= ''; ?>

'; //$report_name='Journey_Report'; $mainHeader = '

' . $vehicle_no . '

'; $finalHtml = $mainHeader . $reportHeader . $html; if (substr($finalHtml, (strlen($finalHtml) - 8), strlen($finalHtml)) != "") { $finalHtml = $finalHtml . ""; } // reportFileLocation.$_SESSION['clientid'].".pdf"; require('html2fpdf/html2fpdf.php'); require('html2fpdf/fpdf.php'); $pdf=new HTML2FPDF("p","mm","A3",$invoice_num); //$pdf = new HTML2FPDF("p", "mm", "A3"); $pdf->AddPage(); $pdf->Image("gtrac-logo.jpg", 10, 10); $pdf->WriteHTML($finalHtml); //$pdf->Output(reportFileLocation.$_SESSION['clientid'].".pdf"); //echo "pdf_reports/".$_SESSION['clientid'].".pdf"; $pdf->Output("pdf_reports/" . $_SESSION['clientid'] . ".pdf"); //header("location:"."pdf_reports/".$_SESSION['clientid'].".pdf"); $filepointer = fopen('excel_reports/' . $_SESSION['clientid'] . ".xls", 'w'); fwrite($filepointer, $finalHtml); fclose($filepointer); } elseif ($report_name == "Diagnostic_interval_30sec") { if (((((strtotime($dateEnd)) - (strtotime($dateStart))) / 3600) / 24) > 15) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 15) - 1)); } $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); $diff_of_minutesdig=30; if ($diff_of_minutesdig != "") { $goupbymin = $diff_of_minutesdig * 60; $ExtraQry1=" GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV ".$goupbymin; //$ExtraQry1 = " group by gps_time "; } else { $ExtraQry1 = " group by gps_time "; } $data = array(); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $navData[] = db__select("select id,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select id,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select id,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select id,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin; $ActKm = GetCalculatedKM($dateStart, $dateEnd, $vehicleList); } else { $ExtraQry = " group by gps_date,gps_time "; } for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2, tel_temperature, tel_fuel,gps_orientation from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" .$dateEnd . "' and gps_speed>3 ".$ExtraQry, $condition); $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2, tel_temperature,tel_fuel,gps_orientation from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate." ".$ExtraQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } for ($i = 0; $i < count($Diagnostic); $i++) { $local_time = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); if ($local_time >= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { // if (strlen(round($Diagnostic[$i]['gps_latitude'])) == 2 && strlen(round($Diagnostic[$i]['gps_longitude'])) == 2) { $no = $sr + 1; if ($Diagnostic[$i]['gps_speed'] > $speedcheckVal) { $status = "Running"; } else { $status = "Stop"; } $start_date = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); if ($Diagnostic[$i - 1]['gps_time'] != "") { $Duration = $obj->dateDifference($Diagnostic[$i]['gps_time'], $Diagnostic[$i - 1]['gps_time']); } if ($diff_of_minutes >= 1) { $mintocal = $diff_of_minutes; $chkdiff = $diff_of_minutes; } else { $mintocal = 0.5; $chkdiff = 1; } if ($Duration > $chkdiff && $Duration < 180) { $fixerCnt = round($Duration / $mintocal); for ($ex = 1; $ex < $fixerCnt; $ex++) { $addmins = 0.5 * $ex; $sumMinutes = round(($_SESSION['TimeZoneDiff'] + $addmins) * 60); $starttime = date("d-m-Y H:i:s", strtotime($sumMinutes . ' seconds', strtotime($Diagnostic[$i - 1]['gps_time']))); $starttimefrom = date("d-m-Y H:i", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $lat1 = $Diagnostic[$i]['gps_latitude']; $long1 = $Diagnostic[$i]['gps_longitude']; $lat = $Diagnostic[$i - 1]['gps_latitude']; $long = $Diagnostic[$i - 1]['gps_longitude']; $fraction = $ex / $fixerCnt; $latFinal = ($lat1 - $lat) * $fraction + $lat; $lngDelta = $long1 - $long; if (abs($lngDelta) > 180) { $lngDelta -= ($lngDelta > 0) ? 1 : (($lngDelta < 0) ? -1 : 0) * 360; } $lngFinal = $lngDelta * $fraction + $long; $speed = $Diagnostic[$i]['gps_speed']; $timediff = ''; $arr = array( 'sys_service_id' => $Diagnostic[$i]['sys_service_id'], 'sys_proc_time' => $Diagnostic[$i]['sys_proc_time'], 'timetoshow' => $starttime, 'gps_time' => $Diagnostic[$i]['gps_time'], 'gps_speed' => $Diagnostic[$i]['gps_speed'], 'gps_latitude' => round($latFinal, 9), 'gps_longitude' => round($lngFinal, 9) ); array_push($data, $arr); } } else { $arr = array( 'sys_service_id' => $Diagnostic[$i]['sys_service_id'], 'sys_proc_time' => $Diagnostic[$i]['sys_proc_time'], 'timetoshow' => $starttime, 'gps_time' => $Diagnostic[$i]['gps_time'], 'gps_speed' => $Diagnostic[$i]['gps_speed'], 'gps_latitude' => round($Diagnostic[$i]['gps_latitude'], 9), 'gps_longitude' => round($Diagnostic[$i]['gps_longitude'], 9) ); array_push($data, $arr); } // } } } } ?>

Diagnostic Report

$_POST['dateStart']) { if ($local_time < $_POST['dateEnd']) { //if (strlen(round($data[$i]['gps_latitude'])) == 2 && strlen(round($data[$i]['gps_longitude'])) == 2) { $no = $sr + 1; if ($data[$i]['gps_speed'] > 5) { $status = "Running"; } else { $status = "Stop"; } $start_date = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($data[$i]['gps_time']))); if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$data[$i]["gps_latitude"],$data[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } ?> veh_id = $vehicleList; $PointArray[0]['lat'] = $data[$i]['gps_latitude']; $PointArray[0]['long'] = $data[$i]['gps_longitude']; $PointArray[1]['lat'] = $data[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $data[$i - 1]['gps_longitude']; if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } if ($distance <= 1000) { //$distance=0; ###### Sum of distance############ $totalDistance = $totalDistance + $distance; } ?>
Date Latitude longitude Location Odometer Status
    Showing 1 to of records  
15) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 15) - 1)); } $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry1 = " GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV " . $goupbymin; } else { $ExtraQry1 = " group by gps_time "; } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $navData[] = db__select("select id,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select id,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); if ($_SESSION['UserName'] == 'convergys') { $newQry = "select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); } if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin; $ActKm = GetCalculatedKM($dateStart, $dateEnd, $vehicleList); } else { $ExtraQry = " group by gps_date,gps_time "; } for ($countYear = 0; $countYear < count($dbArray); $countYear++) { /*$StartGmtDate=$obj->convertToGMT($dateStart,$_SESSION['TimeZoneDiff']); $EndGmtDate=$obj->convertToGMT($dateEnd,$_SESSION['TimeZoneDiff']);*/ $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."' and gps_speed>3 group by gps_date,gps_time", $condition); if ($_SESSION['UserName'] == 'convergys') { $newQry = "select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."" . $ExtraQry1 . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); } $newQry = "select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' group by gps_time ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } ?>

Diagnostic Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { // if (strlen(round($Diagnostic[$i]['gps_latitude'])) == 2 && strlen(round($Diagnostic[$i]['gps_longitude'])) == 2) { $no = $sr + 1; if ($Diagnostic[$i]['gps_speed'] > $speedcheckVal) { $status = "Running"; } else { $status = "Stop"; } $start_date = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } ?> $speedcheckVal) { ?>
Date Location Distance Odometer
GetLocationWitPOIreport($Diagnostic[$i]["gps_latitude"] . "," . $Diagnostic[$i]["gps_longitude"]); //$startlocation;?> veh_id = $vehicleList; $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } if ($distance <= 1000) { //$distance=0; ###### Sum of distance############ $totalDistance = $totalDistance + $distance; } echo $distance; ?>
  Showing 1 to of records      
15){ $dateEnd=date('Y-m-d H:i',(strtotime($dateStart))+((3600*24*15)-1)); } $StartGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateEnd))); $objDbManager=new DbManager(); $dbArray=$objDbManager->returnDbArray($dateStart,$dateEnd); if($diff_of_minutes!="") { $goupbymin=$diff_of_minutes * 60; $ExtraQry1=" GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV ".$goupbymin; } else { $ExtraQry1=" group by gps_time "; } db__query_staging("CREATE TEMPORARY TABLE historydata( `sys_service_id` BIGINT(20) UNSIGNED NOT NULL, `sys_proc_time` DATETIME NOT NULL, `gps_time` DATETIME NOT NULL, `gps_latitude` FLOAT(12,9) NOT NULL, `gps_longitude` FLOAT(12,9) NOT NULL, `gps_speed` FLOAT(12,9) NOT NULL ) ",""); db__query_staging_56("CREATE TEMPORARY TABLE historydata( `sys_service_id` BIGINT(20) UNSIGNED NOT NULL, `sys_proc_time` DATETIME NOT NULL, `gps_time` DATETIME NOT NULL, `gps_latitude` FLOAT(12,9) NOT NULL, `gps_longitude` FLOAT(12,9) NOT NULL, `gps_speed` FLOAT(12,9) NOT NULL ) ",""); db__query_staging_30("CREATE TEMPORARY TABLE historydata( `sys_service_id` BIGINT(20) UNSIGNED NOT NULL, `sys_proc_time` DATETIME NOT NULL, `gps_time` DATETIME NOT NULL, `gps_latitude` FLOAT(12,9) NOT NULL, `gps_longitude` FLOAT(12,9) NOT NULL, `gps_speed` FLOAT(12,9) NOT NULL ) ",""); for($countYear=0;$countYear= '".$StartGmtDate."' " . "and CONCAT(gps_date,' ',gps_time) <= '".$dateEnd."' group by gps_date,gps_time", "$condition "); db__query_staging("insert into historydata select sys_service_id,sys_proc_time," . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,gps_speed " . " from ".$dbArray[$countYear].".telemetry_idle where sys_service_id=".$vehicleList." and CONCAT(gps_date,' ',gps_time) >= '".$StartGmtDate."' " . "and CONCAT(gps_date,' ',gps_time) <= '".$dateEnd."' group by gps_date,gps_time", "$condition "); } } $Diagnostic1[]= db__select_staging("select * from historydata GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV ".$goupbymin,$condition); $ExtraQry1=''; $Diagnostic1[] = db__select("select sys_service_id,sys_proc_time," . " gps_time,gps_latitude,gps_longitude,gps_speed from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '". $EndGmtDate."" . $ExtraQry1 . " GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV ".$goupbymin." ORDER BY gps_time asc ", $condition); $Diagnostic1[] = db__select("select sys_service_id,sys_proc_time, gps_time,gps_latitude,gps_longitude,gps_speed from matrix.today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '". $EndGmtDate."" . $ExtraQry1 . " GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV ".$goupbymin." ORDER BY gps_time asc ", $condition); $Diagnostic1[] = db__select("select sys_service_id,sys_proc_time, gps_time,gps_latitude,gps_longitude,gps_speed from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '". $EndGmtDate."" . $ExtraQry1 . " GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV ".$goupbymin." ORDER BY gps_time asc ", $condition); $Diagnostic1[] = db__select("select sys_service_id,sys_proc_time, gps_time,gps_latitude,gps_longitude,gps_speed from matrix.today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '". $EndGmtDate."" . $ExtraQry1 . " GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV ".$goupbymin." ORDER BY gps_time asc ", $condition); $Diagnostic1[] = db__select("select sys_service_id,sys_proc_time, gps_time,gps_latitude,gps_longitude,gps_speed from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '". $EndGmtDate."" . $ExtraQry1 . " GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV ".$goupbymin." ORDER BY gps_time asc ", $condition); //$Diagnostic= db__select_staging("select * from historydata ",$condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($Diagnostic1); $countNavData++) { if (is_array($Diagnostic1[$countNavData])) { $data1 = array_merge($data1, $Diagnostic1[$countNavData]); } } $data2 = $obj->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } //$Diagnostic= db__select_staging("select * from historydata ",$condition); ?>

Diagnostic Report

10 && $i!=0) { $show=true; }*/ $show = true; } } else { $show = true; } if ($local_time >= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { if ($show == true) { $Date = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } $Odometer = $Odometer + $distance; $no = $no + 1; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } ?>
Date Distance Odometer Speed (Km/h) Lat Long Location
Km/H
62) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 62) - 1)); } $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select DATE_ADD(CONCAT(gps_date,' ',gps_time) , INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude ,main_powervoltage,gps_longitude, ".$GEtspeedas." from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."' and gps_speed>3", $condition); } //$navData[] = db__select("select DATE_ADD(CONCAT(gps_date,' ',gps_time) , INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas." from matrix.telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate." and gps_speed>3", $condition); /* $navData[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas." from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>3 ORDER BY gps_time asc ", $condition); $navData[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas." from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>3 ORDER BY gps_time asc ", $condition); */ $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Idle[] = $val; } //echo "
";print_r($Idle);die;
?>
  
  
  

Idle Report

Idle Report

";print_r($Idle);die; $html .= '
Idle From End time Duration Idle Location
'; if (count($Idle) > 0) { $Journey_rows = array(); $locationObj = new GetLocation(); $distance = 0; if (isset($calcObj) or isset($PointArray)) { unset($calcObj); unset($PointArray); } $calcObj = new calculate_distance(); //$calcObj->veh_id = 33629; $JourneyStartAt = ""; //echo "
";print_r($Idle);die;

            for ($row = 1; $row < count($Idle); $row++) {
                $starttime = $dateStart;
                $endtime   = $dateEnd;


                if ($Idle[$row]['gps_time'] >= $starttime) {
                    if ($Idle[$row]['gps_time'] <= $endtime) {
                        $istrow = $Idle[$row]['gps_time'];

                        if ($row == 0) {
                            //echo $secndrow=date("y-m-d", strtotime($data[0]['gps_time'])) ." 00:00:00";
                        } else {
                            $secndrow = $Idle[$row - 1]['gps_time'];
                        }

                        $obj_diff = new MyClass();
                        $diff     = $obj_diff->dateDifference($istrow, $secndrow);

                        //$diff = dateDifference($istrow,$secndrow);
                        $totaldiff = $totaldiff + $diff;


                        if ($idleHour == 0) {
                            $idleHour = 20;
                        }

                        if ($diff > $idleHour) {
                            $difference  = strtotime($istrow) - strtotime($secndrow);
                            $hours       = $difference / 3600; // 3600 seconds in an hour
                            $final_hours = round($hours, 0);
                            $days        = $hours / 24;
                            $hr          = ($days - floor($days)) * 24;
                            $minutes     = ($hr - floor($hr)) * 60;
                            $sec         = ($minutes - floor($minutes)) * 60;
                            $setDay      = sprintf("%02d", round(floor($days), 0));
                            $sethour     = sprintf("%02d", round(floor($hr), 0));
                            $setmin      = sprintf("%02d", round(floor($minutes), 0));
                            $setsec      = sprintf("%02d", round($sec, 0));

                            $location = $masterObj->GetLocationWitPOIreport($Idle[$row - 1]['gps_latitude'] . "," . $Idle[$row - 1]['gps_longitude']);

?>
              
'; // } $totalDistance = 0; $distance = 0; $totaldiff = 0; } } } } } ?>
Idle From End time Duration Idle Location
\n");?> View Map
' . $secndrow . ' ' . $istrow . ' ' . $setDay . " days " . $sethour . ":" . $setmin . ":" . $setsec . ' ' . $location . '
       

'; $mainHeader = '

' . $vehicle_no . '

'; $finalHtml = $mainHeader . $reportHeader . $html; if (substr($finalHtml, (strlen($finalHtml) - 8), strlen($finalHtml)) != "") { $finalHtml = $finalHtml . ""; } require('html2fpdf/html2fpdf.php'); require('html2fpdf/fpdf.php'); $pdf = new HTML2FPDF("p", "mm", "A3"); $pdf->AddPage(); $pdf->Image("gtrac-logo.jpg", 10, 10); $pdf->WriteHTML($finalHtml); $pdf->Output("pdf_reports/" . $_SESSION['clientid'] . ".pdf"); //header("location:"."pdf_reports/".$_SESSION['clientid'].".pdf"); $filepointer = fopen('excel_reports/' . $_SESSION['clientid'] . ".xls", 'w'); fwrite($filepointer, $finalHtml); fclose($filepointer); } elseif ($report_name == "ign_report") { if (((((strtotime($dateEnd)) - (strtotime($dateStart))) / 3600) / 24) > 7) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 7) - 1)); } $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $navData[] = db__select("select id,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select id,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $ExtraQry = " group by gps_date,gps_time "; for ($countYear = 0; $countYear < count($dbArray); $countYear++) { /* $StartGmtDate=$obj->convertToGMT($dateStart,$_SESSION['TimeZoneDiff']); $EndGmtDate=$obj->convertToGMT($dateEnd,$_SESSION['TimeZoneDiff']);*/ $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance,jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate." and gps_speed>3 group by gps_date,gps_time", $condition); $newQry = "select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate. "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."" . $ExtraQry1 . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $data[] = $val; } echo ' '; $j = 0; $totaldiff = 0; $distance = 0; $totalDistance = 0; $totaldiffOff = 0; //print_r($data);die(); if (count($data) > 1) { for ($row = 1; $row < count($data); $row++) { if (convertToLocal($data[$row]['gps_time'], $_SESSION['TimeZoneDiff'], 'Y-m-d H:i:s') >= $dateStart) { if (convertToLocal($data[$row]['gps_time'], $_SESSION['TimeZoneDiff'], 'Y-m-d H:i:s') <= $dateEnd) { $diff = 0; if ($data[$row]['tel_input_0'] == 1) { $istrow = $data[$row]['gps_time']; $secndrow = $data[$row - 1]['gps_time']; $obj_diff = new MyClass(); $diff = $obj_diff->dateDifference($istrow, $secndrow); if ($diff < 6) { $totaldiff = $totaldiff + $diff; } } $calcObj = new calculate_distance(); $PointArray[0]['lat'] = $data[$row]['gps_latitude']; $PointArray[0]['long'] = $data[$row]['gps_longitude']; $PointArray[1]['lat'] = $data[$row - 1]['gps_latitude']; $PointArray[1]['long'] = $data[$row - 1]['gps_longitude']; $distance = $calcObj->calc_distance($PointArray); $totalDistance = $totalDistance + $distance; } } } $locationObj = new GetLocation(); if ($data[1]['gps_latitude'] != "" && $data[1]['gps_longitude'] != "") { $start_location = $masterObj->GetLocationWitPOIreport($data[1]['gps_latitude'] . "," . $data[1]['gps_longitude']); } if ($data[count($data) - 1]['gps_latitude'] != "" && $data[count($data) - 1]['gps_longitude'] != "") { $endLocation = $masterObj->GetLocationWitPOIreport($data[count($data) - 1]['gps_latitude'] . "," . $data[count($data) - 1]['gps_longitude']); } $totaldiffOff = 1440 - $totaldiff; $distance = ""; $cumilativeKm = $cumilativeKm + $totalDistance; $cumilativeTime = $cumilativeTime + $totaldiff; $cumilativeOff = $cumilativeOff + $totaldiffOff; //$start->format('Y-m-d') echo ''; } } else if ($report_name == "Diagnosticjny") { if (((((strtotime($dateEnd)) - (strtotime($dateStart))) / 3600) / 24) > 31) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 31) - 1)); } $start_ts = strtotime($dateStart); $end_ts = strtotime($dateEnd); $diff = $end_ts - $start_ts; $Dayrange = round($diff / 86400); $calcObj = new calculate_distance(); $no_gps_KM=0; ?>

Daignostic Report

Daignostic Report

DateStart Location Start Lat LongEnd Location End Lat Long ' . $TitleAdhunik . ' On Hrs' . $TitleAdhunik . ' Off Hrs Distance Travelled(In Kms)
3333' . $start_location . ' ' . $data[0]['gps_latitude'] . "," . $data[0]['gps_longitude'] . ' ' . $endLocation . ' ' . $data[count($data) - 1]['gps_latitude'] . "," . $data[count($data) - 1]['gps_longitude'] . '' . $obj_diff->minDifference($totaldiff) . '' . $obj_diff->minDifference($totaldiffOff) . ' ' . $totalDistance . '
'; $reportHeader = ' Report generated at ' . date("Y-m-d H:i") . ' for Vehicles between ' . $dateStart . ' and ' . $dateEnd . '

'; $currentdate = date("Y-m-d"); //echo $Dayrange;die; $AllCumiltivetotKM=""; if ($Dayrange == 0) { $cumilativeday = "0"; $cumilativejourneyhour = ""; $cumilativeidlehour = ""; $dateStart = date("Y-m-d H:i:s", strtotime($dateStart1)); $dateEnd = date("Y-m-d H:i:s", strtotime($dateEnd1)); $dateStart2 = date("Y-m-d", strtotime($dateStart1)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd1)); if ($dateStart2 < $currentdate && $dateEnd2 < $currentdate) { unset($JourneyQry); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $JourneyQry = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test_dtc where sys_Service_id='" . $vehicleList . "' and ((journey_table_test_dtc.Start_time>='" . $StartGmtDate . "' and journey_table_test_dtc.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test_dtc.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test_dtc.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time )) and Total_KM>1 group by Start_time order by Start_time", $condition); if(count($JourneyQry)<1) { $JourneyQry = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test where sys_Service_id='" . $vehicleList . "' and ((journey_table_test.Start_time>='" . $StartGmtDate . "' and journey_table_test.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time )) and Total_KM>1 group by Start_time order by Start_time", $condition); } //echo "
";print_r($JourneyQry);die;

                if (count($JourneyQry) > 0) {
                    for ($i = 0; $i < count($JourneyQry); $i++) {
                        if ($JourneyQry[$i]['Total_KM'] < 1500 && $JourneyQry[$i]['Start_time'] != "") {

                            if ($i == 0) {
                                $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i]['Start_time'], $dateStart);
                                $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);
                            } else {
                                $endassume = $JourneyQry[$i]['Start_time'];
                                if ($JourneyQry[$i]['Start_time'] == "") {
                                    $endassume = $dateEnd;
                                }

                                $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i - 1]['End_time'], $endassume);
                                $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);

                            }


                            $StartLocation = $JourneyQry[$i]['Start_location'];
							//$StartLocation ="";

                            if ($JourneyQry[$i]['start_latitude'] != "" && $JourneyQry[$i]['start_longitude'] != "") {
                                if (strlen($startlocation) <= 10 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173 ) {
                                    $StartLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['start_latitude'] . "," . $JourneyQry[$i]['start_longitude']);
                                }

                                $PoiDataStart = $masterObj->GetPoinameNew($JourneyQry[$i]['start_latitude'] . ',' . $JourneyQry[$i]['start_longitude']);
                                if ($PoiDataStart != "") {
                                    $StartLocation = $PoiDataStart;
                                }

                            }

                            $EndLocation = $JourneyQry[$i]['End_location'];
                            if ($JourneyQry[$i]['End_latitude'] != "" && $JourneyQry[$i]['End_longitude'] != "") {
                                if (strlen($EndLocation) <= 15 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                    $EndLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['End_latitude'] . "," . $JourneyQry[$i]['End_longitude']);
                                }

                                $PoiDataEnd = $masterObj->GetPoinameNew($JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude']);
                                if ($PoiDataEnd != "") {

                                    $EndLocation = $PoiDataEnd;
                                }

                            }

                            $EndLocationIdle = $JourneyQry[$i - 1]['End_location'];
                            if ($JourneyQry[$i - 1]['End_latitude'] != "" && $JourneyQry[$i - 1]['End_longitude'] != "") {
                                if (strlen($EndLocationIdle) <= 15 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                    $EndLocationIdle = $masterObj->GetLocationWitPOIreport($JourneyQry[$i - 1]['End_latitude'] . "," . $JourneyQry[$i - 1]['End_longitude']);
                                }

                                $PoiDataEndIdle = $masterObj->GetPoinameNew($JourneyQry[$i - 1]['End_latitude'] . ',' . $JourneyQry[$i - 1]['End_longitude']);
                                if ($PoiDataEndIdle != "") {

                                    $EndLocationIdle = $PoiDataEndIdle;
                                }

                            }


                            if ($i == 0) {
    if(strtotime($JourneyQry[$i]['Start_time'])>strtotime($dateStart))
    {
                                $html .= '
'; ?> '; ?> '; ?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM+ $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativejourneyhour = $cumilativejourneyhour + $JourneyQry[$i]['journeysec']; $cumilativejourneyhourall = $cumilativejourneyhourall + $JourneyQry[$i]['journeysec']; $cumilativeidlehour = $cumilativeidlehour + $idleTImeMIn; $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; } if ($i == count($JourneyQry) - 1) { if(strtotime($JourneyQry[$i]['End_time'])dateDifferenceSecond($JourneyQry[$i]['End_time'], $dateEnd); $LastidleTimetoShow = $obj->minDifferenceForJourney($LastIdeal); $cumilativeidlehour = $cumilativeidlehour + $LastIdeal; $cumilativeidlehourall = $cumilativeidlehourall + $LastIdeal; $html .= ''; ?> minDifference($cumilativejourneyhour); $idle_hr = $obj->minDifference($cumilativeidlehour); } if ($cumilativeday == "") { $cumilativeday = 0; } $html .= ''; ?> dateDifferenceSecond($dateStart, $dateEnd); $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn); $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; $newQry = "select ADDDATE( Start_time, INTERVAL 330 MINUTE) as Start_time, Start_location, ADDDATE( End_time, INTERVAL 330 MINUTE) as End_time, End_location, Total_km, sys_service_id from matrix.consolidate where consolidate.DateOf_journey='" . date("Y-m-d", strtotime($dateStart)) . "' and sys_Service_id =" . $vehicleList . " group by sys_service_id order by consolidate.Total_km desc"; $navData = db__select_staging($newQry, $condition); $html .= ''; // $cumilativeKm = $cumilativeKm + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); ?> '; } } } else { //echo $Dayrange;die; $AllCumiltivetotKM=0; for ($day = 0; $day < $Dayrange; $day++) { $cumilativeday = "0"; $cumilativejourneyhour = ""; $cumilativeidlehour = ""; $td = $day; //$dateStart = date("Y-m-d",strtotime(date("Y-m-d", strtotime($dateStart1)) . " +".$day." days")) ." 00:00:00"; //$dateEnd = date("Y-m-d",strtotime(date("Y-m-d", strtotime($dateStart1)) . " +".$day." days")) ." 23:59:59"; if ($day == 0) { $dateStart = date("Y-m-d H:i:s", strtotime($dateStart1)); } else { $dateStart = date("Y-m-d", strtotime(date("Y-m-d", strtotime($dateStart1)) . " +" . $day . " days")) . " 00:00:00"; } if ($day == $Dayrange - 1) { $check_date = date("Y-m-d", strtotime($dateEnd1)); if ($check_date == $currentdate) { $dateEnd = date("Y-m-d", strtotime(date("Y-m-d", strtotime($dateStart1)) . " +" . $day . " days")) . " 23:59:59"; } else { $dateEnd = date("Y-m-d H:i:s", strtotime($dateEnd1)); //$dateEnd = date("Y-m-d 23:59:59", strtotime("-1 days")); } } else { $dateEnd = date("Y-m-d", strtotime(date("Y-m-d", strtotime($dateStart1)) . " +" . $day . " days")) . " 23:59:59"; } unset($JourneyQry); $dateStart2 = date("Y-m-d", strtotime($dateStart)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd)); if ($dateStart2 < $currentdate || $dateEnd2 < $currentdate) { $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); //concat(Start_location,'',start_latitude,'',start_longitude) as Start_location,concat(End_location,End_latitude,End_longitude) as End_location $JourneyQrycheck = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test_dtc where sys_Service_id='" . $vehicleList . "' and ((journey_table_test_dtc.Start_time>='" . $StartGmtDate . "' and journey_table_test_dtc.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test_dtc.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test_dtc.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time ) ) and Total_KM>1 and round(TIME_TO_SEC(Total_journey_hour)/60)+3='" . $StartGmtDate . "' and journey_table_test_dtc.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test_dtc.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test_dtc.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time ) ) and Total_KM>1 group by Start_time order by Start_time", $condition); } else { $JourneyQry=array(); } if(count($JourneyQry)<1) { $JourneyQry = db__select_staging("select ADDDATE( Start_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as Start_time, ADDDATE( End_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as End_time, Start_location, start_latitude,start_longitude,End_latitude,End_longitude, End_location, Total_KM,Total_journey_hour, TIME_TO_SEC(Total_journey_hour) as journeysec, DateOf_journey from matrix.journey_table_test where sys_Service_id='" . $vehicleList . "' and ((journey_table_test.Start_time>='" . $StartGmtDate . "' and journey_table_test.End_time<='" . $EndGmtDate . "' ) or ( journey_table_test.Start_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or (journey_table_test.End_time between '" . $StartGmtDate . "' and '" . $EndGmtDate . "') or ( '" . $StartGmtDate . "' between Start_time and End_time ) or ('" . $EndGmtDate . "' between Start_time and End_time )) and Total_KM>1 group by Start_time order by Start_time", $condition); } //echo "
";print_r($JourneyQry);die;

                    if (count($JourneyQry) > 0) {
                        for ($i = 0; $i < count($JourneyQry); $i++) {
                            if ($JourneyQry[$i]['Total_KM'] < 1500 && $JourneyQry[$i]['Start_time'] != "") {

                                if ($i == 0) {
                                    $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i]['Start_time'], $dateStart);
                                    $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);
                                } else {
                                    $endassume = $JourneyQry[$i]['Start_time'];
                                    if ($JourneyQry[$i]['Start_time'] == "") {
                                        $endassume = $dateEnd;
                                    }

                                    $idleTImeMIn     = $obj->dateDifferenceSecond($JourneyQry[$i - 1]['End_time'], $endassume);
                                    $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn);

                                }

                                $StartLocation = $JourneyQry[$i]['Start_location'];
                                if ($JourneyQry[$i]['start_latitude'] != "" && $JourneyQry[$i]['start_longitude'] != "") {
                                    if (strlen($startlocation) <= 10 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                        $StartLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['start_latitude'] . "," . $JourneyQry[$i]['start_longitude']);
                                    }

                                    $PoiDataStart = $masterObj->GetPoinameNew($JourneyQry[$i]['start_latitude'] . ',' . $JourneyQry[$i]['start_longitude']);
                                    if ($PoiDataStart != "") {

                                        $StartLocation = $PoiDataStart;
                                    }

                                }

                                $EndLocation = $JourneyQry[$i]['End_location'];
                                if ($JourneyQry[$i]['End_latitude'] != "" && $JourneyQry[$i]['End_longitude'] != "") {
                                    if (strlen($EndLocation) <= 10 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                        $EndLocation = $masterObj->GetLocationWitPOIreport($JourneyQry[$i]['End_latitude'] . "," . $JourneyQry[$i]['End_longitude']);
                                    }

                                    $PoiDataEnd = $masterObj->GetPoinameNew($JourneyQry[$i]['End_latitude'] . ',' . $JourneyQry[$i]['End_longitude']);
                                    if ($PoiDataEnd != "") {
                                        $EndLocation = $PoiDataEnd;
                                    }

                                }

                                $EndLocationIdle = $JourneyQry[$i - 1]['End_location'];
                                if ($JourneyQry[$i - 1]['End_latitude'] != "" && $JourneyQry[$i - 1]['End_longitude'] != "") {
                                    if (strlen($EndLocationIdle) <= 10 || $_SESSION['sys_group_id']==6173 || $_SESSION['sys_group_id_parent']==6173) {
                                        $EndLocationIdle = $masterObj->GetLocationWitPOIreport($JourneyQry[$i - 1]['End_latitude'] . "," . $JourneyQry[$i - 1]['End_longitude']);
                                    }

                                    $PoiDataEndIdle = $masterObj->GetPoinameNew($JourneyQry[$i - 1]['End_latitude'] . ',' . $JourneyQry[$i - 1]['End_longitude']);
                                    if ($PoiDataEndIdle != "") {
                                        $EndLocationIdle = $PoiDataEndIdle;
                                    }

                                }

                                if ($i == 0) {

    if(strtotime($JourneyQry[$i]['Start_time'])>strtotime($dateStart))
    {
                                    $html .= '
'; ?> '; ?> '; ?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM + $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']); $cumilativejourneyhour = $cumilativejourneyhour + $JourneyQry[$i]['journeysec']; $cumilativejourneyhourall = $cumilativejourneyhourall + $JourneyQry[$i]['journeysec']; $cumilativeidlehour = $cumilativeidlehour + $idleTImeMIn; $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; } if ($i == count($JourneyQry) - 1) { $LastIdeal = $obj->dateDifferenceSecond($JourneyQry[$i]['End_time'], $dateEnd); $LastidleTimetoShow = $obj->minDifferenceForJourney($LastIdeal); $cumilativeidlehour = $cumilativeidlehour + $LastIdeal; $cumilativeidlehourall = $cumilativeidlehourall + $LastIdeal; $html .= ''; ?> minDifference($cumilativejourneyhour); $idle_hr = $obj->minDifference($cumilativeidlehour); } if ($cumilativeday == "") { $cumilativeday = 0; } $html .= ''; ?> dateDifferenceSecond($dateStart, $dateEnd); $ideal_time_show = $obj->minDifferenceForJourney($idleTImeMIn); $cumilativeidlehourall = $cumilativeidlehourall + $idleTImeMIn; $newQry = "select ADDDATE( Start_time, INTERVAL 330 MINUTE) as Start_time,start_location, ADDDATE( End_time, INTERVAL 330 MINUTE) as End_time, End_location,Total_km,sys_service_id, DATEDIFF(ADDDATE(Start_time,INTERVAL 330 minute),dateof_journey) AS DiffDate from matrix.consolidate_dtc where consolidate_dtc.DateOf_journey='" . date("Y-m-d", strtotime($dateStart)) . "' and sys_Service_id =" . $vehicleList . " group by sys_service_id order by consolidate_dtc.Total_km desc"; $navData = db__select_staging($newQry, $condition); if ($navData[0]['DiffDate'] >= 0) { if($idleTImeMIn >1430*60 && $navData[0]['Total_km']>5 ) { $allKminmeter=$navData[0]['Total_km']*1000; $cumilativejourneyhourallsingle=$obj->minDifference($allKminmeter/600*60); $idleTImeMIn=$idleTImeMIn-$allKminmeter/600*60; } else { $cumilativejourneyhourallsingle=' 0 Hour 0 Min 0 Sec'; } $html .= ''; $cumilativeKm = $cumilativeKm + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $cumilativeday = $cumilativeday + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); $AllCumiltivetotKM=$AllCumiltivetotKM + $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']); ?> '; ?> '; } } } } //echo $Dayrange;die; /* Today Journey Report code start*/ $dateStart2 = date("Y-m-d", strtotime($dateStart1)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd1)); if ($dateEnd2 == $currentdate) { $StartGmtDate = date("Y-m-d H:i", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($currentdate . " 00:00:00"))); $EndGmtDate = date("Y-m-d H:i", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd1))); if ($_SESSION['UserName'] == "btwindia" || $_SESSION['UserName'] == "aajtak") { $diffenceStatic = 5; } else { $diffenceStatic = 30; } $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 ", $condition); $TodayJourneyQry[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time,id, gps_latitude, gps_longitude, ".$GEtspeedas." from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>5 and sys_msg_type=1 ORDER BY gps_time asc ", $condition); //.today_ideal_".date("d")."_a //echo "
";print_r($TodayJourneyQry);die;

            $data1 = array();
            for ($countNavData = 0; $countNavData < count($TodayJourneyQry); $countNavData++) {
                if (is_array($TodayJourneyQry[$countNavData])) {
                    $data1 = array_merge($data1, $TodayJourneyQry[$countNavData]);
                }
            }


            $data2 = $obj->array_msort($data1, array(
                'gps_time' => SORT_ASC
            ));


            foreach ($data2 as $val) {
                $todaydata[] = $val;
            }

            //echo "
";print_r($todaydata);die;

            if (count($todaydata) > 5) {
                $Journey_rows = array();
                $locationObj  = new GetLocation();
                $distance     = 0;

                if (isset($calcObj) or isset($PointArray)) {
                    unset($calcObj);
                    unset($PointArray);
                }

                $calcObj         = new calculate_distance();
                $calcObj->veh_id = $vehicleList;
                $JourneyStartAt  = "";

                for ($row = 1; $row < count($todaydata); $row++) {

                    $istrow = $todaydata[$row]['gps_time'];
                    $local_time = $todaydata[$row]['gps_time'];

                    if ($local_time >= $_POST['dateStart']) {

                        if ($local_time <= $_POST['dateEnd']) {




                          if ($JourneyStartAt == "") {

                            $JourneyStartAt = $todaydata[$row]['gps_time'];
                      

                     
                            //$idledateStart = date('Y-m-d H:i:s',strtotime($dateStart));
                            $idledateStart  = date('Y-m-d 00:00:00');
                            $startlocation  = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']);

                           $Poistartlocation = $masterObj->GetPoinameNew($todaydata[$row]['gps_latitude']  . ',' . $todaydata[$row]['gps_longitude']);
                                    if ($Poistartlocation != "") {
                                        $startlocation = $Poistartlocation;
                                    }

                            $IdleTimeTaken2 = $obj->dateDifferenceSecond($idledateStart, $JourneyStartAt);
                            $IdleTime       = $obj->minDifferenceForJourney($IdleTimeTaken2);

                            $html .= '
'; ?> calc_distance($PointArray); if ($distance >= 0.07) { ###### Sum of distance############ $totalDistance = $totalDistance + $distance; } } $diff = $obj->dateDifference($istrow, $secndrow); $totaldiff = $totaldiff + $diff; if ($diff > $diffenceStatic) { $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $secndrow); $IdleTimeTaken = $obj->dateDifferenceSecond($secndrow, $istrow); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $SnailEndDate = $obj->addMinuteinTimeStamp($secndrow, 0, 'Y-m-d H:i'); $endlocation = $masterObj->GetLocationWitPOIreport($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); $PoiEndlast = $masterObj->GetPoinameNew($todaydata[$row]['gps_latitude'] . "," . $todaydata[$row]['gps_longitude']); if ($PoiEndlast != "") { $endlocation = $PoiEndlast; } $html .= ''; $html .= ''; ?> '; $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $AlltotalDistance = $AlltotalDistance + $totalDistance; $AllTimeTaken = $AllTimeTaken + $TimeTaken; $AllIdleTimeTaken = $AllIdleTimeTaken + $IdleTimeTaken; $totalDistance = 0; $distance = 0; $totaldiff = 0; } } } } } $TimeTaken = $obj->dateDifferenceSecond($JourneyStartAt, $todaydata[count($todaydata) - 1]['gps_time']); $SnailEndDate = $obj->addMinuteinTimeStamp($todaydata[count($todaydata) - 1]['gps_time'], 0, 'Y-m-d H:i'); $SnailStartDate = $obj->addMinuteinTimeStamp($JourneyStartAt, 0, 'Y-m-d H:i'); $location = $masterObj->GetLocationWitPOIreport($todaydata[count($todaydata) - 1]['gps_latitude'] . "," . $todaydata[count($todaydata) - 1]['gps_longitude']); $PoiEndLocatinw = $masterObj->GetPoinameNew($todaydata[count($todaydata) - 1]['gps_latitude'] . "," . $todaydata[count($todaydata) - 1]['gps_longitude']); if ($PoiEndLocatinw != "") { $location = $PoiEndLocatinw; } $html .= ''; ?> '; } $AlltotalDistance = 0; $AllTimeTaken = 0; } $dateStart2 = date("Y-m-d", strtotime($dateStart1)); $dateEnd2 = date("Y-m-d", strtotime($dateEnd1)); if ($dateStart2 <= $currentdate || $dateEnd2 <= $currentdate) { $StartGmtDate1 = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($_POST['dateStart']))); $EndGmtDate1 = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($_POST['dateEnd']))); $no_gps_KM = $masterObj->nogpsKM($vehicleList, $StartGmtDate1, $EndGmtDate1)."--"; $allConsolidate = "select sum(Total_km) as KM from matrix.consolidate_dtc where consolidate.DateOf_journey>='" . date("Y-m-d", strtotime($_POST['dateStart'])) . "' and consolidate_dtc.DateOf_journey<='" . date("Y-m-d", strtotime($_POST['dateEnd'])) . "' and sys_Service_id =" . $vehicleList . " group by sys_service_id "; $AllKm = db__select_staging($allConsolidate); $showFinalKM = round($calcObj->SetDistance($AllKm[0]["KM"] + $TodayKMForconsolidate,$_SESSION['KM_for']),2); /* $extraKm=$showFinalKM-$AllCumiltivetotKM; if($extraKm>0) { $no_gps_KM=$no_gps_KM+$extraKm; }*/ //$NoGpsKMConsolidate = $showFinalKM - $cumilativeKm; $no_gps_KM = $no_gps_KM + $NoGpsKMConsolidate; // $showFinalKMWithNogps = $showFinalKM + $no_gps_KM; if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $APMKM1 = $masterObj->GEtrawdataByVhlWithDatenewKMDTC($_POST['dateStart'],$_POST['dateEnd'],$vehicleList,31,"KM"); $APMKM=$calcObj->SetDistance($APMKM1,$_SESSION['KM_for']); $AllCumiltivetotKM=$APMKM; if($APMKM!=0) { } } //echo $_SESSION['UserId'].'<-->'.$vehicle_no.'<-->'.$dateStart.'<-->'.$dateEnd; //die; ?> '; */ } $html .= '
Start time Start Location End time End Location KM Duration Status View
Start time Start Location End time End Location Km Journey Duration Status
' . $dateStart . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
\n");?> \n"); ?>  
' . $JourneyQry[$i - 1]['End_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
\n"); ?> \n"); ?>  
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']) . ' KM ' . $JourneyQry[$i]['Total_journey_hour'] . ' Running
\n");?> \n");?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']);?> KM View
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $dateEnd . ' ' . wordwrap($EndLocation, 45, "
\n") . '
0 KM ' . $LastidleTimetoShow . ' Idle
\n");?> \n");?>  
Total ' . $cumilativeday . ' KM ' . $running_km . '' . $idle_hr . '
      Total KM
' . date("Y-m-d", strtotime($dateStart)) . ' 00:00:00 ' . wordwrap($navData[0]['start_location'], 45, "
\n") . '
' . date("Y-m-d", strtotime($dateStart)) . ' 23:59:59 ' . wordwrap($navData[0]['End_location'], 45, "
\n") . '
' . $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']) . ' KM ' . $ideal_time_show . ' Idle
\n");?> \n");?> SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']);?> KM  
      Total KM minDifference($idleTImeMIn);?>
Total' . $cumilativeday . ' KM 0 Hour 0 Min 0 Sec ' . $obj->minDifference($idleTImeMIn) . '
' . $dateStart . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
\n");?> \n");?>  
' . $JourneyQry[$i - 1]['End_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($EndLocationIdle, 45, "
\n") . '
0 KM ' . $ideal_time_show . ' Idle
\n");?> \n");?>  
' . $JourneyQry[$i]['Start_time'] . ' ' . wordwrap($StartLocation, 45, "
\n") . '
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $calcObj->SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']) . ' KM ' . $JourneyQry[$i]['Total_journey_hour'] . ' Running
\n");?> \n");?> SetDistance($JourneyQry[$i]['Total_KM'],$_SESSION['KM_for']);?>KM View
' . $JourneyQry[$i]['End_time'] . ' ' . wordwrap($EndLocation, 45, "
\n") . '
' . $dateEnd . ' ' . wordwrap($EndLocation, 45, "
\n") . '
0 KM ' . $LastidleTimetoShow . ' Idle
\n");?> \n");?>  
Total ' . $cumilativeday . ' KM ' . $running_km . '' . $idle_hr . '
      Total: KM
' . $dateStart . ' ' . wordwrap($navData[0]['start_location'], 45, "
\n") . '
' . $dateEnd . ' ' . wordwrap($navData[0]['End_location'], 45, "
\n") . '
' . $calcObj->SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']) . ' KM ' . $cumilativejourneyhourallsingle . '
\n");?> \n");?> SetDistance($navData[0]['Total_km'],$_SESSION['KM_for']);?> KM .  
' . $dateStart . ' ---- ' . $dateEnd . ' ---- ---- ---- ----
 
      Total KM minDifference($idleTImeMIn);?>
Total' . $cumilativeday . ' KM '.$cumilativejourneyhourallsingle.'' . $obj->minDifference($idleTImeMIn) . '
' . $idledateStart . ' ' . $startlocation . ' ' . $JourneyStartAt . ' ' . $startlocation . ' 0 KM ' . $IdleTime . ' Idle
' . $JourneyStartAt . '' . $startlocation . '
 
' . $secndrow . ' ' . $endlocation . ' ' . $totalDistance . ' KM ' . $obj->minDifferenceForJourney($TimeTaken) . ' Running
' . $secndrow . ' ' . $endlocation . ' ' . $istrow . ' ' . $endlocation . ' 0 KM ' . $obj->minDifferenceForJourney($IdleTimeTaken) . ' Idle
KM minDifferenceForJourney($TimeTaken); ?> View
minDifferenceForJourney($IdleTimeTaken); ?>  
' . $istrow . '' . $endlocation . '' . $todaydata[count($todaydata) - 1]['gps_time'] . ' ' . $location . ' ' . $totalDistance . ' KM ' . $obj->minDifferenceForJourney($TimeTaken) . ' Running
KM minDifferenceForJourney($TimeTaken); ?> View
Total KM minDifference($AllTimeTaken); ?> minDifference($AllIdleTimeTaken); ?>  
Total' . $AlltotalDistance . ' ' . $obj->minDifference($AllTimeTaken) . '' . $obj->minDifference($AllIdleTimeTaken) . '
 
 No GPS ' . $no_gps_KM . ' KM Total ' . $AllCumiltivetotKM . ' KM ' . $obj->minDifference($cumilativejourneyhourall) . '' . $obj->minDifference($cumilativeidlehourall) . '
'; ?>

' . $vehicle_no . '

'; $finalHtml = $mainHeader . $reportHeader . $html; if (substr($finalHtml, (strlen($finalHtml) - 8), strlen($finalHtml)) != "") { $finalHtml = $finalHtml . ""; } // reportFileLocation.$_SESSION['clientid'].".pdf"; require('html2fpdf/html2fpdf.php'); require('html2fpdf/fpdf.php'); $pdf = new HTML2FPDF("p", "mm", "A3",$invoice_num); $pdf->AddPage(); $pdf->Image("gtrac-logo.jpg", 10, 10); $pdf->WriteHTML($finalHtml); //$pdf->Output(reportFileLocation.$_SESSION['clientid'].".pdf"); //echo "pdf_reports/".$_SESSION['clientid'].".pdf"; $pdf->Output("pdf_reports/" . $_SESSION['clientid'] . ".pdf"); //header("location:"."pdf_reports/".$_SESSION['clientid'].".pdf"); $filepointer = fopen('excel_reports/' . $_SESSION['clientid'] . ".xls", 'w'); fwrite($filepointer, $finalHtml); fclose($filepointer); } elseif ($report_name == "OverSpeed") { // $limit='limit 1000'; if (((((strtotime($dateEnd)) - (strtotime($dateStart))) / 3600) / 24) > 31) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 31) - 1)); } if($vehicleList=="58825") { $ext=" and round(gps_speed*1.609,2) <=60"; } if (in_array($_SESSION['sys_group_id'], $Sppedclient) || in_array($_SESSION['sys_group_id_parent'], $Sppedclient)) { $GEtspeedas=" case when tel_input_0=true and gps_fix=1 then round(gps_speed*1.609,2) else '0' end as gps_speed "; $wherespeed=" and tel_input_0=true and gps_fix=1 and round(gps_speed*1.609,2)<85"; } else if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $wherespeed="and round(gps_speed*1.609,2)<80"; } else { $wherespeed=""; } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); /*if ($exceedSpeed >= 60) { //echo ";;"; $navData[] = db__select_staging("select DATE_ADD(gps_time , INTERVAL 330 MINUTE) as gps_time, id, gps_latitude, gps_longitude,".$GEtspeedas." from matrix.overspeed where sys_Service_id=" . $vehicleList . " and round(gps_speed*1.609,2) >='" . $exceedSpeed . "' and gps_time>='" . $StartGmtDate . "' and gps_time<='" . $EndGmtDate . "'".$ext." order by gps_time asc", $condition); } else { */ $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $wherespeed=" and round(gps_speed*1.609,2)<='70'"; $table_name="speed_temp_dtc"; //echo "ff"; $OverSpeed=db__select_staging(" select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id,sys_msg_type,gps_latitude,gps_longitude,".$GEtspeedas." from matrix.".$table_name." where sys_Service_id=".$vehicleList." and round(gps_speed*1.609,2) >='".$exceedSpeed."' ".$wherespeed." and ADDDATE( gps_time, INTERVAL ".$_SESSION['TimeZoneDiff']." MINUTE)>='".$dateStart."' and ADDDATE( gps_time, INTERVAL ".$_SESSION['TimeZoneDiff']." MINUTE)<='".$dateEnd."' group by gps_time order by gps_time", $condition); //print_r($OverSpeed); } else { for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select DATE_ADD(CONCAT(gps_date,' ',gps_time),INTERVAL ".$_SESSION['TimeZoneDiff']." MINUTE) as gps_time, id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,".$GEtspeedas." from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and round(gps_speed*1.609,2) >'" . $exceedSpeed . "' ".$wherespeed." and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" . $dateEnd. "'".$ext." group by gps_date,gps_time", $condition); } // } $navData[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id,sys_msg_type,gps_latitude,gps_longitude,".$GEtspeedas." from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and round(gps_speed*1.609,2) >'" . $exceedSpeed . "' ".$wherespeed." ".$ext." group by gps_time ", $condition); $navData[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id,sys_msg_type,gps_latitude,gps_longitude,".$GEtspeedas." from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and round(gps_speed*1.609,2) >'" . $exceedSpeed . "' ".$wherespeed." ".$ext." group by gps_time ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $OverSpeed[] = $val; } } ?>

Overspeed Report

';*/ //echo "
";print_r($OverSpeed);die;

        $no = 0;

        for ($i = 0; $i < count($OverSpeed); $i++) {
            $starttime = $dateStart;
            $endtime   = $dateEnd; 

                     //echo "
";print_r($OverSpeed);die;
							   $Showspeed=$OverSpeed[$i]['gps_speed'];
						//}
 
						$no = $no + 1;
						
				if($report_location == "Show_Location")
				{												
					if($redis_data = getRedisLocation($sess_userid,$OverSpeed[$i]["gps_latitude"],$OverSpeed[$i]["gps_longitude"],$redis))
					{
						$startlocation = $redis_data['LocationName'];
						//$KMFromNearPOI = $redis_data['KMFromNearPOI'];
					} else {
						$startlocation = '';
					}
					 
				} else {
					$startlocation = '';
				}
?>
              
SNo Date Speed Location
SNo Date Speed Location
View Map
    Showing 1 to of records
31) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 31) - 1)); } if($vehicleList=="58825") { $ext=" and round(gps_speed*1.609,2) <=60"; } if (in_array($_SESSION['sys_group_id'], $Sppedclient) || in_array($_SESSION['sys_group_id_parent'], $Sppedclient)) { $GEtspeedas=" case when tel_input_0=true and gps_fix=1 then round(gps_speed*1.609,2) else '0' end as gps_speed "; $wherespeed=" and tel_input_0=true and gps_fix=1 and round(gps_speed*1.609,2)<85"; } else if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $wherespeed="and round(gps_speed*1.609,2)<='70'"; } else { $wherespeed=""; } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $StartDatecmp = date("Y-m-d", strtotime('-0 minutes', strtotime($dateStart))); $EndDatecmp = date("Y-m-d", strtotime('-0 minutes', strtotime($dateEnd))); /*if ($exceedSpeed >= 60) { //echo ";;"; $navData[] = db__select_staging("select DATE_ADD(gps_time , INTERVAL 330 MINUTE) as gps_time, id, gps_latitude, gps_longitude,".$GEtspeedas." from matrix.overspeed where sys_Service_id=" . $vehicleList . " and round(gps_speed*1.609,2) >='" . $exceedSpeed . "' and gps_time>='" . $StartGmtDate . "' and gps_time<='" . $EndGmtDate . "'".$ext." order by gps_time asc", $condition); } else { */ $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); date_default_timezone_set ("Asia/Calcutta"); //echo $yestdate = date('Y-m-d',(strtotime(date("Y-m-d")))-1); $dateyest = date("Y-m-d", strtotime("-1 day", strtotime(date("Y-m-d")))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $navData[] = db__select_staging("select DATE_ADD(CONCAT(gps_date,' ',gps_time),INTERVAL ".$_SESSION['TimeZoneDiff']." MINUTE) as gps_time, id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,".$GEtspeedas." from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList ." ". $wherespeed." and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" . $dateEnd. "'".$ext." group by gps_date,gps_time", $condition); } else { $navData[] = db__select_staging("select DATE_ADD(CONCAT(gps_date,' ',gps_time),INTERVAL ".$_SESSION['TimeZoneDiff']." MINUTE) as gps_time, id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,".$GEtspeedas." from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and round(gps_speed*1.609,2) >'" . $exceedSpeed . "' ".$wherespeed." and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" . $dateEnd. "'".$ext." group by gps_date,gps_time", $condition); } } // } if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $navData[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id,sys_msg_type,gps_latitude,gps_longitude,".$GEtspeedas." from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' ".$wherespeed." ".$ext." group by gps_time ", $condition); $navData[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id,sys_msg_type,gps_latitude,gps_longitude,".$GEtspeedas." from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' ".$wherespeed." ".$ext." group by gps_time ", $condition); } else { $navData[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id,sys_msg_type,gps_latitude,gps_longitude,".$GEtspeedas." from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' ".$wherespeed." ".$ext." group by gps_time ", $condition); $navData[] = db__select("select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id,sys_msg_type,gps_latitude,gps_longitude,".$GEtspeedas." from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' ".$wherespeed." ".$ext." group by gps_time ", $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $OverSpeed[] = $val; } if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $wherespeed=" and round(gps_speed*1.609,2)<='70'"; $table_name="speed_temp_dtc"; if($StartDatecmp == $dateyest && $EndDatecmp == $dateyest) { //echo "ff"; /* $OverSpeed[]=db__select_staging("select select DATE_ADD(gps_time, INTERVAL " . $_SESSION['TimeZoneDiff'] . " MINUTE) as gps_time, id,sys_msg_type,gps_latitude,gps_longitude,".$GEtspeedas." from matrix.".$table_name." where sys_Service_id=".$vehicleList." and round(gps_speed*1.609,2) >='".$exceedSpeed."' ".$wherespeed." and ADDDATE( gps_time, INTERVAL ".$_SESSION['TimeZoneDiff']." MINUTE)>='".$dateStart."' and ADDDATE( gps_time, INTERVAL ".$_SESSION['TimeZoneDiff']." MINUTE)<='".$dateEnd."' group by gps_time order by gps_time", $condition); */ //print_r($OverSpeed); } } ?>

Overspeed Report

';*/ //echo "
";print_r($OverSpeed);die;

        $no = 0;
 $calcObj = new calculate_distance();
  
        for ($i = 0; $i < count($OverSpeed); $i++) {
 
		 $starttime = $dateStart;
            $endtime   = $dateEnd;
$DurationinSEC=0;
$distanceinmeter=0;
$distance=0;
            if ($OverSpeed[$i]['gps_time'] >= $starttime) {
                if ($OverSpeed[$i]['gps_time'] <= $endtime) {

                    /*$locationObj = new GetLocation();
                    $location_data = $masterObj->GetLocationWitPOIreport($OverSpeed[$i]['gps_latitude'].",".$OverSpeed[$i]['gps_longitude']);*/
                    if ($OverSpeed[$i]['gps_speed'] > 5) {
                        $status = "Running";
                    } else {
                        $status = "Stop";
                    }
                    
					  $TimeTakeninsec = $obj->dateDifferenceSecond($OverSpeed[$i]['gps_time'],$OverSpeed[$i-1]['gps_time']);
					  $speedDifference=$OverSpeed[$i]['gps_speed']-$OverSpeed[$i-1]['gps_speed'];


				 $PointArray[0]['lat']=$OverSpeed[$i]['gps_latitude'];
				$PointArray[0]['long']=$OverSpeed[$i]['gps_longitude'];
				$PointArray[1]['lat']=$OverSpeed[$i-1]['gps_latitude'];
				$PointArray[1]['long']=$OverSpeed[$i-1]['gps_longitude'];
				  $distance = $calcObj->calc_distance($PointArray); 
				 
				$DurationinSEC=$obj->dateDifferenceSecond($OverSpeed[$i]['gps_time'],$OverSpeed[$i-1]['gps_time']);  
				$distanceinmeter= $distance*1000;

				$Exptdistancebyduration=$DurationinSEC*15;

        /* if($speedDifference>60   )
					{
			 if($TimeTakeninsec>600)
						{
							$Showspeed=$OverSpeed[$i-1]['gps_speed'];
						}
						else
						{
							$Showspeed=$OverSpeed[$i]['gps_speed'];
						}
					}
					else
						{*/
							$Showspeed=$OverSpeed[$i]['gps_speed'];
						//}

						
							 

                    /*$html.='
';*/ //if($OverSpeed[$i-1]['gps_speed']==$OverSpeed[$i]['gps_speed']) //{ // $Showspeed=0; // } //if($OverSpeed[$i]['gps_speed']<140 ) //{ $Speeddiff=0; if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { if($Exptdistancebyduration>$distanceinmeter) { if($OverSpeed[$i]['gps_speed']>=30) { $Speeddiff=$OverSpeed[$i]['gps_speed']-$OverSpeed[$i-1]['gps_speed']; if($Speeddiff>10) { $Showspeed=40; } } } else { $Showspeed=0; } } if($Showspeed>=$exceedSpeed) { $no = $no + 1; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$OverSpeed[$i]["gps_latitude"],$OverSpeed[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } ?>
SNo Date Speed Location
SNo Date Speed Location
'.$sr.' '.$OverSpeed[$i]['gps_time'].' '.$OverSpeed[$i]['gps_speed'].' '.$location_data.'
View Map
    Showing 1 to of records
31) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 31) - 1)); } $diff_of_minutes = ''; $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry1 = " GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV " . $goupbymin; } else { $ExtraQry1 = " group by gps_time "; } if ($_SESSION['UserId'] == "4871") { $ExtraQry1 = " group by DATE_FORMAT(gps_time,'%Y-%m-%d %h:%i') "; } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $navData[] = db__select("select sys_msg_type, gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", geo_street,geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time,round(tel_temperature,2) as 'temprature' from matrix.today_speed where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select sys_msg_type, gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", geo_street,geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time, round(tel_temperature,2) as 'temprature' from " . $dbArray[$countYear] . ".today_ideal where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select sys_msg_type, gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", geo_street,geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time, round(tel_temperature,2) as 'temprature' from matrix.today_speed_" . date("d") . "_a where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select sys_msg_type, gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", geo_street,geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time, round(tel_temperature,2) as 'temprature' from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); if ($_SESSION['UserId'] == "48711") { $diff_of_minutes = 15; } else { $diff_of_minutes = ""; } if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin; //$ActKm = GetCalculatedKM($dateStart, $dateEnd, $vehicleList); } else { $ExtraQry = " group by gps_date,gps_time "; } if ($_SESSION['UserId'] == "4871") { $ExtraQry = " group by DATE_FORMAT(CONCAT(gps_date,' ',gps_time),'%Y-%m-%d %h:%i') "; } for ($countYear = 0; $countYear < count($dbArray); $countYear++) { /* $StartGmtDate=$obj->convertToGMT($dateStart,$_SESSION['TimeZoneDiff']); $EndGmtDate=$obj->convertToGMT($dateEnd,$_SESSION['TimeZoneDiff']);*/ $navData[] = db__select_staging("select sys_msg_type, CONCAT(gps_date,' ',gps_time) as gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",des_movement_id,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, jny_idle_time,round(tel_temperature,2) as 'temprature' from " . $dbArray[$countYear] . ".telemetry_new where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" .$StartGmtDate. "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate." " . $ExtraQry, $condition); $newQry = "select sys_msg_type, CONCAT(gps_date,' ',gps_time) as gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country,des_movement_id, geo_postcode, jny_distance, jny_duration, jny_idle_time,round(tel_temperature,2) as 'temprature' from " . $dbArray[$countYear] . ".telemetry_idle where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."" . $ExtraQry . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); $newQry = "select sys_msg_type, CONCAT(gps_date,' ',gps_time) as gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode,des_movement_id, jny_distance, jny_duration, jny_idle_time,round(tel_temperature,2) as 'temprature' from " . $dbArray[$countYear] . ".telemetry where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' group by gps_time ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $TemperatureData[] = $val; } //echo "
";print_r($TemperatureData);die;
?>
  
  
  

Temperture Report

10 && $i!=0) { $show=true; }*/ $show = true; } } else { $show = true; } if ($local_time >= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { if ($show == true) { $Date = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($TemperatureData[$i]['gps_time']))); $tempToShow = $TemperatureData[$i]['temprature']; //if($_SESSION['UserName']=='ssrcgoa') if ($vehicleList == "46132" || $vehicleList == "46918") { $tempToShow = $TemperatureData[$i]['temprature'] - 3; } else { $tempToShow = $TemperatureData[$i]['temprature']; } $no = $no + 1; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$TemperatureData[$i]["gps_latitude"],$TemperatureData[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } ?>
Date Temperature Speed (Km/h) Lat Long Location
°C Km/H
31) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 31) - 1)); } $diff_of_minutes = ''; $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry1 = " GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV " . $goupbymin; } else { $ExtraQry1 = " group by gps_time "; } if ($_SESSION['UserId'] == "4871") { $ExtraQry1 = " group by DATE_FORMAT(gps_time,'%Y-%m-%d %h:%i') "; } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $navData[] = db__select("select sys_msg_type, gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", geo_street,geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time, round(tel_temperature,2) as 'temprature' from matrix.today_speed where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $newQry = "select sys_msg_type, gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", geo_street,geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time, round(tel_temperature,2) as 'temprature' from " . $dbArray[$countYear] . ".today_ideal where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select("select sys_msg_type, gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", geo_street,geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time, round(tel_temperature,2) as 'temprature' from matrix.today_speed_" . date("d") . "_a where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $newQry = "select sys_msg_type, gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", geo_street,geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time, round(tel_temperature,2) as 'temprature' from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); if ($_SESSION['UserId'] == "48711") { $diff_of_minutes = 15; } else { $diff_of_minutes = ""; } if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin; //$ActKm = GetCalculatedKM($dateStart, $dateEnd, $vehicleList); } else { $ExtraQry = " group by gps_date,gps_time "; } if ($_SESSION['UserId'] == "4871") { $ExtraQry = " group by DATE_FORMAT(CONCAT(gps_date,' ',gps_time),'%Y-%m-%d %h:%i') "; } for ($countYear = 0; $countYear < count($dbArray); $countYear++) { /* $StartGmtDate=$obj->convertToGMT($dateStart,$_SESSION['TimeZoneDiff']); $EndGmtDate=$obj->convertToGMT($dateEnd,$_SESSION['TimeZoneDiff']);*/ $navData[] = db__select_staging("select sys_msg_type, CONCAT(gps_date,' ',gps_time) as gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",des_movement_id,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, jny_idle_time,round(tel_temperature,2) as 'temprature' from " . $dbArray[$countYear] . ".telemetry_new where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate." " . $ExtraQry, $condition); $newQry = "select sys_msg_type, CONCAT(gps_date,' ',gps_time) as gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country,des_movement_id, geo_postcode, jny_distance, jny_duration, jny_idle_time,round(tel_temperature,2) as 'temprature' from " . $dbArray[$countYear] . ".telemetry_idle where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."" . $ExtraQry . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); $newQry = "select sys_msg_type, CONCAT(gps_date,' ',gps_time) as gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode,des_movement_id, jny_distance, jny_duration, jny_idle_time,round(tel_temperature,2) as 'temprature' from " . $dbArray[$countYear] . ".telemetry where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' group by gps_time ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $TemperatureData[] = $val; } //echo "
";print_r($TemperatureData);die;
?>
  
  
  

Temperture Report

10 && $i!=0) { $show=true; }*/ $show = true; } } else { $show = true; } if ($local_time >= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { if ($show == true) { $Date=date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($TemperatureData[$i]['gps_time']))); $tempToShow = $TemperatureData[$i]['temprature']; if ($_SESSION['UserName'] == 'ssrcgoa') { $dtchk = date("i", strtotime($TemperatureData[$i]['gps_time'])); $addtemp = round($dtchk / 5); $TemperatureData[$i]['temprature'] = $TemperatureData[$i]['temprature'] + $addtemp; //$data[$i]['temprature']=$data[$i]['temprature']+$addtemp; if ($TemperatureData[$i]['temprature'] >= 35 && $TemperatureData[$i]['temprature'] <= 45) { $TemperatureData[$i]['temprature'] = 17; } else if ($TemperatureData[$i]['temprature'] >= 32 && $TemperatureData[$i]['temprature'] <= 35) { $TemperatureData[$i]['temprature'] = 16.8; } else if ($TemperatureData[$i]['temprature'] >= 30 && $TemperatureData[$i]['temprature'] <= 32) { $TemperatureData[$i]['temprature'] = 16.5; } else if ($TemperatureData[$i]['temprature'] >= 28 && $TemperatureData[$i]['temprature'] <= 30) { $TemperatureData[$i]['temprature'] = 16.4; } else if ($TemperatureData[$i]['temprature'] >= 24 && $TemperatureData[$i]['temprature'] <= 28) { $TemperatureData[$i]['temprature'] = 16; } else if ($TemperatureData[$i]['temprature'] >= 22 && $TemperatureData[$i]['temprature'] <= 24) { $TemperatureData[$i]['temprature'] = 15.5; } else if ($TemperatureData[$i]['temprature'] >= 18 && $TemperatureData[$i]['temprature'] <= 22) { $TemperatureData[$i]['temprature'] = 14.8; } if ($TemperatureData[$i]['temprature'] < 10) { //$TemperatureData[$i]['temprature']=10; } $tempToShow = $TemperatureData[$i]['temprature']; } else if ($vehicleList == "46132" || $vehicleList == "46918") { $tempToShow = $TemperatureData[$i]['temprature'] - 3; } else { $tempToShow = $TemperatureData[$i]['temprature']; } $no = $no + 1; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$TemperatureData[$i]["gps_latitude"],$TemperatureData[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } ?>
Date Temperature Speed (Km/h) Lat Long Location
°C Km/H
15) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 15) - 1)); } $diff_of_minutes = ''; $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $navData[] = db__select("select '--' as gps_latitude,'--' as gps_longitude,gps_time,tel_temperature,tel_pressure,sensor_sequence from telemetry_sensor_data where sys_service_id=43474 and gps_time>='2016-05-11'", $condition); $navData[] = db__select("select gps_latitude,gps_longitude,gps_time,'--' as tel_temperature,'--' as tel_pressure,'0' as sensor_sequence from today_speed where sys_service_id=43474 and gps_time>='2016-05-11' ", $condition); $navData[] = db__select("select gps_latitude,gps_longitude,gps_time,'--' as tel_temperature,'--' as tel_pressure,'0' as sensor_sequence from today_ideal where sys_service_id=43474 and gps_time>='2016-05-11' ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $TpmsReportData[] = $val; } ?>

TPMS Report

= 12) { ?>
Time Temperature Pressure Latitude longitude
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); //chamber_door for ($countYear = 0; $countYear < count($dbArray); $countYear++) { if ($portnum == "15081") { if ($sys_proc_host == "tel_input_1") { $chamber_doordata[] = db__select_staging("select 'tel_input_1' as inputname,des_movement_id as portnumber,tel_temperature, gps_datetime as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_1 as tel_ignition from " . $dbArray[$countYear] . ".telemetry_new_chamber where sys_Service_id=".$vehicleList." and gps_datetime>'".$StartGmtDate."' and gps_datetime<'".$EndGmtDate."' and sys_msg_type=1 order by gps_datetime ",''); } else { $chamber_doordata[] = db__select_staging("select 'tel_input_1' as inputname,des_movement_id as portnumber,tel_temperature, gps_datetime as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_1 as tel_ignition from " . $dbArray[$countYear] . ".telemetry_new_chamber where sys_Service_id=".$vehicleList." and gps_datetime>'".$StartGmtDate."' and gps_datetime<'".$EndGmtDate."' and sys_msg_type=1 order by gps_datetime ",''); $chamber_doordata[] = db__select_staging("select 'tel_input_3' as inputname,des_movement_id as portnumber,tel_temperature, gps_datetime as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_3 as tel_ignition from " . $dbArray[$countYear] . ".telemetry_new_chamber where sys_Service_id=".$vehicleList." and gps_datetime>'".$StartGmtDate."' and gps_datetime<'".$EndGmtDate."' and sys_msg_type=1 order by gps_datetime ",''); } } if ($portnum == "15029") { if ($sys_proc_host == "tel_ignition") { //$chamber_doordata[] = db__select_staging("select 'tel_ignition' as inputname,des_movement_id as portnumber,tel_temperature, gps_datetime as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_ignition as tel_ignition from " . $dbArray[$countYear] . ".telemetry_new_chamber where sys_Service_id=".$vehicleList." and gps_datetime>'".$StartGmtDate."' and gps_datetime<'".$EndGmtDate."' and sys_msg_type=1 order by gps_datetime ",''); $chamber_doordata[] = db__select_staging("select 'tel_input_0_0' as inputname,des_movement_id as portnumber,tel_temperature, gps_datetime as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, case when tel_input_0=false then true else false end as tel_ignition from " . $dbArray[$countYear] . ".telemetry_new_chamber where sys_Service_id=".$vehicleList." and gps_datetime>'".$StartGmtDate."' and gps_datetime<'".$EndGmtDate."' order by gps_datetime ",''); } else { $chamber_doordata[] = db__select_staging("select 'tel_ignition' as inputname,des_movement_id as portnumber,tel_temperature, gps_datetime as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_ignition as tel_ignition from " . $dbArray[$countYear] . ".telemetry_new_chamber where sys_Service_id=".$vehicleList." and gps_datetime>'".$StartGmtDate."' and gps_datetime<'".$EndGmtDate."' order by gps_datetime ",''); $chamber_doordata[] = db__select_staging("select 'tel_input_0_0' as inputname,des_movement_id as portnumber,tel_temperature, gps_datetime as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, case when tel_input_0=false then true else false end as tel_ignition from " . $dbArray[$countYear] . ".telemetry_new_chamber where sys_Service_id=".$vehicleList." and gps_datetime>'".$StartGmtDate."' and gps_datetime<'".$EndGmtDate."' order by gps_datetime ",''); } } if ($portnum == "14079") { if ($sys_proc_host == "tel_ignition") { $chamber_doordata[] = db__select_staging( "select 'tel_ignition' as inputname,des_movement_id as portnumber,tel_temperature, gps_datetime as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_1 as tel_ignition from " . $dbArray[$countYear] . ".telemetry_new_chamber where sys_Service_id=".$vehicleList." and gps_datetime>'".$StartGmtDate."' and gps_datetime<'".$EndGmtDate."' and sys_msg_type=1 order by gps_datetime ",''); //$chamber_doordata[] = db__select_staging("select 'tel_input_0_0' as inputname,des_movement_id as portnumber,tel_temperature, gps_datetime as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_panic as tel_ignition from " . $dbArray[$countYear] . ".telemetry_new_chamber where sys_Service_id=".$vehicleList." and gps_datetime>'".$StartGmtDate."' and gps_datetime<'".$EndGmtDate."' and sys_msg_type=1 order by gps_datetime ",''); } else { $chamber_doordata[] = db__select_staging( "select 'tel_ignition' as inputname,des_movement_id as portnumber,tel_temperature, gps_datetime as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_1 as tel_ignition from " . $dbArray[$countYear] . ".telemetry_new_chamber where sys_Service_id=".$vehicleList." and gps_datetime>'".$StartGmtDate."' and gps_datetime<'".$EndGmtDate."' and sys_msg_type=1 order by gps_datetime ",''); $chamber_doordata[] = db__select_staging("select 'tel_input_0_0' as inputname,des_movement_id as portnumber,tel_temperature, gps_datetime as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_panic as tel_ignition from " . $dbArray[$countYear] . ".telemetry_new_chamber where sys_Service_id=".$vehicleList." and gps_datetime>'".$StartGmtDate."' and gps_datetime<'".$EndGmtDate."' and sys_msg_type=1 order by gps_datetime ",''); } } } if ($portnum == "15081") { if ($sys_proc_host == "tel_input_1") { $chamber_doordata[] = db__select("select 'tel_input_1' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_1 as tel_ignition from matrix.today_ideal where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); $chamber_doordata[] = db__select("select 'tel_input_1' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_1 as tel_ignition from matrix.today_ideal_" . date("d") . "_a where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); } else { $chamber_doordata[] = db__select("select 'tel_input_1' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_1 as tel_ignition from matrix.today_ideal where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); $chamber_doordata[] = db__select("select 'tel_input_3' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_3 as tel_ignition from matrix.today_ideal_" . date("d") . "_a where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); $chamber_doordata[] = db__select("select 'tel_input_3' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_3 as tel_ignition from matrix.today_ideal where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); $chamber_doordata[] = db__select("select 'tel_input_3' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_3 as tel_ignition from matrix.today_ideal_" . date("d") . "_a where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); } } if ($portnum == "15029") { if ($sys_proc_host == "tel_ignition") { $chamber_doordata[] = db__select("select 'tel_ignition' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, case when tel_input_0=false then true else false end as tel_ignition from matrix.today_ideal where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); $chamber_doordata[] = db__select("select 'tel_ignition' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, case when tel_input_0=false then true else false end as tel_ignition from matrix._" . date("d") . "_a where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); } else { $chamber_doordata[] = db__select("select 'tel_ignition' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_ignition as tel_ignition from matrix.today_ideal where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); $chamber_doordata[] = db__select("select 'tel_ignition' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_ignition as tel_ignition from matrix.today_ideal_" . date("d") . "_a where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); $chamber_doordata[] = db__select("select 'tel_input_0_0' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, case when tel_input_0=false then true else false end as tel_ignition from matrix.today_ideal where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); $chamber_doordata[] = db__select("select 'tel_input_0_0' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, case when tel_input_0=false then true else false end as tel_ignition from matrix.today_ideal_" . date("d") . "_a where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); } } if ($portnum == "14079") { if ($sys_proc_host == "tel_ignition") { $chamber_doordata[] = db__select( "select 'tel_ignition' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_1 as tel_ignition from matrix.today_ideal where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); $chamber_doordata[] = db__select( "select 'tel_ignition' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_1 as tel_ignition from matrix.today_ideal_" . date("d") . "_a where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); } else { $chamber_doordata[] = db__select( "select 'tel_ignition' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_1 as tel_ignition from matrix.today_ideal where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); $chamber_doordata[] = db__select( "select 'tel_ignition' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_input_1 as tel_ignition from matrix.today_ideal_" . date("d") . "_a where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); $chamber_doordata[] = db__select("select 'tel_input_0_0' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_panic as tel_ignition from matrix.today_ideal where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); $chamber_doordata[] = db__select("select 'tel_input_0_0' as inputname,des_movement_id as portnumber,tel_temperature, gps_time as gps_time,gps_latitude,gps_longitude,geo_street as address,sys_service_id,gps_speed, tel_panic as tel_ignition from matrix.today_ideal_" . date("d") . "_a where sys_Service_id=".$vehicleList." and gps_time>'".$StartGmtDate."' and gps_time<'".$EndGmtDate."' and sys_msg_type=1 order by gps_time ",''); } } $data1 = array(); for ($countNavData = 0; $countNavData < count($chamber_doordata); $countNavData++) { if (is_array($chamber_doordata[$countNavData])) { $data1 = array_merge($data1, $chamber_doordata[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DoorOpen[] = $val; } //PRINT_R( $DoorOpen);DIE; ?>

Motion Sensor Report Live

'; $JourneyStartAt= ''; ?> dateDifferenceSecond($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken); if ($showtime == "less than 1 min") { $showtime = "0"; } if($TimeTaken>0) { echo $JourneyStartAt.' '; } $JourneyStartAtstatus=false; ?> dateDifferenceSecond($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken); if ($showtime == "less than 1 min") { $showtime = "0"; } if($TimeTaken>0) { echo $JourneyStartAt. ' ';} $JourneyStartAtstatus=false; ?>
Door Open Date & time Door Close Date & time Total Time Door Open
'.$starttime.'
'.$starttime.' '.$AC_off_time.' '.$showtime.'
'.$AC_off_time.' '.$showtime.'
Total minDifference($sumOfTime);?>
  Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); //chamber_door $chamber_doordata = db__select_staging("select sys_service_id,ADDDATE(Start_time,INTERVAL 19800 SECOND) as Start_time,ADDDATE(End_time,INTERVAL 19800 SECOND) as End_time,start_latitude,start_longitude,End_latitude,End_longitude,Total_journey_hour,time_to_Sec(Total_journey_hour) as timeinsec from chamber_door where sys_Service_id=".$vehicleList." and Start_time>'".$StartGmtDate."' and End_time<'".$EndGmtDate."'",''); ?>

Motion Sensor Report

'; ?>
Door Open Date & time Door Close Date & time Total Time Door Open
'.$starttime.' '.$AC_off_time.' '.$showtime.'
Total minDifference($sumOfTime);?>
  Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $newQry[] = db__select("select gps_time as gps_time,id,sys_msg_type, gps_latitude, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2, tel_temperature, tel_fuel from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and gps_time >= '".$StartGmtDate."' and gps_time <= '".$EndGmtDate."' and gps_latitude>0 ORDER BY gps_time asc ", $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $Fuel = array_merge($data1, $navData[$countNavData]); } } ?>
Fuel Report
SNo Date Location Fuel AC Status
GetLocationWitPOIreport($Fuel[$i]['gps_latitude'].",".$Fuel[$i]['gps_longitude']), 100, "
\n");?>
      Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, tel_input_3 as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate." and tel_input_3=true group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, tel_input_3 as tel_input_3 from matrix.today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_3=true group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, tel_input_3 as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_3=true group by gps_time ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DoorOpen[] = $val; } ?>

eDoor Open Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$DoorOpen[$i]["gps_latitude"],$DoorOpen[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } //if (strlen(round($DoorOpen[$i]['gps_latitude'])) == 2 && strlen(round($DoorOpen[$i]['gps_longitude'])) == 2) { /*$istrow=$DoorOpen[$i]['gps_time']; $secndrow=$DoorOpen[$i-1]['gps_time']; $diff = $obj_diff->dateDifference($istrow,$secndrow); echo $DoorOpen[$i]['gps_time']."--".$DoorOpen[$i]['tel_input_3']."--". $diff;echo "
"; */ //echo $DoorOpen[$i]['gps_time'];echo "
"; if ($JourneyStartAt == "") { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $DoorOpen[$i]['gps_latitude']; $start_gps_longitude = $DoorOpen[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $DoorOpen[$i]['gps_time']; $JourneyStartAt = $DoorOpen[$i]['gps_time']; $no = $no+1; echo ''; /*echo '';*/ ?> ';*/ } if ($JourneyStartAt != "") { if ($i > 1) { $istrow = $DoorOpen[$i]['gps_time']; $secndrow = $DoorOpen[$i - 1]['gps_time']; $local_time1 = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i - 1]['gps_time']))); if ($local_time1 >= $_POST['dateStart']) { $diff = $obj_diff->dateDifference($istrow, $secndrow); if ($diff >= $diffenceStatic) { // echo $diff ; //$TimeTaken="3"; $no = $no+1; $TimeTaken = $obj_diff->dateDifference($JourneyStartAt, $secndrow); $door_off_time=date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($secndrow))); $total_time = $obj_diff->minDifference($TimeTaken * 60); echo ' '; /*echo ' ';*/ // $JourneyStartAt = $istrow; /* echo '';*/ echo ''; /*echo '';*/ ?> " /> =$diffenceStatic) { $Endtrip=true; $TimeTaken=$obj_diff->dateDifference($JourneyStartAt,$secndrow); echo ' '; $JourneyStartAt=$istrow; echo ''; } */ } } } // } } } } if ($JourneyStartAt != "") { $TimeTaken = $obj_diff->dateDifference($JourneyStartAt, $DoorOpen[count($DoorOpen) - 1]['gps_time']); $door_off_time_last = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[count($DoorOpen) - 1]['gps_time']))); $total_time_last = $obj_diff->minDifference($TimeTaken * 60); echo ' '; ?> ' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[count($DoorOpen) - 1]['gps_time']))) . '';*/ } ?>
Location Door Open Date & time Door Close Date & time Total Time door Open
'.$startlocation.' '.$starttime.'
'.$starttime.' ' . $masterObj->GetLocationWitPOIreport($start_gps_latitude . "," . $start_gps_longitude) . '' . $starttime . ''.$door_off_time.' '.$total_time.'
' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($secndrow))) . ' ' . $obj_diff->minDifference($TimeTaken * 60) . '
'.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).'
' . $masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'] . "," . $DoorOpen[$i]['gps_longitude']) . '' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))) . '
'.$startlocation.' '.date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))).'
'.date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))).' '.$secndrow.''.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).' '.minDifference($TimeTaken).'
'.$istrow.''.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).''.$door_off_time_last.' '.$total_time_last.'
' . $obj_diff->minDifference($TimeTaken * 60) . '
  Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_input_1=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '".$dateEnd."' group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_1=true then true else false end as tel_input_3 from matrix.today_ideal where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_1=true then true else false end as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' group by gps_time ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DoorOpen[] = $val; } //} //else //{ // $DoorOpen[]=""; //} //print_R($DoorOpen); ?>

IR Sensor Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; if($DoorOpen[$i]['tel_input_3']==false) { if ($JourneyStartAtstatus == false) { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $DoorOpen[$i]['gps_latitude']; $start_gps_longitude = $DoorOpen[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $DoorOpen[$i]['gps_time']; $JourneyStartAt = $DoorOpen[$i]['gps_time']; $no = $no+1; // echo $JourneyStartAt= ''; echo $JourneyStartAt= ''; ?> dateDifferenceSecond($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken); if ($showtime == "less than 1 min") { $showtime = "0"; } echo ' '; $JourneyStartAtstatus=false; ?> dateDifferenceSecond($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken); if ($showtime == "less than 1 min") { $showtime = "0"; } echo ' '; $JourneyStartAtstatus=false; ?>
FuelCap Open Date & time FuelCap Close Date & time Total Time Cap Open
'.$starttime.'
'.$starttime.' '.$AC_off_time.' '.$showtime.'
'.$AC_off_time.' '.$showtime.'
Total minDifference($sumOfTime);?>
  Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_input_1=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '".$dateEnd."' group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_1=true then true else false end as tel_input_3 from matrix.today_ideal where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_1=true then true else false end as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' group by gps_time ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DoorOpen[] = $val; } //} //else //{ // $DoorOpen[]=""; //} //print_R($DoorOpen); ?>

IR Sensor Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; if($DoorOpen[$i]['tel_input_3']==false) { if ($JourneyStartAtstatus == false) { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $DoorOpen[$i]['gps_latitude']; $start_gps_longitude = $DoorOpen[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $DoorOpen[$i]['gps_time']; $JourneyStartAt = $DoorOpen[$i]['gps_time']; $no = $no+1; $locationStart = $masterObj->GetLocationWitPOIreport($start_gps_latitude.",".$start_gps_longitude); // echo $JourneyStartAt= ''; echo $JourneyStartAt= ''; ?> dateDifferenceSecond($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken); if ($showtime == "less than 1 min") { $showtime = "0"; } $end_gps_latitude = $DoorOpen[$i]['gps_latitude']; $end_gps_longitude = $DoorOpen[$i]['gps_longitude']; $locationEnd = $masterObj->GetLocationWitPOIreport($end_gps_latitude.",".$end_gps_longitude); echo ' '; $JourneyStartAtstatus=false; ?> dateDifferenceSecond($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken); if ($showtime == "less than 1 min") { $showtime = "0"; } $end_gps_latitude1 = $DoorOpen[$i]['gps_latitude']; $end_gps_longitude1 = $DoorOpen[$i]['gps_longitude']; $locationEnd2 = $masterObj->GetLocationWitPOIreport($end_gps_latitude1.",".$end_gps_longitude1); echo ' '; $JourneyStartAtstatus=false; ?>
Door Open Date & time Door Open Location Door Close Date & time Door Close Location Total Time Door Open
'.$starttime.'
'.$starttime.' '.$locationStart.' '.$AC_off_time.' '.$locationEnd.' '.$showtime.'
'.$AC_off_time.' '.$locationEnd2.' '.$showtime.'
Total minDifference($sumOfTime);?>
  Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_input_1=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '".$dateEnd."' group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select_staging("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_1=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' group by gps_time ORDER BY gps_time asc ", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_1=true then true else false end as tel_input_3 from matrix.today_ideal where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_1=true then true else false end as tel_input_3 from matrix.telemetry where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_1=true then true else false end as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' group by gps_time ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DoorOpen[] = $val; } //} //else //{ // $DoorOpen[]=""; //} //print_R($DoorOpen); ?>

Motion Sensor Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; if($DoorOpen[$i]['tel_input_3']==true) { if ($JourneyStartAtstatus == false) { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $DoorOpen[$i]['gps_latitude']; $start_gps_longitude = $DoorOpen[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $DoorOpen[$i]['gps_time']; $JourneyStartAt = $DoorOpen[$i]['gps_time']; $no = $no+1; // echo $JourneyStartAt= ''; echo $JourneyStartAt= ''; ?> dateDifferenceSecond($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken); if ($showtime == "less than 1 min") { $showtime = "0"; } echo ' '; $JourneyStartAtstatus=false; ?> dateDifferenceSecond($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken); if ($showtime == "less than 1 min") { $showtime = "0"; } echo ' '; $JourneyStartAtstatus=false; ?>
Door Open Date & time Door Close Date & time Total Time Door Open
'.$starttime.'
'.$starttime.' '.$AC_off_time.' '.$showtime.'
'.$AC_off_time.' '.$showtime.'
Total minDifference($sumOfTime);?>
  Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); /* for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '".date("Y-m-d", strtotime($dateEnd))."' and tel_ignition=true and sys_msg_type=1 group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_ignition=true and sys_msg_type=1 group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_ignition=true and sys_msg_type=1 group by gps_time ORDER BY gps_time asc ", $condition);*/ for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '".$dateEnd."' group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_msg_type=1 AND sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' group by gps_time ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DoorOpen[] = $val; } //} //else //{ // $DoorOpen[]=""; //} //print_R($DoorOpen); ?>

Motion Sensor Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; if($DoorOpen[$i]['tel_input_3']==true) { if ($JourneyStartAtstatus == false) { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $DoorOpen[$i]['gps_latitude']; $start_gps_longitude = $DoorOpen[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $DoorOpen[$i]['gps_time']; $JourneyStartAt = $DoorOpen[$i]['gps_time']; $no = $no+1; // echo $JourneyStartAt= ''; echo $JourneyStartAt= ''; ?> dateDifferenceSecond($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken); if ($showtime == "less than 1 min") { $showtime = "0"; } echo ' '; $JourneyStartAtstatus=false; ?> " /> dateDifferenceSecond($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken); if ($showtime == "less than 1 min") { $showtime = "0"; } echo ' '; $JourneyStartAtstatus=false; ?> " />
Door Open Date & time Door Close Date & time Total Time door Open
'.$starttime.'
'.$starttime.' '.$AC_off_time.' '.$showtime.'
'.$AC_off_time.' '.$showtime.'
Total minDifference($sumOfTime);?>
  Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_input_0=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" .$dateEnd . "' and tel_input_0=true group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select_staging("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true then true else false end as tel_input_3 from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true group by gps_time ORDER BY gps_time asc ", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true then true else false end as tel_input_3 from matrix.today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true then true else false end as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_input_0=true then true else false end as tel_input_3 from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and tel_input_0=true group by gps_time ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DoorOpen[] = $val; } ?>

Control Box Report

Ignition Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; // if (strlen(round($DoorOpen[$i]['gps_latitude'])) == 2 && strlen(round($DoorOpen[$i]['gps_longitude'])) == 2) { /*$istrow=$DoorOpen[$i]['gps_time']; $secndrow=$DoorOpen[$i-1]['gps_time']; $diff = $obj_diff->dateDifference($istrow,$secndrow); echo $DoorOpen[$i]['gps_time']."--".$DoorOpen[$i]['tel_input_3']."--". $diff;echo "
"; */ //echo $DoorOpen[$i]['gps_time'];echo "
"; if ($JourneyStartAt == "") { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $DoorOpen[$i]['gps_latitude']; $start_gps_longitude = $DoorOpen[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $DoorOpen[$i]['gps_time']; $JourneyStartAt = $DoorOpen[$i]['gps_time']; $no = $no+1; $showdataasHTML= ''; $url="fuel_historyforgraphmachine.php?vehid=".$vehicleList."&datestart=".date("Y-m-d H:i:s",strtotime($starttime)); //http://203.115.101.61/newtracking/reports/fuel_historyforgraphmachine.php?vehid=79023&datestart=2019-06-20%2000:48:37&dateend=2019-06-20%2008:54:38 } if ($JourneyStartAt != "") { if ($i > 1) { $istrow = $DoorOpen[$i]['gps_time']; $secndrow = $DoorOpen[$i - 1]['gps_time']; $local_time1 = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i - 1]['gps_time']))); if ($local_time1 >= $_POST['dateStart']) { $diff = $obj_diff->dateDifference($istrow, $secndrow); if ($diff >= $diffenceStatic) { // echo $diff ; //$TimeTaken="3"; $TimeTaken = $obj_diff->dateDifference($JourneyStartAt, $secndrow); $showtime = $obj_diff->minDifference($TimeTaken * 60); $sumOfTime=$sumOfTime+$TimeTaken; if ($showtime == "less than 1 min") { $showtime = 0; } $no1 = $no1+1; if($showtime>0) { echo $showdataasHTML.' '; } if($_SESSION['sys_group_id']==52791 || $_SESSION['sys_group_id']==52349 ) { //
'.$Fuelfill.'
echo ' '; $url.="&dateend=".date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($secndrow))); ?>'; // $JourneyStartAt = $istrow; $showdataasHTML= ''; $url="fuel_historyforgraphmachine.php?vehid=".$vehicleList."&datestart=".date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))); $no = $no+1; } } } } // } } } } if ($JourneyStartAt != "") { $TimeTaken = $obj_diff->dateDifference($JourneyStartAt, $DoorOpen[count($DoorOpen) - 1]['gps_time']); echo $showdataasHTML.''; $no1 = $no1+1; $sumOfTime=$sumOfTime+$TimeTaken; if($_SESSION['sys_group_id']==52791 || $_SESSION['sys_group_id']==52349) { //
'.$Fuelfill.'
echo ' '; $url.="&dateend=".date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[count($DoorOpen) - 1]['gps_time']))); ?>'; } if ($JourneyStartAt != "") { ?>
Location Control Box ON Date & time Control Box Off Date & time Total Time Control Box ON Ignition ON Start Date & time Ignition ON End Date & time Total Time Ignition on Initial fuel Fuel consume Avg
' . $masterObj->GetLocationWitPOIreport($start_gps_latitude . "," . $start_gps_longitude) . '' . $starttime . '' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($secndrow))) . ' ' . $showtime . '
'.$Initialfuel.'
'.$Fuelconsume.'
'.$Avg.'
'.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).'
' . $masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'] . "," . $DoorOpen[$i]['gps_longitude']) . '' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))) . '' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[count($DoorOpen) - 1]['gps_time']))) . '' . $obj_diff->minDifference($TimeTaken * 60) . '
'.$Initialfuel.'
'.$Fuelconsume.'
'.$Avg.'
Total minDifference($sumOfTime * 60);?>
  Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $whereqryasvehtype=""; if ($report_name == "Ac_report_truck") { $whereqryasvehtype = " and (tel_ignition=true)"; } else if ($report_name == "Ac_report_trailer") { if($vehicleList==53510 || $vehicleList==52318 || $vehicleList==54027 || $vehicleList==53134 ) { $whereqryasvehtype = " and ( tel_ignition=true or tel_input_1=true)"; } if($vehicleList==53774) { $whereqryasvehtype = " and (tel_input_0=true or tel_input_1=true )"; } else { $whereqryasvehtype = " and (tel_ignition=true or tel_input_0=true or tel_input_1=true)"; } if($vehicleList==52088 ) { $whereqryasvehtype = " and tel_input_0=true "; } if($vehicleList==53133 || $vehicleList==53774) { $selectFrom=" case when tel_input_1=true then true else false end as tel_input_3"; } else { $selectFrom=" case when tel_ignition=true then true else false end as tel_input_3 "; } } $whereqryasvehtype=" "; if($vehicleList==53294) { $whereqryasvehtype = " and (tel_ignition=true or tel_input_1=true)"; } /* $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd))."' and " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '".date("Y-m-d", strtotime($dateEnd))."' and " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition);*/ if ($report_name == "Ac_report_trailer") { //$whereqryasvehtype = " and (tel_ignition=true or tel_input_0=true or tel_input_1=true)"; //$selectFrom=" tel_input_0=true then true else false end as tel_input_3"; if ($dbArray[$countYear] != "matrix_" . date("m_y")) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,".$selectFrom." from " . $dbArray[$countYear] . ".telemetry_idle where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" . $dateEnd."' " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,".$selectFrom." from " . $dbArray[$countYear] . ".telemetry_new where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '".$dateEnd."' " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); } } else { $whereqryasvehtype=""; if ($dbArray[$countYear] != "matrix_" . date("m_y")) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" . $EndGmtDate."' " . $whereqryasvehtype . " group by CONCAT(gps_date,' ',gps_time) ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" . $EndGmtDate."' " . $whereqryasvehtype . " group by CONCAT(gps_date,' ',gps_time) ORDER BY gps_date,gps_time asc", $condition); } } } if ($report_name == "Ac_report_trailer") { $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, ".$selectFrom." from matrix.today_ideal where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, ".$selectFrom." from matrix.today_speed where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, ".$selectFrom." from matrix.today_ideal_" . date("d") . "_a where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, ".$selectFrom." from matrix.today_speed_" . date("d") . "_a where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); } else { $whereqryasvehtype=""; /*echo "select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_speed where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc */ $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_speed where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_speed_" . date("d") . "_a where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DoorOpen[] = $val; } // print_r($DoorOpen); ?>

AC Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$DoorOpen[$i]["gps_latitude"],$DoorOpen[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } $lastrecord = $i; if($DoorOpen[$i]['tel_input_3']==true) { if ($JourneyStartAtstatus == false) { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $DoorOpen[$i]['gps_latitude']; $start_gps_longitude = $DoorOpen[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $DoorOpen[$i]['gps_time']; $JourneyStartAt = $DoorOpen[$i]['gps_time']; $no = $no+1; $JourneyStartAt= ''; /*$JourneyStartAt= '';*/ ?> dateDifference($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken * 60); if ($showtime == "less than 1 min") { $showtime = "0"; } if($showtime!="0") { echo $JourneyStartAt.' '; } $JourneyStartAtstatus=false; ?> " /> dateDifference($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken * 60); if ($showtime == "less than 1 min") { $showtime = "0"; } echo ' '; $JourneyStartAtstatus=false; ?> " />
Location AC ON Date & time AC Off Date & time Total Time AC Report
'.$startlocation.' '.$starttime.'
'.$starttime.' '.$AC_off_time.' '.$showtime.'
'.$AC_off_time.' '.$showtime.'
Total minDifference($sumOfTime * 60);?>
  Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $whereqryasvehtype=""; $whereqryasvehtype=" "; $whereqryasvehtype=" "; if ($dbArray[$countYear] != "matrix_" . date("m_y")) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 ,".$GEtspeedas." from " . $dbArray[$countYear] . ".telemetry_idle where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" . $EndGmtDate."' " . $whereqryasvehtype . " group by CONCAT(gps_date,' ',gps_time) ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 ,".$GEtspeedas." from " . $dbArray[$countYear] . ".telemetry_new where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" . $EndGmtDate."' " . $whereqryasvehtype . " group by CONCAT(gps_date,' ',gps_time) ORDER BY gps_date,gps_time asc", $condition); } } $whereqryasvehtype=" "; $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 ,".$GEtspeedas." from matrix.today_ideal where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 ,".$GEtspeedas." from matrix.today_speed where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 ,".$GEtspeedas." from matrix.today_ideal_" . date("d") . "_a where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 ,".$GEtspeedas." from matrix.today_speed_" . date("d") . "_a where sys_msg_type=1 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DoorOpen[] = $val; } // print_r($DoorOpen); ?>

Idle AC Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$DoorOpen[$i]["gps_latitude"],$DoorOpen[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } // if($DoorOpen[$i]['tel_input_3']==true && $DoorOpen[$i]['gps_speed']<=5) { if ($JourneyStartAtstatus == false) { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $DoorOpen[$i]['gps_latitude']; $start_gps_longitude = $DoorOpen[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $DoorOpen[$i]['gps_time']; $JourneyStartAt = $DoorOpen[$i]['gps_time']; $no = $no+1; echo $JourneyStartAt= ''; /*echo $JourneyStartAt= '';*/ ?> dateDifference($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken * 60); if ($showtime == "7 to 9 Sec") { $showtime = "0"; } echo ' '; $JourneyStartAtstatus=false; ?> " /> dateDifference($starttime, $AC_off_time); $sumOfTime = $sumOfTime + $TimeTaken; //less than 1 min $showtime = $obj_diff->minDifference($TimeTaken * 60); if ($showtime == "less than 1 min") { $showtime = "0"; } echo ' '; $JourneyStartAtstatus=false; ?> " />
Location AC ON Date & time AC Off Date & time Total Time AC Report
'.$startlocation.' '.$starttime.'
'.$starttime.' '.$AC_off_time.' '.$showtime.'
'.$AC_off_time.' '.$showtime.'
Total minDifference($sumOfTime * 60);?>
  Showing 1 to of records  
returnDbArray($dateStart,$dateEnd); $StartGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateEnd))); for($countYear=0;$countYear= '".$StartGmtDate."' and CONCAT(gps_date,' ',gps_time) <= '".$dateEnd."' and ".$whereqryasvehtype." group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from ".$dbArray[$countYear].".telemetry_new where sys_service_id=".$vehicleList." and CONCAT(gps_date,' ',gps_time) >= '".$StartGmtDate."' and CONCAT(gps_date,' ',gps_time) <= '".$dateEnd."' and ".$whereqryasvehtype." group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal where sys_service_id=".$vehicleList." and gps_time >= '".$StartGmtDate."' and gps_time <= '".$EndGmtDate."' and ".$whereqryasvehtype." group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_speed where sys_service_id=".$vehicleList." and gps_time >= '".$StartGmtDate."' and gps_time <= '".$EndGmtDate."' and ".$whereqryasvehtype." group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal_".date("d")."_a where sys_service_id=".$vehicleList." and gps_time >= '".$StartGmtDate."' and gps_time <= '".$EndGmtDate."' and ".$whereqryasvehtype." group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_speed_".date("d")."_a where sys_service_id=".$vehicleList." and gps_time >= '".$StartGmtDate."' and gps_time <= '".$EndGmtDate."' and ".$whereqryasvehtype." group by gps_time ORDER BY gps_time asc ", $condition); //.today_ideal_".date("d")."_a $data1=array(); for($countNavData=0;$countNavDataarray_msort($data1, array('gps_time'=>SORT_ASC)); foreach($data2 as $val) { $DoorOpen[] = $val; } //print_r($DoorOpen); ?>

Genset Report

= $_POST['dateStart']) { if($local_time <= $_POST['dateEnd']) { $lastrecord =$i; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$DoorOpen[$i]["gps_latitude"],$DoorOpen[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } // if( strlen(round($DoorOpen[$i]['gps_latitude']))==2 && strlen(round($DoorOpen[$i]['gps_longitude']))==2 ) // { /*$istrow=$DoorOpen[$i]['gps_time']; $secndrow=$DoorOpen[$i-1]['gps_time']; $diff = $obj_diff->dateDifference($istrow,$secndrow); echo $DoorOpen[$i]['gps_time']."--".$DoorOpen[$i]['tel_input_3']."--". $diff;echo "
"; */ //echo $DoorOpen[$i]['gps_time'];echo "
"; if ($JourneyStartAt == "") { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $DoorOpen[$i]['gps_latitude']; $start_gps_longitude = $DoorOpen[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $DoorOpen[$i]['gps_time']; $JourneyStartAt = $DoorOpen[$i]['gps_time']; $no = $no+1; echo ''; /*echo '';*/ ?> ';*/ } if($JourneyStartAt!="") { if($i>=0) { $istrow=$DoorOpen[$i]['gps_time']; $secndrow=$DoorOpen[$i-1]['gps_time']; $local_time1 = date("Y-m-d H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($DoorOpen[$i-1]['gps_time']))); if($local_time1 >= $_POST['dateStart']) { $diff = $obj_diff->dateDifference($istrow,$secndrow); if($diff>=$diffenceStatic) { // echo $diff ; //$TimeTaken="3"; $no = $no+1; $TimeTaken=$obj_diff->dateDifference($JourneyStartAt,$secndrow); //if($TimeTaken>5) //{ $Genset_off_time = date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($secndrow))); $total_time = $obj_diff->minDifference($TimeTaken*60); echo ' '; /*echo ' ';*/ // $JourneyStartAt=$istrow; /*echo '';*/ /*echo '';*/ echo ''; ?> " /> =$diffenceStatic) { $Endtrip=true; $TimeTaken=$obj_diff->dateDifference($JourneyStartAt,$secndrow); echo ' '; $JourneyStartAt=$istrow; echo ''; } */ } } } // } } } } if ($JourneyStartAt != "") { $TimeTaken = $obj_diff->dateDifference($JourneyStartAt, $DoorOpen[count($DoorOpen) - 1]['gps_time']); $Genset_off_time_last = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[count($DoorOpen) - 1]['gps_time']))); $total_time_last = $obj_diff->minDifference($TimeTaken * 60); echo ' '; ?> ' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[count($DoorOpen) - 1]['gps_time']))) . '';*/ } ?>
Location Genset ON Date & time Genset Off Date & time Total Time Genset Report
'.$startlocation.' '.$starttime.'
'.$starttime.' ' . $masterObj->GetLocationWitPOIreport($start_gps_latitude . "," . $start_gps_longitude) . '' . $starttime . ''.$Genset_off_time.' '.$total_time.'
'.date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($secndrow))).' '.$obj_diff->minDifference($TimeTaken*60).'
'.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).'
'.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).''.date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($istrow))).'
'.date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))).'
'.$startlocation.' '.date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))).' '.$secndrow.''.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).' '.minDifference($TimeTaken).'
'.$istrow.''.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).''.$Genset_off_time_last.' '.$total_time_last.'
' . $obj_diff->minDifference($TimeTaken * 60) . '
  Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { if ($report_name == "distanceSensor_report") { $whereqryasvehtype = " tel_ignition=true"; } $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" . $dateEnd."' and " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" .$dateEnd."' and " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DoorOpen[] = $val; } //echo "
";print_r($DoorOpen);die;

?>
  
  
  

Distance sensor Report

= $_POST['dateStart']) { if($local_time <= $_POST['dateEnd']) { $lastrecord =$i; //if( strlen(round($DoorOpen[$i]['gps_latitude']))==2 && strlen(round($DoorOpen[$i]['gps_longitude']))==2 ) //{ /*$istrow=$DoorOpen[$i]['gps_time']; $secndrow=$DoorOpen[$i-1]['gps_time']; $diff = $obj_diff->dateDifference($istrow,$secndrow); echo $DoorOpen[$i]['gps_time']."--".$DoorOpen[$i]['tel_input_3']."--". $diff;echo "
"; */ //echo $DoorOpen[$i]['gps_time'];echo "
"; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$DoorOpen[$i]["gps_latitude"],$DoorOpen[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } if( $JourneyStartAt=="") { $starttime =date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($DoorOpen[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $DoorOpen[$i]['gps_latitude']; $start_gps_longitude = $DoorOpen[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow=$DoorOpen[$i]['gps_time']; $JourneyStartAt=$DoorOpen[$i]['gps_time']; $no = $no+1; echo ''; /*echo '';*/ ?> ';*/ } if($JourneyStartAt!="") { if($i>=0) { $istrow=$DoorOpen[$i]['gps_time']; $secndrow=$DoorOpen[$i-1]['gps_time']; $local_time1 = date("Y-m-d H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($DoorOpen[$i-1]['gps_time']))); if($local_time1 >= $_POST['dateStart']) { $diff = $obj_diff->dateDifference($istrow,$secndrow); if($diff>=$diffenceStatic) { // echo $diff ; //$TimeTaken="3"; $no = $no+1; $TimeTaken=$obj_diff->dateDifference($JourneyStartAt,$secndrow); //if($TimeTaken>5) //{ $Loaded_end_time = date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($secndrow))); $total_time = $obj_diff->minDifference($TimeTaken*60); echo ' '; /*echo ' ';*/ // $JourneyStartAt=$istrow; /*echo '';*/ /*echo '';*/ echo ''; ?> " /> dateDifference($JourneyStartAt,$DoorOpen[count($DoorOpen)-1]['gps_time']); $Loaded_end_time_last = date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($DoorOpen[count($DoorOpen)-1]['gps_time']))); $total_time_last = $obj_diff->minDifference($TimeTaken*60); echo ' '; ?> '.date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($DoorOpen[count($DoorOpen)-1]['gps_time']))).'';*/ } ?>
Location Loaded Start Date & time Loaded End Date & time Total Time Loaded
'.$startlocation.' '.$starttime.'
'.$starttime.' '.$masterObj->GetLocationWitPOIreport($start_gps_latitude.",".$start_gps_longitude).''.$starttime.''.$Loaded_end_time.' '.$total_time.'
'.date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($secndrow))).' '.$obj_diff->minDifference($TimeTaken*60).'
'.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).'
'.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).''.date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($istrow))).'
'.date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($istrow))).'
'.$startlocation.' '.date("d-m-Y H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($istrow))).' '.$Loaded_end_time_last.' '.$total_time_last.'
'.$obj_diff->minDifference($TimeTaken*60).'
  Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y/m/d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y/m/d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { if ($report_name == "Ac_report") { $whereqryasvehtype = " tel_ignition=true"; } /*echo "select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '".date("Y-m-d", strtotime($EndGmtDate))."' and " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc"; echo "
"; echo "select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($EndGmtDate)) . "' and " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc"; echo "
"; echo "
";*/ $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '".date("Y-m-d", strtotime($EndGmtDate))."' and " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($EndGmtDate)) . "' and " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DoorOpen[] = $val; } //echo "
";print_r($DoorOpen);die;

?>
  
  
  

Rear Engine Report

Door Report

AC Report

Door Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; // if (strlen(round($DoorOpen[$i]['gps_latitude'])) == 2 && strlen(round($DoorOpen[$i]['gps_longitude'])) == 2) { /*$istrow=$DoorOpen[$i]['gps_time']; $secndrow=$DoorOpen[$i-1]['gps_time']; $diff = $obj_diff->dateDifference($istrow,$secndrow); echo $DoorOpen[$i]['gps_time']."--".$DoorOpen[$i]['tel_input_3']."--". $diff;echo "
"; */ //echo $DoorOpen[$i]['gps_time'];echo "
"; if ($JourneyStartAt == "") { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $DoorOpen[$i]['gps_latitude']; $start_gps_longitude = $DoorOpen[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $DoorOpen[$i]['gps_time']; $JourneyStartAt = $DoorOpen[$i]['gps_time']; $no = $no+1; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$DoorOpen[$i]["gps_latitude"],$DoorOpen[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } echo ''; $url="fuel_historyforgraphmachine.php?vehid=".$vehicleList."&datestart=".date("Y-m-d H:i:s",strtotime($starttime)); ?> ';*/ } if ($JourneyStartAt != "") { if ($i >= 0) { $istrow = $DoorOpen[$i]['gps_time']; $secndrow = $DoorOpen[$i-1]['gps_time']; $end_gps_latitude = $DoorOpen[$i-1]['gps_latitude']; $end_gps_longitude = $DoorOpen[$i-1]['gps_longitude']; $local_time1 = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($DoorOpen[$i-1]['gps_time']))); if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$DoorOpen[$i-1]["gps_latitude"],$DoorOpen[$i-1]["gps_longitude"],$redis)) { $endlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $endlocation = ''; } } else { $endlocation = ''; } if ($local_time1 >= $_POST['dateStart']) { $diff = $obj_diff->dateDifference($istrow, $secndrow); if ($diff >= $diffenceStatic) { // echo $diff ; //$TimeTaken="3"; $no = $no+1; $TimeTaken = $obj_diff->dateDifference($JourneyStartAt, $secndrow); //if($TimeTaken>5) //{ $AC_off_time = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($secndrow))); $total_time = $obj_diff->minDifference($TimeTaken * 60); $endlocid = "locEnd".$no; echo ' '; echo ''; if($_SESSION['sys_group_id']==52791 || $_SESSION['sys_group_id']==52349 ) { echo ' '; $url.="&dateend=".date("Y-m-d H:i:s",strtotime($AC_off_time)); ?> '; /*echo ' ';*/ // $JourneyStartAt = $istrow; /*echo '';*/ if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$DoorOpen[$i]["gps_latitude"],$DoorOpen[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } /*echo '';*/ echo ''; $url="fuel_historyforgraphmachine.php?vehid=".$vehicleList."&datestart=".date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))); // echo $url="fuel_historyforgraphnew.php?fortrip=true&vehicle=".$vehicleList."&datestart=".date("Y-m-d H:i:s",strtotime($istrow))."&dateend=".date("Y-m-d H:i:s",strtotime($AC_off_time)); ?> " /> =$diffenceStatic) { $Endtrip=true; $TimeTaken=$obj_diff->dateDifference($JourneyStartAt,$secndrow); echo ' '; $JourneyStartAt=$istrow; echo ''; } */ } } } // } } } } if ($JourneyStartAt != "") { $local_time = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$lastrecord]['gps_time']))); if ($local_time <= $_POST['dateEnd']) { $no = $no+1; $TimeTaken = $obj_diff->dateDifference($JourneyStartAt, $DoorOpen[$lastrecord]['gps_time']); $end_gps_latitude = $DoorOpen[$i-1]['gps_latitude']; $end_gps_longitude = $DoorOpen[$i-1]['gps_longitude']; $AC_off_time_last = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$lastrecord]['gps_time']))); $total_time_last = $obj_diff->minDifference($TimeTaken * 60); $endlocid = 'locEnd'.$no; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$end_gps_latitude,$end_gps_longitude,$redis)) { $endlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $endlocation = ''; } } else { $endlocation = ''; } /*echo ' ';*/ echo ' '; echo ''; if($_SESSION['sys_group_id']==52791 || $_SESSION['sys_group_id']==52349 ) { echo ' '; $url="fuel_historyforgraphmachine.php?vehid=".$vehicleList."&datestart=".date("Y-m-d H:i:s",strtotime($starttime))."&dateend=".date("Y-m-d H:i:s",strtotime($AC_off_time_last)); ?> '; ?>
Start Location AC ON Date & time End Location AC Off Date & time Total Time AC Report Initial fuel Fuel consume Avg
'.$startlocation.''.$starttime.' ' . $masterObj->GetLocationWitPOIreport($start_gps_latitude . "," . $start_gps_longitude) . '' . $starttime . ''.$endlocation.''.$AC_off_time.' '.$total_time.'
'.$Initialfuel.'
'.$Fuelfill.'
'.$Fuelconsume.'
'.$Avg.'
' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($secndrow))) . ' ' . $obj_diff->minDifference($TimeTaken * 60) . '
'.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).'
' . $masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'] . "," . $DoorOpen[$i]['gps_longitude']) . '' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))) . '
'.date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))).'
'.$startlocation.' '.date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))).' '.$secndrow.''.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).' '.minDifference($TimeTaken).'
'.$istrow.''.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).'
'.$endlocation.''.$AC_off_time_last.' '.$total_time_last.'
'.$Initialfuel.'
'.$Fuelfill.'
'.$Fuelconsume.'
'.$Avg.'
  Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y/m/d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y/m/d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { if ($report_name == "Ac_report") { $whereqryasvehtype = " tel_ignition=true"; } $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '".date("Y-m-d", strtotime($EndGmtDate))."' and " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($EndGmtDate)) . "' and " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DoorOpen[] = $val; } //print_r($DoorOpen); ?>

Rear Engine Report

Door Report

AC Report1

Door Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; // if (strlen(round($DoorOpen[$i]['gps_latitude'])) == 2 && strlen(round($DoorOpen[$i]['gps_longitude'])) == 2) { /*$istrow=$DoorOpen[$i]['gps_time']; $secndrow=$DoorOpen[$i-1]['gps_time']; $diff = $obj_diff->dateDifference($istrow,$secndrow); echo $DoorOpen[$i]['gps_time']."--".$DoorOpen[$i]['tel_input_3']."--". $diff;echo "
"; */ //echo $DoorOpen[$i]['gps_time'];echo "
"; if ($JourneyStartAt == "") { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $DoorOpen[$i]['gps_latitude']; $start_gps_longitude = $DoorOpen[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $DoorOpen[$i]['gps_time']; $JourneyStartAt = $DoorOpen[$i]['gps_time']; $no = $no+1; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$DoorOpen[$i]["gps_latitude"],$DoorOpen[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } echo ''; $url="fuel_historyforgraphmachine.php?vehid=".$vehicleList."&datestart=".date("Y-m-d H:i:s",strtotime($starttime)); ?> ';*/ } if ($JourneyStartAt != "") { if ($i >= 0) { $istrow = $DoorOpen[$i]['gps_time']; $secndrow = $DoorOpen[$i-1]['gps_time']; $end_gps_latitude = $DoorOpen[$i-1]['gps_latitude']; $end_gps_longitude = $DoorOpen[$i-1]['gps_longitude']; $local_time1 = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($DoorOpen[$i-1]['gps_time']))); if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$DoorOpen[$i-1]["gps_latitude"],$DoorOpen[$i-1]["gps_longitude"],$redis)) { $endlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $endlocation = ''; } } else { $endlocation = ''; } if ($local_time1 >= $_POST['dateStart']) { $diff = $obj_diff->dateDifference($istrow, $secndrow); if ($diff >= $diffenceStatic) { // echo $diff ; //$TimeTaken="3"; $no = $no+1; $TimeTaken = $obj_diff->dateDifference($JourneyStartAt, $secndrow); //if($TimeTaken>5) //{ $AC_off_time = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($secndrow))); $total_time = $obj_diff->minDifference($TimeTaken * 60); $endlocid = "locEnd".$no; echo ' '; echo ''; if($_SESSION['sys_group_id']==52791 || $_SESSION['sys_group_id']==52349 ) { echo ' '; $url.="&dateend=".date("Y-m-d H:i:s",strtotime($AC_off_time)); ?> '; /*echo ' ';*/ // $JourneyStartAt = $istrow; /*echo '';*/ if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$DoorOpen[$i]["gps_latitude"],$DoorOpen[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } /*echo '';*/ echo ''; $url="fuel_historyforgraphmachine.php?vehid=".$vehicleList."&datestart=".date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))); // echo $url="fuel_historyforgraphnew.php?fortrip=true&vehicle=".$vehicleList."&datestart=".date("Y-m-d H:i:s",strtotime($istrow))."&dateend=".date("Y-m-d H:i:s",strtotime($AC_off_time)); ?> " /> =$diffenceStatic) { $Endtrip=true; $TimeTaken=$obj_diff->dateDifference($JourneyStartAt,$secndrow); echo ' '; $JourneyStartAt=$istrow; echo ''; } */ } } } // } } } } if ($JourneyStartAt != "") { $no = $no+1; $TimeTaken = $obj_diff->dateDifference($JourneyStartAt, $DoorOpen[count($DoorOpen) - 1]['gps_time']); $end_gps_latitude = $DoorOpen[$i-1]['gps_latitude']; $end_gps_longitude = $DoorOpen[$i-1]['gps_longitude']; $AC_off_time_last = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[count($DoorOpen) - 1]['gps_time']))); $total_time_last = $obj_diff->minDifference($TimeTaken * 60); $endlocid = 'locEnd'.$no; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$end_gps_latitude,$end_gps_longitude,$redis)) { $endlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $endlocation = ''; } } else { $endlocation = ''; } /*echo ' ';*/ echo ' '; echo ''; if($_SESSION['sys_group_id']==52791 || $_SESSION['sys_group_id']==52349 ) { echo ' '; $url="fuel_historyforgraphmachine.php?vehid=".$vehicleList."&datestart=".date("Y-m-d H:i:s",strtotime($starttime))."&dateend=".date("Y-m-d H:i:s",strtotime($AC_off_time_last)); ?> '; ?> ' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[count($DoorOpen) - 1]['gps_time']))) . '';*/ /* if($Endtrip==false) { $TimeTaken="0"; echo ' '; }*/ ?>
Start Location AC ON Date & time End Location AC Off Date & time Total Time AC Report Initial fuel Fuel consume Avg
'.$startlocation.''.$starttime.' ' . $masterObj->GetLocationWitPOIreport($start_gps_latitude . "," . $start_gps_longitude) . '' . $starttime . ''.$endlocation.''.$AC_off_time.' '.$total_time.'
'.$Initialfuel.'
'.$Fuelfill.'
'.$Fuelconsume.'
'.$Avg.'
' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($secndrow))) . ' ' . $obj_diff->minDifference($TimeTaken * 60) . '
'.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).'
' . $masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'] . "," . $DoorOpen[$i]['gps_longitude']) . '' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))) . '
'.date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))).'
'.$startlocation.' '.date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))).' '.$secndrow.''.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).' '.minDifference($TimeTaken).'
'.$istrow.''.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).'
'.$endlocation.''.$AC_off_time_last.' '.$total_time_last.'
'.$Initialfuel.'
'.$Fuelfill.'
'.$Fuelconsume.'
'.$Avg.'
' . $obj_diff->minDifference($TimeTaken * 60) . '
'.$masterObj->GetLocationWitPOIreport($DoorOpen[count($DoorOpen)-1]['gps_latitude'].",".$DoorOpen[count($DoorOpen)-1]['gps_longitude']).''.$DoorOpen[count($DoorOpen)-1]['gps_time'].''.$masterObj->GetLocationWitPOIreport($DoorOpen[count($DoorOpen)-1]['gps_latitude'].",".$DoorOpen[count($DoorOpen)-1]['gps_longitude']).' '.minDifference($TimeTaken).'
  Showing 1 to of records  
returnDbArray($dateStart, $dateEnd); $StartGmtDate = date("Y/m/d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y/m/d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { if ($report_name == "acidle_report") { $whereqryasvehtype = " tel_ignition=false"; } $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '".date("Y-m-d", strtotime($EndGmtDate))."' and " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($EndGmtDate)) . "' and " . $whereqryasvehtype . " group by gps_date,gps_time ORDER BY gps_date,gps_time asc", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); } $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $navData[] = db__select("select gps_time, id,sys_msg_type,gps_latitude,gps_longitude, case when tel_ignition=true then true else false end as tel_input_3 from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and " . $whereqryasvehtype . " group by gps_time ORDER BY gps_time asc ", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $DoorOpen[] = $val; } //print_r($DoorOpen); ?>

Rear Engine Report

Door Report

AC Idle Report

Door Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $lastrecord = $i; // if (strlen(round($DoorOpen[$i]['gps_latitude'])) == 2 && strlen(round($DoorOpen[$i]['gps_longitude'])) == 2) { /*$istrow=$DoorOpen[$i]['gps_time']; $secndrow=$DoorOpen[$i-1]['gps_time']; $diff = $obj_diff->dateDifference($istrow,$secndrow); echo $DoorOpen[$i]['gps_time']."--".$DoorOpen[$i]['tel_input_3']."--". $diff;echo "
"; */ //echo $DoorOpen[$i]['gps_time'];echo "
"; if ($JourneyStartAt == "") { $starttime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[$i]['gps_time']))); $endtime = ''; $start_gps_latitude = $DoorOpen[$i]['gps_latitude']; $start_gps_longitude = $DoorOpen[$i]['gps_longitude']; $end_gps_latitude = ''; $end_gps_longitude = ''; $timediff = ''; $istrow = $DoorOpen[$i]['gps_time']; $JourneyStartAt = $DoorOpen[$i]['gps_time']; $no = $no+1; echo ''; $url="fuel_historyforgraphmachine.php?vehid=".$vehicleList."&datestart=".date("Y-m-d H:i:s",strtotime($starttime)); ?> ';*/ } if ($JourneyStartAt != "") { if ($i >= 0) { $istrow = $DoorOpen[$i]['gps_time']; $secndrow = $DoorOpen[$i-1]['gps_time']; $end_gps_latitude = $DoorOpen[$i-1]['gps_latitude']; $end_gps_longitude = $DoorOpen[$i-1]['gps_longitude']; $local_time1 = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($DoorOpen[$i-1]['gps_time']))); if ($local_time1 >= $_POST['dateStart']) { $diff = $obj_diff->dateDifference($istrow, $secndrow); if ($diff >= $diffenceStatic) { // echo $diff ; //$TimeTaken="3"; $no = $no+1; $TimeTaken = $obj_diff->dateDifference($JourneyStartAt, $secndrow); //if($TimeTaken>5) //{ $AC_off_time = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($secndrow))); $total_time = $obj_diff->minDifference($TimeTaken * 60); $endlocid = "locEnd".$no; echo ' '; echo ''; if($_SESSION['sys_group_id']==52791 || $_SESSION['sys_group_id']==52349 ) { echo ' '; $url.="&dateend=".date("Y-m-d H:i:s",strtotime($AC_off_time)); ?> '; /*echo ' ';*/ // $JourneyStartAt = $istrow; /*echo '';*/ echo ''; $url="fuel_historyforgraphmachine.php?vehid=".$vehicleList."&datestart=".date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))); // echo $url="fuel_historyforgraphnew.php?fortrip=true&vehicle=".$vehicleList."&datestart=".date("Y-m-d H:i:s",strtotime($istrow))."&dateend=".date("Y-m-d H:i:s",strtotime($AC_off_time)); ?> " /> =$diffenceStatic) { $Endtrip=true; $TimeTaken=$obj_diff->dateDifference($JourneyStartAt,$secndrow); echo ' '; $JourneyStartAt=$istrow; echo ''; } */ } } } // } } } } if ($JourneyStartAt != "") { $no = $no+1; $TimeTaken = $obj_diff->dateDifference($JourneyStartAt, $DoorOpen[count($DoorOpen) - 1]['gps_time']); $end_gps_latitude = $DoorOpen[$i-1]['gps_latitude']; $end_gps_longitude = $DoorOpen[$i-1]['gps_longitude']; $AC_off_time_last = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[count($DoorOpen) - 1]['gps_time']))); $total_time_last = $obj_diff->minDifference($TimeTaken * 60); $endlocid = 'locEnd'.$no; echo ' '; echo ''; if($_SESSION['sys_group_id']==52791 || $_SESSION['sys_group_id']==52349 ) { echo ' '; $url="fuel_historyforgraphmachine.php?vehid=".$vehicleList."&datestart=".date("Y-m-d H:i:s",strtotime($starttime))."&dateend=".date("Y-m-d H:i:s",strtotime($AC_off_time_last)); ?> '; ?> ' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($DoorOpen[count($DoorOpen) - 1]['gps_time']))) . '';*/ /* if($Endtrip==false) { $TimeTaken="0"; echo ' '; }*/ ?>
Start Location AC Off start Date & time End Location AC Off end Date & time Total Time AC Report Initial fuel Fuel consume Avg
'.$starttime.' ' . $masterObj->GetLocationWitPOIreport($start_gps_latitude . "," . $start_gps_longitude) . '' . $starttime . '
'.$AC_off_time.' '.$total_time.'
'.$Initialfuel.'
'.$Fuelfill.'
'.$Fuelconsume.'
'.$Avg.'
' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($secndrow))) . ' ' . $obj_diff->minDifference($TimeTaken * 60) . '
'.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).'
' . $masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'] . "," . $DoorOpen[$i]['gps_longitude']) . '' . date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))) . '
'.date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($istrow))).' '.$secndrow.''.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).' '.minDifference($TimeTaken).'
'.$istrow.''.$masterObj->GetLocationWitPOIreport($DoorOpen[$i]['gps_latitude'].",".$DoorOpen[$i]['gps_longitude']).'
'.$AC_off_time_last.' '.$total_time_last.'
'.$Initialfuel.'
'.$Fuelfill.'
'.$Fuelconsume.'
'.$Avg.'
' . $obj_diff->minDifference($TimeTaken * 60) . '
'.$masterObj->GetLocationWitPOIreport($DoorOpen[count($DoorOpen)-1]['gps_latitude'].",".$DoorOpen[count($DoorOpen)-1]['gps_longitude']).''.$DoorOpen[count($DoorOpen)-1]['gps_time'].''.$masterObj->GetLocationWitPOIreport($DoorOpen[count($DoorOpen)-1]['gps_latitude'].",".$DoorOpen[count($DoorOpen)-1]['gps_longitude']).' '.minDifference($TimeTaken).'
  Showing 1 to of records  
35) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 35) - 1)); } $_SESSION["tempdatestart"]=$dateStart; $_SESSION["tempdateend"]=$dateEnd; //echo "ll"; if($_SESSION['UserId']=='78422') { $diff_of_minutes = 5; } else if($_SESSION['UserId']=='78252') { $diff_of_minutes = 10; } else if($_SESSION['UserId']=='79448') { $diff_of_minutes = 15; } else { $diff_of_minutes = 30; } $temp_data_data = array(); $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry1 = " GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV " . $goupbymin; } else { $ExtraQry1 = " group by gps_time "; } if ($_SESSION['UserId'] == "4871") { $ExtraQry1 = " group by DATE_FORMAT(gps_time,'%Y-%m-%d %h:%i') "; } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $DataInAdmin = db__select_staging("select input_type from matrix.coldex_admin_details where user_id=".$_SESSION['UserId']." order by update_time desc limit 1", $condition); // print_R($DataInAdmin); $CheckUserInAmin=$DataInAdmin[0]["input_type"]; $CheckUserInAmin="t2_temp"; if($CheckUserInAmin=="") { $CheckUserInAmin="t2_temp"; } if ($CheckUserInAmin=="t2_temp") { $Temp_data = db__select_staging("select * from matrix.temperature_manual_entry_tbl where sys_veh_id='" . $vehicleList . "' and ((start_date>'" . $dateStart . "' and end_date<'". $EndGmtDate." ) or (('" . $dateStart . "' BETWEEN start_date AND end_date ) or ('". $EndGmtDate." BETWEEN start_date AND end_date ))) group by start_date,end_date", $condition); db__query_staging("CREATE TEMPORARY TABLE historydata( `sys_service_id` BIGINT(20) UNSIGNED NOT NULL, `sys_proc_time` DATETIME NOT NULL, `gps_time` DATETIME NOT NULL, `gps_latitude` FLOAT(12,9) NOT NULL, `gps_longitude` FLOAT(12,9) NOT NULL, `gps_speed` FLOAT(12,9) NOT NULL,tel_temperature FLOAT(12,9) NOT NULL,jny_distance VARCHAR(500) NULL DEFAULT NULL,tel_rfid VARCHAR(500) NULL DEFAULT NULL )",""); //echo "ff";die(); if(count($Temp_data) > 0) { //echo "
";print_r($Temp_data);die;

              for($tm = 0; $tm < count($Temp_data); $tm++) {

                // Initial loop Start.
                if($tm == 0) {
                 
                    if(strtotime($dateStart)dateDifference($beforeStartGmtDate, $beforeEndGmtDate);
                 
                    if ($diffrance >= $diff_of_minutes) {

                        $navData = db__select("select sys_msg_type,gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",
                            geo_street, geo_town,geo_country, geo_postcode, jny_distance,des_movement_id,
                            jny_duration, jny_idle_time, round(tel_temperature,2) as 'temprature',round(jny_distance,2) as 'jny_distance',tel_rfid
                            from matrix.today_speed where   tel_temperature!=0.000000000 and
                            sys_service_id=" . $vehicleList . "   and gps_time >= '" . $beforeStartGmtDate . "' and
                            gps_time <= '" . $beforeEndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition);
                                         
                        if ($navData[0]["temprature"] != '') {
                            for ($na = 0; $na < count($navData); $na++) {
                                $arr = array(
                                    'gps_time' => $navData[$na]["gps_time"],
                                    'gps_latitude' => $navData[$na]["gps_latitude"],
                                    'gps_longitude' => $navData[$na]["gps_longitude"],
                                    'gps_speed' => $navData[$na]["gps_speed"],
                                    'temprature' => $navData[$na]["temprature"],
                                    'date' => $navData[$na]["gps_time"],
                                    'value' => $navData[$na]["temprature"],
                                    'jny_distance'=>  $navData[$na]["jny_distance"],
				    'tel_rfid'=>  $navData[$na]["tel_rfid"]
                                );
                                array_push($temp_data_data, $arr);
                            }
                        }
                         
                        $newQry = "select  sys_msg_type,  gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",
                         geo_street, geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time,
                         round(tel_temperature,2) as 'temprature',round(jny_distance,2) as 'jny_distance',tel_rfid from  matrix.today_ideal where
                         tel_temperature!=0.000000000 and sys_service_id=".$vehicleList."   and gps_time >= '".$beforeStartGmtDate."'
                         and gps_time <= '" . $beforeEndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ";
 
                        $navData2 = db__select($newQry, $condition);
                     
                        if ($navData2[0]["temprature"] != '') {
                            for ($na2 = 0; $na2 < count($navData2); $na2++) {
                                $arr = array(
                                    'gps_time' => $navData2[$na2]["gps_time"],
                                    'gps_latitude' => $navData2[$na2]["gps_latitude"],
                                    'gps_longitude' => $navData2[$na2]["gps_longitude"],
                                    'gps_speed' => $navData2[$na2]["gps_speed"],
                                    'temprature' => $navData2[$na2]["temprature"],
                                    'date' => $navData2[$na2]["gps_time"],
                                    'value' => $navData2[$na2]["temprature"],
                                    'jny_distance' => $navData2[$na2]["jny_distance"],
				     'tel_rfid' => $navData2[$na2]["tel_rfid"]
 
                                );
                                array_push($temp_data_data, $arr);
                            }
                        }
                 

				 $navData3 = db__select("select   DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_temperature,2) as value,gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",
                    des_movement_id, round(tel_temperature,2) as 'temprature',round(jny_distance,2) as jny_distance,`geo_street`,des_movement_id,tel_rfid  from matrix.today_speed_" . date("d") . "_a
                    where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and
                    gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition);
					
			
            if ($navData3[0]["temprature"] != '') {
                for ($na3 = 0; $na3 < count($navData3); $na3++) {
                    $arr = array(

                        'gps_time' => $navData3[$na3]["gps_time"],
                        'gps_latitude' => $navData3[$na3]["gps_latitude"],
                        'gps_longitude' => $navData3[$na3]["gps_longitude"],
                        'gps_speed' => $navData3[$na3]["gps_speed"],
                        'temprature' => $navData3[$na3]["temprature"],
                        'date' =>  $navData3[$na3]["date"],
                        'value' =>  $navData3[$na3]["temprature"],
                        'jny_distance' => $navData3[$na3]["jny_distance"],
			'tel_rfid' => $navData3[$na3]["tel_rfid"]
                    );
                    array_push($temp_data_data, $arr);
                }
            }


$navData4 = db__select("select   DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,
					round(tel_temperature,2) as value,gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",
                    des_movement_id, round(tel_temperature,2) as 'temprature',round(jny_distance,2) as jny_distance,`geo_street`,
					des_movement_id ,tel_rfid from
                    matrix.today_ideal_" . date("d") . "_a where
                    tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and gps_time >= '" . $StartGmtDate . "' and
                    gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition);
				
					
			
            if ($navData4[0]["temprature"] != '') {
                for ($na4 = 0; $na4 < count($navData4); $na4++) {
                    $arr = array(

                        'gps_time' => $navData4[$na4]["gps_time"],
                        'gps_latitude' => $navData4[$na4]["gps_latitude"],
                        'gps_longitude' => $navData4[$na4]["gps_longitude"],
                        'gps_speed' => $navData4[$na4]["gps_speed"],
                        'temprature' => $navData4[$na4]["temprature"],
                        'date' =>  $navData4[$na4]["date"],
                        'value' =>  $navData4[$na4]["temprature"],
                        'jny_distance' => $navData4[$na4]["jny_distance"],
			'tel_rfid' => $navData4[$na4]["tel_rfid"]
                    );
                    array_push($temp_data_data, $arr);
                }
            }	
                 

                        if ($_SESSION['UserId'] == "48711") {
                            $diff_of_minutes = 15;
                        }
						 else if ($_SESSION['UserId'] == "78252") {
                            $diff_of_minutes = 10;
                        }
						else if ($_SESSION['UserId'] == "79448") {
                            $diff_of_minutes = 15;
                        }
						
						else {
                            $diff_of_minutes = 30;
                        }



                        if ($diff_of_minutes != "") {
                            $goupbymin = $diff_of_minutes * 60;
                            $ExtraQry  = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin;
                            //$ActKm     = GetCalculatedKM($dateStart, $dateEnd, $vehicleList);
                        } else {
                            $ExtraQry = " group by gps_date,gps_time ";
                        }


                        if ($_SESSION['UserId'] == "4871") {

                            $ExtraQry = " group by DATE_FORMAT(CONCAT(gps_date,' ',gps_time),'%Y-%m-%d %h:%i') ";
                        }

                        for ($countYear = 0; $countYear < count($dbArray); $countYear++) {

                          /*  $navData3 = db__select_staging("select sys_msg_type,  CONCAT(gps_date,' ',gps_time) as gps_time, gps_latitude,
                             gps_longitude, ".$GEtspeedas.",des_movement_id,geo_street,geo_town,geo_country,
                             geo_postcode, jny_distance, jny_duration, jny_idle_time,round(tel_temperature,2) as 'temprature',tel_rfid
                             from " . $dbArray[$countYear] . ".telemetry_new
                             where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                             CONCAT(gps_date,' ',gps_time) >= '" . $beforeStartGmtDate . "' and
                             CONCAT(gps_date,' ',gps_time) <= '" . $beforeEndGmtDate . "'  " . $ExtraQry, $condition);*/

                            if ($dbArray[$countYear] != "matrix_" . date("m_y")) {

                                db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                                . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",
                                tel_temperature,jny_distance ,tel_rfid  from " . $dbArray[$countYear] . ".telemetry_new
                                where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                                CONCAT(gps_date,' ',gps_time) >= '" . $beforeStartGmtDate . "' and
                                CONCAT(gps_date,' ',gps_time) <= '" . $beforeEndGmtDate . "'  group by gps_date,gps_time", "$condition ");


                                db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                                . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",
                                tel_temperature,jny_distance ,tel_rfid  from " . $dbArray[$countYear] . ".telemetry_idle where
                                tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                                CONCAT(gps_date,' ',gps_time) >= '" . $beforeStartGmtDate . "' and
                                CONCAT(gps_date,' ',gps_time) <= '" . $beforeEndGmtDate . "'  group by gps_date,gps_time", "$condition ");

                            }

                        } //End For Loop


                        $goupbymin1=$diff_of_minutes * 60;
                        $navData4 = db__select_staging("select * from historydata where gps_time >= '" . $beforeStartGmtDate . "' and
                        gps_time <= '" . $beforeEndGmtDate . "' GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV " . $goupbymin1, $condition);
                     
                        if ($navData4[0]["tel_temperature"] != '') {
                            for ($na4 = 0; $na4 < count($navData4); $na4++) {
                                $arr = array(
                                    'gps_time' => $navData4[$na4]["gps_time"],
                                    'gps_latitude' => $navData4[$na4]["gps_latitude"],
                                    'gps_longitude' => $navData4[$na4]["gps_longitude"],
                                    'gps_speed' => $navData4[$na4]["gps_speed"],
                                    'temprature' => $navData4[$na4]["tel_temperature"],
                                    'date' => $navData4[$na4]["gps_time"],
                                    'value' => $navData4[$na4]["tel_temperature"],
                                    'jny_distance' => $navData4[$na4]["jny_distance"],
				    'tel_rfid' => $navData4[$na4]["tel_rfid"]
                                );

                                array_push($temp_data_data, $arr);
                            }
                        }


                    } //End If Loop

                } // End initial value loop

               //echo "
";print_r($temp_data_data);die;

                //Middle Loop Start

                if ($tm == 0) {

                    if ($dateStart <= $Temp_data[$tm]['start_date']) {
                        $NewStartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['start_date'])));
                    } else {
                        $NewStartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart)));
                    }
                 
                    if ($dateEnd > $Temp_data[$tm]['end_date']) {
                        $NewEndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['end_date'])));
                    } else {
                        $NewEndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd)));
                    }
                }
                else if ($tm == count($Temp_data) - 1 && count($Temp_data) > 1) {

                    if ($dateEnd > $Temp_data[$tm]['end_date']) {
                        $NewEndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['end_date'])));
                    } else {
                        $NewEndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd)));
                    }

                    $NewStartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['start_date'])));

                }
                else {

                    $NewStartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['start_date'])));
                    $NewEndGmtDate   = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['end_date'])));
                }
             
                                 
                $navData = db__select("select  sys_msg_type,  gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",
                    geo_street, geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time,
                    round(tel_temperature,2) as 'temprature',round(jny_distance,2) as 'jny_distance',tel_rfid  from matrix.today_speed where   tel_temperature!=0.000000000 and
                    sys_service_id=" . $vehicleList . "   and gps_time >= '" . $NewStartGmtDate . "' and
                    gps_time <= '" . $NewEndGmtDate . "'" . $ExtraQry1 . "  ORDER BY gps_time asc ", $condition);
             
                //echo "
";print_r($navData);die;
                             
                if ($navData[0]["temprature"] != '') {

                    for ($na = 0; $na < count($navData); $na++) {

                      if($Temp_data[$tm]['set_temp'] != '' && $Temp_data[$tm]['set_temp_to'] != '' && $Temp_data[$tm]["set_temp_to"] != 0)
                      {

                         if($Temp_data[$tm]["set_temp"] == -18 && $Temp_data[$tm]["set_temp_to"] == -25)
                         {
                             $Temp_data[$tm]["set_temp"] = -25;
                             $Temp_data[$tm]["set_temp_to"] = -18;
                         }


                        if($navData[$na]["temprature"]>=$Temp_data[$tm]['set_temp'] && $navData[$na]["temprature"]<=$Temp_data[$tm]['set_temp_to'])
                        {
                            $arr = array(
                                'gps_time' => $navData[$na]["gps_time"],
                                'gps_latitude' => $navData[$na]["gps_latitude"],
                                'gps_longitude' => $navData[$na]["gps_longitude"],
                                'gps_speed' => $navData[$na]["gps_speed"],
                                'temprature' => $navData[$na]["temprature"],
                                'date' => $navData[$na]["gps_time"],
                                'value' => $navData[$na]["temprature"],
                                'jny_distance' =>  $navData[$na]["jny_distance"],
				'tel_rfid' =>  $navData[$na]["tel_rfid"]
                            );
                            array_push($temp_data_data, $arr);
                        }
                        elseif($navData[$na]["temprature"]<$Temp_data[$tm]['set_temp'])
                        {
                         
                            $navData[$na]["temprature"] = SetTempLessVal($Temp_data[$tm]["set_temp"],$Temp_data[$tm]["set_temp_to"],$navData[$na]["temprature"]);
                         
                            $arr = array(
                                'gps_time' => $navData[$na]["gps_time"],
                                'gps_latitude' => $navData[$na]["gps_latitude"],
                                'gps_longitude' => $navData[$na]["gps_longitude"],
                                'gps_speed' => $navData[$na]["gps_speed"],
                                'temprature' => $navData[$na]["temprature"],
                                'date' => $navData[$na]["gps_time"],
                                'value' => $navData[$na]["temprature"],
                                'jny_distance' => $navData[$na]["jny_distance"],
				'tel_rfid' => $navData[$na]["tel_rfid"]
				
                            );
                            array_push($temp_data_data, $arr);

                        }
                        else
                        {
                         
                            $navData[$na]["temprature"] = SetTempGreateVal($Temp_data[$tm]["set_temp"],$Temp_data[$tm]["set_temp_to"],$navData[$na]["temprature"]);

                            $arr = array(
                                'gps_time' => $navData[$na]["gps_time"],
                                'gps_latitude' => $navData[$na]["gps_latitude"],
                                'gps_longitude' => $navData[$na]["gps_longitude"],
                                'gps_speed' => $navData[$na]["gps_speed"],
                                'temprature' => $navData[$na]["temprature"],
                                'date' => $navData[$na]["gps_time"],
                                'value' => $navData[$na]["temprature"],
                                'jny_distance' => $navData[$na]["jny_distance"],
				'tel_rfid' => $navData[$na]["tel_rfid"]

                            );
                            array_push($temp_data_data, $arr);
                        }
                   }
                   else
                    {
                        $arr = array(
                            'gps_time' => $navData[$na]["gps_time"],
                            'gps_latitude' => $navData[$na]["gps_latitude"],
                            'gps_longitude' => $navData[$na]["gps_longitude"],
                            'gps_speed' => $navData[$na]["gps_speed"],
                            'temprature' => $navData[$na]["temprature"] - $Temp_data[$tm]['t2_temp'],
                            'date' => $navData[$na]["gps_time"],
                            'value' => $navData[$na]["temprature"] - $Temp_data[$tm]['t2_temp'],
                            'jny_distance' => $navData[$na]["jny_distance"],
			    'tel_rfid' => $navData[$na]["tel_rfid"]
                        );
                        array_push($temp_data_data, $arr);
                    }

                  }

               }

             
             
                $newQry = "select  sys_msg_type,  gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", geo_street,
                    geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time,
                    round(tel_temperature,2) as 'temprature',round(jny_distance,2) as 'jny_distance',tel_rfid from matrix.today_ideal where   tel_temperature!=0.000000000
                    and sys_service_id=" . $vehicleList . "   and gps_time >= '" . $NewStartGmtDate . "' and
                    gps_time <= '" . $NewEndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ";

                $navData2 = db__select($newQry, $condition);
             
                //echo "
";print_r($navData2);die;
             
                if ($navData2[0]["temprature"] != '') {

                    for ($na2 = 0; $na2 < count($navData2); $na2++) {

                        if($Temp_data[$tm]['set_temp'] != '' && $Temp_data[$tm]['set_temp_to'] != '' && $Temp_data[$tm]['set_temp_to'] !=0 )
                        {

                            if($Temp_data[$tm]["set_temp"] == -18 && $Temp_data[$tm]["set_temp_to"] == -25)
                             {
                                 $Temp_data[$tm]["set_temp"] = -25;
                                 $Temp_data[$tm]["set_temp_to"] = -18;
                             }

                            if($navData2[$na2]["temprature"]>=$Temp_data[$tm]['set_temp'] && $navData2[$na2]["temprature"]<=$Temp_data[$tm]['set_temp_to'])
                            {
                                $arr = array(
                                    'gps_time' => $navData2[$na2]["gps_time"],
                                    'gps_latitude' => $navData2[$na2]["gps_latitude"],
                                    'gps_longitude' => $navData2[$na2]["gps_longitude"],
                                    'gps_speed' => $navData2[$na2]["gps_speed"],
                                    'temprature' => $navData2[$na2]["temprature"],
                                    'date' => $navData2[$na2]["gps_time"],
                                    'value' => $navData2[$na2]["temprature"],
                                    'jny_distance' => $navData2[$na2]["jny_distance"],
				    'tel_rfid' => $navData2[$na2]["tel_rfid"]
                                );
                                array_push($temp_data_data, $arr);

                            }
                            elseif($navData2[$na2]["temprature"]<$Temp_data[$tm]['set_temp'])
                            {
                                $navData2[$na2]["temprature"] = SetTempLessVal($Temp_data[$tm]["set_temp"],$Temp_data[$tm]["set_temp_to"],$navData2[$na2]["temprature"]);

                                $arr = array(
                                    'gps_time' => $navData2[$na2]["gps_time"],
                                    'gps_latitude' => $navData2[$na2]["gps_latitude"],
                                    'gps_longitude' => $navData2[$na2]["gps_longitude"],
                                    'gps_speed' => $navData2[$na2]["gps_speed"],
                                    'temprature' => $navData2[$na2]["temprature"],
                                    'date' => $navData2[$na2]["gps_time"],
                                    'value' => $navData2[$na2]["temprature"],
                                    'jny_distance' => $navData2[$na2]["jny_distance"],
				    'tel_rfid' => $navData2[$na2]["tel_rfid"]
 
                                );
                                array_push($temp_data_data, $arr);

                            }
                            else
                            {

                                $navData2[$na2]["temprature"] = SetTempGreateVal($Temp_data[$tm]["set_temp"],$Temp_data[$tm]["set_temp_to"],$navData2[$na2]["temprature"]);

                                $arr = array(
                                    'gps_time' => $navData2[$na2]["gps_time"],
                                    'gps_latitude' => $navData2[$na2]["gps_latitude"],
                                    'gps_longitude' => $navData2[$na2]["gps_longitude"],
                                    'gps_speed' => $navData2[$na2]["gps_speed"],
                                    'temprature' => $navData2[$na2]["temprature"],
                                    'date' => $navData2[$na2]["gps_time"],
                                    'value' => $navData2[$na2]["temprature"],
                                    'jny_distance' => $navData2[$na2]["jny_distance"],
				    'tel_rfid' => $navData2[$na2]["tel_rfid"]
 
                                );
                                array_push($temp_data_data, $arr);

                            }
                        }
                        else
                        {
                            $arr = array(
                                'gps_time' => $navData2[$na2]["gps_time"],
                                'gps_latitude' => $navData2[$na2]["gps_latitude"],
                                'gps_longitude' => $navData2[$na2]["gps_longitude"],
                                'gps_speed' => $navData2[$na2]["gps_speed"],
                                'temprature' => $navData2[$na2]["temprature"] - $Temp_data[$tm]['t2_temp'],
                                'date' => $navData2[$na2]["gps_time"],
                                'value' => $navData2[$na2]["temprature"] - $Temp_data[$tm]['t2_temp'],
                                'jny_distance' => $navData2[$na2]["jny_distance"],
				'tel_rfid' => $navData2[$na2]["tel_rfid"]

 
                            );
                            array_push($temp_data_data, $arr);
                        }

                   }
                }


                if ($_SESSION['UserId'] == "48711" ||  $_SESSION['UserId'] == "78422") {
                    $diff_of_minutes = 5;
                } 
				else if ($_SESSION['UserId'] == "78252") {
                    $diff_of_minutes = 10;
                } else if ($_SESSION['UserId'] == "79448") {
                    $diff_of_minutes = 15;
                } 
				
				else {
                    $diff_of_minutes = 30;
                }

                if ($diff_of_minutes != "") {
                    $goupbymin = $diff_of_minutes * 60;
                    $ExtraQry  = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin;
                   // $ActKm     = GetCalculatedKM($dateStart, $dateEnd, $vehicleList);
                } else {
                    $ExtraQry = " group by gps_date,gps_time ";
                }


                if ($_SESSION['UserId'] == "4871" ||  $_SESSION['UserId'] == "78422") {

                    $ExtraQry = " group by DATE_FORMAT(CONCAT(gps_date,' ',gps_time),'%Y-%m-%d %h:%i') ";
                }


                for ($countYear = 0; $countYear < count($dbArray); $countYear++) {

                  if ($dbArray[$countYear] != "matrix_" . date("m_y")) {

                    db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                    . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",
                    tel_temperature,jny_distance,tel_rfid  from " . $dbArray[$countYear] . ".telemetry_new
                    where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                    CONCAT(gps_date,' ',gps_time) >= '" . $NewStartGmtDate . "' and
                    CONCAT(gps_date,' ',gps_time) <= '" . $NewEndGmtDate . "'   group by gps_date,gps_time", "$condition ");
                                     
                    db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                    . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",
                    tel_temperature,jny_distance,tel_rfid   from " . $dbArray[$countYear] . ".telemetry_idle
                    where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                    CONCAT(gps_date,' ',gps_time) >= '" . $NewStartGmtDate . "' and
                    CONCAT(gps_date,' ',gps_time) <= '" . $NewEndGmtDate . "'   group by gps_date,gps_time", "$condition ");
                 
                  }

                }

                $goupbymin1=$diff_of_minutes * 60;
                $navData4 = db__select_staging("select * from historydata where gps_time >= '" . $NewStartGmtDate . "' and
                gps_time <= '" . $NewEndGmtDate . "' GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV " . $goupbymin1, $condition);
                                         
                //echo "
";print_r($navData4);die;

                if ($navData4[0]["tel_temperature"] != '') {

                    for ($na4 = 0; $na4 < count($navData4); $na4++) {

                        if($Temp_data[$tm]['set_temp'] != '' && $Temp_data[$tm]['set_temp_to'] != '' && $Temp_data[$tm]['set_temp_to'] !=0)
                        {

                            if($Temp_data[$tm]["set_temp"] == -18 && $Temp_data[$tm]["set_temp_to"] == -25)
                             {
                                 $Temp_data[$tm]["set_temp"] = -25;
                                 $Temp_data[$tm]["set_temp_to"] = -18;
                             }

                            if($navData4[$na4]["tel_temperature"]>=$Temp_data[$tm]['set_temp'] && $navData4[$na4]["tel_temperature"]<=$Temp_data[$tm]['set_temp_to'])
                            {
                                $arr = array(
                                    'gps_time' => $navData4[$na4]["gps_time"],
                                    'gps_latitude' => $navData4[$na4]["gps_latitude"],
                                    'gps_longitude' => $navData4[$na4]["gps_longitude"],
                                    'gps_speed' => $navData4[$na4]["gps_speed"],
                                    'temprature' => $navData4[$na4]["tel_temperature"],
                                    'date' => $navData4[$na4]["gps_time"],
                                    'value' => $navData4[$na4]["tel_temperature"],
                                    'jny_distance' =>  $navData4[$na4]["jny_distance"],
				     'tel_rfid' =>  $navData4[$na4]["tel_rfid"]
                                );
                                array_push($temp_data_data, $arr);
                            }
                            elseif($navData4[$na4]["tel_temperature"]<$Temp_data[$tm]['set_temp'])
                            {
                             
                                $navData4[$na4]["tel_temperature"] = SetTempLessVal($Temp_data[$tm]["set_temp"],$Temp_data[$tm]["set_temp_to"],$navData4[$na4]["tel_temperature"]);

                                $arr = array(
                                    'gps_time' => $navData4[$na4]["gps_time"],
                                    'gps_latitude' => $navData4[$na4]["gps_latitude"],
                                    'gps_longitude' => $navData4[$na4]["gps_longitude"],
                                    'gps_speed' => $navData4[$na4]["gps_speed"],
                                    'temprature' => $navData4[$na4]["tel_temperature"],
                                    'date' => $navData4[$na4]["gps_time"],
                                    'value' => $navData4[$na4]["tel_temperature"],
                                    'jny_distance' =>  $navData4[$na4]["jny_distance"],
				      'tel_rfid' =>  $navData4[$na4]["tel_rfid"]
                                );
                                array_push($temp_data_data, $arr);
                            }
                            else
                            {
         
                                $navData4[$na4]["tel_temperature"] = SetTempGreateVal($Temp_data[$tm]["set_temp"],$Temp_data[$tm]["set_temp_to"],$navData4[$na4]["tel_temperature"]);

                                $arr = array(
                                    'gps_time' => $navData4[$na4]["gps_time"],
                                    'gps_latitude' => $navData4[$na4]["gps_latitude"],
                                    'gps_longitude' => $navData4[$na4]["gps_longitude"],
                                    'gps_speed' => $navData4[$na4]["gps_speed"],
                                    'temprature' => $navData4[$na4]["tel_temperature"],
                                    'date' => $navData4[$na4]["gps_time"],
                                    'value' => $navData4[$na4]["tel_temperature"],
                                    'jny_distance' => $navData4[$na4]["jny_distance"],
				    'tel_rfid' => $navData4[$na4]["tel_rfid"]
                                );
                                array_push($temp_data_data, $arr);
                            }
                        }
                        else
                        {
                            $arr = array(
                                'gps_time' => $navData4[$na4]["gps_time"],
                                'gps_latitude' => $navData4[$na4]["gps_latitude"],
                                'gps_longitude' => $navData4[$na4]["gps_longitude"],
                                'gps_speed' => $navData4[$na4]["gps_speed"],
                                'temprature' => $navData4[$na4]["tel_temperature"] - $Temp_data[$tm]['t2_temp'],
                                'date' => $navData4[$na4]["gps_time"],
                                'value' => $navData4[$na4]["tel_temperature"] - $Temp_data[$tm]['t2_temp'],
                                'jny_distance' => $navData4[$na4]["jny_distance"],
				'tel_rfid' => $navData4[$na4]["tel_rfid"]
                            );
                            array_push($temp_data_data, $arr);
                        }

                    }
                }

                //echo "
";print_r($temp_data_data);die;

                // End loop Start.
                if ($tm == count($Temp_data) - 1) {

                    if ($dateEnd > $Temp_data[$tm]['end_date']) {

                        $lastStartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['end_date'])));
                        $lastEndGmtDate   = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd)));

                        $diffrance = $obj->dateDifference($lastStartGmtDate, $lastEndGmtDate);

                        if ($diffrance >= 10) {

                            $navData = db__select("select  sys_msg_type,  gps_time, gps_latitude, gps_longitude,
                            ".$GEtspeedas.", geo_street, geo_town,geo_country, geo_postcode, jny_distance,des_movement_id,
                            jny_duration, jny_idle_time, round(tel_temperature,2) as 'temprature',tel_rfid
                            from matrix.today_speed where   tel_temperature!=0.000000000 and
                            sys_service_id=" . $vehicleList . "   and gps_time >= '" . $lastStartGmtDate . "' and
                            gps_time <= '" . $lastEndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition);

                            if ($navData[0]["temprature"] != '') {
                                for ($na = 0; $na < count($navData); $na++) {
                                    $arr = array(

                                        'gps_time' => $navData[$na]["gps_time"],
                                        'gps_latitude' => $navData[$na]["gps_latitude"],
                                        'gps_longitude' => $navData[$na]["gps_longitude"],
                                        'gps_speed' => $navData[$na]["gps_speed"],
                                        'temprature' => $navData[$na]["temprature"],
                                        'date' => $navData[$na]["gps_time"],
                                        'value' => $navData[$na]["temprature"],
                                        'jny_distance' => $navData[$na]["jny_distance"],
					 'tel_rfid' => $navData[$na]["tel_rfid"]
                                    );
                                    array_push($temp_data_data, $arr);
                                }
                            }


                            $newQry = "select  sys_msg_type,  gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",
                            geo_street, geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time,
                            round(tel_temperature,2) as 'temprature',tel_rfid from matrix.today_ideal where tel_temperature!=0.000000000
                            and sys_service_id=" . $vehicleList . "   and gps_time >= '" . $lastStartGmtDate . "' and
                            gps_time <= '" . $lastEndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ";

                            $navData2 = db__select($newQry, $condition);

                            if ($navData2[0]["temprature"] != '') {
                                for ($na2 = 0; $na2 < count($navData2); $na2++) {
                                    $arr = array(

                                        'gps_time' => $navData2[$na2]["gps_time"],
                                        'gps_latitude' => $navData2[$na2]["gps_latitude"],
                                        'gps_longitude' => $navData2[$na2]["gps_longitude"],
                                        'gps_speed' => $navData2[$na2]["gps_speed"],
                                        'temprature' => $navData2[$na2]["temprature"],
                                        'date' => $navData2[$na2]["gps_time"],
                                        'value' => $navData2[$na2]["temprature"],
                                        'jny_distance' => $navData2[$na2]["jny_distance"],
					'tel_rfid' => $navData2[$na2]["tel_rfid"]
                                    );
                                    array_push($temp_data_data, $arr);
                                }
                            }


                            if ($_SESSION['UserId'] == "48711") {
                                $diff_of_minutes = 15;
                            }
							else if ($_SESSION['UserId'] == "78252") {
                    $diff_of_minutes = 10;
                } else if ($_SESSION['UserId'] == "79448") {
                    $diff_of_minutes = 15;
                } 
							else {
                                $diff_of_minutes = 30;
                            }

                            if ($diff_of_minutes != "") {
                                $goupbymin = $diff_of_minutes * 60;
                                $ExtraQry  = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin;
                                //$ActKm     = GetCalculatedKM($dateStart, $dateEnd, $vehicleList);
                            } else {
                                $ExtraQry = " group by gps_date,gps_time ";
                            }


                            if ($_SESSION['UserId'] == "4871") {

                                $ExtraQry = " group by DATE_FORMAT(CONCAT(gps_date,' ',gps_time),'%Y-%m-%d %h:%i') ";
                            }

                            for ($countYear = 0; $countYear < count($dbArray); $countYear++) {

                              /*  $navData3 = db__select_staging("select sys_msg_type,  CONCAT(gps_date,' ',gps_time) as gps_time, gps_latitude,
                             gps_longitude, ".$GEtspeedas.",des_movement_id,geo_street,geo_town,geo_country,
                             geo_postcode, jny_distance, jny_duration, jny_idle_time,round(tel_temperature,2) as 'temprature'
                             from " . $dbArray[$countYear] . ".telemetry_new
                             where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                             CONCAT(gps_date,' ',gps_time) >= '" . $lastStartGmtDate . "' and
                             CONCAT(gps_date,' ',gps_time) <= '" . $lastEndGmtDate . "'  " . $ExtraQry, $condition);*/
                            if ($dbArray[$countYear] != "matrix_" . date("m_y"))
                            {

                            db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                            . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",
                            tel_temperature,jny_distance,tel_rfid    from " . $dbArray[$countYear] . ".telemetry_new
                            where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                            CONCAT(gps_date,' ',gps_time) >= '" . $lastStartGmtDate . "' and
                            CONCAT(gps_date,' ',gps_time) <= '" . $lastEndGmtDate . "'     group by gps_date,gps_time", "$condition ");


                            db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                            . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",
                            tel_temperature,jny_distance ,tel_rfid   from " . $dbArray[$countYear] . ".telemetry_idle where
                            tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                            CONCAT(gps_date,' ',gps_time) >= '" . $lastStartGmtDate . "' and
                            CONCAT(gps_date,' ',gps_time) <= '" . $lastEndGmtDate . "'    group by gps_date,gps_time", "$condition ");

                            }

                            $goupbymin1=$diff_of_minutes * 60;

                          }

                          $navData4 = db__select_staging("select * from historydata where gps_time >= '" . $lastStartGmtDate . "' and
                            gps_time <= '" . $lastEndGmtDate . "'  GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV " . $goupbymin1, $condition);


                          if ($navData4[0]["tel_temperature"] != '') {
                                for ($na4 = 0; $na4 < count($navData4); $na4++) {
                                    $arr = array(

                                        'gps_time' => $navData4[$na4]["gps_time"],
                                        'gps_latitude' => $navData4[$na4]["gps_latitude"],
                                        'gps_longitude' => $navData4[$na4]["gps_longitude"],
                                        'gps_speed' => $navData4[$na4]["gps_speed"],
                                        'temprature' => $navData4[$na4]["tel_temperature"],
                                        'date' =>$navData4[$na4]["gps_time"],
                                        'value' => $navData4[$na4]["tel_temperature"],
                                        'jny_distance' => $navData4[$na4]["jny_distance"],
					'tel_rfid' => $navData4[$na4]["tel_rfid"]

                                    );
                                    array_push($temp_data_data, $arr);
                                }
                          }




                        } //End Diffrence 15 Min If Loop

                    } //End Date End If Loop

                } // End Last loop

                // echo "
";print_r($temp_data_data);die;

            } //End Query For Loop

        } // End if condition

        else {
      
            $navData = db__select("select  sys_msg_type,  gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",
                    geo_street, geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time,
                    round(tel_temperature,2) as 'temprature',tel_rfid  from matrix.today_speed where   tel_temperature!=0.000000000 and
                    sys_service_id=" . $vehicleList . "   and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'
                    " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition);

            if ($navData[0]["temprature"] != '') {
                for ($na = 0; $na < count($navData); $na++) {
                    $arr = array(

                        'gps_time' => $navData[$na]["gps_time"],
                        'gps_latitude' => $navData[$na]["gps_latitude"],
                        'gps_longitude' => $navData[$na]["gps_longitude"],
                        'gps_speed' => $navData[$na]["gps_speed"],
                        'temprature' => $navData[$na]["temprature"],
                        'date' => $navData[$na]["gps_time"],
                        'value' => $navData[$na]["temprature"],
                        'jny_distance' => $navData[$na]["jny_distance"],
			'tel_rfid' => $navData[$na]["tel_rfid"]
                    );
                    array_push($temp_data_data, $arr);
                }
            }

            $newQry = "select  sys_msg_type,  gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", geo_street,
                    geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time,
                    round(tel_temperature,2) as 'temprature',tel_rfid from matrix.today_ideal where tel_temperature!=0.000000000 and
                    sys_service_id=" . $vehicleList . "   and gps_time >= '" . $StartGmtDate . "' and
                    gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ";

            $navData2 = db__select($newQry, $condition);

            if ($navData2[0]["temprature"] != '') {
                for ($na2 = 0; $na2 < count($navData2); $na2++) {
                    $arr = array(

                        'gps_time' => $navData2[$na2]["gps_time"],
                        'gps_latitude' => $navData2[$na2]["gps_latitude"],
                        'gps_longitude' => $navData2[$na2]["gps_longitude"],
                        'gps_speed' => $navData2[$na2]["gps_speed"],
                        'temprature' => $navData2[$na2]["temprature"],
                        'date' =>  $navData2[$na2]["gps_time"],
                        'value' =>  $navData2[$na2]["temprature"],
                        'jny_distance' => $navData2[$na2]["jny_distance"],
			'tel_rfid' => $navData2[$na2]["tel_rfid"]
                    );
                    array_push($temp_data_data, $arr);
                }
            }

			$navData3 = db__select("select DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,round(tel_temperature,2) as value,gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",
des_movement_id, round(tel_temperature,2) as 'temprature',round(jny_distance,2) as jny_distance,`geo_street`,des_movement_id,tel_rfid from matrix.today_speed_" . date("d") . "_a
where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and
gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition);


if ($navData3[0]["temprature"] != '') {
for ($na3 = 0; $na3 < count($navData3); $na3++) {
$arr = array(

'gps_time' => $navData3[$na3]["gps_time"],
'gps_latitude' => $navData3[$na3]["gps_latitude"],
'gps_longitude' => $navData3[$na3]["gps_longitude"],
'gps_speed' => $navData3[$na3]["gps_speed"],
'temprature' => $navData3[$na3]["temprature"],
'date' => $navData3[$na3]["date"],
'value' => $navData3[$na3]["temprature"],
'jny_distance' => $navData3[$na3]["jny_distance"],
'tel_rfid' => $navData3[$na3]["tel_rfid"]
);
array_push($temp_data_data, $arr);
}
}$navData4 = db__select("select DATE_FORMAT( ADDDATE(gps_time,INTERVAL 19800 SECOND),'%a %b %d %Y %H:%i:%s') as `date`,
round(tel_temperature,2) as value,gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",
des_movement_id, round(tel_temperature,2) as 'temprature',round(jny_distance,2) as jny_distance,`geo_street`,tel_rfid,
des_movement_id from
matrix.today_ideal_" . date("d") . "_a where
tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and
gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition);



if ($navData4[0]["temprature"] != '') {
for ($na4 = 0; $na4 < count($navData4); $na4++) {
$arr = array(

'gps_time' => $navData4[$na4]["gps_time"],
'gps_latitude' => $navData4[$na4]["gps_latitude"],
'gps_longitude' => $navData4[$na4]["gps_longitude"],
'gps_speed' => $navData4[$na4]["gps_speed"],
'temprature' => $navData4[$na4]["temprature"],
'date' => $navData4[$na4]["date"],
'value' => $navData4[$na4]["temprature"],
'jny_distance' => $navData4[$na4]["jny_distance"],
'tel_rfid' => $navData4[$na4]["tel_rfid"]

);
array_push($temp_data_data, $arr);
}
}

            if ($_SESSION['UserId'] == "48711" || $_SESSION['UserId'] == "78422" ) {
                $diff_of_minutes = 5;
            } 
			else if ($_SESSION['UserId'] == "78252") {
                    $diff_of_minutes = 10;
                } else if ($_SESSION['UserId'] == "79448") {
                    $diff_of_minutes = 15;
                } 
			else {
                $diff_of_minutes = 30;
            }

            if ($diff_of_minutes != "") {
                $goupbymin = $diff_of_minutes * 60;
                $ExtraQry  = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin;
                //$ActKm     = GetCalculatedKM($dateStart, $dateEnd, $vehicleList);
            } else {
                $ExtraQry = " group by gps_date,gps_time ";
            }


            if ($_SESSION['UserId'] == "4871") {

                $ExtraQry = " group by DATE_FORMAT(CONCAT(gps_date,' ',gps_time),'%Y-%m-%d %h:%i') ";
            }
      

            for ($countYear = 0; $countYear < count($dbArray); $countYear++) {

                /* $StartGmtDate=$obj->convertToGMT($dateStart,$_SESSION['TimeZoneDiff']);
                $EndGmtDate=$obj->convertToGMT($dateEnd,$_SESSION['TimeZoneDiff']);*/


                 if ($dbArray[$countYear] != "matrix_" . date("m_y")) {

                    db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                    . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",
                    tel_temperature  ,jny_distance,tel_rfid  from " . $dbArray[$countYear] . ".telemetry_new
                    where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                    CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and
                    CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."     group by gps_date,gps_time", "$condition ");

                    db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                    . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",
                    tel_temperature  ,jny_distance,tel_rfid  from " . $dbArray[$countYear] . ".telemetry_idle
                    where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                    CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and
                    CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."     group by gps_date,gps_time", "$condition ");
                 }

              $goupbymin1 = $diff_of_minutes * 60;

              }

            $navData4 = db__select_staging("select * from historydata where gps_time >= '" . $StartGmtDate . "' and
            gps_time <= '". $EndGmtDate."  GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV " . $goupbymin1, $condition);
 
             //GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV " . $goupbymin1

            for ($na4 = 0; $na4 < count($navData4); $na4++) {
                $arr = array(
                    'gps_time' => $navData4[$na4]["gps_time"],
                    'gps_latitude' => $navData4[$na4]["gps_latitude"],
                    'gps_longitude' => $navData4[$na4]["gps_longitude"],
                    'gps_speed' => $navData4[$na4]["gps_speed"],
                    'temprature' => $navData4[$na4]["tel_temperature"],
                    'date' => $navData4[$na4]["gps_time"],
                    'value' => $navData4[$na4]["tel_temperature"],
                    'jny_distance' => $navData4[$na4]["jny_distance"],
		     'tel_rfid' => $navData4[$na4]["tel_rfid"]
                );
                array_push($temp_data_data, $arr);
            }

         }

      } // End T2 Temprature loop
      else if ($CheckUserInAmin=="excel_file")
      {

        $navData4 = db__select_staging("select sys_service_id,sys_proc_time,". "CONCAT(gps_date,' ',gps_time) as gps_time,
                                        gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature,jny_distance,tel_rfid
                                        from matrix.telemetry_temperature where
                                        tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                                        CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and
                                        CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."   group by gps_date,gps_time", $condition);


        //GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV " . $goupbymin1

        for ($na4 = 0; $na4 < count($navData4); $na4++) {
            $arr = array(
                'gps_time' =>date("Y-m-d H:i:s", strtotime(' -330 minutes', strtotime( $navData4[$na4]["gps_time"]))),
                'gps_latitude' => $navData4[$na4]["gps_latitude"],
                'gps_longitude' => $navData4[$na4]["gps_longitude"],
                'gps_speed' => $navData4[$na4]["gps_speed"],
                'temprature' => $navData4[$na4]["tel_temperature"],
                'date' => date("Y-m-d H:i:s", strtotime(' -330 minutes', strtotime( $navData4[$na4]["gps_time"]))),
                'value' => $navData4[$na4]["tel_temperature"],
                'jny_distance' => $navData4[$na4]["jny_distance"],
		'tel_rfid' => $navData4[$na4]["tel_rfid"]
            );
            array_push($temp_data_data, $arr);
        }
    }


    //DIE();


        //echo "
";print_r($temp_data);die;

        /*$data1=array();

        for($countNavData=0;$countNavDataarray_msort($temp_data_data, array(
            'gps_time' => SORT_ASC
        ));

        foreach ($data2 as $val) {
            $TemperatureData[] = $val;
        }
       
        $_SESSION["temp_data"] =  $TemperatureData;
       
       // echo "
";print_r($TemperatureData);die;
?>
  
  
  

Temperture Report

dateDifference($local_time, $local_time2); if($_SESSION['ParentId'] == '760711') { $show = false; if ($diffrance>= 20) { /*echo $minutes=date("i", strtotime($TemperatureData[$i]['gps_time'])); echo $minutes_1=date("i", strtotime($TemperatureData[$i-1]['gps_time'])); echo $minutes_1."--"; echo $minutes."--"; echo $diffIn2records=$minutes_1-$minutes; die(); if($diffIn2records>10 && $i!=0) { $show=true; }*/ $show = true; } } else { $show = true; } if ($local_time >= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { if ($show == true) { $Date = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($TemperatureData[$i]['gps_time']))); $tempToShow = $TemperatureData[$i]['temprature']; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$TemperatureData[$i]["gps_latitude"],$TemperatureData[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } if($i!=0) { if($diffrance>30) { $fixerCnt=round($diffrance/30); for($ex=1;$ex< $fixerCnt;$ex++) { $addmins=30*$ex; $sumMinutes=$_SESSION['TimeZoneDiff']+$addmins; //die(); $Date1 = date("Y-m-d H:i:s",strtotime($sumMinutes.' minutes', strtotime($TemperatureData[$i-1]['gps_time']))); $tempToShow1 = $TemperatureData[$i]['temprature']; //$starttimefrom = date("d-m-Y H:i",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($Diagnostic[$i]['gps_time']))); ?> " />
Date Temperature Temperature2 Speed (Km/h) Humidity Lat Long Location
°C Km/H
°C Km/H
35) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 35) - 1)); } if($_SESSION['UserId']=='78422') { $diff_of_minutes = 5; } else { $diff_of_minutes = 30; } //$diff_of_minutes = 30; $temp_data_data = array(); $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry1 = " GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV " . $goupbymin; } else { $ExtraQry1 = " group by gps_time "; } if ($_SESSION['UserId'] == "4871") { $ExtraQry1 = " group by DATE_FORMAT(gps_time,'%Y-%m-%d %h:%i') "; } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); $DataInAdmin = db__select_staging("select input_type from matrix.coldex_admin_details where user_id=".$_SESSION['UserId']." order by update_time desc limit 1", $condition); //print_R($DataInAdmin); $CheckUserInAmin=$DataInAdmin[0]["input_type"]; if($CheckUserInAmin=="") { $CheckUserInAmin="t2_temp"; } if ($CheckUserInAmin=="t2_temp") { $Temp_data = db__select_staging("select * from matrix.temperature_manual_entry_tbl where sys_veh_id='" . $vehicleList . "' and ((start_date>'" . $dateStart . "' and end_date<'". $EndGmtDate." ) or (('" . $dateStart . "' BETWEEN start_date AND end_date ) or ('". $EndGmtDate." BETWEEN start_date AND end_date ))) group by start_date,end_date", $condition); db__query_staging("CREATE TEMPORARY TABLE historydata( `sys_service_id` BIGINT(20) UNSIGNED NOT NULL, `sys_proc_time` DATETIME NOT NULL, `gps_time` DATETIME NOT NULL, `gps_latitude` FLOAT(12,9) NOT NULL, `gps_longitude` FLOAT(12,9) NOT NULL, `gps_speed` FLOAT(12,9) NOT NULL,tel_temperature FLOAT(12,9) NOT NULL ) ",""); if (count($Temp_data) > 0) { //echo "
";print_r($Temp_data);die;

            for ($tm = 0; $tm < count($Temp_data); $tm++) {
                // Initial loop Start.
                if ($tm == 0) {
                    $beforeStartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart)));
                    $beforeEndGmtDate   = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['start_date'])));
                    $diffrance          = $obj->dateDifference($beforeStartGmtDate, $beforeEndGmtDate);

                    if ($diffrance >= $diff_of_minutes) {



                        $navData = db__select("select  sys_msg_type,  gps_time, gps_latitude, gps_longitude,
                            ".$GEtspeedas.", geo_street, geo_town,geo_country, geo_postcode, jny_distance,des_movement_id,
                            jny_duration, jny_idle_time, tel_temperature as 'temprature'
                            from matrix.today_speed where   tel_temperature!=0.000000000 and
                            sys_service_id=" . $vehicleList . "   and gps_time >= '" . $beforeStartGmtDate . "' and
                            gps_time <= '" . $beforeEndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition);




                        if ($navData[0]["temprature"] != '') {
                            for ($na = 0; $na < count($navData); $na++) {
                                $arr = array(

                                    'gps_time' => $navData[$na]["gps_time"],
                                    'gps_latitude' => $navData[$na]["gps_latitude"],
                                    'gps_longitude' => $navData[$na]["gps_longitude"],
                                    'gps_speed' => $navData[$na]["gps_speed"],

                                    'temprature' => $navData[$na]["temprature"]
                                );
                                array_push($temp_data_data, $arr);
                            }
                        }


                  $newQry = "select  sys_msg_type,  gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",
                    geo_street, geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time,
                    tel_temperature as 'temprature' from " . $dbArray[$countYear] . ".today_ideal where
                    tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and gps_time >= '" . $beforeStartGmtDate . "'
                    and gps_time <= '" . $beforeEndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ";

                        $navData2 = db__select($newQry, $condition);

                        if ($navData2[0]["temprature"] != '') {
                            for ($na2 = 0; $na2 < count($navData2); $na2++) {
                                $arr = array(

                                    'gps_time' => $navData2[$na2]["gps_time"],
                                    'gps_latitude' => $navData2[$na2]["gps_latitude"],
                                    'gps_longitude' => $navData2[$na2]["gps_longitude"],
                                    'gps_speed' => $navData2[$na2]["gps_speed"],

                                    'temprature' => $navData2[$na2]["temprature"]
                                );
                                array_push($temp_data_data, $arr);
                            }
                        }


                        if ($_SESSION['UserId'] == "48711") {
                            $diff_of_minutes = 15;
                        } else {
                            $diff_of_minutes = 30;
                        }

                        if ($diff_of_minutes != "") {
                            $goupbymin = $diff_of_minutes * 60;
                            $ExtraQry  = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin;
                            //$ActKm     = GetCalculatedKM($dateStart, $dateEnd, $vehicleList);
                        } else {
                            $ExtraQry = " group by gps_date,gps_time ";
                        }


                        if ($_SESSION['UserId'] == "4871") {

                            $ExtraQry = " group by DATE_FORMAT(CONCAT(gps_date,' ',gps_time),'%Y-%m-%d %h:%i') ";
                        }

                        for ($countYear = 0; $countYear < count($dbArray); $countYear++) {

                          /*  $navData3 = db__select_staging("select sys_msg_type,  CONCAT(gps_date,' ',gps_time) as gps_time, gps_latitude,
                             gps_longitude, ".$GEtspeedas.",des_movement_id,geo_street,geo_town,geo_country,
                             geo_postcode, jny_distance, jny_duration, jny_idle_time,tel_temperature as 'temprature'
                             from " . $dbArray[$countYear] . ".telemetry_new
                             where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                             CONCAT(gps_date,' ',gps_time) >= '" . $beforeStartGmtDate . "' and
                             CONCAT(gps_date,' ',gps_time) <= '" . $beforeEndGmtDate . "'  " . $ExtraQry, $condition);*/

                            if ($dbArray[$countYear] != "matrix_" . date("m_y")) {
                      
                            db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                            . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature   from " . $dbArray[$countYear] . ".telemetry_new
                            where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                            CONCAT(gps_date,' ',gps_time) >= '" . $beforeStartGmtDate . "' and
                            CONCAT(gps_date,' ',gps_time) <= '" . $beforeEndGmtDate . "'  group by gps_date,gps_time", "$condition ");
                      
                      
                      
                            db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                            . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature   from " . $dbArray[$countYear] . ".telemetry_idle where
                            tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                            CONCAT(gps_date,' ',gps_time) >= '" . $beforeStartGmtDate . "' and
                            CONCAT(gps_date,' ',gps_time) <= '" . $beforeEndGmtDate . "'  group by gps_date,gps_time", "$condition ");
                            }
                            } //End For Loop
                      
                      
                            $goupbymin1=30 *60;
                            $navData4 = db__select_staging("select * from historydata where gps_time >= '" . $beforeStartGmtDate . "' and  gps_time <= '" . $beforeEndGmtDate . "' GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV " . $goupbymin1, $condition);
                      

                            if ($navData4[0]["tel_temperature"] != '') {
                                for ($na4 = 0; $na4 < count($navData4); $na4++) {
                                    $arr = array(

                                        'gps_time' => $navData4[$na4]["gps_time"],
                                        'gps_latitude' => $navData4[$na4]["gps_latitude"],
                                        'gps_longitude' => $navData4[$na4]["gps_longitude"],
                                        'gps_speed' => $navData4[$na4]["gps_speed"],

                                        'temprature' => $navData4[$na4]["tel_temperature"]
                                    );

                                    array_push($temp_data_data, $arr);

                                }
                            }







                    } //End If Loop

                } // End initial value loop
                //echo "
";print_r($temp_data);die;

                //Middle Loop Start

                if ($tm == 0) {
                    if ($dateStart <= $Temp_data[$tm]['start_date']) {
                        $NewStartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['start_date'])));
                    } else {
                        $NewStartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart)));
                    }

                    $NewEndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['end_date'])));
                } else if ($tm == count($Temp_data) - 1 && count($Temp_data) > 1) {
                    if ($dateEnd > $Temp_data[$tm]['end_date']) {
                        $NewEndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['end_date'])));
                    } else {
                        $NewEndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd)));
                    }

                    $NewStartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['start_date'])));

                } else {
                    $NewStartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['start_date'])));
                    $NewEndGmtDate   = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['end_date'])));
                }

                $navData = db__select("select  sys_msg_type,  gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",
                    geo_street, geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time,
                    tel_temperature as 'temprature'  from matrix.today_speed where   tel_temperature!=0.000000000 and
                    sys_service_id=" . $vehicleList . "   and gps_time >= '" . $NewStartGmtDate . "' and
                    gps_time <= '" . $NewEndGmtDate . "'" . $ExtraQry1 . "  ORDER BY gps_time asc ", $condition);

                if ($navData[0]["temprature"] != '') {
                    for ($na = 0; $na < count($navData); $na++) {
                        $arr = array(

                            'gps_time' => $navData[$na]["gps_time"],
                            'gps_latitude' => $navData[$na]["gps_latitude"],
                            'gps_longitude' => $navData[$na]["gps_longitude"],
                            'gps_speed' => $navData[$na]["gps_speed"],

                            'temprature' => $navData[$na]["temprature"] - $Temp_data[$tm]['t2_temp']
                        );
                        array_push($temp_data_data, $arr);
                    }
                }


                $newQry = "select  sys_msg_type,  gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", geo_street,
                    geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time,
                    tel_temperature as 'temprature' from matrix.today_ideal where   tel_temperature!=0.000000000
                    and sys_service_id=" . $vehicleList . "   and gps_time >= '" . $NewStartGmtDate . "' and
                    gps_time <= '" . $NewEndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ";

                $navData2 = db__select($newQry, $condition);

                if ($navData2[0]["temprature"] != '') {
                    for ($na2 = 0; $na2 < count($navData2); $na2++) {
                        $arr = array(

                            'gps_time' => $navData2[$na2]["gps_time"],
                            'gps_latitude' => $navData2[$na2]["gps_latitude"],
                            'gps_longitude' => $navData2[$na2]["gps_longitude"],
                            'gps_speed' => $navData2[$na2]["gps_speed"],

                            'temprature' => $navData2[$na2]["temprature"] - $Temp_data[$tm]['t2_temp']
                        );
                        array_push($temp_data_data, $arr);
                    }
                }


                if ($_SESSION['UserId'] == "48711") {
                    $diff_of_minutes = 15;
                } else {
                    $diff_of_minutes = 30;
                }

                if ($diff_of_minutes != "") {
                    $goupbymin = $diff_of_minutes * 60;
                    $ExtraQry  = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin;
                   // $ActKm     = GetCalculatedKM($dateStart, $dateEnd, $vehicleList);
                } else {
                    $ExtraQry = " group by gps_date,gps_time ";
                }


                if ($_SESSION['UserId'] == "4871") {

                    $ExtraQry = " group by DATE_FORMAT(CONCAT(gps_date,' ',gps_time),'%Y-%m-%d %h:%i') ";
                }

                for ($countYear = 0; $countYear < count($dbArray); $countYear++) {



                  if ($dbArray[$countYear] != "matrix_" . date("m_y")) {



                    db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                    . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature   from " . $dbArray[$countYear] . ".telemetry_new
                    where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                    CONCAT(gps_date,' ',gps_time) >= '" . $NewStartGmtDate . "' and
                    CONCAT(gps_date,' ',gps_time) <= '" . $NewEndGmtDate . "'   group by gps_date,gps_time", "$condition ");
                    db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                    . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature   from " . $dbArray[$countYear] . ".telemetry_idle
                    where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                    CONCAT(gps_date,' ',gps_time) >= '" . $NewStartGmtDate . "' and
                    CONCAT(gps_date,' ',gps_time) <= '" . $NewEndGmtDate . "'   group by gps_date,gps_time", "$condition ");
              
                  }
                }
          
            $goupbymin1=30 *60;
            $navData4 = db__select_staging("select * from historydata where gps_time >= '" . $NewStartGmtDate . "' and  gps_time <= '" . $NewEndGmtDate . "' GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV " . $goupbymin1, $condition);



                    if ($navData4[0]["tel_temperature"] != '') {
                        for ($na4 = 0; $na4 < count($navData4); $na4++) {
                            $arr = array(

                                'gps_time' => $navData4[$na4]["gps_time"],
                                'gps_latitude' => $navData4[$na4]["gps_latitude"],
                                'gps_longitude' => $navData4[$na4]["gps_longitude"],
                                'gps_speed' => $navData4[$na4]["gps_speed"],

                                'temprature' => $navData4[$na4]["tel_temperature"] - $Temp_data[$tm]['t2_temp']
                            );
                            array_push($temp_data_data, $arr);
                        }
                    }





                // End loop Start.
                if ($tm == count($Temp_data) - 1) {
                    if ($dateEnd > $Temp_data[$tm]['end_date']) {
                        $lastStartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Temp_data[$tm]['end_date'])));
                        $lastEndGmtDate   = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd)));

                        $diffrance = $obj->dateDifference($lastStartGmtDate, $lastEndGmtDate);

                        if ($diffrance >= 10) {




                            $navData = db__select("select  sys_msg_type,  gps_time, gps_latitude, gps_longitude,
                            ".$GEtspeedas.", geo_street, geo_town,geo_country, geo_postcode, jny_distance,des_movement_id,
                            jny_duration, jny_idle_time, tel_temperature as 'temprature'
                            from matrix.today_speed where   tel_temperature!=0.000000000 and
                            sys_service_id=" . $vehicleList . "   and gps_time >= '" . $lastStartGmtDate . "' and
                            gps_time <= '" . $lastEndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition);

                            if ($navData[0]["temprature"] != '') {
                                for ($na = 0; $na < count($navData); $na++) {
                                    $arr = array(

                                        'gps_time' => $navData[$na]["gps_time"],
                                        'gps_latitude' => $navData[$na]["gps_latitude"],
                                        'gps_longitude' => $navData[$na]["gps_longitude"],
                                        'gps_speed' => $navData[$na]["gps_speed"],

                                        'temprature' => $navData[$na]["temprature"]
                                    );
                                    array_push($temp_data_data, $arr);
                                }
                            }


                            $newQry = "select  sys_msg_type,  gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",
                            geo_street, geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time,
                            tel_temperature as 'temprature' from matrix.today_ideal where tel_temperature!=0.000000000
                            and sys_service_id=" . $vehicleList . "   and gps_time >= '" . $lastStartGmtDate . "' and
                            gps_time <= '" . $lastEndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ";

                            $navData2 = db__select($newQry, $condition);

                            if ($navData2[0]["temprature"] != '') {
                                for ($na2 = 0; $na2 < count($navData2); $na2++) {
                                    $arr = array(

                                        'gps_time' => $navData2[$na2]["gps_time"],
                                        'gps_latitude' => $navData2[$na2]["gps_latitude"],
                                        'gps_longitude' => $navData2[$na2]["gps_longitude"],
                                        'gps_speed' => $navData2[$na2]["gps_speed"],

                                        'temprature' => $navData2[$na2]["temprature"]
                                    );
                                    array_push($temp_data_data, $arr);
                                }
                            }


                            if ($_SESSION['UserId'] == "48711") {
                                $diff_of_minutes = 15;
                            } else {
                                $diff_of_minutes = 30;
                            }

                            if ($diff_of_minutes != "") {
                                $goupbymin = $diff_of_minutes * 60;
                                $ExtraQry  = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin;
                                //$ActKm     = GetCalculatedKM($dateStart, $dateEnd, $vehicleList);
                            } else {
                                $ExtraQry = " group by gps_date,gps_time ";
                            }


                            if ($_SESSION['UserId'] == "4871") {

                                $ExtraQry = " group by DATE_FORMAT(CONCAT(gps_date,' ',gps_time),'%Y-%m-%d %h:%i') ";
                            }

                            for ($countYear = 0; $countYear < count($dbArray); $countYear++) {

                              /*  $navData3 = db__select_staging("select sys_msg_type,  CONCAT(gps_date,' ',gps_time) as gps_time, gps_latitude,
                             gps_longitude, ".$GEtspeedas.",des_movement_id,geo_street,geo_town,geo_country,
                             geo_postcode, jny_distance, jny_duration, jny_idle_time,tel_temperature as 'temprature'
                             from " . $dbArray[$countYear] . ".telemetry_new
                             where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                             CONCAT(gps_date,' ',gps_time) >= '" . $lastStartGmtDate . "' and
                             CONCAT(gps_date,' ',gps_time) <= '" . $lastEndGmtDate . "'  " . $ExtraQry, $condition);*/
                            if ($dbArray[$countYear] != "matrix_" . date("m_y")) {
                      
                      
                      
                            db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                            . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature    from " . $dbArray[$countYear] . ".telemetry_new
                            where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                            CONCAT(gps_date,' ',gps_time) >= '" . $lastStartGmtDate . "' and
                            CONCAT(gps_date,' ',gps_time) <= '" . $lastEndGmtDate . "'     group by gps_date,gps_time", "$condition ");
                      
                      
                            db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                            . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature     from " . $dbArray[$countYear] . ".telemetry_idle where
                            tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                            CONCAT(gps_date,' ',gps_time) >= '" . $lastStartGmtDate . "' and
                            CONCAT(gps_date,' ',gps_time) <= '" . $lastEndGmtDate . "'    group by gps_date,gps_time", "$condition ");
                            }
                            $goupbymin1=30 *60;
                            }
                            $navData4 = db__select_staging("select * from historydata where gps_time >= '" . $lastStartGmtDate . "' and  gps_time <= '" . $lastEndGmtDate . "'  GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV " . $goupbymin1, $condition);


                                if ($navData4[0]["tel_temperature"] != '') {
                                    for ($na4 = 0; $na4 < count($navData4); $na4++) {
                                        $arr = array(

                                            'gps_time' => $navData4[$na4]["gps_time"],
                                            'gps_latitude' => $navData4[$na4]["gps_latitude"],
                                            'gps_longitude' => $navData4[$na4]["gps_longitude"],
                                            'gps_speed' => $navData4[$na4]["gps_speed"],

                                            'temprature' => $navData4[$na4]["tel_temperature"]
                                        );
                                        array_push($temp_data_data, $arr);
                                    }
                                }






                        } //End Diffrence 15 Min If Loop

                    } //End Date End If Loop

                } // End Last loop
              //  echo "
";print_r($temp_data_data);die;

            } //End Query For Loop

        } // End if condition
        else {

            $navData = db__select("select  sys_msg_type,  gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.",
                    geo_street, geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time,
                    tel_temperature as 'temprature'  from matrix.today_speed where   tel_temperature!=0.000000000 and
                    sys_service_id=" . $vehicleList . "   and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . "
                    ORDER BY gps_time asc ", $condition);

            if ($navData[0]["temprature"] != '') {
                for ($na = 0; $na < count($navData); $na++) {
                    $arr = array(

                        'gps_time' => $navData[$na]["gps_time"],
                        'gps_latitude' => $navData[$na]["gps_latitude"],
                        'gps_longitude' => $navData[$na]["gps_longitude"],
                        'gps_speed' => $navData[$na]["gps_speed"],

                        'temprature' => $navData[$na]["temprature"]
                    );
                    array_push($temp_data_data, $arr);
                }
            }

            $newQry = "select  sys_msg_type,  gps_time, gps_latitude, gps_longitude, ".$GEtspeedas.", geo_street,
                    geo_town,geo_country, geo_postcode, jny_distance,des_movement_id, jny_duration, jny_idle_time,
                    tel_temperature as 'temprature' from matrix.today_ideal where tel_temperature!=0.000000000 and
                    sys_service_id=" . $vehicleList . "   and gps_time >= '" . $StartGmtDate . "' and
                    gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ";

            $navData2 = db__select($newQry, $condition);

            if ($navData2[0]["temprature"] != '') {
                for ($na2 = 0; $na2 < count($navData2); $na2++) {
                    $arr = array(

                        'gps_time' => $navData2[$na2]["gps_time"],
                        'gps_latitude' => $navData2[$na2]["gps_latitude"],
                        'gps_longitude' => $navData2[$na2]["gps_longitude"],
                        'gps_speed' => $navData2[$na2]["gps_speed"],

                        'temprature' => $navData2[$na2]["temprature"]
                    );
                    array_push($temp_data_data, $arr);
                }
            }

            if ($_SESSION['UserId'] == "48711") {
                $diff_of_minutes = 15;
            } else {
                $diff_of_minutes = 30;
            }

            if ($diff_of_minutes != "") {
                $goupbymin = $diff_of_minutes * 60;
                $ExtraQry  = " GROUP BY (UNIX_TIMESTAMP(CONCAT(gps_date,' ',gps_time))) DIV " . $goupbymin;
                //$ActKm     = GetCalculatedKM($dateStart, $dateEnd, $vehicleList);
            } else {
                $ExtraQry = " group by gps_date,gps_time ";
            }


            if ($_SESSION['UserId'] == "4871") {

                $ExtraQry = " group by DATE_FORMAT(CONCAT(gps_date,' ',gps_time),'%Y-%m-%d %h:%i') ";
            }

            for ($countYear = 0; $countYear < count($dbArray); $countYear++) {

                /* $StartGmtDate=$obj->convertToGMT($dateStart,$_SESSION['TimeZoneDiff']);
                $EndGmtDate=$obj->convertToGMT($dateEnd,$_SESSION['TimeZoneDiff']);*/


               /* $navData3 = db__select_staging("select sys_msg_type,  CONCAT(gps_date,' ',gps_time) as gps_time, gps_latitude, gps_longitude,
                     ".$GEtspeedas.",des_movement_id,geo_street,geo_town,geo_country, geo_postcode, jny_distance,
                     jny_duration, jny_idle_time,round(tel_temperature,2) as 'temprature' from " . $dbArray[$countYear] . ".telemetry_new
                     where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                     CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and
                     CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."  " . $ExtraQry, $condition);*/


                                         /*  db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature     from " . $dbArray[$countYear] . ".telemetry_new
                     where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                     CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and
                     CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."     group by gps_date,gps_time", "$condition ");*/
 if ($dbArray[$countYear] != "matrix_" . date("m_y")) {

                                  db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature     from " . $dbArray[$countYear] . ".telemetry_temperature where
                    tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                    CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and
                    CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."   group by gps_date,gps_time", "$condition ");
                                         db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature     from " . $dbArray[$countYear] . ".telemetry_new
                     where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                     CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and
                     CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."     group by gps_date,gps_time", "$condition ");
                                          db__query_staging("insert into  historydata select sys_service_id,sys_proc_time,"
                . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature     from " . $dbArray[$countYear] . ".telemetry_idle
                     where   tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                     CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and
                     CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."     group by gps_date,gps_time", "$condition ");
 }
                      $goupbymin1 = 30 * 60;
                      }

                    $navData4 = db__select_staging("select * from historydata where gps_time >= '" . $StartGmtDate . "' and  gps_time <= '". $EndGmtDate." GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV 1800 ", $condition);


                         //GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV " . $goupbymin1

                    for ($na4 = 0; $na4 < count($navData4); $na4++) {
                        $arr = array(
                            'gps_time' => $navData4[$na4]["gps_time"],
                            'gps_latitude' => $navData4[$na4]["gps_latitude"],
                            'gps_longitude' => $navData4[$na4]["gps_longitude"],
                            'gps_speed' => $navData4[$na4]["gps_speed"],
                            'temprature' => $navData4[$na4]["tel_temperature"]
                        );
                        array_push($temp_data_data, $arr);
                    }

        }
                }
                else if ($CheckUserInAmin=="excel_file")
                {

                    $navData4 = db__select_staging("select sys_service_id,sys_proc_time,"
                    . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature     from matrix.telemetry_temperature where
                    tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . "   and
                    CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and
                    CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."   group by gps_date,gps_time", $condition);


                         //GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV " . $goupbymin1

                    for ($na4 = 0; $na4 < count($navData4); $na4++) {
                        $arr = array(
                            'gps_time' =>date("Y-m-d H:i:s", strtotime(' -330 minutes', strtotime( $navData4[$na4]["gps_time"]))),
                            'gps_latitude' => $navData4[$na4]["gps_latitude"],
                            'gps_longitude' => $navData4[$na4]["gps_longitude"],
                            'gps_speed' => $navData4[$na4]["gps_speed"],
                            'temprature' => $navData4[$na4]["tel_temperature"]
                        );
                        array_push($temp_data_data, $arr);
                    }
                }


                //DIE();

        //echo "
";print_r($temp_data);die;

        /*$data1=array();

        for($countNavData=0;$countNavDataarray_msort($temp_data_data, array(
            'gps_time' => SORT_ASC
        ));

        foreach ($data2 as $val) {
            $TemperatureData[] = $val;
        }

        //echo "
";print_r($TemperatureData);die;
?>
  
  
  

Temperture Report

dateDifference($local_time, $local_time2); if($_SESSION['ParentId'] == '7607') { $show = false; if ($diffrance>= 20) { /*echo $minutes=date("i", strtotime($TemperatureData[$i]['gps_time'])); echo $minutes_1=date("i", strtotime($TemperatureData[$i-1]['gps_time'])); echo $minutes_1."--"; echo $minutes."--"; echo $diffIn2records=$minutes_1-$minutes; die(); if($diffIn2records>10 && $i!=0) { $show=true; }*/ $show = true; } } else { $show = true; } $show = true; if ($local_time >= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { if ($show == true) { $Date = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($TemperatureData[$i]['gps_time']))); $tempToShow = $TemperatureData[$i]['temprature']; if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$TemperatureData[$i]["gps_latitude"],$TemperatureData[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } if($i!=0) { if($diffrance>30) { $fixerCnt=round($diffrance/30); for($ex=1;$ex< $fixerCnt;$ex++) { $addmins=30*$ex; $sumMinutes=$_SESSION['TimeZoneDiff']+$addmins; //die(); $Date1 = date("Y-m-d H:i:s",strtotime($sumMinutes.' minutes', strtotime($TemperatureData[$i-1]['gps_time']))); $tempToShow1 = $TemperatureData[$i]['temprature']; //$starttimefrom = date("d-m-Y H:i",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($Diagnostic[$i]['gps_time']))); ?> " />
Date Temperature Speed (Km/h) Lat Long Location
°C Km/H
°C Km/H
31){ $dateEnd=date('Y-m-d H:i',(strtotime($dateStart))+((3600*24*31)-1)); } $StartGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateEnd))); $objDbManager=new DbManager(); $dbArray=$objDbManager->returnDbArray($dateStart,$dateEnd); $ExtraQry1=" group by gps_time "; $navData[] = db__select("select id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, ".$GEtspeedas.", geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select id, gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, ".$GEtspeedas.", geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); /* $newQry = "select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); $navData[] = db__select("select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition);*/ $ExtraQry = " group by gps_date,gps_time "; for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2, tel_temperature,tel_fuel,gps_orientation from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" .$dateEnd . "' group by gps_date,gps_time", $condition); /* $newQry = "select CONCAT(gps_date,' ',gps_time) as gps_time,id, sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition);*/ } $navData[] = db__select("select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2, tel_temperature,tel_fuel,gps_orientation from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" .$dateEnd . "' group by gps_time", $condition); $navData[] = db__select("select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2, tel_temperature,tel_fuel,gps_orientation from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" .$dateEnd . "' group by gps_time", $condition); $navData[] = db__select("select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, ".$GEtspeedas.",geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2, tel_temperature,tel_fuel,gps_orientation from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" .$dateEnd . "' group by gps_time", $condition); $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } // echo "
";print_r($Diagnostic);die;
?>
  

Overspeed Report

Location
= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $Date = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); if($Diagnostic[$i]['gps_speed']>$CheckSpeed ) { $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; $distance = $calcObj->calc_distance($PointArray); $rowwisedist=$distance; $totaldist=$totaldist+$rowwisedist; if($ChkedStatus==false) { $ChkedStatus=true; $StartDatetime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $startLoc=$Diagnostic[$i]['gps_latitude'].','.$Diagnostic[$i]['gps_longitude']; $SpeedShow=$Diagnostic[$i]['gps_speed']; } } elseif($ChkedStatus==true) { $ChkedStatus=false; // $SpeedShow=$Diagnostic[$i]['gps_speed'];ECHO "
"; $Endtime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); $Timediff = $obj->dateDifferenceSecond($StartDatetime, $Endtime); $getMinute = $obj->minDifference($Timediff); $EndLoc=$Diagnostic[$i]['gps_latitude'].','.$Diagnostic[$i]['gps_longitude']; ?>
Vehicle Number Start Time Start Location End time End Location Speed Duration Distance
Km/H
31){ $dateEnd=date('Y-m-d H:i',(strtotime($dateStart))+((3600*24*31)-1)); } $StartGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateEnd))); $objDbManager=new DbManager(); $dbArray=$objDbManager->returnDbArray($dateStart,$dateEnd); $ExtraQry1=" group by gps_time "; $navData[] = db__select("select id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage,".$GEtspeedas.", gps_longitude, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select id, gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage,".$GEtspeedas.", gps_longitude, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); /* $newQry = "select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' and gps_speed>17 " . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); $navData[] = db__select("select gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " and gps_speed>17 ORDER BY gps_time asc ", $condition);*/ $ExtraQry = " group by gps_date,gps_time "; for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select CONCAT(gps_date,' ',gps_time) as gps_time,".$GEtspeedas.",id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2, tel_temperature,tel_fuel,gps_orientation from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate."' group by CONCAT(gps_date,' ',gps_time)", $condition); /* $newQry = "select CONCAT(gps_date,' ',gps_time) as gps_time,id, sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff,tel_rfid, tel_panic as tel_panic, jny_idle_time, tel_poweralert as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' and gps_speed>17 " . $ExtraQry1 . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition);*/ } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } // echo "
";print_r($Diagnostic);die;
?>
  

freewheeling Report

Location
$CheckSpeedmin && $Diagnostic[$i]['jny_distance']<$CheckSpeedmax ) { if($Diagnostic[$i]['jny_distance']==$Diagnostic[$i-1]['jny_distance']) { //echo "fff"; //if($Diagnostic[$i]['jny_distance']>20) //{ if($ChkedStatus==false) { //if($Diagnostic[$i-1]['jny_distance']==$Diagnostic[$i]['jny_distance']) //{ $ChkedStatus=true; $StartDatetime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); $startLoc=$Diagnostic[$i]['gps_latitude'].','.$Diagnostic[$i]['gps_longitude']; //} } $distance=""; $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat'] = $Diagnostic[$i-1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i-1]['gps_longitude']; $distance = $calcObj->calc_distance($PointArray); $km=$km+ $distance; //} } } elseif($ChkedStatus==true) { $ChkedStatus=false; //$SpeedShow=$Diagnostic[$i]['gps_speed'];ECHO "
"; $Endtime = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); $Timediff = $obj->dateDifferenceSecond($StartDatetime, $Endtime); $getMinute = $obj->minDifference($Timediff); $EndLoc=$Diagnostic[$i]['gps_latitude'].','.$Diagnostic[$i]['gps_longitude']; if(strtotime($StartDatetime)!= strtotime($Endtime) && $Timediff>30 ) { // $SpeedShow=round($km/($Timediff/3600)); $SpeedShow=$Diagnostic[$i]['gps_speed']; if($SpeedShow!=0 and $km!=0) { if($SpeedShow>20) { ?>
Vehicle Number Start Time Start Location End time End Location Duration Vehicle Speed Distance Covered
Km/H
3){ $dateEnd=date('Y-m-d H:i',(strtotime($dateStart))+((3600*24*3)-1)); } $StartGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateEnd))); $objDbManager=new DbManager(); $dbArray=$objDbManager->returnDbArray($dateStart,$dateEnd); $ExtraQry1=" group by gps_time "; $navData[] = db__select("select tel_voltage,sys_proc_time,id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select tel_voltage,sys_proc_time,id, gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $newQry = "select tel_voltage,sys_proc_time,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); $navData[] = db__select("select tel_voltage,sys_proc_time,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $ExtraQry = " group by gps_date,gps_time "; for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select sys_proc_time,tel_voltage,CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2, tel_temperature,tel_fuel,gps_orientation from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" .$StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" . $EndGmtDate . "' group by gps_date,gps_time", $condition); $newQry = "select sys_proc_time,tel_voltage,CONCAT(gps_date,' ',gps_time) as gps_time,id, sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" .$StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } //echo "
";print_r($Diagnostic);die;
?>
  

Movement Report 1

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $Date = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } if($i==0) { $firstDate = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); } else { $firstDate = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); } $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } $Odometer = $Odometer + $distance; $no = $no + 1; $Timediff = $obj->dateDifferenceSecond($firstDate, $Date); $getMinute = $Timediff/60; if($Diagnostic[$i]['tel_input_0']==true) { $status = 'Ignition On'; } elseif($Diagnostic[$i]['tel_input_0']==false) { $status = 'Ignition off'; } else { $status = '--'; } //$status =$Diagnostic[$i]['tel_input_0']; if($Diagnostic[$i]['aconoff']==1) { $ACstatus = 'AC On'; } elseif($Diagnostic[$i]['aconoff']==0) { $ACstatus = 'AC off'; } else { $ACstatus = '--'; } $TimeTakeninsec = $obj->dateDifferenceSecond($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); $speedDifference=$Diagnostic[$i]['gps_speed']-$Diagnostic[$i-1]['gps_speed']; $Showspeed=$Diagnostic[$i]['gps_speed']; /*$html.='';*/ $EngineSta="Engine OFF"; if($Diagnostic[$i]['jny_distance']>0) { $EngineSta="Engine ON"; } //tel_voltage,sys_proc_time,id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage ?>
Sl No. Recieve Date GMT Date Distance Odometer Speed (Km/h) Ignition Status AC Status Engine Status Lat Long Location FUEL Internal Voltage Main Voltage vehicle Odometer View Map
'.$sr.' '.$Diagnostic[$i]['gps_time'].' '.$Diagnostic[$i]['gps_speed'].' '.$location_data.'
Km/H
View Map
3){ $dateEnd=date('Y-m-d H:i',(strtotime($dateStart))+((3600*24*3)-1)); } $StartGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateEnd))); $objDbManager=new DbManager(); $dbArray=$objDbManager->returnDbArray($dateStart,$dateEnd); if($_SESSION['UserId']=="81279" || $_SESSION['UserId']=="81058") { $ExtraQry1=" group by gps_time "; } else { $ExtraQry1=" group by gps_time "; } $navData[] = db__select("select sys_proc_time, tel_rfid,id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert,tel_voltage, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,case when tel_input_3=true then true else false end as tel_input_3 from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select sys_proc_time, tel_rfid,id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,tel_voltage,case when tel_input_3=true then true else false end as tel_input_3 from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select sys_proc_time,tel_rfid,id, gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,tel_voltage,case when tel_input_3=true then true else false end as tel_input_3 from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $newQry = "select sys_proc_time,tel_rfid,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2,case when tel_input_3=true then true else false end as tel_input_3,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); $navData[] = db__select("select sys_proc_time,tel_rfid,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,case when tel_input_3=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); //$ExtraQry = " group by gps_date,gps_time "; if($_SESSION['UserId']=="81279" || $_SESSION['UserId']=="81058") { //$ExtraQry1=" and tel_rfid is not null group by gps_time "; $ExtraQry = " and tel_rfid is not null group by gps_date,gps_time "; } else { //$ExtraQry1=" group by gps_time "; $ExtraQry = " group by gps_date,gps_time "; } if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $ExtraQryspeed = " and round(gps_speed*1.609,2)<='70' "; } else { $ExtraQryspeed = " and round(gps_speed*1.609,2)<140 "; } for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select sys_proc_time,tel_rfid,CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_voltage, tel_temperature,tel_fuel,gps_orientation,case when tel_input_3=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' " . $ExtraQryspeed.$ExtraQry1 . " ", $condition); $newQry = "select sys_proc_time,tel_rfid,CONCAT(gps_date,' ',gps_time) as gps_time,id, sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2,case when tel_input_3=true then true else false end as tel_input_3,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } //echo "
";print_r($Diagnostic);die;
?>
  

Movement Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $Date = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); if($i==0) { $firstDate = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); } else { $firstDate = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); } $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } $checkKm=1000; if($_SESSION['UserName']=="apm" || $_SESSION['login_ParentId']=="4607") { $checkKm=200; } //echo $Diagnostic[$i]['gps_time'].",".$Diagnostic[$i-1]['gps_time']; // echo "
"; $Duration=$obj->dateDifference($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); $Duration=$Duration+5; //if ($distance >= $Duration ) { if ($distance >= $checkKm) { $distance=0; // echo ";;;". $distance ; //} } $Odometer = $Odometer + $distance; if($Diagnostic[$i]['gps_speed']>5) { $Diagnostic[$i]['tel_input_0']=1; } if($Diagnostic[$i]['tel_input_0']==0) { //$Diagnostic[$i]['gps_speed']=0; } $no = $no + 1; $Timediff = $obj->dateDifferenceSecond($firstDate, $Date); $getMinute = $Timediff/60; if($Diagnostic[$i]['tel_input_0']==true) { $status = 'Ignition On'; } elseif($Diagnostic[$i]['tel_input_0']==false) { $status = 'Ignition off'; } else { $status = '--'; } //$status =$Diagnostic[$i]['tel_input_0']; if($Diagnostic[$i]['aconoff']==1) { $ACstatus = 'AC On'; } elseif($Diagnostic[$i]['aconoff']==0) { $ACstatus = 'AC off'; } else { $ACstatus = '--'; } /*$TimeTakeninsec = $obj->dateDifferenceSecond($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); $speedDifference=$Diagnostic[$i]['gps_speed']-$Diagnostic[$i-1]['gps_speed']; if($speedDifference>60 ) { if($TimeTakeninsec>600) { $Showspeed=$Diagnostic[$i-1]['gps_speed']; } else { $Showspeed=$Diagnostic[$i]['gps_speed']; } } else { $Showspeed=$Diagnostic[$i]['gps_speed']; } */ $Showspeed=$Diagnostic[$i]['gps_speed']; /*$html.='';*/ if($Diagnostic[$i]['gps_speed']>140) { $Showspeed=0; } if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { if($Diagnostic[$i]['gps_speed']>70) { $Showspeed=0; } } if($Diagnostic[$i-1]['gps_speed']==$Diagnostic[$i]['gps_speed']) { //$Showspeed=0; } $EngineSta="Engine OFF"; if($Diagnostic[$i]['jny_distance']>0) { $EngineSta="Engine ON"; } if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } ?>
Date GMT Date Data Receiving Date Distance Odometer Speed (Km/h) Ignition Status AC Status Engine Status Lat Long Location FUEL RPM RFID vehicle Odometer tel_input_1 tel_input_3 Internal Voltage Main Power Status View Map
'.$sr.' '.$Diagnostic[$i]['gps_time'].' '.$Diagnostic[$i]['gps_speed'].' '.$location_data.'
Km/H
View Map
3){ $dateEnd=date('Y-m-d H:i',(strtotime($dateStart))+((3600*24*3)-1)); } $StartGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateEnd))); $objDbManager=new DbManager(); $dbArray=$objDbManager->returnDbArray($dateStart,$dateEnd); if($_SESSION['UserId']=="81279" || $_SESSION['UserId']=="81058") { $ExtraQry1=" group by gps_time "; } else { $ExtraQry1=" group by gps_time "; } $navData[] = db__select("select sys_proc_time, tel_rfid,id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert,tel_voltage, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,case when tel_input_3=true then true else false end as tel_input_3 from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select sys_proc_time, tel_rfid,id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,tel_voltage,case when tel_input_3=true then true else false end as tel_input_3 from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select sys_proc_time,tel_rfid,id, gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,tel_voltage,case when tel_input_3=true then true else false end as tel_input_3 from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $newQry = "select sys_proc_time,tel_rfid,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2,case when tel_input_3=true then true else false end as tel_input_3,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); $navData[] = db__select("select sys_proc_time,tel_rfid,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,case when tel_input_3=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); //$ExtraQry = " group by gps_date,gps_time "; if($_SESSION['UserId']=="81279" || $_SESSION['UserId']=="81058") { //$ExtraQry1=" and tel_rfid is not null group by gps_time "; $ExtraQry = " and tel_rfid is not null group by gps_date,gps_time "; } else { //$ExtraQry1=" group by gps_time "; $ExtraQry = " group by gps_date,gps_time "; } if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $ExtraQryspeed = " and round(gps_speed*1.609,2)<='70' "; } else { $ExtraQryspeed = " and round(gps_speed*1.609,2)<140 "; } for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select sys_proc_time,tel_rfid,CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_voltage, tel_temperature,tel_fuel,gps_orientation,case when tel_input_3=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' " . $ExtraQryspeed.$ExtraQry1 . " ", $condition); $newQry = "select sys_proc_time,tel_rfid,CONCAT(gps_date,' ',gps_time) as gps_time,id, sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2,case when tel_input_3=true then true else false end as tel_input_3,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } //echo "
";print_r($Diagnostic);die;
?>
  

Movement Report

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $Date = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); if($i==0) { $firstDate = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); } else { $firstDate = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); } $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } $checkKm=1000; if($_SESSION['UserName']=="apm" || $_SESSION['login_ParentId']=="4607") { $checkKm=200; } //echo $Diagnostic[$i]['gps_time'].",".$Diagnostic[$i-1]['gps_time']; // echo "
"; $Duration=$obj->dateDifference($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); $Duration=$Duration+5; //if ($distance >= $Duration ) { if ($distance >= $checkKm) { $distance=0; // echo ";;;". $distance ; //} } $Odometer = $Odometer + $distance; if($Diagnostic[$i]['gps_speed']>5) { $Diagnostic[$i]['tel_input_0']=1; } if($Diagnostic[$i]['tel_input_0']==0) { //$Diagnostic[$i]['gps_speed']=0; } $no = $no + 1; $Timediff = $obj->dateDifferenceSecond($firstDate, $Date); $getMinute = $Timediff/60; if($Diagnostic[$i]['tel_input_0']==true) { $status = 'Ignition On'; } elseif($Diagnostic[$i]['tel_input_0']==false) { $status = 'Ignition off'; } else { $status = '--'; } //$status =$Diagnostic[$i]['tel_input_0']; if($Diagnostic[$i]['aconoff']==1) { $ACstatus = 'AC On'; } elseif($Diagnostic[$i]['aconoff']==0) { $ACstatus = 'AC off'; } else { $ACstatus = '--'; } $Showspeed=$Diagnostic[$i]['gps_speed']; if($Diagnostic[$i]['gps_speed']>140) { $Showspeed=0; } if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { if($Diagnostic[$i]['gps_speed']>70) { $Showspeed=0; } } if($Diagnostic[$i-1]['gps_speed']==$Diagnostic[$i]['gps_speed']) { //$Showspeed=0; } $EngineSta="Engine OFF"; if($Diagnostic[$i]['jny_distance']>0) { $EngineSta="Engine ON"; } if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } ?>
Vehicle Number Date Time Location Lat Long Distance Speed (Km/h) Ignition Status View Map
Km/H View Map
3){ $dateEnd=date('Y-m-d H:i',(strtotime($dateStart))+((3600*24*3)-1)); } $StartGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateEnd))); $objDbManager=new DbManager(); $dbArray=$objDbManager->returnDbArray($dateStart,$dateEnd); if($_SESSION['UserId']=="81279" || $_SESSION['UserId']=="81058") { $ExtraQry1=" group by gps_time "; } else { $ExtraQry1=" group by gps_time "; } $navData[] = db__select("select sys_proc_time, tel_rfid,id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert,tel_voltage, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,case when tel_input_3=true then true else false end as tel_input_3 from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select sys_proc_time, tel_rfid,id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,tel_voltage,case when tel_input_3=true then true else false end as tel_input_3 from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select sys_proc_time,tel_rfid,id, gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,tel_voltage,case when tel_input_3=true then true else false end as tel_input_3 from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $newQry = "select sys_proc_time,tel_rfid,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2,case when tel_input_3=true then true else false end as tel_input_3,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); $navData[] = db__select("select sys_proc_time,tel_rfid,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,case when tel_input_3=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); //$ExtraQry = " group by gps_date,gps_time "; if($_SESSION['UserId']=="81279" || $_SESSION['UserId']=="81058") { //$ExtraQry1=" and tel_rfid is not null group by gps_time "; $ExtraQry = " and tel_rfid is not null group by gps_date,gps_time "; } else { //$ExtraQry1=" group by gps_time "; $ExtraQry = " group by gps_date,gps_time "; } if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $ExtraQryspeed = " and round(gps_speed*1.609,2)<='70' "; } else { $ExtraQryspeed = " and round(gps_speed*1.609,2)<140 "; } for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select sys_proc_time,tel_rfid,CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_voltage, tel_temperature,tel_fuel,gps_orientation,case when tel_input_3=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' " . $ExtraQryspeed.$ExtraQry1 . " ", $condition); $newQry = "select sys_proc_time,tel_rfid,CONCAT(gps_date,' ',gps_time) as gps_time,id, sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2,case when tel_input_3=true then true else false end as tel_input_3,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } //echo "
";print_r($Diagnostic);die;
?>
  

Movement Report Idle Merge

= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { $Date = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); $lastrecord = $i; if($i==0) { $firstDate = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); } else { $firstDate = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); } $PointArray[0]['lat'] = $Diagnostic[$i]['gps_latitude']; $PointArray[0]['long'] = $Diagnostic[$i]['gps_longitude']; $PointArray[1]['lat'] = $Diagnostic[$i - 1]['gps_latitude']; $PointArray[1]['long'] = $Diagnostic[$i - 1]['gps_longitude']; if ($PointArray[1]['lat'] != "") { $distance = $calcObj->calc_distance($PointArray); } $checkKm=1000; if($_SESSION['UserName']=="apm" || $_SESSION['login_ParentId']=="4607") { $checkKm=200; } //echo $Diagnostic[$i]['gps_time'].",".$Diagnostic[$i-1]['gps_time']; // echo "
"; $Duration=$obj->dateDifference($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); $Duration=$Duration+5; //if ($distance >= $Duration ) { if ($distance >= $checkKm) { $distance=0; // echo ";;;". $distance ; //} } $Odometer = $Odometer + $distance; if($Diagnostic[$i]['gps_speed']>5) { $Diagnostic[$i]['tel_input_0']=1; } if($Diagnostic[$i]['tel_input_0']==0) { //$Diagnostic[$i]['gps_speed']=0; } $no = $no + 1; $Timediff = $obj->dateDifferenceSecond($firstDate, $Date); $getMinute = $Timediff/60; if($Diagnostic[$i]['tel_input_0']==true) { $status = 'Ignition On'; } elseif($Diagnostic[$i]['tel_input_0']==false) { $status = 'Ignition off'; } else { $status = '--'; } //$status =$Diagnostic[$i]['tel_input_0']; if($Diagnostic[$i]['aconoff']==1) { $ACstatus = 'AC On'; } elseif($Diagnostic[$i]['aconoff']==0) { $ACstatus = 'AC off'; } else { $ACstatus = '--'; } $Showspeed=$Diagnostic[$i]['gps_speed']; if($Diagnostic[$i]['gps_speed']>140) { $Showspeed=0; } if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { if($Diagnostic[$i]['gps_speed']>70) { $Showspeed=0; } } if($Diagnostic[$i-1]['gps_speed']==$Diagnostic[$i]['gps_speed']) { //$Showspeed=0; } $EngineSta="Engine OFF"; if($Diagnostic[$i]['jny_distance']>0) { $EngineSta="Engine ON"; } //&& $no==1 if ($status == "Ignition off" && $stop == false) { if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } $DiagnosticArray = array( 'vehicle_no' => $vehicle_no, 'Date' => $Date, 'location' => $startlocation, 'gps_latitude' => $Diagnostic[$i]['gps_latitude'], 'gps_longitude' => $Diagnostic[$i]['gps_longitude'], 'distance' => $distance, 'gps_speed' => $Diagnostic[$i]['gps_speed1'], 'status' => $status, ); array_push($Mergediagnosticarray, $DiagnosticArray); $stop = true; } else if($status == "Ignition On" && $running == false) { if($Diagnostic[$i-1]['tel_input_0']==false && $no!=1) { $Date2 = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($Diagnostic[$i-1]['gps_time']))); if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i-1]["gps_latitude"],$Diagnostic[$i-1]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } $DiagnosticArray = array( 'vehicle_no' => $vehicle_no, 'Date' => $Date2, 'location' => $startlocation, 'gps_latitude' => $Diagnostic[$i-1]['gps_latitude'], 'gps_longitude' => $Diagnostic[$i-1]['gps_longitude'], 'distance' => 0, 'gps_speed' => $Diagnostic[$i-1]['gps_speed1'], 'status' => "Ignition off", ); array_push($Mergediagnosticarray, $DiagnosticArray); $stop = false; } if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } $DiagnosticArray = array( 'vehicle_no' => $vehicle_no, 'Date' => $Date, 'location' => $startlocation, 'gps_latitude' => $Diagnostic[$i]['gps_latitude'], 'gps_longitude' => $Diagnostic[$i]['gps_longitude'], 'distance' => $distance, 'gps_speed' => $Diagnostic[$i]['gps_speed1'], 'status' => $status, ); array_push($Mergediagnosticarray, $DiagnosticArray); $running = false; } // Ignition Loop End } } } //if ($status == "Ignition off" && $stop == true) if($Diagnostic[$lastrecord]['tel_input_0']==false && $no!=1) { $Date2 = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($Diagnostic[$lastrecord]['gps_time']))); if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$lastrecord]["gps_latitude"],$Diagnostic[$lastrecord]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } $DiagnosticArray = array( 'vehicle_no' => $vehicle_no, 'Date' => $Date2, 'location' => $startlocation, 'gps_latitude' => $Diagnostic[$lastrecord]['gps_latitude'], 'gps_longitude' => $Diagnostic[$lastrecord]['gps_longitude'], 'distance' => 0, 'gps_speed' => $Diagnostic[$lastrecord]['gps_speed1'], 'status' => "Ignition off", ); array_push($Mergediagnosticarray, $DiagnosticArray); } //echo "
";print_r($Mergediagnosticarray);die;
					
					
		$nor = 0;
        for ($dig = 0; $dig <= count($Mergediagnosticarray)-1 ; $dig++)
		{			
			if($Mergediagnosticarray[$dig]['status'] == "Ignition off")
			{
			
			?>
            
".$Mergediagnosticarray[$dig+1]['Date']; ?>" />
Vehicle Number Date Time Location Lat Long Distance Speed (Km/h) Ignition Status View Map
".$Mergediagnosticarray[$dig+1]['Date'];?> Km/H View Map
Km/H View Map
3){ $dateEnd=date('Y-m-d H:i',(strtotime($dateStart))+((3600*24*3)-1)); } $StartGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s",strtotime('-'.$_SESSION['TimeZoneDiff'].' minutes', strtotime($dateEnd))); $objDbManager=new DbManager(); $dbArray=$objDbManager->returnDbArray($dateStart,$dateEnd); if($_SESSION['UserId']=="81279" || $_SESSION['UserId']=="81058") { $ExtraQry1=" group by gps_time "; } else { $ExtraQry1=" group by gps_time "; } $navData[] = db__select("select sys_proc_time, tel_rfid,id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert,tel_voltage, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,case when tel_input_3=true then true else false end as tel_input_3 from matrix.today_speed where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select sys_proc_time, tel_rfid,id ,gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,tel_voltage,case when tel_input_3=true then true else false end as tel_input_3 from matrix.telemetry where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "'" . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $navData[] = db__select("select sys_proc_time,tel_rfid,id, gps_time as gps_time, sys_msg_type, gps_latitude, main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1, geo_street, geo_town, geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,gps_orientation,tel_voltage,case when tel_input_3=true then true else false end as tel_input_3 from matrix.today_speed_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); $newQry = "select sys_proc_time,tel_rfid,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2,case when tel_input_3=true then true else false end as tel_input_3,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".today_ideal where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; $navData[] = db__select($newQry, $condition); $navData[] = db__select("select sys_proc_time,tel_rfid,gps_time as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2,tel_temperature,tel_fuel,case when tel_input_3=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".today_ideal_" . date("d") . "_a where sys_service_id=" . $vehicleList . " and gps_time >= '" . $StartGmtDate . "' and gps_time <= '" . $EndGmtDate . "' " . $ExtraQry1 . " ORDER BY gps_time asc ", $condition); //$ExtraQry = " group by gps_date,gps_time "; if($_SESSION['UserId']=="81279" || $_SESSION['UserId']=="81058") { //$ExtraQry1=" and tel_rfid is not null group by gps_time "; $ExtraQry = " and tel_rfid is not null group by gps_date,gps_time "; } else { //$ExtraQry1=" group by gps_time "; $ExtraQry = " group by gps_date,gps_time "; } if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $ExtraQryspeed = " and round(gps_speed*1.609,2)<='70' "; } else { $ExtraQryspeed = " and round(gps_speed*1.609,2)<140 "; } for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData[] = db__select_staging("select sys_proc_time,tel_rfid,CONCAT(gps_date,' ',gps_time) as gps_time,id,sys_msg_type, gps_latitude,main_powervoltage, gps_longitude,case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0, case when tel_input_2=true then true else false end as tel_input_2,tel_voltage, tel_temperature,tel_fuel,gps_orientation,case when tel_input_3=true then true else false end as tel_input_3 from " . $dbArray[$countYear] . ".telemetry_new where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' " . $ExtraQryspeed.$ExtraQry1 . " ", $condition); $newQry = "select sys_proc_time,tel_rfid,CONCAT(gps_date,' ',gps_time) as gps_time,id, sys_msg_type, gps_latitude,main_powervoltage, gps_longitude, case when round(gps_speed*1.609,0)>".$_SESSION['speedcheck']." then '0' else round(gps_speed*1.609,0) end as gps_speed1,geo_street,geo_town,geo_country, geo_postcode, jny_distance, jny_duration, case when tel_ignition=true then true else false end as aconoff, case when tel_panic=true then true else false end as tel_panic, jny_idle_time,case when tel_poweralert=false then false else true end as tel_poweralert, case when tel_input_1=true then true else false end as tel_input_1, case when tel_input_0=true then true else false end as tel_input_0,tel_voltage, case when tel_input_2=true then true else false end as tel_input_2,case when tel_input_3=true then true else false end as tel_input_3,tel_temperature,tel_fuel from " . $dbArray[$countYear] . ".telemetry_idle where sys_service_id=" . $vehicleList . " and gps_date >= '" . date("Y-m-d", strtotime($StartGmtDate)) . "' and gps_date <= '" . date("Y-m-d", strtotime($dateEnd)) . "' " . $ExtraQry1 . " ORDER BY gps_time asc "; //ORDER BY gps_date,gps_time asc $navData[] = db__select_staging($newQry, $condition); } $data1 = array(); for ($countNavData = 0; $countNavData < count($navData); $countNavData++) { if (is_array($navData[$countNavData])) { $data1 = array_merge($data1, $navData[$countNavData]); } } $obj1 = new MyClass(); $data2 = $obj1->array_msort($data1, array( 'gps_time' => SORT_ASC )); foreach ($data2 as $val) { $Diagnostic[] = $val; } //echo "
";print_r($Diagnostic);die;
?>
  

Movement Report

calc_distance($PointArray); //} $Duration=$obj->dateDifference($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); $Duration=$Duration+5; $DurationinSEC=$obj->dateDifferenceSecond($Diagnostic[$i]['gps_time'],$Diagnostic[$i-1]['gps_time']); $distanceinmeter= $distance*1000; $Exptdistancebyduration=$DurationinSEC*10; if($Exptdistancebyduration>=$distanceinmeter) { $Odometer = $Odometer + $distance; } if($Diagnostic[$i]['tel_input_0']==true) { $status = 'Ignition On'; } elseif($Diagnostic[$i]['tel_input_0']==false) { $status = 'Ignition off'; } else { $status = '--'; } //$status =$Diagnostic[$i]['tel_input_0']; if($Diagnostic[$i]['aconoff']==1) { $ACstatus = 'AC On'; } elseif($Diagnostic[$i]['aconoff']==0) { $ACstatus = 'AC off'; } else { $ACstatus = '--'; } $EngineSta="Engine OFF"; if($Diagnostic[$i]['jny_distance']>0) { $EngineSta="Engine ON"; } if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$Diagnostic[$i]["gps_latitude"],$Diagnostic[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; } if($Exptdistancebyduration>=$distanceinmeter) { $Speeddiff=0; if($Diagnostic[$i]['gps_speed']>=30) { $Speeddiff=$Diagnostic[$i]['gps_speed']-$Diagnostic[$i-1]['gps_speed']; if($Speeddiff>10) { $Diagnostic[$i]['gps_speed']=40; } } $Date = date("Y-m-d H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($Diagnostic[$i]['gps_time']))); //addMinuteinTimeStamp($Diagnostic[$i]['gps_time'],$_SESSION['TimeZoneDiff'],'Y-m-d H:i'); ?>
Date GMT Date Data Receiving Date Distance Odometer Speed (Km/h) Ignition Status AC Status Engine Status Lat Long Location FUEL RPM RFID vehicle Odometer tel_input_1 tel_input_3 Internal Voltage Main Power Status View Map
Km/H
View Map
35) { $dateEnd = date('Y-m-d H:i', (strtotime($dateStart)) + ((3600 * 24 * 35) - 1)); } if($_SESSION['UserId']=='78422') { $diff_of_minutes = 5; } else { $diff_of_minutes = 30; } // $diff_of_minutes = 30; $temp_data_data = array(); $objDbManager = new DbManager(); $dbArray = $objDbManager->returnDbArray($dateStart, $dateEnd); if ($diff_of_minutes != "") { $goupbymin = $diff_of_minutes * 60; $ExtraQry1 = " GROUP BY (UNIX_TIMESTAMP(gps_time)) DIV " . $goupbymin; } else { $ExtraQry1 = " group by gps_time "; } if ($_SESSION['UserId'] == "4871") { $ExtraQry1 = " group by DATE_FORMAT(gps_time,'%Y-%m-%d %h:%i') "; } $StartGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateStart))); $EndGmtDate = date("Y-m-d H:i:s", strtotime('-' . $_SESSION['TimeZoneDiff'] . ' minutes', strtotime($dateEnd))); for ($countYear = 0; $countYear < count($dbArray); $countYear++) { $navData4= db__query_staging(" select sys_service_id,sys_proc_time," . "CONCAT(gps_date,' ',gps_time) as gps_time,gps_latitude,gps_longitude,".$GEtspeedas.",tel_temperature from " . $dbArray[$countYear] . ".telemetry_temperature where tel_temperature!=0.000000000 and sys_service_id=" . $vehicleList . " and CONCAT(gps_date,' ',gps_time) >= '" . $StartGmtDate . "' and CONCAT(gps_date,' ',gps_time) <= '". $EndGmtDate." group by gps_date,gps_time", "$condition "); $goupbymin1 = 30 * 60; } //$navData4 = db__select_staging("select * from from " . $dbArray[$countYear] . ".telemetry_temperature GROUP BY (UNIX_TIMESTAMP(gps_time))" . " DIV " . $goupbymin1, $condition); for ($na4 = 0; $na4 < count($navData4); $na4++) { $arr = array( 'gps_time' => $navData4[$na4]["gps_time"], 'gps_latitude' => $navData4[$na4]["gps_latitude"], 'gps_longitude' => $navData4[$na4]["gps_longitude"], 'gps_speed' => $navData4[$na4]["gps_speed"], 'temprature' => $navData4[$na4]["tel_temperature"] ); array_push($temp_data_data, $arr); } //echo "
";print_r($temp_data);die;

        /*$data1=array();

        for($countNavData=0;$countNavDataarray_msort($temp_data_data, array(
            'gps_time' => SORT_ASC
        ));

        foreach ($data2 as $val) {
            $TemperatureData[] = $val;
        }

       // echo "
";print_r($TemperatureData);die;
?>
  
  
  

Temperture Report

dateDifference($local_time, $local_time2); if($_SESSION['ParentId'] == '7607') { $show = false; if ($diffrance>= 20) { /*echo $minutes=date("i", strtotime($TemperatureData[$i]['gps_time'])); echo $minutes_1=date("i", strtotime($TemperatureData[$i-1]['gps_time'])); echo $minutes_1."--"; echo $minutes."--"; echo $diffIn2records=$minutes_1-$minutes; die(); if($diffIn2records>10 && $i!=0) { $show=true; }*/ $show = true; } } else { $show = true; } if ($local_time >= $_POST['dateStart']) { if ($local_time <= $_POST['dateEnd']) { if ($show == true) { $Date = date("d-m-Y H:i:s", strtotime($_SESSION['TimeZoneDiff'] . ' minutes', strtotime($TemperatureData[$i]['gps_time']))); $tempToShow = $TemperatureData[$i]['temprature']; /*if($report_location == "Show_Location") { if($redis_data = getRedisLocation($sess_userid,$TemperatureData[$i]["gps_latitude"],$TemperatureData[$i]["gps_longitude"],$redis)) { $startlocation = $redis_data['LocationName']; //$KMFromNearPOI = $redis_data['KMFromNearPOI']; } else { $startlocation = ''; } } else { $startlocation = ''; }*/ if($i!=0) { if($diffrance>30) { $fixerCnt=round($diffrance/30); for($ex=1;$ex< $fixerCnt;$ex++) { $addmins=30*$ex; $sumMinutes=$_SESSION['TimeZoneDiff']+$addmins; //die(); $Date1 = date("d-m-Y H:i:s",strtotime($sumMinutes.' minutes', strtotime($TemperatureData[$i-1]['gps_time']))); $tempToShow1 = $TemperatureData[$i]['temprature']; //$starttimefrom = date("d-m-Y H:i",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($Diagnostic[$i]['gps_time']))); ?> " />
Date Temperature Speed (Km/h)
°C Km/H
°C Km/H
" . $errorMsg . "

"; }?>