Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / manufacturer-statistics-registration.php
blob675272c9b26a046a7aadc9b3c8ce9e2a25e97e57
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_manufacturer'])) {
7 header('Location: '.$globalURL.'/manufacturer');
8 die();
10 $Spotter = new Spotter();
11 $manufacturer = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING))));
12 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13 $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort);
15 if (!empty($spotter_array))
17 $title = sprintf(_("Most Common Aircraft by Registration from %s"),$manufacturer);
18 require_once('header.php');
20 print '<div class="select-item">';
21 print '<form action="'.$globalURL.'/manufacturer" method="post">';
22 print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
23 $Stats = new Stats();
24 $all_manufacturers = $Stats->getAllManufacturers();
25 if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
26 foreach($all_manufacturers as $all_manufacturer)
28 if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
30 print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
31 } else {
32 print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
35 print '</select>';
36 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
37 print '</form>';
38 print '</div>';
40 print '<div class="info column">';
41 print '<h1>'.$manufacturer.'</h1>';
42 print '</div>';
44 include('manufacturer-sub-menu.php');
45 print '<div class="column">';
46 print '<h2>'._("Most Common Aircraft by Registration").'</h2>';
47 print '<p>'.sprintf(_("The statistic below shows the most common aircraft by registration of flights from <strong>%s</strong>."),$manufacturer).'</p>';
49 $aircraft_array = $Spotter->countAllAircraftRegistrationByManufacturer($manufacturer);
50 if (!empty($aircraft_array))
52 print '<div class="table-responsive">';
53 print '<table class="common-type table-striped">';
54 print '<thead>';
55 print '<th></th>';
56 print '<th></th>';
57 print '<th>'._("Registration").'</th>';
58 print '<th>'._("Aircraft Type").'</th>';
59 print '<th>'._("# of times").'</th>';
60 print '<th></th>';
61 print '</thead>';
62 print '<tbody>';
63 $i = 1;
64 foreach($aircraft_array as $aircraft_item)
66 print '<tr>';
67 print '<td><strong>'.$i.'</strong></td>';
68 if ($aircraft_item['image_thumbnail'] != "")
70 print '<td class="aircraft_thumbnail">';
71 if (isset($aircraft_item['aircraft_type'])) {
72 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>';
73 } else {
74 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>';
76 print '</td>';
77 } else {
78 print '<td class="aircraft_thumbnail">';
79 if (isset($aircraft_item['aircraft_type'])) {
80 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>';
81 } else {
82 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>';
84 print '</td>';
86 print '<td>';
87 print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'">'.$aircraft_item['registration'].'</a>';
88 print '</td>';
89 print '<td>';
90 print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>';
91 print '</td>';
92 print '<td>';
93 print $aircraft_item['registration_count'];
94 print '</td>';
95 print '<td><a href="'.$globalURL.'/search?registration='.$aircraft_item['registration'].'&manufacturer='.$manufacturer.'">'._("Search flights").'</a></td>';
96 print '</tr>';
97 $i++;
99 print '<tbody>';
100 print '</table>';
101 print '</div>';
103 print '</div>';
104 } else {
105 $title = _("Manufacturer");
106 require_once('header.php');
107 print '<h1>'._("Error").'</h1>';
108 print '<p>'._("Sorry, the aircraft manufacturer does not exist in this database. :(").'</p>';
111 require_once('footer.php');