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","");
20 if (!empty($spotter_array) ||
$alliance === true)
23 $title = sprintf(_("Most Common Time of Day from %s"),str_replace('_',' ',str_replace('alliance_','',$airline)));
25 $title = sprintf(_("Most Common Time of Day from %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']);
27 require_once('header.php');
28 print '<div class="select-item">';
29 print '<form action="'.$globalURL.'/airline" method="post">';
30 print '<select name="airline" class="selectpicker" data-live-search="true">';
31 print '<option></option>';
32 $alliances = $Spotter->getAllAllianceNames();
33 if (!empty($alliances)) {
34 foreach ($alliances as $al) {
35 if ($alliance && str_replace('_',' ',str_replace('alliance_','',$airline)) == $al['alliance']) {
36 print '<option value="alliance_'.str_replace(' ','_',$al['alliance']).'" selected>'.$al['alliance'].'</option>';
38 print '<option value="alliance_'.str_replace(' ','_',$al['alliance']).'">'.$al['alliance'].'</option>';
41 print '<option disabled>────────────────</option>';
44 $airline_names = $Stats->getAllAirlineNames();
45 if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames();
46 foreach($airline_names as $airline_name)
48 if($airline == $airline_name['airline_icao'])
50 print '<option value="'.$airline_name['airline_icao'].'" selected="selected">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>';
52 print '<option value="'.$airline_name['airline_icao'].'">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>';
56 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
63 if ($alliance === false) {
64 print '<div class="info column">';
65 print '<h1>'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')</h1>';
66 if ($globalIVAO && @getimagesize
($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.gif'))
68 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" />';
70 elseif (@getimagesize
($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png'))
72 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" />';
74 print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['airline_name'].'</div>';
75 print '<div><span class="label">'._("Country").'</span>'.$spotter_array[0]['airline_country'].'</div>';
76 print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['airline_icao'].'</div>';
77 print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>';
78 print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>';
79 print '<div><span class="label">'._("Type").'</span>'.ucwords($spotter_array[0]['airline_type']).'</div>';
82 print '<div class="info column">';
83 print '<h1>'.str_replace('_',' ',str_replace('alliance_','',$airline)).'</h1>';
84 if (@getimagesize
($globalURL.'/images/airlines/'.str_replace('alliance_','',$airline).'.png') ||
getimagesize('images/airlines/'.str_replace('alliance_','',$airline).'.png'))
86 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" />';
88 print '<div><span class="label">'._("Name").'</span>'.str_replace('_',' ',str_replace('alliance_','',$airline)).'</div>';
92 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>';
95 include('airline-sub-menu.php');
96 print '<div class="column">';
97 print '<h2>'._("Most Common Time of Day").'</h2>';
99 print '<p>'.sprintf(_("The statistic below shows the most common time of day from <strong>%s</strong>."),str_replace('_',' ',str_replace('alliance_','',$airline))).'</p>';
101 print '<p>'.sprintf(_("The statistic below shows the most common time of day from <strong>%s</strong>."),$spotter_array[0]['airline_name']).'</p>';
105 $hour_array = $Spotter->countAllHoursByAirline('',array('alliance' => str_replace('_',' ',str_replace('alliance_','',$airline))));
107 $hour_array = $Spotter->countAllHoursByAirline($airline);
110 $hour_array = $Stats->countAllHours('hour',true,$airline);
111 print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
112 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
113 print '<script type="text/javascript" src="'.$globalURL.'/js/c3.min.js"></script>';
114 print '<div id="chartHour" class="chart" width="100%"></div><script>';
118 foreach($hour_array as $hour_item)
120 while($last != $hour_item['hour_name']) {
121 $hour_data .= '"'.$last.':00",';
126 $hour_data .= '"'.$hour_item['hour_name'].':00",';
127 $hour_cnt .= $hour_item['hour_count'].',';
129 $hour_data = "[".substr($hour_data, 0, -1)."]";
130 $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
132 bindto: "#chartHour",
134 columns: ['.$hour_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
136 x: { type: "category", categories: '.$hour_data.'},
137 y: { label: "# of Flights"}},legend: { show: false }
140 if (!empty($hour_array))
142 print '<div class="table-responsive">';
143 print '<table class="common-hour table-striped">';
145 print '<th>'._("Hour").'</th>';
146 print '<th>'._("Number").'</th>';
150 foreach($hour_array as $hour_item)
153 print '<td>'.$hour_item['hour_name'].':00</td>';
154 print '<td>'.$hour_item['hour_count'].'</td>';
164 $title = _("Airline Statistic");
165 require_once('header.php');
166 print '<h1>'._("Error").'</h1>';
167 print '<p>'._("Sorry, the airline does not exist in this database. :(").'</p>';
169 require_once('footer.php');