Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / owner-statistics-aircraft.php
blobd71b912398053dcf7c63c34e2620007cf2f853ff
1 <?php
2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.SpotterArchive.php');
5 require_once('require/class.Language.php');
6 if (!isset($_GET['owner'])) {
7 header('Location: '.$globalURL.'/owner');
8 die();
10 $Spotter = new Spotter();
11 $SpotterArchive = new SpotterArchive();
12 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13 $owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING));
14 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
16 $filter = array();
17 if ($year != '') $filter = array_merge($filter,array('year' => $year));
18 if ($month != '') $filter = array_merge($filter,array('month' => $month));
19 $archive = false;
20 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
22 $archive = true;
23 $spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
26 if (!empty($spotter_array))
28 $title = sprintf(_("Most Common Aircraft of %s"),$spotter_array[0]['aircraft_owner']);
29 require_once('header.php');
30 print '<div class="info column">';
31 print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
32 // print '<div><span class="label">'._("Ident").'</span>'.$spotter_array[0]['ident'].'</div>';
33 // print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>';
34 print '</div>';
36 include('owner-sub-menu.php');
37 print '<div class="column">';
38 print '<h2>'._("Most Common Aircraft").'</h2>';
39 print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
41 if ($archive === false) {
42 $aircraft_array = $Spotter->countAllAircraftTypesByOwner($owner,$filter);
43 } else {
44 $aircraft_array = $SpotterArchive->countAllAircraftTypesByOwner($owner,$filter);
46 if (!empty($aircraft_array))
48 print '<div class="table-responsive">';
49 print '<table class="common-type table-striped">';
50 print '<thead>';
51 print '<th></th>';
52 print '<th>'._("Aircraft Type").'</th>';
53 print '<th>'._("# of times").'</th>';
54 print '</thead>';
55 print '<tbody>';
56 $i = 1;
57 foreach($aircraft_array as $aircraft_item)
59 print '<tr>';
60 print '<td><strong>'.$i.'</strong></td>';
61 print '<td>';
62 print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>';
63 print '</td>';
64 print '<td>';
65 print $aircraft_item['aircraft_icao_count'];
66 print '</td>';
67 print '</tr>';
68 $i++;
70 print '<tbody>';
71 print '</table>';
72 print '</div>';
74 print '</div>';
75 } else {
76 $title = _("Owner");
77 require_once('header.php');
78 print '<h1>'._("Error").'</h1>';
79 print '<p>'._("Sorry, this owner is not in the database. :(").'</p>';
82 require_once('footer.php');