Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / route-statistics-registration.php
blob77db578fb519ef6bc35a8d97e247e86ec7627f82
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');
11 $Spotter = new Spotter();
12 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13 $departure_airport = filter_input(INPUT_GET,'departure_airport',FILTER_SANITIZE_STRING);
14 $arrival_airport = filter_input(INPUT_GET,'arrival_airport',FILTER_SANITIZE_STRING);
15 if (isset($_GET['departure_airport']) && isset($_GET['arrival_airport'])) {
16 $spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, "0,1", $sort);
17 } else $spotter_array = array();
19 if (!empty($spotter_array))
21 $title = sprintf(_("Most Common Aircraft by Registration 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']);
22 require_once('header.php');
23 print '<div class="info column">';
24 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>';
25 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>';
26 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>';
27 print '</div>';
29 include('route-sub-menu.php');
30 print '<div class="column">';
31 print '<h2>'._("Most Common Aircraft by Registration").'</h2>';
32 print '<p>'.sprintf(_("The statistic below shows the most common aircraft by registration 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>';
34 $aircraft_array = $Spotter->countAllAircraftRegistrationByRoute($departure_airport, $arrival_airport);
35 if (!empty($aircraft_array))
37 print '<div class="table-responsive">';
38 print '<table class="common-type table-striped">';
39 print '<thead>';
40 print '<th></th>';
41 print '<th></th>';
42 print '<th>'._("Registration").'</th>';
43 print '<th>'._("Aircraft Type").'</th>';
44 print '<th>'._("# of times").'</th>';
45 print '<th></th>';
46 print '</thead>';
47 print '<tbody>';
48 $i = 1;
49 foreach($aircraft_array as $aircraft_item)
51 print '<tr>';
52 print '<td><strong>'.$i.'</strong></td>';
53 if ($aircraft_item['image_thumbnail'] != "")
55 print '<td class="aircraft_thumbnail">';
56 if (isset($aircraft_item['aircraft_type'])) {
57 print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'"><img src="'.$aircraft_item['image_thumbnail'].'" class="img-rounded" data-toggle="popover" title="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_icao'].' - '.$aircraft_item['airline_name'].'" alt="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_type'].' - '.$aircraft_item['airline_name'].'" data-content="'._("Registration:").' '.$aircraft_item['registration'].'<br />'._("Aircraft:").' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')<br />'._("Airline:").' '.$aircraft_item['airline_name'].'" data-html="true" width="100px" /></a>';
58 } else {
59 print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'"><img src="'.$aircraft_item['image_thumbnail'].'" class="img-rounded" data-toggle="popover" title="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_icao'].' - '.$aircraft_item['airline_name'].'" alt="'.$aircraft_item['registration'].' - '.$aircraft_item['airline_name'].'" data-content="'._("Registration:").' '.$aircraft_item['registration'].'<br />'._("Aircraft:").' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')<br />'._("Airline:").' '.$aircraft_item['airline_name'].'" data-html="true" width="100px" /></a>';
61 print '</td>';
62 } else {
63 print '<td class="aircraft_thumbnail">';
64 if (isset($aircraft_item['aircraft_type'])) {
65 print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_icao'].' - '.$aircraft_item['airline_name'].'" alt="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_type'].' - '.$aircraft_item['airline_name'].'" data-content="'._("Registration:").' '.$aircraft_item['registration'].'<br />'._("Aircraft:").' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')<br />'._("Airline:").' '.$aircraft_item['airline_name'].'" data-html="true" width="100px" /></a>';
66 } else {
67 print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_icao'].' - '.$aircraft_item['airline_name'].'" alt="'.$aircraft_item['registration'].' - '.$aircraft_item['airline_name'].'" data-content="'._("Registration:").' '.$aircraft_item['registration'].'<br />'._("Aircraft:").' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')<br />'._("Airline:").' '.$aircraft_item['airline_name'].'" data-html="true" width="100px" /></a>';
69 print '</td>';
71 print '<td>';
72 print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'">'.$aircraft_item['registration'].'</a>';
73 print '</td>';
74 print '<td>';
75 print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>';
76 print '</td>';
77 print '<td>';
78 print $aircraft_item['registration_count'];
79 print '</td>';
80 print '<td><a href="'.$globalURL.'/search?registration='.$aircraft_item['registration'].'&departure_airport_route='.$departure_airport.'&arrival_airport_route='.$arrival_airport.'">'._("Search flights").'</a></td>';
81 print '</tr>';
82 $i++;
84 print '<tbody>';
85 print '</table>';
86 print '</div>';
88 print '</div>';
89 } else {
90 $title = _("Unknown Route");
91 require_once('header.php');
92 print '<h1>'._("Error").'</h1>';
93 print '<p>'._("Sorry, this route does not exist in this database. :(").'</p>';
96 require_once('footer.php');