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 $airport_array = $Spotter->getAllAirportInfo($airport);
14 if (!empty($airport_array))
16 //$spotter_array = $Spotter->getSpotterDataByAirport($airport,"0,1","");
17 $title = sprintf(_("Most Common Airlines to/from %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']);
18 require_once('header.php');
19 print '<div class="select-item">';
20 print '<form action="'.$globalURL.'/airport" method="post">';
21 print '<select name="airport" class="selectpicker" data-live-search="true">';
22 print '<option></option>';
24 $airport_names = $Stats->getAllAirportNames();
25 if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames();
26 ksort($airport_names);
27 foreach($airport_names as $airport_name)
29 if($airport == $airport_name['airport_icao'])
31 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>';
33 print '<option value="'.$airport_name['airport_icao'].'">'.$airport_name['airport_city'].', '.$airport_name['airport_name'].', '.$airport_name['airport_country'].' ('.$airport_name['airport_icao'].')</option>';
37 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
44 print '<div class="info column">';
45 print '<h1>'.$airport_array[0]['city'].', '.$airport_array[0]['name'].' ('.$airport_array[0]['icao'].')</h1>';
46 print '<div><span class="label">'._("Name").'</span>'.$airport_array[0]['name'].'</div>';
47 print '<div><span class="label">'._("City").'</span>'.$airport_array[0]['city'].'</div>';
48 print '<div><span class="label">'._("Country").'</span>'.$airport_array[0]['country'].'</div>';
49 print '<div><span class="label">'._("ICAO").'</span>'.$airport_array[0]['icao'].'</div>';
50 print '<div><span class="label">'._("IATA").'</span>'.$airport_array[0]['iata'].'</div>';
51 print '<div><span class="label">'._("Altitude").'</span>'.$airport_array[0]['altitude'].'</div>';
52 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>';
55 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>';
58 include('airport-sub-menu.php');
59 print '<div class="column">';
60 print '<h2>'._("Most Common Airlines").'</h2>';
61 print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights to/from <strong>%s, %s (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>';
63 $airline_array = $Spotter->countAllAirlinesByAirport($airport);
64 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
65 print '<script type="text/javascript" src="'.$globalURL.'/js/d3pie.min.js"></script>';
66 print '<div id="chart" class="chart" width="100%"></div><script>';
68 foreach($airline_array as $airline_item)
70 $airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
72 $airline_data = substr($airline_data, 0, -1);
73 print 'var series = ['.$airline_data.'];';
74 print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
75 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
76 print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
77 print 'var airlinescnt = new d3pie("chart",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
79 print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
81 if (!empty($airline_array))
83 print '<div class="table-responsive">';
84 print '<table class="common-airline table-striped">';
88 print '<th>'._("Airline").'</th>';
89 print '<th>'._("Country").'</th>';
90 print '<th>'._("# of times").'</th>';
95 foreach($airline_array as $airline_item)
98 print '<td><strong>'.$i.'</strong></td>';
99 print '<td class="logo">';
100 print '<a href="'.$globalURL.'/airline/'.$airline_item['airline_icao'].'"><img src="';
101 if ($globalIVAO && @getimagesize
($globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.gif'))
103 print $globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.gif';
104 } elseif (@getimagesize
($globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.png'))
106 print $globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.png';
108 print $globalURL.'/images/airlines/placeholder.png';
113 print '<a href="'.$globalURL.'/airline/'.$airline_item['airline_icao'].'">'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')</a>';
116 print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airline_item['airline_country'])).'">'.$airline_item['airline_country'].'</a>';
119 print $airline_item['airline_count'];
121 print '<td><a href="'.$globalURL.'/search?airline='.$airline_item['airline_icao'].'&airport='.$airport.'">'._("Search flights").'</a></td>';
132 require_once('header.php');
133 print '<h1>'._("Error").'</h1>';
134 print '<p>'._("Sorry, the airport does not exist in this database. :(").'</p>';
137 require_once('footer.php');