Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / manufacturer-statistics-aircraft.php
blob9ba7fde799b70ebc0723e1f0d158ccabcd97f262
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 from %s"),$manufacturer);
19 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($manufacturer == ucwords($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").'</h2>';
47 print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights from <strong>%s</strong>."),$manufacturer).'</p>';
49 $aircraft_array = $Spotter->countAllAircraftTypesByManufacturer($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>'._("Aircraft Type").'</th>';
57 print '<th>'._("# of times").'</th>';
58 print '<th></th>';
59 print '</thead>';
60 print '<tbody>';
61 $i = 1;
62 foreach($aircraft_array as $aircraft_item)
64 print '<tr>';
65 print '<td><strong>'.$i.'</strong></td>';
66 print '<td>';
67 print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>';
68 print '</td>';
69 print '<td>';
70 print $aircraft_item['aircraft_icao_count'];
71 print '</td>';
72 print '<td><a href="'.$globalURL.'/search?aircraft='.$aircraft_item['aircraft_icao'].'&manufacturer='.$manufacturer.'">'._("Search flights").'</a></td>';
73 print '</tr>';
74 $i++;
76 print '<tbody>';
77 print '</table>';
78 print '</div>';
80 print '</div>';
81 } else {
82 $title = _("Manufacturer");
83 require_once('header.php');
84 print '<h1>'._("Error").'</h1>';
85 print '<p>'._("Sorry, the aircraft manufacturer does not exist in this database. :(").'</p>';
88 require_once('footer.php');