Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / registration-statistics-route.php
blobb60e069fe456443eefadf36a2ee3375211121f3a
1 <?php
2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Language.php');
5 $Spotter = new Spotter();
6 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
7 $registration = filter_input(INPUT_GET,'registration',FILTER_SANITIZE_STRING);
8 $spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,1", $sort);
9 $aircraft_array = $Spotter->getAircraftInfoByRegistration($registration);
12 if (!empty($spotter_array))
14 $title = sprintf(_("Most Common Routes from aircraft with registration %s"),$registration);
16 require_once('header.php');
17 print '<div class="info column">';
18 print '<h1>'.$registration.' - '.$aircraft_array[0]['aircraft_name'].' ('.$aircraft_array[0]['aircraft_icao'].')</h1>';
19 print '<div><span class="label">'._("Name").'</span><a href="'.$globalURL.'/aircraft/'.$aircraft_array[0]['aircraft_icao'].'">'.$aircraft_array[0]['aircraft_name'].'</a></div>';
20 print '<div><span class="label">'._("ICAO").'</span><a href="'.$globalURL.'/aircraft/'.$aircraft_array[0]['aircraft_icao'].'">'.$aircraft_array[0]['aircraft_icao'].'</a></div>';
21 print '<div><span class="label">'._("Manufacturer").'</span><a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $aircraft_array[0]['aircraft_manufacturer'])).'">'.$aircraft_array[0]['aircraft_manufacturer'].'</a></div>';
22 print '</div>';
24 include('registration-sub-menu.php');
25 print '<div class="column">';
26 print '<h2>'._("Most Common Routes").'</h2>';
27 print '<p>'.sprintf(_("The statistic below shows the most common routes of aircraft with registration <strong>%s</strong>."),$registration).'</p>';
29 $route_array = $Spotter->countAllRoutesByRegistration($registration);
30 if (!empty($route_array))
32 print '<div class="table-responsive">';
33 print '<table class="common-routes table-striped">';
34 print '<thead>';
35 print '<th></th>';
36 print '<th>'._("Departure Airport").'</th>';
37 print '<th>'._("Arrival Airport").'</th>';
38 print '<th>'._("# of times").'</th>';
39 print '<th></th>';
40 print '</thead>';
41 print '<tbody>';
42 $i = 1;
43 foreach($route_array as $route_item)
45 print '<tr>';
46 print '<td><strong>'.$i.'</strong></td>';
47 print '<td>';
48 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>';
49 print '</td>';
50 print '<td>';
51 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>';
52 print '</td>';
53 print '<td>';
54 print $route_item['route_count'];
55 print '</td>';
56 print '<td>';
57 print '<a href="'.$globalURL.'/route/'.$route_item['airport_departure_icao'].'/'.$route_item['airport_arrival_icao'].'">'._("Route Profile").'</a>';
58 print '</td>';
59 print '</tr>';
60 $i++;
62 print '<tbody>';
63 print '</table>';
64 print '</div>';
66 print '</div>';
67 } else {
68 $title = _("Registration");
69 require_once('header.php');
70 print '<h1>'._("Error").'</h1>';
71 print '<p>'._("Sorry, this registration does not exist in this database. :(").'</p>';
74 require_once('footer.php');