Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / owner-statistics-airline.php
blobdac8c695935cc91fefe069cced50aab3eb78fc3b
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);
25 if (!empty($spotter_array))
27 $title = sprintf(_("Most Common Airlines of %s"),$spotter_array[0]['aircraft_owner']);
28 require_once('header.php');
29 print '<div class="info column">';
30 print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
31 // print '<div><span class="label">'._("Ident").'</span>'.$spotter_array[0]['ident'].'</div>';
32 // print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>';
33 print '</div>';
35 include('owner-sub-menu.php');
36 print '<div class="column">';
37 print '<h2>'._("Most Common Airlines").'</h2>';
38 print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
40 if ($archive === false) {
41 $airline_array = $Spotter->countAllAirlinesByOwner($owner,$filter);
42 } else {
43 $airline_array = $SpotterArchive->countAllAirlinesByOwner($owner,$filter);
45 if (!empty($airline_array))
47 print '<div class="table-responsive">';
48 print '<table class="common-airline table-striped">';
49 print '<thead>';
50 print '<th></th>';
51 print '<th></th>';
52 print '<th>'._("Airline").'</th>';
53 print '<th>'._("Country").'</th>';
54 print '<th>'._("# of times").'</th>';
55 print '<th></th>';
56 print '</thead>';
57 print '<tbody>';
58 $i = 1;
59 foreach($airline_array as $airline_item)
61 print '<tr>';
62 print '<td><strong>'.$i.'</strong></td>';
63 print '<td class="logo">';
64 print '<a href="'.$globalURL.'/airline/'.$airline_item['airline_icao'].'"><img src="';
65 if ($globalIVAO && @getimagesize($globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.gif'))
67 print $globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.gif';
68 } elseif (@getimagesize($globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.png'))
70 print $globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.png';
71 } else {
72 print $globalURL.'/images/airlines/placeholder.png';
74 print '" /></a>';
75 print '</td>';
76 print '<td>';
77 print '<a href="'.$globalURL.'/airline/'.$airline_item['airline_icao'].'">'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')</a>';
78 print '</td>';
79 print '<td>';
80 print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airline_item['airline_country'])).'">'.$airline_item['airline_country'].'</a>';
81 print '</td>';
82 print '<td>';
83 print $airline_item['airline_count'];
84 print '</td>';
85 print '<td><a href="'.$globalURL.'/search?airline='.$airline_item['airline_icao'].'&owner='.$owner.'">'._("Search flights").'</a></td>';
86 print '</tr>';
87 $i++;
89 print '<tbody>';
90 print '</table>';
91 print '</div>';
93 print '</div>';
94 } else {
95 $title = _("Owner");
96 require_once('header.php');
97 print '<h1>'._("Error").'</h1>';
98 print '<p>'._("Sorry, this owner is not in the database. :(").'</p>';
101 require_once('footer.php');