2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Stats.php');
5 require_once('require/class.Language.php');
6 if (!isset($_GET['airport'])) {
7 header('Location: '.$globalURL.'/airport');
10 $airport = filter_input(INPUT_GET
,'airport',FILTER_SANITIZE_STRING
);
11 $Spotter = new Spotter();
12 //$spotter_array = $Spotter->getSpotterDataByAirport($airport,"0,1","");
13 $airport_array = $Spotter->getAllAirportInfo($airport);
15 if (!empty($airport_array))
17 $title = sprintf(_("Most Common Time of Day to/from %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']);
19 require_once('header.php');
20 print '<div class="select-item">';
21 print '<form action="'.$globalURL.'/airport" method="post">';
22 print '<select name="airport" class="selectpicker" data-live-search="true">';
23 print '<option></option>';
25 $airport_names = $Stats->getAllAirportNames();
26 if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames();
27 ksort($airport_names);
28 foreach($airport_names as $airport_name)
30 if($airport == $airport_name['airport_icao'])
32 print '<option value="'.$airport_name['airport_icao'].'" selected="selected">'.$airport_name['airport_city'].', '.$airport_name['airport_name'].', '.$airport_name['airport_country'].' ('.$airport_name['airport_icao'].')</option>';
34 print '<option value="'.$airport_name['airport_icao'].'">'.$airport_name['airport_city'].', '.$airport_name['airport_name'].', '.$airport_name['airport_country'].' ('.$airport_name['airport_icao'].')</option>';
38 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
45 print '<div class="info column">';
46 print '<h1>'.$airport_array[0]['city'].', '.$airport_array[0]['name'].' ('.$airport_array[0]['icao'].')</h1>';
47 print '<div><span class="label">'._("Name").'</span>'.$airport_array[0]['name'].'</div>';
48 print '<div><span class="label">'._("City").'</span>'.$airport_array[0]['city'].'</div>';
49 print '<div><span class="label">'._("Country").'</span>'.$airport_array[0]['country'].'</div>';
50 print '<div><span class="label">'._("ICAO").'</span>'.$airport_array[0]['icao'].'</div>';
51 print '<div><span class="label">'._("IATA").'</span>'.$airport_array[0]['iata'].'</div>';
52 print '<div><span class="label">'._("Altitude").'</span>'.$airport_array[0]['altitude'].'</div>';
53 print '<div><span class="label">'._("Coordinates").'</span><a href="http://maps.google.ca/maps?z=10&t=k&q='.$airport_array[0]['latitude'].','.$airport_array[0]['longitude'].'" target="_blank">Google Map<i class="fa fa-angle-double-right"></i></a></div>';
56 print '<div class="alert alert-warning">'._("This special airport profile shows all flights that do <u>not</u> have a departure and/or arrival airport associated with them.").'</div>';
59 include('airport-sub-menu.php');
60 print '<div class="column">';
61 print '<h2>'._("Most Common Time of Day").'</h2>';
62 print '<p>'.sprintf(_("The statistic below shows the most common time of day to/from <strong>%s, %s (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>';
64 $hour_array = $Spotter->countAllHoursByAirport($airport);
65 print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
66 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
67 print '<script type="text/javascript" src="'.$globalURL.'/js/c3.min.js"></script>';
68 print '<div id="chartHour" class="chart" width="100%"></div><script>';
72 foreach($hour_array as $hour_item)
74 while($last != $hour_item['hour_name']) {
75 $hour_data .= '"'.$last.':00",';
80 $hour_data .= '"'.$hour_item['hour_name'].':00",';
81 $hour_cnt .= $hour_item['hour_count'].',';
83 $hour_data = "[".substr($hour_data, 0, -1)."]";
84 $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
88 columns: ['.$hour_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}
91 x: { type: "category", categories: '.$hour_data.'},
92 y: { label: "# of Flights"}
94 legend: { show: false }
97 if (!empty($hour_array))
99 print '<div class="table-responsive">';
100 print '<table class="common-hour table-striped">';
102 print '<th>'._("Hour").'</th>';
103 print '<th>'._("Number").'</th>';
107 foreach($hour_array as $hour_item)
110 print '<td>'.$hour_item['hour_name'].':00</td>';
111 print '<td>'.$hour_item['hour_count'].'</td>';
121 $title = _("Airport");
122 require_once('header.php');
123 print '<h1>'._("Error").'</h1>';
124 print '<p>'._("Sorry, the airport does not exist in this database. :(").'</p>';
127 require_once('footer.php');