Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / route-statistics-aircraft.php
blob3eb9784f184d875004a5d3f9103659c3a7018e76
1 <?php
2 if ($_GET['departure_airport'] == "" || $_GET['arrival_airport'] == "")
4 header('Location: /');
7 require_once('require/class.Connection.php');
8 require_once('require/class.Spotter.php');
9 require_once('require/class.Language.php');
10 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
11 $departure_airport = filter_input(INPUT_GET,'departure_airport',FILTER_SANITIZE_STRING);
12 $arrival_airport = filter_input(INPUT_GET,'arrival_airport',FILTER_SANITIZE_STRING);
13 $Spotter = new Spotter();
14 $spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, "0,1", $sort);
16 if (!empty($spotter_array))
18 $title = sprintf(_("Most Common Aircraft between %s (%s), %s - %s (%s), %s"),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']);
19 require_once('header.php');
20 print '<div class="info column">';
21 print '<h1>'._("Flights between").' '.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].' - '.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</h1>';
22 print '<div><span class="label">'._("Coming From").'</span><a href="'.$globalURL.'/airport/'.$spotter_array[0]['departure_airport_icao'].'">'.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].'</a></div>';
23 print '<div><span class="label">'._("Flying To").'</span><a href="'.$globalURL.'/airport/'.$spotter_array[0]['arrival_airport_icao'].'">'.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</a></div>';
24 print '</div>';
26 include('route-sub-menu.php');
27 print '<div class="column">';
28 print '<h2>'._("Most Common Aircraft").'</h2>';
29 print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']).'</p>';
31 $aircraft_array = $Spotter->countAllAircraftTypesByRoute($departure_airport, $arrival_airport);
32 if (!empty($aircraft_array))
34 print '<div class="table-responsive">';
35 print '<table class="common-type table-striped">';
36 print '<thead>';
37 print '<th></th>';
38 print '<th>'._("Aircraft Type").'</th>';
39 print '<th>'._("# of times").'</th>';
40 print '<th></th>';
41 print '</thead>';
42 print '<tbody>';
43 $i = 1;
44 foreach($aircraft_array as $aircraft_item)
46 print '<tr>';
47 print '<td><strong>'.$i.'</strong></td>';
48 print '<td>';
49 print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>';
50 print '</td>';
51 print '<td>';
52 print $aircraft_item['aircraft_icao_count'];
53 print '</td>';
54 print '<td><a href="'.$globalURL.'/search?aircraft='.$aircraft_item['aircraft_icao'].'&departure_airport_route='.$departure_airport.'&arrival_airport_route='.$arrival_airport.'">'._("Search flights").'</a></td>';
55 print '</tr>';
56 $i++;
58 print '<tbody>';
59 print '</table>';
60 print '</div>';
62 print '</div>';
63 } else {
64 $title = _("Unknown Route");
65 require_once('header.php');
66 print '<h1>'._("Error").'</h1>';
67 print '<p>'._("Sorry, this route does not exist in this database. :(").'</p>';
70 require_once('footer.php');