Merge branch 'master' of https://github.com/maxious/ACTBus-ui
Merge branch 'master' of https://github.com/maxious/ACTBus-ui

Conflicts:
include/common-db.inc.php

--- a/include/common-template.inc.php
+++ b/include/common-template.inc.php
@@ -5,6 +5,7 @@
 function googleAnalyticsGetImageUrl()
 {
 	global $GA_ACCOUNT, $GA_PIXEL;
+	//if (stristr($_SERVER['HTTP_USER_AGENT'], 'Googlebot') return "";
 	$url = "";
 	$url.= $GA_PIXEL . "?";
 	$url.= "utmac=" . $GA_ACCOUNT;
@@ -125,7 +126,25 @@
 border-radius: 15px;
     }
  
-
+/*#leftcolumn { 
+	float: none;
+}			
+.min-width-768px #leftcolumn {
+	float: left;
+	width: 30%;
+}
+#rightcolumn { 
+	float: none;
+}			
+.min-width-768px #rightcolumn {
+	float: right;
+	width: 68%;
+}*/	
+
+#footer {
+clear:both;
+text-align:center;
+}
     // source http://webaim.org/techniques/skipnav/
     #skip a, #skip a:hover, #skip a:visited 
 { 
@@ -144,7 +163,7 @@
 height:auto; 
 }
 </style>';
-	if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPod')) {
+	if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPod') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
 		echo '<meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  <link rel="apple-touch-startup-image" href="startup.png" />
@@ -175,7 +194,11 @@
 }
 $(document).ready(function() {
         $('#here').click(function(event) { $('#geolocate').val(geolocate()); return false;});
-$('#here').show();
+        $('#here').show();
+	/*if ($.mobile.media('screen and (min-width: 768px)')) {
+	  $('map a:first').click();
+	  $('#settings a:first').click();
+	}*/
 });
 ";
 		if (!isset($_SESSION['lat']) || $_SESSION['lat'] == "") echo "geolocate();";
@@ -187,6 +210,7 @@
   var _gaq = _gaq || [];
   _gaq.push(['_setAccount', 'UA-22173039-1']);
   _gaq.push(['_trackPageview']);
+   _gaq.push(['_trackPageLoadTime']);
 </script>";
 	echo '</head>
 <body>
@@ -249,7 +273,7 @@
         or enter an address/co-ordinates in the box below.';
 	}
 	echo '</div>';
-	echo '<div data-role="collapsible" data-collapsed="' . !$geoerror . '">
+	echo '<div id="settings" data-role="collapsible" data-collapsed="' . !$geoerror . '">
         <h3>Change Time/Place (' . (isset($_SESSION['time']) ? $_SESSION['time'] : "Current Time,") . ' ' . ucwords(service_period()) . ')...</h3>
         <form action="' . basename($_SERVER['PHP_SELF']) . "?" . $_SERVER['QUERY_STRING'] . '" method="post">
         <div class="ui-body"> 

--- a/include/db/route-dao.inc.php
+++ b/include/db/route-dao.inc.php
@@ -200,7 +200,7 @@
 	$query = $conn->prepare($query);
 	$query->bindParam(":service_period", $service_period);
 	$query->bindParam(":distance", $distance);
-	$query->bindParam(":limit", $limit);
+	if ($limit != "") $query->bindParam(":limit", $limit);
 	$query->execute();
 	if (!$query) {
 		databaseError($conn->errorInfo());

file:a/index.php -> file:b/index.php
--- a/index.php
+++ b/index.php
@@ -28,5 +28,4 @@
 echo ' <a href="labs/index.php" data-role="button" data-icon="beaker">Busness R&amp;D</a>';
 include_footer(true)
 ?>
-        
 

--- a/labs/myway_api.json.php
+++ b/labs/myway_api.json.php
@@ -23,7 +23,7 @@
 	"DOBday" => "day",
 	"DOByear" => "year",
 	"secret_answer" => "pwrd",
-	"button" => "button"
+	"button" => "Submit"
 );
 foreach (Array(
 	"card_number",
@@ -64,6 +64,7 @@
 	curl_setopt($ch, CURLOPT_POST, count($fields));
 	curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
 	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+	curl_setopt($ch, CURLOPT_REFERER, "https://www.action.act.gov.au/ARTS/getbalance.asp");
 	curl_setopt($ch, CURLOPT_HEADER, 0);
 	curl_setopt($ch, CURLOPT_TIMEOUT, 30);
 	//execute post
@@ -75,6 +76,7 @@
 
 if (!isset($return['error'])) {
 	include_once ('lib/simple_html_dom.php');
+	//print_r($pageHTML);
 	$page = str_get_html($pageHTML);
 	$pageAlerts = $page->find(".smartCardAlert");
 	if (sizeof($pageAlerts) > 0) {
@@ -94,12 +96,14 @@
 				$tableColumns[$tableColumnNum] = cleanString($th->plaintext);
 				$tableColumnNum++;
 			}
+			//print_r($tableColumns);
 			$tableRowNum = 0;
 			foreach ($table->find("tr") as $tr) {
 				$tableColumnNum = 0;
 				foreach ($tr->find("td") as $td) {
 					if ($tableNum == 1) $return[$tableName[$tableNum]][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext);
 					else $return[$tableName[$tableNum]][$tableRowNum][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext);
+					//print_r($return);
 					$tableColumnNum++;
 				}
 				$tableRowNum++;

--- a/labs/mywaybalance.php
+++ b/labs/mywaybalance.php
@@ -29,8 +29,10 @@
 		echo '<ul data-role="listview" data-inset="true"><li data-role="list-divider"> Recent Transactions </li>';
 		$txCount=0;
 		foreach ($return['myway_transactions'] as $transaction) {
-			echo "<li><b>" . $transaction["Date / Time"] . "</b>";
-			echo "<br><small>" . $transaction["TX Reference No / Type"] . "</small>";
+			echo "<li>";
+			if ($transaction["Deduction Type"] == "DEFAULT") echo '<img src="css/images/warning.png" alt="Failed to tap off: " class="ui-li-icon">';
+			echo"<b>" . $transaction["Date / Time"] . "</b>";
+			echo "<br><small>" .$transaction["Route"] ." at " . $transaction["Stop Name"]. "<br>". $transaction["TX Reference No / Type"] . "</small>";
 			echo '<p class="ui-li-aside">' . $transaction["TX Amount"] . '</p>';
 			echo "</li>";
 			$txCount++;

file:a/robots.txt -> file:b/robots.txt
--- a/robots.txt
+++ b/robots.txt
@@ -1,4 +1,6 @@
 User-agent: *
 Allow: /
+User-agent: *
+Disallow: /lib/ga.php
 sitemap: http://bus.lambdacomplex.org/sitemap.xml.php
 

file:a/stop.php -> file:b/stop.php
--- a/stop.php
+++ b/stop.php
@@ -60,6 +60,7 @@
 	}
 }
 include_header($stop['stop_name'], "stop");
+echo '<span id="leftcolumn">';
 timePlaceSettings();
 echo $stopLinks;
 if (sizeof($stops) > 0) {
@@ -75,6 +76,7 @@
 		)
 	)) ;
 }
+echo '</span><span id="rightcolumn">';
 echo '  <ul data-role="listview"  data-inset="true">';
 if (sizeof($allStopsTrips) > 0) {
     sktimesort($allStopsTrips,"arrival_time", true);
@@ -107,6 +109,7 @@
 	}
 }
 echo '</ul>';
+echo '</span>';
 include_footer();
 ?>
 

file:a/trip.php -> file:b/trip.php
--- a/trip.php
+++ b/trip.php
@@ -16,7 +16,7 @@
 include_header("Stops on " . $trip['route_short_name'] . ' ' . $trip['route_long_name'], "trip");
 trackEvent("Route/Trip View","View Route",  $trip['route_short_name'] . ' ' . $trip['route_long_name'], $routeid);
 
-
+echo '<span id="leftcolumn">';
 echo '<h2>Via:</h2> <small>' . viaPointNames($tripid) . '</small>';
 echo '<h2>Other Trips:</h2> ';
 foreach (getRouteTrips($routeid) as $othertrip) {
@@ -27,6 +27,7 @@
 foreach (getRoutesByNumber($trip['route_short_name']) as $row) {
 	if ($row['route_id'] != $routeid) echo '<a href="trip.php?routeid=' . $row['route_id'] . '">' . $row['route_long_name'] . ' (' . ucwords($row['service_id']) . ')</a> ';
 }
+echo '</span><span id="rightcolumn">';
 flush(); @ob_flush();
 echo '  <ul data-role="listview"  data-inset="true">';
 $stopsGrouped = Array();
@@ -44,10 +45,11 @@
 			$stopsGrouped["endTime"] = $tripStopTime['arrival_time'];
 			echo '<a href="stop.php?stopids=' . implode(",", $stopsGrouped['stop_ids']) . '">';
 			echo '<p class="ui-li-aside">' . $stopsGrouped['startTime'] . ' to ' . $stopsGrouped['endTime'];
-                        echo '</p>';
+                        
                         if (isset($_SESSION['lat']) && isset($_SESSION['lon'])) {
-						echo '<span class="ui-li-count">' . distance($stop['stop_lat'],$stop['stop_lon'], $_SESSION['lat'], $_SESSION['lon'], true) . 'm away</span>';
+						echo '<br>' . distance($tripStopTime['stop_lat'],$tripStopTime['stop_lon'], $_SESSION['lat'], $_SESSION['lon'], true) . 'm away';
 					}
+                                        echo '</p>';
 			echo bracketsMeanNewLine($tripStopTime["stop_name"]);
 			echo '</a></li>';
                         flush(); @ob_flush();
@@ -56,10 +58,11 @@
 		else {
 			// just a normal stop
 			echo '<a href="stop.php?stopid=' . $tripStopTime['stop_id'] . (startsWith($tripStopTime['stop_code'], "Wj") ? '&amp;stopcode=' . $tripStopTime['stop_code'] : "") . '">';
-			echo '<p class="ui-li-aside">' . $tripStopTime['arrival_time'] . '</p>';
+			echo '<p class="ui-li-aside">' . $tripStopTime['arrival_time']; 
 			if (isset($_SESSION['lat']) && isset($_SESSION['lon'])) {
-						echo '<span class="ui-li-count">' . distance($stop['stop_lat'],$stop['stop_lon'], $_SESSION['lat'], $_SESSION['lon'], true) . 'm away</span>';
+						echo '<br>' . distance($tripStopTime['stop_lat'],$tripStopTime['stop_lon'], $_SESSION['lat'], $_SESSION['lon'], true) . 'm away';
 					}
+                                        echo '</p>';
                                         echo bracketsMeanNewLine($tripStopTime['stop_name']);
 			echo '</a></li>';
                         flush(); @ob_flush();
@@ -85,6 +88,8 @@
 	}
 }
 echo '</ul>';
+
+echo '</span>';
 include_footer();
 ?>