Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / ident-statistics-aircraft.php
blob65a6dbf31996e45c9d7544c5daf3981801ecade0
1 <?php
2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Language.php');
5 if (!isset($_GET['ident'])) {
6 header('Location: '.$globalURL.'/ident');
7 die();
9 $Spotter = new Spotter();
10 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
11 $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
12 if ($sort != '') {
13 $spotter_array = $Spotter->getSpotterDataByIdent($ident,"0,1", $sort);
14 } else {
15 $spotter_array = $Spotter->getSpotterDataByIdent($ident,"0,1", '');
18 if (!empty($spotter_array))
20 $title = sprintf(_("Most Common Aircraft of %s"),$spotter_array[0]['ident']);
21 require_once('header.php');
22 print '<div class="info column">';
23 print '<h1>'.$spotter_array[0]['ident'].'</h1>';
24 print '<div><span class="label">'._("Ident").'</span>'.$spotter_array[0]['ident'].'</div>';
25 print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>';
26 print '</div>';
28 include('ident-sub-menu.php');
29 print '<div class="column">';
30 print '<h2>'._("Most Common Aircraft").'</h2>';
31 print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights using the ident/callsign <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
33 $aircraft_array = $Spotter->countAllAircraftTypesByIdent($ident);
34 if (!empty($aircraft_array))
36 print '<div class="table-responsive">';
37 print '<table class="common-type table-striped">';
38 print '<thead>';
39 print '<th></th>';
40 print '<th>'._("Aircraft Type").'</th>';
41 print '<th>'._("# of times").'</th>';
42 print '<th></th>';
43 print '</thead>';
44 print '<tbody>';
45 $i = 1;
46 foreach($aircraft_array as $aircraft_item)
48 print '<tr>';
49 print '<td><strong>'.$i.'</strong></td>';
50 print '<td>';
51 print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>';
52 print '</td>';
53 print '<td>';
54 print $aircraft_item['aircraft_icao_count'];
55 print '</td>';
56 print '<td><a href="'.$globalURL.'/search?aircraft='.$aircraft_item['aircraft_icao'].'&callsign='.$ident.'">'._("Search flights").'</a></td>';
57 print '</tr>';
58 $i++;
60 print '<tbody>';
61 print '</table>';
62 print '</div>';
64 print '</div>';
65 } else {
66 $title = _("Ident");
67 require_once('header.php');
68 print '<h1>'._("Error").'</h1>';
69 print '<p>'._("Sorry, this ident/callsign is not in the database. :(").'</p>';
72 require_once('footer.php');