Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / airport-statistics-registration.php
blob1770acf5b100af58f6c4a7b9f322ff3aa2eaffe3
1 <?php
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');
8 die();
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 Aircraft by Registration 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>';
24 $Stats = new Stats();
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($_GET['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>';
33 } else {
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>';
37 print '</select>';
38 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
39 print '</form>';
40 print '</div>';
41 print '<br />';
43 if ($airport != "NA")
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>';
54 print '</div>';
55 } else {
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 Aircraft by Registration").'</h2>';
62 print '<p>'.sprintf(_("The statistic below shows the most common aircraft by registration of flights to/from <strong>%s, %s (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>';
64 $aircraft_array = $Spotter->countAllAircraftRegistrationByAirport($airport);
65 if (!empty($aircraft_array))
67 print '<div class="table-responsive">';
68 print '<table class="common-type table-striped">';
69 print '<thead>';
70 print '<th></th>';
71 print '<th></th>';
72 print '<th>'._("Registration").'</th>';
73 print '<th>'._("Aircraft Type").'</th>';
74 print '<th>'._("# of times").'</th>';
75 print '<th></th>';
76 print '</thead>';
77 print '<tbody>';
78 $i = 1;
79 foreach($aircraft_array as $aircraft_item)
81 print '<tr>';
82 print '<td><strong>'.$i.'</strong></td>';
83 if ($aircraft_item['image_thumbnail'] != "")
85 print '<td class="aircraft_thumbnail">';
86 if (isset($aircraft_item['aircraft_type'])) {
87 print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'"><img src="'.$aircraft_item['image_thumbnail'].'" class="img-rounded" data-toggle="popover" title="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_icao'].' - '.$aircraft_item['airline_name'].'" alt="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_type'].' - '.$aircraft_item['airline_name'].'" data-content="'._("Registration:").' '.$aircraft_item['registration'].'<br />'._("Aircraft:").' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')<br />'._("Airline:").' '.$aircraft_item['airline_name'].'" data-html="true" width="100px" /></a>';
88 } else {
89 print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'"><img src="'.$aircraft_item['image_thumbnail'].'" class="img-rounded" data-toggle="popover" title="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_icao'].' - '.$aircraft_item['airline_name'].'" alt="'.$aircraft_item['registration'].' - '.$aircraft_item['airline_name'].'" data-content="'._("Registration:").' '.$aircraft_item['registration'].'<br />'._("Aircraft:").' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')<br />'._("Airline:").' '.$aircraft_item['airline_name'].'" data-html="true" width="100px" /></a>';
91 print '</td>';
92 } else {
93 print '<td class="aircraft_thumbnail">';
94 if (isset($aircraft_item['aircraft_type'])) {
95 print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_icao'].' - '.$aircraft_item['airline_name'].'" alt="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_type'].' - '.$aircraft_item['airline_name'].'" data-content="'._("Registration:").' '.$aircraft_item['registration'].'<br />'._("Aircraft:").' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')<br />'._("Airline:").' '.$aircraft_item['airline_name'].'" data-html="true" width="100px" /></a>';
96 } else {
97 print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_icao'].' - '.$aircraft_item['airline_name'].'" alt="'.$aircraft_item['registration'].' - '.$aircraft_item['airline_name'].'" data-content="'._("Registration:").' '.$aircraft_item['registration'].'<br />'._("Aircraft:").' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')<br />'._("Airline:").' '.$aircraft_item['airline_name'].'" data-html="true" width="100px" /></a>';
99 print '</td>';
101 print '<td>';
102 print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'">'.$aircraft_item['registration'].'</a>';
103 print '</td>';
104 print '<td>';
105 print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>';
106 print '</td>';
107 print '<td>';
108 print $aircraft_item['registration_count'];
109 print '</td>';
110 print '<td><a href="'.$globalURL.'/search?registration='.$aircraft_item['registration'].'&airport='.$airport.'">'._("Search flights").'</a></td>';
111 print '</tr>';
112 $i++;
114 print '<tbody>';
115 print '</table>';
116 print '</div>';
118 print '</div>';
119 } else {
120 $title = _("Airport");
121 require_once('header.php');
122 print '<h1>'._("Error").'</h1>';
123 print '<p>'._("Sorry, the airport does not exist in this database. :(").'</p>';
126 require_once('footer.php');