Fix indenting of php files and split includes logically
[busui.git] / tripPlanner.php
blob:a/tripPlanner.php -> blob:b/tripPlanner.php
--- a/tripPlanner.php
+++ b/tripPlanner.php
@@ -1,11 +1,14 @@
 <?php
 include ('common.inc.php');
-include_header("Trip Planner", "tripPlanner", true, true);
+include_header("Trip Planner", "tripPlanner", true, true, true);
 $from = (isset($_REQUEST['from']) ? filter_var($_REQUEST['from'], FILTER_SANITIZE_STRING) : "Brigalow");
 $to = (isset($_REQUEST['to']) ? filter_var($_REQUEST['to'], FILTER_SANITIZE_STRING) : "Barry");
 $date = (isset($_REQUEST['date']) ? filter_var($_REQUEST['date'], FILTER_SANITIZE_STRING) : date("m/d/Y"));
 $time = (isset($_REQUEST['time']) ? filter_var($_REQUEST['time'], FILTER_SANITIZE_STRING) : date("H:i"));
-// todo: convert date from form to h:ia?
+function formatTime($timeString) {
+  $timeParts = explode("T",$timeString);
+  return str_replace("Z","",$timeParts[1]);
+}
 function tripPlanForm($errorMessage = "")
 {
 	global $date, $time, $from, $to;
@@ -40,7 +43,7 @@
 }
 function processItinerary($itineraryNumber, $itinerary)
 {
-	echo '<div data-role="collapsible" ' . ($itineraryNumber > 0 ? 'data-collapsed="true"' : "") . '> <h3> Option #' . ($itineraryNumber + 1) . ": " . floor($itinerary->duration / 60000) . " minutes ({$itinerary->startTime} to {$itinerary->endTime})</h3><p>";
+	echo '<div data-role="collapsible" ' . ($itineraryNumber > 0 ? 'data-collapsed="true"' : "") . '> <h3> Option #' . ($itineraryNumber + 1) . ": " . floor($itinerary->duration / 60000) . " minutes (".formatTime($itinerary->startTime)." to ".formatTime($itinerary->endTime).")</h3><p>";
 	echo "Walking time: " . floor($itinerary->walkTime / 60000) . " minutes (" . floor($itinerary->walkDistance) . " meters)<br>\n";
 	echo "Transit time: " . floor($itinerary->transitTime / 60000) . " minutes<br>\n";
 	echo "Waiting time: " . floor($itinerary->waitingTime / 60000) . " minutes<br>\n";
@@ -103,23 +106,6 @@
 		tripPlanForm($errorMessage);
 	}
 	else {
-		if (isMetricsOn()) {
-			// Create a new Instance of the tracker
-			$owa = new owa_php();
-			// Set the ID of the site being tracked
-			$owa->setSiteId($owaSiteID);
-			// Create a new event object
-			$event = $owa->makeEvent();
-			// Set the Event Type, in this case a "video_play"
-			$event->setEventType('view_trip_plan');
-			// Set a property
-			$event->set('from', $from);
-			$event->set('to', $to);
-			$event->set('time', $time);
-			$event->set('date', $date);
-			// Track the event
-			$owa->trackEvent($event);
-		}
 		$url = $otpAPIurl . "ws/plan?date=" . urlencode($_REQUEST['date']) . "&time=" . urlencode($_REQUEST['time']) . "&mode=TRANSIT%2CWALK&optimize=QUICK&maxWalkDistance=840&wheelchair=false&toPlace=$toPlace&fromPlace=$fromPlace&intermediatePlaces=";
 		$ch = curl_init($url);
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@@ -136,7 +122,7 @@
 			$tripplan = json_decode($page);
 			debug(print_r($triplan, true));
 			echo "<h1> From: {$tripplan->plan->from->name} To: {$tripplan->plan->to->name} </h1>";
-			echo "<h1> At: {$tripplan->plan->date} </h1>";
+			echo "<h1> At: ".formatTime($tripplan->plan->date)." </h1>";
 			if (is_array($tripplan->plan->itineraries->itinerary)) {
 				echo '<div data-role="collapsible-set">';
 				foreach ($tripplan->plan->itineraries->itinerary as $itineraryNumber => $itinerary) {