bus.of.je | Liberty Bus Timetables
'. $schedule['service_number'] . ' - ' . $schedule['service_name'] . '';
// print service updates for current timetable
foreach ($servUpdates as $update) {
if(in_array($route, $update['services'])) {
array_push($routeUpdates, $update['content']);
}
}
if (!empty($routeUpdates)) {
echo ' Service Updates:
';
foreach ($routeUpdates as $update) {
echo $update . '
';
}
}
// print timetables
foreach ($days as $day) {
if ($schedule['schedule'][$day] == 'true') {
// set display friendly variables for days
switch ($day){
case "mon_fri":
$displayDay = "Mon - Fri";
break;
case "sat":
$displayDay = "Saturday";
break;
case "sun":
$displayDay = "Sunday";
break;
default:
break;
}
foreach ($directions as $direction) {
if ($schedule['directions'][$direction] == 'true') {
$stopList = getData('stoplist', $route, $direction, false);
// print timetable info while setting display friendly case for directions
// TODO: add linebreaks between end of table and next table title
echo '
' . ucfirst($direction) . ' | ' . $displayDay . '';
echo '
';
$trips = getData('trips', $route, $direction, $day);
// TODO: sort stopList by stopList['order']
// TODO: must be a more efficient way to search for $rowStop['stop_name'] in $trip?
foreach ($stopList as $rowStop) {
echo '' . $rowStop['stop_name'] . ' | ';
foreach ($trips as $trip) {
$found=False;
foreach ($trip['stops'] as $stop) {
if ($stop['stop_name'] == $rowStop['stop_name']) {
echo '' . $stop['departure_time'] . ' | ';
$found=True;
}
}
// print something to show bus doesn't use this stop on this trip e.g. route variation
if ($found != True) {
echo '---- | ';
}
}
echo '
';
}
echo '
';
}
}
}
}
}
// print landing page if no route is selected
else {
$routes = getData('routes', false, false, false);
$meta = getData('meta', false, false, false);
echo '' . $meta['name']. ' | ' . $meta['from'] . ' - ' . $meta['to'] . '
';
echo 'Service Updates:
\n';
foreach ($servUpdates as $update) {
echo $update['content'] . '- Affected Routes: ' . implode(", ",$update['services']) . '
';
}
foreach ($routes as $route) {
echo '
';
}
echo '';
}
?>