$TruckDriver = GPSMaps::GetTruckDriver($GPSID);
} else {
    $TruckDriver = -1;
}
$StartDate = isset($_REQUEST['Day']) ? $_REQUEST['Day'] : date('Y-m-d');
$FinishDate = isset($_REQUEST['Day']) ? $_REQUEST['Day'] : date('Y-m-d');
if ($StartDate == '') {
    $StartDate = $_POST['Day'];
    $FinishDate = $_POST['Day'];
}
$Speed = array();
$Braking = array();
$Accel = array();
$SpeedAlert = 0;
$CurrentLat = $CurrentLng = $PrevLat = $PrevLng = $CurrentTimeStamp = $PrevTimeStamp = "";
$coords = GPSMaps::GetData($GPSID, $StartDate, $FinishDate);
$coordtotal = $coords->RowCount();
$TruckList = GPSMaps::GetTruckDropDown($_SESSION['customerId'], 'yes');
$TList = array();
while ($TL = $TruckList->fetch(PDO::FETCH_OBJ)) {
    if ($TL->TruckDriver == $TruckDriver) {
        $selected = "selected='selected'";
    } else {
        $selected = "";
    }
    $TList[] = "<option value='{$TL->TruckID}' {$selected} >{$TL->TruckName} ({$TL->TruckSerial})</option>";
}
$Grade = 100;
?>

<!DOCTYPE html>
    $RouteTimeStampArray = str_split($RouteTimeStamp, 21);
    for ($g = 0; $g < count($RouteTimeStampArray) - 1; $g++) {
        $RouteTimeStampArray[$g] = substr($RouteTimeStampArray[$g], 0, -2);
    }
    $RouteString = $stm->Route;
    $RouteArray = str_split($RouteString, 22);
    for ($h = 0; $h < count($RouteArray) - 1; $h++) {
        $RouteArray[$h] = substr($RouteArray[$h], 0, -1);
    }
} else {
    $regenerate = 0;
    $stm = GPSMaps::GetData($GPSID, $StartDate, $FinishDate);
    $nearsite = GPSMaps::GetData($GPSID, $StartDate, $FinishDate);
}
// Get Idle times
$idle = GPSMaps::GetData($GPSID, $StartDate, $FinishDate);
$LastEntry = $idle->RowCount();
$y = 0;
while ($i = $idle->fetch(PDO::FETCH_OBJ)) {
    if ($y == 0) {
        $startPoint = "new google.maps.LatLng(parseFloat(" . $i->Latitude . "), parseFloat(" . $i->Longitude . "))";
    }
    $y++;
    $time = $i->TimeStamp;
    $lat = $i->Latitude;
    $lng = $i->Longitude;
    if ($prevLat != $lat && $prevLng != $lng) {
        if ($startTime == 0) {
            $startTime = $time;
        }
        $stopTime = 0;