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['airline'])) {
7 header('Location: '.$globalURL.'/airline');
10 $airline = urldecode(filter_input(INPUT_GET
,'airline',FILTER_SANITIZE_STRING
));
11 $Spotter = new Spotter();
13 if (strpos($airline,'alliance_') !== FALSE) {
16 $spotter_array = $Spotter->getSpotterDataByAirline($airline,"0,1","");
19 if (!empty($spotter_array) ||
$alliance === true)
22 $title = sprintf(_("Most Common Arrival Airports by Country from %s"),str_replace('_',' ',str_replace('alliance_','',$airline)));
24 $title = sprintf(_("Most Common Arrival Airports by Country from %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']);
26 require_once('header.php');
27 print '<div class="select-item">';
28 print '<form action="'.$globalURL.'/airline" method="post">';
29 print '<select name="airline" class="selectpicker" data-live-search="true">';
30 print '<option></option>';
31 $alliances = $Spotter->getAllAllianceNames();
32 if (!empty($alliances)) {
33 foreach ($alliances as $al) {
34 if ($alliance && str_replace('_',' ',str_replace('alliance_','',$airline)) == $al['alliance']) {
35 print '<option value="alliance_'.str_replace(' ','_',$al['alliance']).'" selected>'.$al['alliance'].'</option>';
37 print '<option value="alliance_'.str_replace(' ','_',$al['alliance']).'">'.$al['alliance'].'</option>';
40 print '<option disabled>─────────────────</option>';
43 $airline_names = $Stats->getAllAirlineNames();
44 if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames();
45 foreach($airline_names as $airline_name)
47 if($_GET['airline'] == $airline_name['airline_icao'])
49 print '<option value="'.$airline_name['airline_icao'].'" selected="selected">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>';
51 print '<option value="'.$airline_name['airline_icao'].'">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>';
55 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
62 if ($alliance === false) {
63 print '<div class="info column">';
64 print '<h1>'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')</h1>';
65 if ($globalIVAO && @getimagesize
($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.gif'))
67 print '<img src="'.$globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.gif" alt="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" title="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" class="logo" />';
69 elseif (@getimagesize
($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png'))
71 print '<img src="'.$globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png" alt="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" title="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" class="logo" />';
73 print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['airline_name'].'</div>';
74 print '<div><span class="label">'._("Country").'</span>'.$spotter_array[0]['airline_country'].'</div>';
75 print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['airline_icao'].'</div>';
76 print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>';
77 print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>';
78 print '<div><span class="label">'._("Type").'</span>'.ucwords($spotter_array[0]['airline_type']).'</div>';
81 print '<div class="info column">';
82 print '<h1>'.str_replace('_',' ',str_replace('alliance_','',$airline)).'</h1>';
83 if (@getimagesize
($globalURL.'/images/airlines/'.str_replace('alliance_','',$airline).'.png') || @getimagesize
('images/airlines/'.str_replace('alliance_','',$airline).'.png'))
85 print '<img src="'.$globalURL.'/images/airlines/'.str_replace('alliance_','',$airline).'.png" alt="'.str_replace('_',' ',str_replace('alliance_','',$airline)).'" title="'.str_replace('_',' ',str_replace('alliance_','',$airline)).'" class="logo" />';
87 print '<div><span class="label">'._("Name").'</span>'.str_replace('_',' ',str_replace('alliance_','',$airline)).'</div>';
91 print '<div class="alert alert-warning">'._("This special airline profile shows all flights that do <u>not</u> have a airline associated with them.").'</div>';
94 include('airline-sub-menu.php');
95 print '<div class="column">';
96 print '<h2>'._("Most Common Arrival Airports by Country").'</h2>';
98 print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s</strong>."),str_replace('_',' ',str_replace('alliance_','',$airline))).'</p>';
100 print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s</strong>."),$spotter_array[0]['airline_name']).'</p>';
104 $airport_country_array = $Spotter->countAllArrivalAirportCountriesByAirline('',array('alliance' => str_replace('_',' ',str_replace('alliance_','',$airline))));
106 $airport_country_array = $Spotter->countAllArrivalAirportCountriesByAirline($airline);
109 $airport_country_array = $Stats->countAllArrivalCountries(true,$airline);
110 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
111 print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
112 print '<script type="text/javascript" src="'.$globalURL.'/js/datamaps.world.min.js"></script>';
113 print '<div id="chartCountry" class="chart" width="100%"></div><script>';
114 print 'var series = [';
116 foreach($airport_country_array as $airport_item)
118 $country_data .= '[ "'.$airport_item['airport_arrival_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],';
120 $country_data = substr($country_data, 0, -1);
123 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);';
124 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
125 print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
127 element: document.getElementById("chartCountry"),
128 projection: "mercator", // big world map
129 fills: { defaultFill: "#F5F5F5" },
133 borderColor: "#DEDEDE",
134 highlightBorderWidth: 2,
135 highlightFillColor: function(geo) {
136 return geo["fillColor"] || "#F5F5F5";
138 highlightBorderColor: "#B7B7B7",
139 done: function(datamap) {
140 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
142 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
145 popupTemplate: function(geo, data) {
146 if (!data) { return ; }
147 return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
153 if (!empty($airport_country_array))
155 print '<div class="table-responsive">';
156 print '<table class="common-country table-striped">';
159 print '<th>'._("Country").'</th>';
160 print '<th>'._("# of times").'</th>';
164 foreach($airport_country_array as $airport_item)
167 print '<td><strong>'.$i.'</strong></td>';
169 print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airport_item['airport_arrival_country'])).'">'.$airport_item['airport_arrival_country'].'</a>';
172 print $airport_item['airport_arrival_country_count'];
183 $title = _("Airline Statistic");
184 require_once('header.php');
185 print '<h1>'._("Error").'</h1>';
186 print '<p>'._("Sorry, the airline does not exist in this database. :(").'</p>';
189 require_once('footer.php');