Improve airport-data matching
[FlightAirMap.git] / manufacturer-statistics-route.php
blob544888351495cda1d258bbca279b1c0172092443
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);
14 $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort);
16 if (!empty($spotter_array))
18 $title = sprintf(_("Most Common Routes from %s"),$manufacturer);
20 require_once('header.php');
21 print '<div class="select-item">';
22 print '<form action="'.$globalURL.'/manufacturer" method="post">';
23 print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
24 $Stats = new Stats();
25 $all_manufacturers = $Stats->getAllManufacturers();
26 if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
27 foreach($all_manufacturers as $all_manufacturer)
29 if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
31 print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
32 } else {
33 print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'">'.$all_manufacturer['aircraft_manufacturer'].'</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 print '<div class="info column">';
42 print '<h1>'.$manufacturer.'</h1>';
43 print '</div>';
45 include('manufacturer-sub-menu.php');
46 print '<div class="column">';
47 print '<h2>'._("Most Common Routes").'</h2>';
48 print '<p>'.sprintf(_("The statistic below shows the most common routes from <strong>%s</strong>."),$manufacturer).'</p>';
50 $route_array = $Spotter->countAllRoutesByManufacturer($manufacturer);
51 if (!empty($route_array))
53 print '<div class="table-responsive">';
54 print '<table class="common-routes table-striped">';
55 print '<thead>';
56 print '<th></th>';
57 print '<th>'._("Departure Airport").'</th>';
58 print '<th>'._("Arrival Airport").'</th>';
59 print '<th>'._("# of times").'</th>';
60 print '<th></th>';
61 print '<th></th>';
62 print '</thead>';
63 print '<tbody>';
64 $i = 1;
65 foreach($route_array as $route_item)
67 print '<tr>';
68 print '<td><strong>'.$i.'</strong></td>';
69 print '<td>';
70 print '<a href="'.$globalURL.'/airport/'.$route_item['airport_departure_icao'].'">'.$route_item['airport_departure_city'].', '.$route_item['airport_departure_country'].' ('.$route_item['airport_departure_icao'].')</a>';
71 print '</td>';
72 print '<td>';
73 print '<a href="'.$globalURL.'/airport/'.$route_item['airport_arrival_icao'].'">'.$route_item['airport_arrival_city'].', '.$route_item['airport_arrival_country'].' ('.$route_item['airport_arrival_icao'].')</a>';
74 print '</td>';
75 print '<td>';
76 print $route_item['route_count'];
77 print '</td>';
78 print '<td>';
79 print '<a href="'.$globalURL.'/search?manufacturer='.$manufacturer.'&departure_airport_route='.$route_item['airport_departure_icao'].'&arrival_airport_route='.$route_item['airport_arrival_icao'].'">'._("Search Flights").'</a>';
80 print '</td>';
81 print '<td>';
82 print '<a href="'.$globalURL.'/route/'.$route_item['airport_departure_icao'].'/'.$route_item['airport_arrival_icao'].'">'._("Route History").'</a>';
83 print '</td>';
84 print '</tr>';
85 $i++;
87 print '<tbody>';
88 print '</table>';
89 print '</div>';
91 print '</div>';
92 } else {
93 $title = _("Manufacturer");
94 require_once('header.php');
95 print '<h1>'._("Error").'</h1>';
96 print '<p>'._("Sorry, the aircraft manufacturer does not exist in this database. :(").'</p>';
99 require_once('footer.php');