ClientUniqueID(); $masterObj = new master(); $obj = new MyClass(); $movingspeed = 500; if(isset($_POST["submit"])) { //echo "
";print_r($_POST);die;
	//$start_date=convert_date_to_yyyymmdd(vin_safe($_GET['Sdate']));
    $start_date=vin_safe($_POST['dateStart']);
    
    //$end_date=convert_date_to_yyyymmdd(vin_safe($_GET['Edate']));
    $end_date=vin_safe($_POST['dateEnd']);
    $veh_id=safe($_POST['veh_no']);
    
    //$veh_id = db__select("select id from services where veh_reg='".$veh_no."'", $condition);
    $movingspeed=safe($_POST['range']);

    $start_date1=1;
    $end_date1=1;
    $veh_id1=1;
    $movingspeed1=1;

    $pattern = '/^[A-Za-z0-9 \,.-]*[A-Za-z0-9][A-Za-z0-9 \,.-]*$/';
    $datePatteren='/^(?=.*[0-9])([0-9 :-]+)$/';

    //preg_match('/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', '2008-09-01 12:35:45', $m1);
    if($start_date!="")
    {
         $start_date1 = preg_match($datePatteren, $start_date, $matches, PREG_OFFSET_CAPTURE);
    }
    if($end_date!="")
    {
         $end_date1 = preg_match($datePatteren, $end_date, $matches2, PREG_OFFSET_CAPTURE);
    }
    if($veh_id!="")
    {
        $veh_id1 = preg_match($pattern, $veh_id, $matches3, PREG_OFFSET_CAPTURE);
    }
    if($movingspeed1!="")
    {
        $movingspeed1 = preg_match($pattern, $movingspeed, $matches4, PREG_OFFSET_CAPTURE);
    }

    if($start_date1 == 0 || $end_date1 == 0 || $veh_id1 == 0 || $movingspeed1 ==0)
    {
        $message= "Not Allowed  Special Character";
         exit;
         //echo "
"; } $start_date=convertToGMT($start_date,$_SESSION['TimeZoneDiff']); $end_date=convertToGMT($end_date,$_SESSION['TimeZoneDiff']); if(((((strtotime($end_date))-(strtotime($start_date)))/3600)/24)>30){ $end_date=date('Y-m-d H:i',(strtotime($start_date))+((3600*24*30)-1)); } //echo $start_date.'--'.$end_date;die; $draw_line=true; // $end_date=convertToGMT($end_date,$_SESSION['TimeZoneDiff']); //echo $veh_id.'test'; //$sys_device_type = select_query("select sys_device_type,veh_reg from services where id='$veh_id'"); //$veh_reg=$sys_device_type[0]["veh_reg"]; // Updated sys_msg_type=1 from vimal on 05- Feb // Update or sys_msg_type=7 from vineet 24 March if($veh_id!="") { $objDbManager=new DbManager(); $dbArray=$objDbManager->returnDbArray($start_date,$end_date); for($countYear=0;$countYear= '".date("Y-m-d",strtotime($start_date))."' and gps_date <= '".date("Y-m-d",strtotime($end_date))."' ", $condition); $navData[]=db__select_staging("select id,CONCAT(gps_date,' ',gps_time) as gps_time,geo_street,round(gps_speed*1.609,2) as gps_speed, geo_town,geo_country,gps_latitude,gps_longitude,round(gps_orientation,2) as gps_orientation from ".$dbArray[$countYear].".telemetry_idle where sys_service_id=".$veh_id." and gps_date >= '".date("Y-m-d",strtotime($start_date))."' and gps_date <= '".date("Y-m-d",strtotime($end_date))."' ", $condition); if($dbArray[$countYear]=="matrix") { $navData[]=db__select("select id,gps_time,geo_street,round(gps_speed*1.609,2) as gps_speed,geo_town,geo_country,gps_latitude,gps_longitude,round(gps_orientation,2) as gps_orientation from ".$dbArray[$countYear].".today_ideal where sys_service_id=".$veh_id." and gps_time>'".$start_date."' and gps_time<='".$end_date."' order by gps_time asc", $condition); $navData[]=db__select("select id,gps_time,geo_street,round(gps_speed*1.609,2) as gps_speed,geo_town,geo_country,gps_latitude,gps_longitude,round(gps_orientation,2) as gps_orientation from ".$dbArray[$countYear].".today_speed where sys_service_id=".$veh_id." and gps_time>'".$start_date."' and gps_time<='".$end_date."' order by gps_time asc", $condition); $navData[]=db__select("select id,gps_time,geo_street,round(gps_speed*1.609,2) as gps_speed,geo_town,geo_country,gps_latitude,gps_longitude,round(gps_orientation,2) as gps_orientation from ".$dbArray[$countYear].".today_ideal_".date("d")."_a where sys_service_id=".$veh_id." and gps_time>'".$start_date."' and gps_time<='".$end_date."' order by gps_time asc", $condition); $navData[]=db__select("select id,gps_time,geo_street,round(gps_speed*1.609,2) as gps_speed,geo_town,geo_country,gps_latitude,gps_longitude,round(gps_orientation,2) as gps_orientation from ".$dbArray[$countYear].".today_speed_".date("d")."_a where sys_service_id=".$veh_id." and gps_time>'".$start_date."' and gps_time<='".$end_date."' order by gps_time asc", $condition); $navData[]=db__select("select id,gps_time,geo_street,round(gps_speed*1.609,2) as gps_speed,geo_town,geo_country,gps_latitude,gps_longitude,round(gps_orientation,2) as gps_orientation from ".$dbArray[$countYear].".telemetry where sys_service_id=".$veh_id." and gps_time>'".$start_date."' and gps_time<='".$end_date."' order by gps_time asc", $condition); } } $data1=array(); for($countNavData=0;$countNavDataarray_msort($data1, array('gps_time'=>SORT_ASC)); foreach($data2 as $val) { $data[] = $val; } $ActTotalKm=0; $j=0; $statusspeedcheck=false; for($i=0;$i= $_POST['dateStart']) { if($local_time <= $_POST['dateEnd']) { //echo convertToLocal($data[$i]['gps_time'],$_SESSION['TimeZoneDiff'],'Y-m-d H:i:s'); $calcObj=new calculate_distance(); $calcObj->veh_id = $veh_id; // Below Code was Recreated as earlier we wrere getting each 5 records in in loop //$calcObj->start_date = $obj[$objArrayCount-1]->start_date; //$calcObj->end_date = $obj[$objArrayCount]->start_date; //$distance = $calcObj->calculate(); /* DiffMin = GetDiffInMin(Convert.ToDateTime(SpeedRecords.Rows[countLoop - 1]["gps_time"]), Convert.ToDateTime(SpeedRecords.Rows[countLoop]["gps_time"])); int DiffMintoCHk = DiffMin + 5; if ((CalCulatedDistance < 500) && (DiffMintoCHk > CalCulatedDistance) ) { TotalCalculatedDistance = TotalCalculatedDistance + CalCulatedDistance; JournyKM = JournyKM + CalCulatedDistance; DiffMintoCHk = 0; } */ if(date("Y-m-d H:i:s",strtotime($_SESSION['TimeZoneDiff'].' minutes', strtotime($data[$i-1]['gps_time']))) >= $_POST['dateStart']) { $Duration=$obj->dateDifference($data[$i]['gps_time'],$data[$i-1]['gps_time']); $DiffMintoCHk=$Duration+5; $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']; $distance = $calcObj->calc_distance($PointArray); //echo "
"; if($distance<500 && $DiffMintoCHk>$distance) { $ActTotalKm=$ActTotalKm+$distance; } if(in_array($_SESSION['sys_group_id'], $SppedclientGt) || in_array($_SESSION['sys_group_id_parent'], $SppedclientGt)) { $Speedcheck=80; } else { $Speedcheck=200; } if(($data[$i]['gps_speed'])>=5 && ($data[$i]['gps_speed'])<=$Speedcheck) { $currentJourney->start_date=$data[$i]['gps_time']; $currentJourney->id=$data[$i]['id']; $currentJourney->start_lat=$data[$i]['gps_latitude']; $currentJourney->start_long=$data[$i]['gps_longitude']; $currentJourney->gps_speed=$data[$i]['gps_speed']; $currentJourney->gps_orientation=$data[$i]['gps_orientation']; $currentJourney->stopwithIgnon="running"; $currentJourney->duration=""; $statusspeedcheck=false; $iststop=""; $rowposition=""; $obj_distance[$j]=$currentJourney; $j=$j+1; unset($currentJourney); } else if($statusspeedcheck==false) { $statusspeedcheck=1; $iststop=$data[$i]['gps_time']; $rowposition=$i; } } } } } $point_array=array(); $temp_script=''; $StartDate=""; $StopDate=""; $speed=""; $StopStatus=false; $setDiffValue=9; if($_SESSION['UserName']=='hcil' || $_SESSION['UserName']=='sabharwal' || $_SESSION['UserName']=='marutiempp'){ $setDiffValue=1; } for($objArrayCount=0;$objArrayCount<=count($obj_distance);$objArrayCount++){ $istrow=$obj_distance[$objArrayCount]->start_date; $secndrow=$obj_distance[$objArrayCount-1]->start_date; $firsttime=addMinuteinTimeStamp($obj_distance[1]->start_date,$_SESSION['TimeZoneDiff'],'Y-m-d H:i'); if($obj_distance[$objArrayCount]->stopwithIgnon=="stop") { $StopStatus=true; if($obj_distance[$objArrayCount]->duration==0) { $diffinmin="less than 1 min"; } else { $diffinmin=$obj->minDifference($obj_distance[$objArrayCount]->duration*60); } //echo $diffinmin;echo "ppp"; $StartDate=addMinuteinTimeStamp($secndrow,$_SESSION['TimeZoneDiff'],'d-m-y H:i'); $StartDate=$secndrow; if($secndrow!="") { $lastcontact=addMinuteinTimeStamp($secndrow,$_SESSION['TimeZoneDiff'],'d-m-y H:i'); } else { $lastcontact=0; } $speed=$obj_distance[$objArrayCount]->gps_speed; $point_array[$i]['lat']=$obj_distance[$objArrayCount-1]->start_lat; $point_array[$i]['long']=$obj_distance[$objArrayCount-1]->start_long; // if($point_array[$i]["lat"]!="") { $temp_script.='{lat:'.$point_array[$i]["lat"].', lng:'.$point_array[$i]["long"].' ,veh_reg:"'.$veh_reg.'" ,veh_id:"'.$veh_id.'",gps_orientation:"'.$obj_distance[$objArrayCount]->gps_orientation.'",lastcontact:"'.$lastcontact.'" , speed:"'.$speed.'", StopStatus:"'.$StopStatus.'", start:"'.$StartDate.'"'; $temp_script.=',stop:"'.$diffinmin.'"},'; } } else { $StopStatus=false; $point_array[$i]['lat']=$obj_distance[$objArrayCount]->start_lat; $point_array[$i]['long']=$obj_distance[$objArrayCount]->start_long; if($point_array[$i]["lat"]!="") { $temp_script.='{lat:'.$point_array[$i]["lat"].', lng:'.$point_array[$i]["long"].' ,veh_reg:"'.$veh_reg.'" ,veh_id:"'.$veh_id.'",gps_orientation:"'.$obj_distance[$objArrayCount]->gps_orientation.'",lastcontact:"'.addMinuteinTimeStamp($obj_distance[$objArrayCount]->start_date,$_SESSION['TimeZoneDiff'],'d-m-y H:i').'" , speed:"'.$speed.'", StopStatus:"'.$StopStatus.'", start:"", stop:""},'; } $speed=$obj_distance[$objArrayCount]->gps_speed; $StartDate=""; $StopDate=""; } // $lastTime=$istrow; $lastTime=addMinuteinTimeStamp($obj_distance[$objArrayCount-1]->start_date,$_SESSION['TimeZoneDiff'],'Y-m-d H:i'); } $temp_script.='];'; $final='var data = ['.$temp_script; } else { echo "Please select a vehicle"; } } ?>

History Replay

Start time : Total KM Till