Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / owner-statistics-registration.php
blob1225815aff78e91eff874faff13b6b981e8a3c40
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 $owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING));
13 $sort = filter_input(INPUT_GET,'sort',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 $spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
24 if (!empty($spotter_array))
26 $title = sprintf(_("Most Common Aircraft by Registration of %s"),$spotter_array[0]['aircraft_owner']);
27 require_once('header.php');
28 print '<div class="info column">';
29 print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
30 // print '<div><span class="label">'._("Ident").'</span>'.$spotter_array[0]['ident'].'</div>';
31 // print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>';
32 print '</div>';
34 include('owner-sub-menu.php');
35 print '<div class="column">';
36 print '<h2>'._("Most Common Aircraft by Registration").'</h2>';
37 print '<p>'.sprintf(_("The statistic below shows the most common aircraft by Registration of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
38 if ($archive === false) {
39 $aircraft_array = $Spotter->countAllAircraftRegistrationByOwner($owner,$filter);
40 } else {
41 $aircraft_array = $SpotterArchive->countAllAircraftRegistrationByOwner($owner,$filter);
44 if (!empty($aircraft_array))
46 print '<div class="table-responsive">';
47 print '<table class="common-type table-striped">';
48 print '<thead>';
49 print '<th></th>';
50 print '<th></th>';
51 print '<th>'._("Registration").'</th>';
52 print '<th>'._("Aircraft Type").'</th>';
53 print '<th>'._("# of times").'</th>';
54 print '<th></th>';
55 print '</thead>';
56 print '<tbody>';
57 $i = 1;
58 foreach($aircraft_array as $aircraft_item)
60 print '<tr>';
61 print '<td><strong>'.$i.'</strong></td>';
62 if ($aircraft_item['image_thumbnail'] != "")
64 print '<td class="aircraft_thumbnail">';
65 if (isset($aircraft_item['aircraft_type'])) {
66 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>';
67 } else {
68 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>';
70 print '</td>';
71 } else {
72 print '<td class="aircraft_thumbnail">';
73 if (isset($aircraft_item['aircraft_type'])) {
74 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>';
75 } else {
76 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>';
78 print '</td>';
80 print '<td>';
81 print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'">'.$aircraft_item['registration'].'</a>';
82 print '</td>';
83 print '<td>';
84 print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>';
85 print '</td>';
86 print '<td>';
87 print $aircraft_item['registration_count'];
88 print '</td>';
89 print '<td><a href="'.$globalURL.'/search?registration='.$aircraft_item['registration'].'&owner='.$owner.'">'._("Search flights").'</a></td>';
90 print '</tr>';
91 $i++;
93 print '<tbody>';
94 print '</table>';
95 print '</div>';
97 print '</div>';
98 } else {
99 $title = _("Owner");
100 require_once('header.php');
101 print '<h1>'._("Error").'</h1>';
102 print '<p>'._("Sorry, this owner is not in the database. :(").'</p>';
105 require_once('footer.php');