From: Maxious Date: Sat, 26 Nov 2011 13:15:59 +0000 Subject: Unify route list rendering X-Git-Url: http://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=3bcf5a7262cd20693822d73fcefd6c7801143261 --- Unify route list rendering --- --- a/include/common-template.inc.php +++ b/include/common-template.inc.php @@ -212,9 +212,37 @@ } echo "\n"; } - +function timeSettings() { + global $service_periods; +echo '
+

Change Time (' . (isset($_REQUEST['time']) ? $_REQUEST['time'] : "Current Time,") . ' ' . ucwords(service_period()) . ')...

+
+ + + + +
+
+ + + Current Time? +
+
+ + + +
+ + +
+
'; +} function placeSettings() { - global $service_periods; + $geoerror = false; $geoerror = !isset($_SESSION['lat']) || !isset($_SESSION['lat']) || $_SESSION['lat'] == "" || $_SESSION['lon'] == ""; --- a/include/db/route-dao.inc.php +++ b/include/db/route-dao.inc.php @@ -46,11 +46,11 @@ function getRouteHeadsigns($routeID) { global $conn; - $query = "select stops.stop_name, direction_id,max(service_id) as service_id, count(*) + $query = "select stops.stop_name, trip_headsign, direction_id,max(service_id) as service_id, count(*) from routes join trips on trips.route_id = routes.route_id join stop_times on stop_times.trip_id = trips.trip_id join stops on stop_times.stop_id = stops.stop_id where trips.route_id = :routeID -and stop_times.stop_sequence = 1 group by stops.stop_name, direction_id having count(*) > 2"; +and stop_times.stop_sequence = 1 group by stops.stop_name, trip_headsign, direction_id having count(*) > 2"; debug($query, "database"); $query = $conn->prepare($query); $query->bindParam(":routeID", $routeID); @@ -260,25 +260,24 @@ $service_ids = service_ids($service_period); $sidA = $service_ids[0]; $sidB = $service_ids[1]; + global $conn; $query = "SELECT DISTINCT service_id,trips.route_id,route_short_name,route_long_name FROM stop_times join trips on trips.trip_id = stop_times.trip_id join routes on trips.route_id = routes.route_id join stops on stops.stop_id = stop_times.stop_id -WHERE zone_id LIKE ':suburb AND (service_id=:service_periodA OR service_id=:service_periodB) +WHERE stop_desc LIKE :suburb AND (service_id=:service_periodA OR service_id=:service_periodB) ORDER BY route_short_name"; debug($query, "database"); $query = $conn->prepare($query); $query->bindParam(":service_periodA", $sidA); $query->bindParam(":service_periodB", $sidB); - $query->bindParam(":service_period", $service_period); - $suburb = "%" . $suburb . ";%"; + $suburb = "%Suburb: %" . $suburb . "%"; $query->bindParam(":suburb", $suburb); $query->execute(); - if (!$query) { - databaseError($conn->errorInfo()); - return Array(); - } + + databaseError($conn->errorInfo()); + return $query->fetchAll(); } --- a/routeList.php +++ b/routeList.php @@ -18,6 +18,7 @@ include ('include/common.inc.php'); function navbar() { + echo '
'; +} + +function displayRoutes($routes) { + global $nearby; + echo ' '; -} else if (isset($nearby) || isset($suburb)) { - $routes = Array(); +} else if (isset($suburb)) { + if ($suburb) { include_header($suburb . " - " . ucwords(service_period()), "routeList"); navbar(); - timePlaceSettings(); + timeSettings(); trackEvent("Route Lists", "Routes By Suburb", $suburb); - $routes = getRoutesBySuburb($suburb); + displayRoutes(getRoutesBySuburb($suburb)); } - if (isset($nearby)) { - include_header("Routes Nearby", "routeList", true, true); - trackEvent("Route Lists", "Routes Nearby", $_SESSION['lat'] . "," . $_SESSION['lon']); - navbar(); - placeSettings(); - if (!isset($_SESSION['lat']) || !isset($_SESSION['lat']) || $_SESSION['lat'] == "" || $_SESSION['lon'] == "") { - include_footer(); - die(); - } - $routes = getRoutesNearby($_SESSION['lat'], $_SESSION['lon']); +} else if (isset($nearby)) { + $routes = Array(); + include_header("Routes Nearby", "routeList", true, true); + trackEvent("Route Lists", "Routes Nearby", $_SESSION['lat'] . "," . $_SESSION['lon']); + navbar(); + placeSettings(); + if (!isset($_SESSION['lat']) || !isset($_SESSION['lat']) || $_SESSION['lat'] == "" || $_SESSION['lon'] == "") { + include_footer(); + die(); } - echo '