Licence and jqmobile beta 3 upgrade
[busui.git] / myway / myway_timeliness_reconcile.php
blob:a/myway/myway_timeliness_reconcile.php -> blob:b/myway/myway_timeliness_reconcile.php
--- a/myway/myway_timeliness_reconcile.php
+++ b/myway/myway_timeliness_reconcile.php
@@ -17,27 +17,29 @@
 include ('../include/common.inc.php');
 auth();
 foreach ($_REQUEST as $key => $value) {
-    if (strstr($key, "route") && !strstr($value, "Select")) {
+      if (strstr($key, "route") && !strstr($value, "Select")) {
         $myway_route = str_replace("route", "", $key);
-        $route_full_name = $value;
-        $query = "update myway_routes set route_full_name = :route_full_name where myway_route = :myway_route";
+        $vparts = explode("-",$value);
+        $route_short_name = $vparts[0];
+        $trip_headsign = $vparts[1];
+        $query = "update myway_routes set route_short_name = :route_short_name, trip_headsign = :trip_headsign where myway_route = :myway_route";
         debug($query, "database");
         $query = $conn->prepare($query);
         $query->bindParam(":myway_route", $myway_route, PDO::PARAM_STR, 5);
-        $query->bindParam(":route_full_name", $route_full_name, PDO::PARAM_STR, 42);
+        
+        $query->bindParam(":route_short_name", $route_short_name, PDO::PARAM_STR, 42);
+        $query->bindParam(":trip_headsign", $trip_headsign, PDO::PARAM_STR, 42);
         $query->execute();
         die(print_r($conn->errorInfo(), true));
     }
     if (strstr($key, "myway_stop")) {
         $myway_stop = $value;
-        $stop_code = $_REQUEST['stop_code'];
-        $stop_street = $_REQUEST['stop_street'];
-        $query = "update myway_stops set stop_code = :stop_code, stop_street = :stop_street where myway_stop = :myway_stop";
+        $stop_id = $_REQUEST['stop_id'];
+        $query = "update myway_stops set stop_id = :stop_id where myway_stop = :myway_stop";
         debug($query, "database");
         $query = $conn->prepare($query);
         $query->bindParam(":myway_stop", $myway_stop, PDO::PARAM_STR, 25);
-        $query->bindParam(":stop_code", $stop_code, PDO::PARAM_STR, 32);
-        $query->bindParam(":stop_street", $stop_street);
+        $query->bindParam(":stop_id", $stop_id, PDO::PARAM_STR, 32);
         $query->execute();
         die(print_r($conn->errorInfo(), true));
     }
@@ -68,7 +70,7 @@
 echo "<h2>Stops</h2>";
 /* stops
   search start of name, display map and table nuimbered, two text boxes */
-$query = "Select * from myway_stops where stop_code is NULL and stop_street is NUll;";
+$query = "Select * from myway_stops where stop_id is NUll;";
 debug($query, "database");
 $query = $conn->prepare($query);
 $query->execute();
@@ -78,10 +80,9 @@
 }
 foreach ($query->fetchAll() as $myway_stop) {
     echo "<h3>{$myway_stop[0]}</h3>";
-    $stopNameParts = explode(" ", $myway_stop[0]);
     $markers = array();
-    $stopKey = 1;
-    $foundStops = getStops(false, "", $stopNameParts[0] . " " . $stopNameParts[1]);
+    $stopKey = 0;
+    $foundStops = getStops("",$myway_stop[0]);
     if (sizeof($foundStops) > 0) {
         echo "<table>";
         foreach ($foundStops as $stopResult) {
@@ -89,20 +90,16 @@
                 $stopResult['stop_lat'],
                 $stopResult['stop_lon']
             );
-            echo "<tr><td>" . $stopKey++ . "</td><td>" . $stopResult['stop_name'] . "</td><td>" . $stopResult['stop_code'] . "</td></tr>";
+            echo "<tr><td>" . $stopKey++ . "</td><td>" . $stopResult['stop_name'] . "</td><td>" . $stopResult['stop_id'] . "</td></tr>";
         }
         echo '</table>';
-        echo "" . staticmap($markers, 0, "icong", false) . "<br>\n";
+        echo "" . staticmap($markers,false,false,false,true) . "<br>\n";
     }
     echo '<form id="inputform' . md5($myway_stop[0]) . '">
         <input type="hidden" name="myway_stop" value="' . $myway_stop[0] . '">
         <div data-role="fieldcontain">
-        <label for="stop_code">Stop Code</label>
-        <input type="text" name="stop_code" id="stop_code" value="' . $foundStops[0]['stop_code'] . '"  />
-    </div>
-        <div data-role="fieldcontain">
-        <label for="stop_street">Stop Street </label>
-        <input type="text" name="stop_street" id="stop_street" value="' . $foundStops[0]['stop_name'] . '"  />
+        <label for="stop_id">Stop ID</label>
+        <input type="text" name="stop_id" id="stop_id" value="' . $foundStops[0]['stop_id'] . '"  />
     </div>         <input type="button" onclick="$.post(\'myway_timeliness_reconcile.php\', $(\'#inputform' . md5($myway_stop[0]) . '\').serialize())" value="Go!"></form>
 ';
     echo '<hr>';
@@ -110,7 +107,7 @@
 echo '<h2>Routes</h2>';
 /* routes
   remove alpha char, search present dropdown */
-$query = "Select * from myway_routes where route_full_name is NUll;";
+$query = "Select * from myway_routes where route_short_name is NUll;";
 debug($query, "database");
 $query = $conn->prepare($query);
 $query->execute();
@@ -137,8 +134,12 @@
     echo '<form id="inputform' . $myway_route[0] . '">
 <select name="route' . $myway_route[0] . '" onchange=\'$.post("myway_timeliness_reconcile.php", $("#inputform' . $myway_route[0] . '").serialize())\'>
 <option>Select a from/to pair...</option>';
-    foreach (getRoutesByNumber($searchRouteNo) as $routeResult) {
-        echo "<option value=\"{$routeResult['route_short_name']}{$routeResult['route_long_name']}\"> {$routeResult['route_short_name']}{$routeResult['route_long_name']} </option>\n";
+    foreach (getRoutesByShortName($searchRouteNo) as $routeResult) {
+        foreach(getRouteHeadsigns($routeResult['route_id']) as $headsign ) {
+        echo "<option value=\"{$routeResult['route_short_name']}-{$headsign['trip_headsign']}\">
+        {$routeResult['route_short_name']}{$routeResult['route_long_name']} - {$headsign['trip_headsign']} {$headsign['direction_id']} @ {$headsign['stop_name']} </option>\n";
+        }
+        
     }
     echo "</select></form>";
     echo '<hr>';