function getOverAllTripReport($sdate, $vehId, $dest)
{
    $cnt = 1;
    $tmp = -1;
    $t1 = 0.0;
    $t2 = 0.0;
    $timeArr = array();
    $timediff = array();
    $strTime = '';
    $endTime = '';
    $tmpId = 0;
    $srcArr = array();
    $destArr = array();
    $stCunt = 0;
    $stChk = 0;
    $geocheck = 0;
    //print_r($dest);
    $file = $GLOBALS[dataPath] . "client_" . $_SESSION[clientID] . "/" . date("d-m-Y", strtotime($sdate)) . "/" . $vehId . ".txt";
    if (chk_folder($file)) {
        $file1 = @fopen($file, "r");
        if ($file1) {
            while (!feof($file1)) {
                $data = fgets($file1);
            }
            $data = getSortedData($data);
        }
        if (count($data) > 0) {
            $data1 = explode("#", $data);
            for ($j1 = 0; $j1 < count($data1); $j1++) {
                $data2 = explode("\$", $data1[$j1]);
                if (count($data2) > 1) {
                    $data3 = explode(",", $data2[1]);
                    //echo date("d-m-Y", strtotime($sdate))."==".date("d-m-Y",@mktime(($data3[4]+5),($data3[5]+30),$data3[6],$data3[2],$data3[1],$data3[3]));
                    $vehi = $data3[0];
                    $geodate = date("d-m-Y", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                    $geoTime = date("H:i:s A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                    $pos1 = convertLat(calLat($data3[7]));
                    $pos2 = convertLong(calLong($data3[8]));
                    $vehi = $data3[0];
                    /*$getLL=drawCircle("17.98264333","79.601965","0.16");
                    		print_r($getLL);
                    		echo $resLL=getGeofenceStatus($getLL,"17.9809383333","79.6004683333");
                    		exit;*/
                    if ($pos1 > 0 && $pos2 > 0) {
                        $sel_pts = "SELECT * FROM gps_geopoints_info WHERE gpi_clientID=" . $_SESSION[clientID] . " AND gpi_id=" . $dest;
                        $rs_sel_pts = mysql_query($sel_pts);
                        if (@mysql_affected_rows() > 0) {
                            while ($fetch_sel_pts = @mysql_fetch_assoc($rs_sel_pts)) {
                                $gcdLatLng = drawCircle($fetch_sel_pts[gpi_latVal], $fetch_sel_pts[gpi_longVal], $fetch_sel_pts[gpi_miles]);
                                //print_r($fetch_sel_pts);
                                $geocheck = getGeofenceStatus($gcdLatLng, $pos1, $pos2);
                                if ($geocheck == 1) {
                                    //print_r($gcdLatLng);
                                    /*$getLL=drawCircle("17.97905965","79.59972382","0.10");
                                    		print_r($getLL);
                                    		$resLL=getGeofenceStatus($getLL,$pos1,$pos2);*/
                                    //print_r($getLL);
                                    $result_pt = $fetch_sel_pts[gpi_stopName] . "#" . $geoTime;
                                    //echo $k." ".$j1." ".$result_pt." ".$pos1."&&".$pos2."";
                                    if ($tmpId != $fetch_sel_pts[gpi_id]) {
                                        $tmpId = $fetch_sel_pts[gpi_id];
                                        //echo $fetch_sel_pts[gpi_id]." ".$dest;
                                        //echo "pos ".in_array($fetch_sel_pts[gpi_id],$dest);
                                        //if(in_array($fetch_sel_pts[gpi_id],$dest))
                                        //{
                                        if ($destArr[$tmpId] == "") {
                                            //echo "ss".count($destArr[$tmpId])." ".$tmpId." ".$result_pt."<br>";
                                            //$destArr = array_push_assoc($destArr, $tmpId, $result_pt);
                                            $destArr[$tmpId] = $result_pt;
                                            //print_r($destArr);
                                        } else {
                                            //echo $result_pt."<br>";
                                            foreach ($destArr as $key => $value) {
                                                // echo "Key: $key; Value: $value<br />\n";
                                                if ($key == $tmpId) {
                                                    //echo $key ."==". $tmpId;
                                                    $tmpVal = $value;
                                                    //unset($destArr[$key]);
                                                    $destArr[$key] = $value . ',' . $result_pt;
                                                    //print_r($destArr);
                                                    //echo "<br>";
                                                    //echo "<br>";
                                                } else {
                                                    //	$destArr[$tmpId]=$result_pt;
                                                    //$destArr = array_push_assoc($destArr, $tmpId, $result_pt);
                                                    //print_r($destArr);
                                                    //echo "<br>";
                                                }
                                            }
                                            // foreach end
                                        }
                                        // else end
                                        //}
                                        //print_r($destArr);
                                    }
                                } else {
                                    $tmpId = 0;
                                }
                            }
                        }
                        //echo "<br>";
                    }
                }
            }
            fclose($file1);
        }
    }
    $result = $destArr;
    //print_r($destArr);
    //exit;
    //echo $timediff;
    return $result;
}
Beispiel #2
0
function geoAlrtPerDay($lData, $sTime1, $eTime1)
{
    $timeArr = array();
    //$ptArr = array();
    $cnt = 0;
    $totalDistance = 0;
    $data1 = explode("#", $lData);
    $timeArr = array();
    $timediff = array();
    $srcArr = array();
    $destArr = array();
    $strTime = '';
    $endTime = '';
    $endPoint = '';
    $tmpId = -1;
    $lat_lngArr = array();
    for ($j1 = 0; $j1 < count($data1); $j1++) {
        $data2 = explode("@", $data1[$j1]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            $geodate = $data3[8];
            $geoTime = $data3[9];
            $curTime = explode(":", $data3[9]);
            $curTime = $curTime[0] * 60 + $curTime[1];
            //echo "<br>";
            if ($curTime >= $sTime1 && $curTime <= $eTime1) {
                //echo "<br>";
                //echo $curTime." >= ".$sTime1." && ".$curTime."<=".$eTime1;
                //echo "<br>";
                $pos1 = calLat($data3[2]);
                $pos2 = calLong($data3[1]);
                if ($pos1 > 0 && $pos2 > 0) {
                    if (!in_array($geoTime, $timeArr)) {
                        $getDevice = "SELECT * FROM tb_geofence_info WHERE tgi_clientId = " . $_SESSION[clientID] . " AND tgi_isActive = 1 ORDER BY tgi_id ASC";
                        //$getDevice = "SELECT * FROM `tb_geofence_info` WHERE `tgi_name` = 'Colva Beach'";
                        $resDevice = mysql_query($getDevice);
                        if (@mysql_affected_rows() > 0) {
                            while ($fetDevice = @mysql_fetch_assoc($resDevice)) {
                                $lat_lngArr = explode("#", $fetDevice[tgi_coordinates]);
                                for ($i = 0; $i < count($lat_lngArr) - 1; $i++) {
                                    $lat_lng1 = explode(",", $lat_lngArr[$i]);
                                    $lat_lng[$i] = $lat_lng1[0] . "," . $lat_lng1[1];
                                }
                                //print_r($lat_lng);
                                //exit;
                                $res = getGeofenceStatus($lat_lng, $pos1, $pos2);
                                if ($res) {
                                    if ($tmpId == -1) {
                                        $tmpId = $fetDevice[tgi_id];
                                        $finaTime[] = $tmpId . "#" . $geodate . " " . $geoTime . "#Entered#" . $fetDevice[tgi_name];
                                    } elseif ($tmpId == $fetDevice[tgi_id]) {
                                        $endTime = $geodate . " " . $geoTime;
                                        //echo " ";
                                        $endId = $fetDevice[tgi_id];
                                        $endPoint = $fetDevice[tgi_name];
                                        //echo "<br>";
                                        //$tmpId = $fetDevice[tgi_id];
                                    } elseif ($tmpId != $fetDevice[tgi_id] && $tmpid != -1 && $endPoint != '') {
                                        //$finaTime .=$endTime."#LEFT#".$endPoint."@";
                                        //echo $tmpId."#".$geodate." ".$geoTime."#".$endTime."#Left#".$endPoint;
                                        //echo "<br>";
                                        $finaTime[] = $tmpId . "#" . $endTime . "#Left#" . $endPoint;
                                        $tmpId = $fetDevice[tgi_id];
                                        $endPoint = "";
                                        $finaTime[] = $fetDevice[tgi_id] . "#" . $geodate . " " . $geoTime . "#Entered#" . $fetDevice[tgi_name];
                                        //echo "<br>";
                                    }
                                    //echo $finaTime;
                                    //echo "<br>";
                                }
                                $result_pt = "";
                                $lat_lngArr = "";
                                $lat_lng = array();
                                /*if($res == 1 && $data3[3]>0 && $strTime=='')
                                		{
                                			 $finaTime .=$geoTime."#Entered#".$fetDevice[tgi_name]."@";
                                			 $strTime = $geoTime;
                                			 
                                		}
                                		else if($res == 1 && $data3[3]==0 && $endTime=='' && $strTime!='')
                                		{													
                                			$finaTime .=$geoTime."#LEFT#".$fetDevice[tgi_name]."@";
                                			
                                		}*/
                                /*if($res)
                                		{
                                			echo $finaTime = $geodate."#".$geoTime."#".$fetDevice[tgi_name]."@";
                                			echo "<br>";
                                			$strTime='';
                                			$endTime='';
                                			$lat_lngArr = '';
                                		}*/
                            }
                        }
                    }
                }
                $cnt++;
            }
        }
        array_push($timeArr, $geoTime);
    }
    //print_r($finaTime);
    //exit;
    if (count($finaTime) > 0) {
        $finaTime = implode("@", $finaTime);
        return $finaTime;
    } else {
        return false;
    }
}
Beispiel #3
0
         while ($fetGeofence = $db->fetch_array($resGeofenceInfo)) {
             $gpspts = $fetGeofence[tag_geofenceId] . "#" . $fetGeofence[tag_id] . "#" . $fetGeofence[tag_alertSrc] . "#" . $fetGeofence[tag_noofTimes] . "#" . $fetGeofence[tag_inout];
             $resSrv1 = explode("#", $gpspts);
             //print_r($resSrv1);
             //statusGeoPoint($lat,$lng,$resSrv1[0],$resSrv1[1],$resSrv1[2],$resSrv1[3],$resSrv1[4],$devDateTime,$devImei);
             $getDevice = "SELECT * FROM tb_geofence_info WHERE tgi_id = " . $fetGeofence[tag_geofenceId] . " AND tgi_isActive = 1";
             $resDevice = $db->query($getDevice);
             if ($db->affected_rows > 0) {
                 $fetDevice = $db->fetch_array($resDevice);
                 $lat_lng = explode(",", $fetDevice[tgi_latLong]);
                 $radius = $fetDevice[tgi_radius];
                 //echo $lat_lng[0]." , ".$lat_lng[1]." , ".$radius." , ".$lat." , ".$lng."<br>";
                 $latlngArr = drawCircle($lat_lng[0], $lat_lng[1], $radius);
                 //print_r($latlngArr);
                 //exit;
                 $res = getGeofenceStatus($latlngArr, $lat, $lng);
                 //echo "<br>";
                 //exit;
                 $getAlertImeiInfo_repeat = "SELECT COUNT(*) FROM tb_geoalertinfo WHERE tgai_assignDevId = '" . $devImei . "' AND  tgai_reachdevTime2='0000-00-00 00:00:00' AND tgai_geoAssignId=" . $fetGeofence[tag_geofenceId] . " ORDER BY tgai_id DESC LIMIT 0,1";
                 $already_in_alert_sent = $db->query($getAlertImeiInfo_repeat);
                 if ($res) {
                     if ($already_in_alert_sent == '0') {
                         smsmAlertFunc($resSrv1[0], $resSrv1[1], $resSrv1[2], $resSrv1[3], $resSrv1[4], $devDateTime, $devImei, "in");
                     }
                 } else {
                     smsmAlertFunc($resSrv1[0], $resSrv1[1], $resSrv1[2], $resSrv1[3], $resSrv1[4], $devDateTime, $devImei, "out");
                 }
             }
         }
     }
 }
Beispiel #4
0
function getUDAddress($lt, $ln)
{
    //echo $lt;
    $sel_pts = "SELECT * FROM gps_geopoints_info WHERE gpi_clientID=" . $_SESSION[clientID];
    $rs_sel_pts = mysql_query($sel_pts);
    while ($fetch_sel_pts = @mysql_fetch_assoc($rs_sel_pts)) {
        //print_r($fetch_sel_pts);
        $gcdLatLng = drawCircle($fetch_sel_pts[gpi_latVal], $fetch_sel_pts[gpi_longVal], $fetch_sel_pts[gpi_miles]);
        //print_r($gcdLatLng);
        $geocheck = getGeofenceStatus($gcdLatLng, $lt, $ln);
        if ($geocheck == 1) {
            return $fetch_sel_pts[gpi_stopName];
        }
    }
}
Beispiel #5
0
function geoAlrtPerDay($lData, $sTime1, $eTime1)
{
    $cnt = 0;
    $data1 = explode("#", $lData);
    $timeArr = array();
    /*$latlngArr = drawCircle("15.2857824","73.958976","0.50");
    	for($i=0; $i<count($latlngArr);$i++)
    	{
    		$tarr = explode(",",$latlngArr[$i]);
    		$newArr[]= $tarr[1].",".$tarr[0];
    	}
    	print_r($latlngArr);
    	echo $res = getGeofenceStatus($latlngArr,"15.2677360","73.9664768");
    
    	exit;*/
    for ($j1 = 0; $j1 < count($data1); $j1++) {
        $data2 = explode("@", $data1[$j1]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            //echo '<pre>';print_r($data3); echo '</pre>';
            $geodate = $data3[8];
            $geoTime = $data3[9];
            $curTime = explode(":", $data3[9]);
            $curTime = $curTime[0] * 60 + $curTime[1] + $curTime[2];
            if ($curTime >= $sTime1 && $curTime <= $eTime1) {
                $pos1 = calLat($data3[2]);
                $pos2 = calLong($data3[1]);
                //$pos1 = "17.4145664";
                //$pos2 = "78.4665856";
                //echo $curTime." >= ".$sTime1." && ".$curTime."<=".$eTime1." ".$tmpId." ".$res." ".$pos1.",".$pos2;
                //echo "<br>";
                if ($pos1 > 0 && $pos2 > 0) {
                    if (!in_array($geoTime, $timeArr)) {
                        $getDevice = "SELECT * FROM tb_geofence_info WHERE tgi_clientId = " . $_SESSION[clientID] . " AND tgi_isActive = 1 ORDER BY tgi_id ASC";
                        $resDevice = mysql_query($getDevice);
                        if (@mysql_affected_rows() > 0) {
                            while ($fetDevice = @mysql_fetch_assoc($resDevice)) {
                                $lat_lng = explode(",", $fetDevice[tgi_latLong]);
                                $radius = $fetDevice[tgi_radius];
                                //echo $lat_lng[0]." , ".$lat_lng[1]." , ".$radius." , ".$pos1." , ".$pos2."<br>";
                                $latlngArr = drawCircle($lat_lng[0], $lat_lng[1], $radius);
                                $res = getGeofenceStatus($latlngArr, $pos1, $pos2);
                                if ($res) {
                                    if (count($geoId) == 0) {
                                        $geoId[] = $fetDevice[tgi_id];
                                        $finaTime[] = $fetDevice[tgi_id] . "#" . $geodate . " " . $geoTime . "#Entered#" . $fetDevice[tgi_name];
                                        //echo "<br><br>";
                                        $end = 0;
                                    } else {
                                        if ($geoId[count($geoId) - 1] != $fetDevice[tgi_id]) {
                                            /*echo $lat_lng[0]." , ".$lat_lng[1]." , ".$radius." , ".$pos1." , ".$pos2."<br>";
                                            		echo '<pre>';print_r($latlngArr);echo '</pre>';
                                            		for($i=0; $i<count($latlngArr);$i++)
                                            		{
                                            			$tarr = explode(",",$latlngArr[$i]);
                                            			$str .= "new GLatLng(".$tarr[1].",".$tarr[0]."),";
                                            		}
                                            		echo $str;
                                            		exit;*/
                                            $geoId[] = $fetDevice[tgi_id];
                                            $finaTime[] = $fetDevice[tgi_id] . "#" . $geodate . " " . $geoTime . "#Entered#" . $fetDevice[tgi_name];
                                            //echo "<br><br>";
                                            $end = 0;
                                        }
                                    }
                                } else {
                                    if ($geoId[count($geoId) - 1] == $fetDevice[tgi_id] && $end == 0) {
                                        $geoId[] = $fetDevice[tgi_id];
                                        $end = 1;
                                        $finaTime[] = $fetDevice[tgi_id] . "#" . $geodate . " " . $geoTime . "#Left#" . $fetDevice[tgi_name];
                                        //echo "<br><br>";
                                    }
                                }
                            }
                        }
                        array_push($timeArr, $geoTime);
                    }
                }
            }
        }
    }
    //print_r($finaTime);
    //exit;
    if (count($finaTime) > 0) {
        $finaTime = implode("@", $finaTime);
        return $finaTime;
    } else {
        return false;
    }
}
                while ($fetGeofence = $db->fetch_array($resGeofenceInfo)) {
                    $gpspts = $fetGeofence[tag_geofenceId] . "@" . $fetGeofence[tag_id] . "@" . $fetGeofence[tag_alertSrc] . "@" . $fetGeofence[tag_noofTimes] . "@" . $fetGeofence[tag_inout];
                    $resSrv1 = explode("@", $gpspts);
                    //print_r($resSrv1);
                    //statusGeoPoint($lat,$lng,$resSrv1[0],$resSrv1[1],$resSrv1[2],$resSrv1[3],$resSrv1[4],$devDateTime,$devImei);
                    $getDevice = "SELECT * FROM tb_geofence_info WHERE tgi_id = " . $fetGeofence[tag_geofenceId] . " AND tgi_isActive = 1";
                    $resDevice = $db->query($getDevice);
                    if ($db->affected_rows > 0) {
                        $fetDevice = $db->fetch_array($resDevice);
                        $lat_lngArr = explode("#", $fetDevice[tgi_coordinates]);
                        for ($i = 0; $i < count($lat_lngArr) - 1; $i++) {
                            $lat_lng1 = explode(",", $lat_lngArr[$i]);
                            $lat_lng[$i] = $lat_lng1[0] . "," . $lat_lng1[1];
                        }
                        //print_r($lat_lng);
                        $res = getGeofenceStatus($lat_lng, $lat, $lng);
                        if ($res) {
                            smsmAlertFunc($resSrv1[0], $resSrv1[1], $resSrv1[2], $resSrv1[3], $resSrv1[4], $devDateTime, $devImei, "in");
                        } else {
                            smsmAlertFunc($resSrv1[0], $resSrv1[1], $resSrv1[2], $resSrv1[3], $resSrv1[4], $devDateTime, $devImei, "out");
                        }
                    }
                    $lat_lng = "";
                    //echo "<br><br>";
                }
            }
        }
    }
}
function smsmAlertFunc($gid, $aid, $src, $nooftime, $inout, $devDateTime, $devImei, $inorout)
{