function echoStopTimer($stopTimer)
{
    $x = 1;
    foreach ($stopTimer as $timer) {
        if ($x % 2 != 0) {
            $style = "style='background-color:#EEEEEE'";
        } else {
            $style = "style='background-color:#FFFFFF'";
        }
        $timeInSeconds = strtotime($timer['stop']) - strtotime($timer['start']);
        if ($timeInSeconds > 240) {
            echo "<tr {$style}>";
            echo "<td>" . $timer['start'] . "</td>";
            echo "<td>" . $timer['stop'] . "</td>";
            echo "<td>" . gmdate("H:i:s", $timeInSeconds) . "</td>";
            $address = GPSMaps::ReverseGeocoding($timer['lat'], $timer['lng']);
            if ($address) {
                echo "<td><a href='http://maps.google.com/?q={$address}' onClick='gpsLocationPopup(this.href); return false;'>" . $address . "</a></td>";
            } else {
                echo "<td>" . $timer['lat'] . " " . $timer['lng'] . "</td>";
            }
            echo "</tr>";
            $x++;
        }
    }
}
        $PrevMPH = $MilesPerHour;
    }
    // Set Current to Previous for Next Calculation
    $PrevLat = $CurrentLat;
    $PrevLng = $CurrentLng;
    $PrevTimeStamp = $CurrentTimeStamp;
}
$SpeedTotal = 0;
rsort($Speed);
for ($i = 0; $i < $coordtotal; $i++) {
    $SpeedTotal += $Speed[$i];
}
if ($GPSID != -1) {
    echo "<fieldset id='TruckReport'>";
    echo "Average Truck Speed : " . round($SpeedTotal / $coordtotal, 2) . " MPH |&nbsp;";
    echo "Raw Truck Speed * : " . GPSMaps::GetAverageSpeed($GPSID) . " MPH <br /><br />";
    echo "Number of Fast Accel/Harsh Braking Alerts : {$HarshBrakingFastAccel}<br />";
    echo "Number of Driving Alerts : {$SpeedAlert} <br /><br />";
    echo "Top Daily Speeds : <br />{$Speed['0']} MPH <br />{$Speed['1']} MPH <br />{$Speed['2']} MPH <br />{$Speed['3']} MPH <br />{$Speed['4']} MPH <br /><br />";
    echo "Driving Grade : " . round($Grade - ($SpeedAlert * 1 + $HarshBrakingFastAccel * 2), 2) . "<br />";
    echo "</fieldset>";
    echo '<div style="clear: both;">&nbsp;</div>';
    echo "<fieldset id='TruckReport'>";
    echo "<legend>Definitions</legend>";
    echo "Raw Truck Speed - Recorded Speed in MPH by the trucks onboard device.<br />";
    echo "Average Truck Speed - Calibrated Speed in MPH from the LAT and LNG of all recorded positions of the truck.<br />";
    echo "Fast Acceleration / Harsh Braking - Noted when the truck increases or decreases by 30 MPH between Raw Truck Speed recordings.<br />";
    echo "Driving Alerts - Noted when the truck increases over the speed of 75 MPH.<br />";
    echo "</fieldset>";
}
?>
    //								echo "CLOSEST DISTANCES 200m " . ${"Reached_" . $j} . " " . ${"Reached_Job_" . $j} . " @ " . ${"Reached_Timestamp_" . $j} . "<br />";
    //							}
} else {
    for ($k = 0; $k < count($RouteArray); $k++) {
        $RegenLat = substr($RouteArray[$k], 1, 8);
        $RegenLng = substr($RouteArray[$k], 11, 9);
        $RegenTimeStamp = $RouteTimeStampArray[$k];
        for ($l = 0; $l < $jobscount; $l++) {
            if (!${"Reached_" . $l} != '') {
                ${"Reached_" . $l} = 500;
            }
            $jobLat = $jobLng = "";
            $jobLat = $jobs[$l]["Lat"];
            $jobLng = $jobs[$l]["Lng"];
            $houseNum = $jobs[$l]["JobName"];
            $distance = round(GPSMaps::VGCD($RegenLat, $RegenLng, $jobLat, $jobLng, 6371000), 3);
            if ($distance < 500) {
                if (${"Reached_" . $l} > $distance) {
                    ${"Reached_" . $l} = $distance;
                    ${"Reached_Job_" . $l} = $jobs[$l]["JobName"];
                    ${"Reached_Timestamp_" . $l} = $RegenTimeStamp;
                }
            }
            //echo "Regen LAT is $RegenLat AND Regen LNG is $RegenLng <-truck house-> $houseNum | $jobLat AND LNG $jobLng [distance in m $distance] <br />";
            empty($jobLat);
            empty($jobLng);
        }
    }
    //							for($m = 0; $m < $jobscount; $m++ )
    //							{
    //								echo "CLOSEST DISTANCES 200m " . ${"Reached_" . $m} . " " . ${"Reached_Job_" . $m} . " @ " . ${"Reached_Timestamp_" . $m} . "<br />";
$split = array();
// Fill Arrays
if ($view == "crew") {
    $drivers = GPSMaps::GetDriverView($_SESSION['userNum']);
} else {
    $drivers = GPSMaps::GetDrivers($_SESSION['customerId']);
}
while ($drive = $drivers->fetch(PDO::FETCH_OBJ)) {
    array_push($trucks, array("TruckName" => $drive->TruckName, "TruckID" => $drive->TruckID, "Relationship" => $drive->Relationship));
}
if ($view != "crew") {
    $supervisors = GPSMaps::GetSupervisors($_SESSION['customerId']);
    while ($supers = $supervisors->fetch(PDO::FETCH_OBJ)) {
        array_push($trucksSuper, array("TruckName" => $supers->TruckName, "TruckID" => $supers->TruckID));
    }
    $companytasks = GPSMaps::GetCompanyTasks($_SESSION['customerId']);
    while ($tasks = $companytasks->fetch(PDO::FETCH_OBJ)) {
        array_push($eventTypes, array("eventTypeId" => $tasks->EventTypeID, "eventTypeName" => $tasks->EventTypeName));
    }
}
?>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
	<?php 
require "inc_page_head.php";
?>
	<script> window.paceOptions = { ajax: false }; </script>
	<script src="js/pace.min.js"></script>
<?php

require "inc_header_ps.php";
require_once '../lib/GPS.php';
mysql_select_db($db_name, $oConn);
// 2014-09-17 Created ^CS
$Driver = $_GET['Driver'];
$Date = $_GET['Date'];
$stm = GPSMaps::GetTodaysTaskXML($Driver, $Date);
// Create a new XML Document
$dom = new DOMDocument("1.0");
// New Node Markers
$node = $dom->createElement("markers");
// Create Children for Node Markers Design for Node as per Google
//
// <markers>
//	<marker lat lng extra data />
//	<marker lat lng extra data />
// </markers>
//
$parnode = $dom->appendChild($node);
// Create page based off XML
header("Content-type: text/xml");
// Populate nodes
while ($s = $stm->fetch(PDO::FETCH_OBJ)) {
    $node = $dom->createElement("marker");
    $newnode = $parnode->appendChild($node);
    $newnode->setAttribute("task", $s->EventTypeName);
    $newnode->setAttribute("scheduled", $s->ScheduledDate);
    $newnode->setAttribute("closed", $s->ClosedDate);
    $newnode->setAttribute("jobnum", $s->AssignedJobID);
        echo "Daily Mileage: " . round($mileage_array[$t->TruckID]['mileage'], 2) . " Miles<br />";
        echo "Avg Speed: " . GPSMaps::GetAverageSpeed($t->TruckID) . " MPH <br />";
        echo "</fieldset>";
        echo "</td>";
        $x++;
        $i++;
    } else {
        // Reset Row
        $x = 0;
        echo "</tr><tr>";
        echo "<td id='truck{$i}'>";
        echo "<fieldset class='gps' id='newreporting' style='width:auto;'>";
        echo "<legend>{$t->TruckName} (<span class='FakeLink' value='{$i}'>hide</span>)</legend>";
        echo "Current Driver: {$t->FirstName} {$t->LastName}<br />";
        echo "Daily Mileage: " . round($mileage_array[$t->TruckID]['mileage'], 2) . " Miles<br />";
        echo "Avg Speed: " . GPSMaps::GetAverageSpeed($t->TruckID) . " MPH <br />";
        echo "</fieldset>";
        echo "</td>";
        $x++;
        $i++;
    }
    $y++;
}
?>
								</tr>
							</table>
							</fieldset>

							<div style="clear: both;">&nbsp;</div>
						</div> <!-- end content -->
						<div style="clear: both;">&nbsp;</div>
<?php

require "inc_header_ps.php";
require_once '../lib/Relationship.php';
require_once '../lib/GPS.php';
mysql_select_db($db_name, $oConn);
// 2014-09-22 Updated ^CS
// 2014-09-02 Created ^CS
$centerAddress = GPSMaps::GetAddress($_SESSION['customerId']);
?>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<?php 
require "inc_page_head.php";
?>
		<script type="text/javascript">
			window.paceOptions = {
				ajax: false
			};
		</script>
		<script src="js/pace.min.js"></script>
		<link href="css/pace.css" rel="stylesheet" />
		<script src="js/json2.js" type="text/javascript"></script>
		<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBqFUMSIPpWNIvAZ547I-uaKT0c2fBoQME&sensor=false" type="text/javascript"></script>
		<script type="text/javascript">
			//<![CDATA[
			var customIcons = {
				Listed: {