Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / aircraft-statistics-registration.php
blobc17c30517427b16fd149a90e2a15f076e34bfd9d
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['aircraft_type'])) {
7 header('Location: '.$globalURL.'/aircraft');
8 die();
10 $aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING);
11 $Spotter = new Spotter();
12 $spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1","");
15 if (!empty($spotter_array))
17 $title = sprintf(_("Most Common Aircraft by Registration from %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']);
18 require_once('header.php');
19 print '<div class="select-item">';
20 print '<form action="'.$globalURL.'/aircraft" method="get">';
21 print '<select name="aircraft_type" class="selectpicker" data-live-search="true">';
22 print '<option></option>';
23 $Stats = new Stats();
24 $aircraft_types = $Stats->getAllAircraftTypes();
25 if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
26 foreach($aircraft_types as $aircrafttype)
28 if($aircraft_type == $aircrafttype['aircraft_icao'])
30 print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
31 } else {
32 print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
35 print '</select>';
36 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
37 print '</form>';
38 print '</div>';
39 print '<br />';
41 if ($aircraft_type != "NA")
43 print '<div class="info column">';
44 print '<h1>'.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')</h1>';
45 print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['aircraft_name'].'</div>';
46 print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['aircraft_type'].'</div>';
47 print '<div><span class="label">'._("Manufacturer").'</span><a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $spotter_array[0]['aircraft_manufacturer'])).'">'.$spotter_array[0]['aircraft_manufacturer'].'</a></div>';
48 print '</div>';
49 } else {
50 print '<div class="alert alert-warning">'._("This special aircraft profile shows all flights in where the aircraft type is unknown.").'</div>';
52 include('aircraft-sub-menu.php');
53 print '<div class="column">';
54 print '<h2>'._("Most Common Aircraft by Registration").'</h2>';
55 print '<p>'.sprintf(_("The statistic below shows the most common aircraft by registration of flights from aircraft type <strong>%s (%s)</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>';
57 $aircraft_array = $Spotter->countAllAircraftRegistrationByAircraft($aircraft_type);
58 if (!empty($aircraft_array))
60 print '<div class="table-responsive">';
61 print '<table class="common-type table-striped">';
62 print '<thead>';
63 print '<th></th>';
64 print '<th></th>';
65 print '<th>'._("Registration").'</th>';
66 print '<th>'._("Aircraft Type").'</th>';
67 print '<th>'._("# of times").'</th>';
68 print '<th></th>';
69 print '</thead>';
70 print '<tbody>';
71 $i = 1;
72 foreach($aircraft_array as $aircraft_item)
74 print '<tr>';
75 print '<td><strong>'.$i.'</strong></td>';
76 if ($aircraft_item['image_thumbnail'] != "")
78 print '<td class="aircraft_thumbnail">';
79 if (isset($aircraft_item['aircraft_type'])) {
80 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>';
81 } else {
82 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>';
84 print '</td>';
85 } else {
86 print '<td class="aircraft_thumbnail">';
87 if (isset($aircraft_item['aircraft_type'])) {
88 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>';
89 } else {
90 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>';
92 print '</td>';
94 print '<td>';
95 print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'">'.$aircraft_item['registration'].'</a>';
96 print '</td>';
97 print '<td>';
98 print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>';
99 print '</td>';
100 print '<td>';
101 print $aircraft_item['aircraft_registration_count'];
102 print '</td>';
103 print '<td><a href="'.$globalURL.'/search?registration='.$aircraft_item['registration'].'&aircraft='.$aircraft_type.'">'._("Search flights").'</a></td>';
104 print '</tr>';
105 $i++;
107 print '<tbody>';
108 print '</table>';
109 print '</div>';
111 print '</div>';
112 } else {
113 $title = _("Aircraft Type");
114 require_once('header.php');
115 print '<h1>'._("Error").'</h1>';
116 print '<p>'._("Sorry, the aircraft type does not exist in this database. :(").'</p>';
119 require_once('footer.php');