<?php |
<?php |
/* |
/* |
* Copyright 2010,2011 Alexander Sadleir |
* Copyright 2010,2011 Alexander Sadleir |
|
|
Licensed under the Apache License, Version 2.0 (the "License"); |
Licensed under the Apache License, Version 2.0 (the "License"); |
you may not use this file except in compliance with the License. |
you may not use this file except in compliance with the License. |
You may obtain a copy of the License at |
You may obtain a copy of the License at |
|
|
http://www.apache.org/licenses/LICENSE-2.0 |
http://www.apache.org/licenses/LICENSE-2.0 |
|
|
Unless required by applicable law or agreed to in writing, software |
Unless required by applicable law or agreed to in writing, software |
distributed under the License is distributed on an "AS IS" BASIS, |
distributed under the License is distributed on an "AS IS" BASIS, |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
See the License for the specific language governing permissions and |
See the License for the specific language governing permissions and |
limitations under the License. |
limitations under the License. |
*/ |
*/ |
include ('../include/common.inc.php'); |
include ('../include/common.inc.php'); |
auth(); |
auth(); |
foreach ($_REQUEST as $key => $value) { |
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); |
$myway_route = str_replace("route", "", $key); |
$route_id = $value; |
$vparts = explode("-",$value); |
$query = "update myway_routes set route_id = :route_id where myway_route = :myway_route"; |
$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"); |
debug($query, "database"); |
$query = $conn->prepare($query); |
$query = $conn->prepare($query); |
$query->bindParam(":myway_route", $myway_route, PDO::PARAM_STR, 5); |
$query->bindParam(":myway_route", $myway_route, PDO::PARAM_STR, 5); |
$query->bindParam(":route_id", $route_id, 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(); |
$query->execute(); |
die(print_r($conn->errorInfo(), true)); |
die(print_r($conn->errorInfo(), true)); |
} |
} |
if (strstr($key, "myway_stop")) { |
if (strstr($key, "myway_stop")) { |
$myway_stop = $value; |
$myway_stop = $value; |
$stop_id = $_REQUEST['stop_id']; |
$stop_id = $_REQUEST['stop_id']; |
$query = "update myway_stops set stop_id = :stop_id where myway_stop = :myway_stop"; |
$query = "update myway_stops set stop_id = :stop_id where myway_stop = :myway_stop"; |
debug($query, "database"); |
debug($query, "database"); |
$query = $conn->prepare($query); |
$query = $conn->prepare($query); |
$query->bindParam(":myway_stop", $myway_stop, PDO::PARAM_STR, 25); |
$query->bindParam(":myway_stop", $myway_stop, PDO::PARAM_STR, 25); |
$query->bindParam(":stop_id", $stop_id, PDO::PARAM_STR, 32); |
$query->bindParam(":stop_id", $stop_id, PDO::PARAM_STR, 32); |
$query->execute(); |
$query->execute(); |
die(print_r($conn->errorInfo(), true)); |
die(print_r($conn->errorInfo(), true)); |
} |
} |
} |
} |
include_header("MyWay Data Reconcile", "mywayTimeRec"); |
include_header("MyWay Data Reconcile", "mywayTimeRec"); |
// initialise |
// initialise |
$count = $conn->exec("insert into myway_stops |
$count = $conn->exec("insert into myway_stops |
select distinct myway_stop from myway_observations |
select distinct myway_stop from myway_observations |
WHERE myway_stop NOT IN |
WHERE myway_stop NOT IN |
( |
( |
SELECT myway_stop |
SELECT myway_stop |
FROM myway_stops |
FROM myway_stops |
)"); |
)"); |
echo "$count new stops.<br>"; |
echo "$count new stops.<br>"; |
if (!$count) { |
if (!$count) { |
print_r($conn->errorInfo()); |
print_r($conn->errorInfo()); |
} |
} |
$count = $conn->exec("insert into myway_routes select distinct myway_route from myway_observations |
$count = $conn->exec("insert into myway_routes select distinct myway_route from myway_observations |
WHERE myway_route NOT IN |
WHERE myway_route NOT IN |
( |
( |
SELECT myway_route |
SELECT myway_route |
FROM myway_routes |
FROM myway_routes |
)"); |
)"); |
echo "$count new routes.<br>"; |
echo "$count new routes.<br>"; |
if (!$count) { |
if (!$count) { |
print_r($conn->errorInfo()); |
print_r($conn->errorInfo()); |
} |
} |
echo "<h2>Stops</h2>"; |
echo "<h2>Stops</h2>"; |
/* stops |
/* stops |
search start of name, display map and table nuimbered, two text boxes */ |
search start of name, display map and table nuimbered, two text boxes */ |
$query = "Select * from myway_stops where stop_id is NUll;"; |
$query = "Select * from myway_stops where stop_id is NUll;"; |
debug($query, "database"); |
debug($query, "database"); |
$query = $conn->prepare($query); |
$query = $conn->prepare($query); |
$query->execute(); |
$query->execute(); |
if (!$query) { |
if (!$query) { |
databaseError($conn->errorInfo()); |
databaseError($conn->errorInfo()); |
return Array(); |
return Array(); |
} |
} |
foreach ($query->fetchAll() as $myway_stop) { |
foreach ($query->fetchAll() as $myway_stop) { |
echo "<h3>{$myway_stop[0]}</h3>"; |
echo "<h3>{$myway_stop[0]}</h3>"; |
$markers = array(); |
$markers = array(); |
$stopKey = 0; |
$stopKey = 0; |
$foundStops = getStops("",$myway_stop[0]); |
$foundStops = getStops("",$myway_stop[0]); |
if (sizeof($foundStops) > 0) { |
if (sizeof($foundStops) > 0) { |
echo "<table>"; |
echo "<table>"; |
foreach ($foundStops as $stopResult) { |
foreach ($foundStops as $stopResult) { |
$markers[] = array( |
$markers[] = array( |
$stopResult['stop_lat'], |
$stopResult['stop_lat'], |
$stopResult['stop_lon'] |
$stopResult['stop_lon'] |
); |
); |
echo "<tr><td>" . $stopKey++ . "</td><td>" . $stopResult['stop_name'] . "</td><td>" . $stopResult['stop_id'] . "</td></tr>"; |
echo "<tr><td>" . $stopKey++ . "</td><td>" . $stopResult['stop_name'] . "</td><td>" . $stopResult['stop_id'] . "</td></tr>"; |
} |
} |
echo '</table>'; |
echo '</table>'; |
echo "" . staticmap($markers,false,false,false,true) . "<br>\n"; |
echo "" . staticmap($markers,false,false,false,true) . "<br>\n"; |
} |
} |
echo '<form id="inputform' . md5($myway_stop[0]) . '"> |
echo '<form id="inputform' . md5($myway_stop[0]) . '"> |
<input type="hidden" name="myway_stop" value="' . $myway_stop[0] . '"> |
<input type="hidden" name="myway_stop" value="' . $myway_stop[0] . '"> |
<div data-role="fieldcontain"> |
<div data-role="fieldcontain"> |
<label for="stop_id">Stop ID</label> |
<label for="stop_id">Stop ID</label> |
<input type="text" name="stop_id" id="stop_id" value="' . $foundStops[0]['stop_id'] . '" /> |
<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> |
</div> <input type="button" onclick="$.post(\'myway_timeliness_reconcile.php\', $(\'#inputform' . md5($myway_stop[0]) . '\').serialize())" value="Go!"></form> |
'; |
'; |
echo '<hr>'; |
echo '<hr>'; |
} |
} |
echo '<h2>Routes</h2>'; |
echo '<h2>Routes</h2>'; |
/* routes |
/* routes |
remove alpha char, search present dropdown */ |
remove alpha char, search present dropdown */ |
$query = "Select * from myway_routes where route_short_name is NUll;"; |
$query = "Select * from myway_routes where route_short_name is NUll;"; |
debug($query, "database"); |
debug($query, "database"); |
$query = $conn->prepare($query); |
$query = $conn->prepare($query); |
$query->execute(); |
$query->execute(); |
if (!$query) { |
if (!$query) { |
databaseError($conn->errorInfo()); |
databaseError($conn->errorInfo()); |
return Array(); |
return Array(); |
} |
} |
foreach ($query->fetchAll() as $myway_route) { |
foreach ($query->fetchAll() as $myway_route) { |
echo "<h3>{$myway_route[0]}</h3>"; |
echo "<h3>{$myway_route[0]}</h3>"; |
$query = "Select * from myway_observations where myway_route = :route order by time"; |
$query = "Select * from myway_observations where myway_route = :route order by time"; |
debug($query, "database"); |
debug($query, "database"); |
$query = $conn->prepare($query); |
$query = $conn->prepare($query); |
$query->bindParam(":route", $myway_route[0]); |
$query->bindParam(":route", $myway_route[0]); |
$query->execute(); |
$query->execute(); |
if (!$query) { |
if (!$query) { |
databaseError($conn->errorInfo()); |
databaseError($conn->errorInfo()); |
return Array(); |
return Array(); |
} |
} |
foreach ($query->fetchAll() as $myway_obvs) { |
foreach ($query->fetchAll() as $myway_obvs) { |
echo $myway_obvs['myway_stop'] . $myway_obvs['time'] . "<br>"; |
echo $myway_obvs['myway_stop'] . $myway_obvs['time'] . "<br>"; |
} |
} |
$searchRouteNo = preg_replace("/[A-Z]/", "", $myway_route[0]); |
$searchRouteNo = preg_replace("/[A-Z]/", "", $myway_route[0]); |
echo $searchRouteNo; |
echo $searchRouteNo; |
echo '<form id="inputform' . $myway_route[0] . '"> |
echo '<form id="inputform' . $myway_route[0] . '"> |
<select name="route' . $myway_route[0] . '" onchange=\'$.post("myway_timeliness_reconcile.php", $("#inputform' . $myway_route[0] . '").serialize())\'> |
<select name="route' . $myway_route[0] . '" onchange=\'$.post("myway_timeliness_reconcile.php", $("#inputform' . $myway_route[0] . '").serialize())\'> |
<option>Select a from/to pair...</option>'; |
<option>Select a from/to pair...</option>'; |
foreach (getRoutesByShortName($searchRouteNo) as $routeResult) { |
foreach (getRoutesByShortName($searchRouteNo) as $routeResult) { |
foreach(getRouteHeadsigns($routeResult['route_id']) as $headsign ) { |
foreach(getRouteHeadsigns($routeResult['route_id']) as $headsign ) { |
echo "<option value=\"{$routeResult['route_short_name']}{$routeResult['route_long_name']}\"> |
echo "<option value=\"{$routeResult['route_short_name']}-{$headsign['trip_headsign']}\"> |
{$routeResult['route_short_name']}{$routeResult['route_long_name']} {$headsign['trip_headsign']}</option>\n"; |
{$routeResult['route_short_name']}{$routeResult['route_long_name']} - {$headsign['trip_headsign']} {$headsign['direction_id']} @ {$headsign['stop_name']} </option>\n"; |
} |
} |
|
|
} |
} |
echo "</select></form>"; |
echo "</select></form>"; |
echo '<hr>'; |
echo '<hr>'; |
} |
} |
include_footer(); |
include_footer(); |
?> |
?> |
|
|