Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / pilot-statistics-airline.php
blob6221b10b6bebb2301e042b4997dc92eafc6c2653
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['pilot'])) {
6 header('Location: '.$globalURL.'/pilot');
7 die();
9 $Spotter = new Spotter();
10 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
11 $pilot = filter_input(INPUT_GET,'pilot',FILTER_SANITIZE_STRING);
12 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
13 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
14 $filter = array();
15 if ($year != '') $filter = array_merge($filter,array('year' => $year));
16 if ($month != '') $filter = array_merge($filter,array('month' => $month));
17 $spotter_array = $Spotter->getSpotterDataByPilot($pilot,"0,1", $sort,$filter);
19 if (!empty($spotter_array))
21 $title = sprintf(_("Most Common Airlines of %s"),$spotter_array[0]['pilot_name']);
22 require_once('header.php');
23 print '<div class="info column">';
24 print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>';
25 // print '<div><span class="label">'._("Ident").'</span>'.$spotter_array[0]['ident'].'</div>';
26 // print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>';
27 print '</div>';
29 include('pilot-sub-menu.php');
30 print '<div class="column">';
31 print '<h2>'._("Most Common Airlines").'</h2>';
32 print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights owned by <strong>%s</strong>."),$spotter_array[0]['pilot_name']).'</p>';
34 $airline_array = $Spotter->countAllAirlinesByPilot($pilot,$filter);
35 if (!empty($airline_array))
37 print '<div class="table-responsive">';
38 print '<table class="common-airline table-striped">';
39 print '<thead>';
40 print '<th></th>';
41 print '<th></th>';
42 print '<th>'._("Airline").'</th>';
43 print '<th>'._("Country").'</th>';
44 print '<th>'._("# of times").'</th>';
45 print '<th></th>';
46 print '</thead>';
47 print '<tbody>';
48 $i = 1;
49 foreach($airline_array as $airline_item)
51 print '<tr>';
52 print '<td><strong>'.$i.'</strong></td>';
53 print '<td class="logo">';
54 print '<a href="'.$globalURL.'/airline/'.$airline_item['airline_icao'].'"><img src="';
55 if ($globalIVAO && @getimagesize($globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.gif'))
57 print $globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.gif';
58 } elseif (@getimagesize($globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.png'))
60 print $globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.png';
61 } else {
62 print $globalURL.'/images/airlines/placeholder.png';
64 print '" /></a>';
65 print '</td>';
66 print '<td>';
67 print '<a href="'.$globalURL.'/airline/'.$airline_item['airline_icao'].'">'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')</a>';
68 print '</td>';
69 print '<td>';
70 print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airline_item['airline_country'])).'">'.$airline_item['airline_country'].'</a>';
71 print '</td>';
72 print '<td>';
73 print $airline_item['airline_count'];
74 print '</td>';
75 print '<td><a href="'.$globalURL.'/search?airline='.$airline_item['airline_icao'].'&pilot_name='.$spotter_array[0]['pilot_name'].'">'._("Search flights").'</a></td>';
76 print '</tr>';
77 $i++;
79 print '<tbody>';
80 print '</table>';
81 print '</div>';
83 print '</div>';
84 } else {
85 $title = _("Pilot");
86 require_once('header.php');
87 print '<h1>'._("Error").'</h1>';
88 print '<p>'._("Sorry, this pilot is not in the database. :(").'</p>';
91 require_once('footer.php');