Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / country-statistics-manufacturer.php
blob6148aafd619e6265cf03157140074898d7aeaca5
1 <?php
2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Language.php');
5 if (!isset($_GET['country'])) {
6 header('Location: '.$globalURL.'/country');
7 die();
9 $Spotter = new Spotter();
10 $country = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))));
11 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
12 if (isset($_GET['sort'])) {
13 $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort);
14 } else {
15 $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", '');
18 if (!empty($spotter_array))
20 $title = sprintf(_("Most Common Aircraft Manufacturer from %s"),$country);
21 require_once('header.php');
22 print '<div class="select-item">';
23 print '<form action="'.$globalURL.'/country" method="post">';
24 print '<select name="country" class="selectpicker" data-live-search="true">';
25 print '<option></option>';
26 $all_countries = $Spotter->getAllCountries();
27 foreach($all_countries as $all_country)
29 if($country == $all_country['country'])
31 print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>';
32 } else {
33 print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'">'.$all_country['country'].'</option>';
36 print '</select>';
37 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
38 print '</form>';
39 print '</div>';
41 if ($_GET['country'] != "NA")
43 print '<div class="info column">';
44 print '<h1>'.sprintf(_("Airports &amp; Airlines from %s"),$country).'</h1>';
45 print '</div>';
46 } else {
47 print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>';
50 include('country-sub-menu.php');
51 print '<div class="column">';
52 print '<h2>'._("Most Common Aircraft Manufacturer").'</h2>';
53 print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of airlines or departure/arrival airports from <strong>%s</strong>."),$country).'</p>';
54 $manufacturers_array = $Spotter->countAllAircraftManufacturerByCountry($country);
55 if (!empty($manufacturers_array))
57 print '<div class="table-responsive">';
58 print '<table class="common-manufacturer table-striped">';
59 print '<thead>';
60 print '<th></th>';
61 print '<th>'._("Aircraft Manufacturer").'</th>';
62 print '<th>'._("# of times").'</th>';
63 print '</thead>';
64 print '<tbody>';
65 $i = 1;
66 foreach($manufacturers_array as $manufacturer_item)
68 print '<tr>';
69 print '<td><strong>'.$i.'</strong></td>';
70 print '<td>';
71 print '<a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $manufacturer_item['aircraft_manufacturer'])).'">'.$manufacturer_item['aircraft_manufacturer'].'</a>';
72 print '</td>';
73 print '<td>';
74 print $manufacturer_item['aircraft_manufacturer_count'];
75 print '</td>';
76 print '</tr>';
77 $i++;
79 print '<tbody>';
80 print '</table>';
81 print '</div>';
83 print '</div>';
84 } else {
85 $title = _("Country");
86 require_once('header.php');
87 print '<h1>'._("Error").'</h1>';
88 print '<p>'._("Sorry, the country does not exist in this database. :(").'</p>';
91 require_once('footer.php');