Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / aircraft-statistics-route.php
blobed9ea8228310b7e8d8adbecfae89661fe8ba4897
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 Routes 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 Routes").'</h2>';
55 print '<p>'.sprintf(_("The statistic below shows the most common routes from <strong>%s (%s)</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>';
57 $route_array = $Spotter->countAllRoutesByAircraft($aircraft_type);
58 if (!empty($route_array))
60 print '<div class="table-responsive">';
61 print '<table class="common-routes">';
62 print '<thead>';
63 print '<th></th>';
64 print '<th>'._("Departure Airport").'</th>';
65 print '<th>'._("Arrival Airport").'</th>';
66 print '<th>'._("# of times").'</th>';
67 print '<th></th>';
68 print '<th></th>';
69 print '</thead>';
70 print '<tbody>';
71 $i = 1;
72 foreach($route_array as $route_item)
74 print '<tr>';
75 print '<td><strong>'.$i.'</strong></td>';
76 print '<td>';
77 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>';
78 print '</td>';
79 print '<td>';
80 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>';
81 print '</td>';
82 print '<td>';
83 print $route_item['route_count'];
84 print '</td>';
85 print '<td>';
86 print '<a href="'.$globalURL.'/search?aircraft='.$aircraft_type.'&departure_airport_route='.$route_item['airport_departure_icao'].'&arrival_airport_route='.$route_item['airport_arrival_icao'].'">Search Flights</a>';
87 print '</td>';
88 print '<td>';
89 print '<a href="'.$globalURL.'/route/'.$route_item['airport_departure_icao'].'/'.$route_item['airport_arrival_icao'].'">Route Profile</a>';
90 print '</td>';
91 print '</tr>';
92 $i++;
94 print '<tbody>';
95 print '</table>';
96 print '</div>';
98 print '</div>';
99 } else {
100 $title = _("Aircraft Type");
101 require_once('header.php');
102 print '<h1>'._("Error").'</h1>';
103 print '<p>'._("Sorry, the aircraft type does not exist in this database. :(").'</p>';
106 require_once('footer.php');