Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / pilot-statistics-manufacturer.php
blob149e2a12174b3609c20e25c295c6a9da8965b68e
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 Aircraft Manufacturer 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 Aircraft Manufacturer").'</h2>';
32 print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of flights piloted by <strong>%s</strong>."),$spotter_array[0]['pilot_name']).'</p>';
34 $manufacturers_array = $Spotter->countAllAircraftManufacturerByPilot($pilot,$filter);
35 if (!empty($manufacturers_array))
37 print '<div class="table-responsive">';
38 print '<table class="common-manufacturer table-striped">';
39 print '<thead>';
40 print '<th></th>';
41 print '<th>'._("Aircraft Manufacturer").'</th>';
42 print '<th>'._("# of times").'</th>';
43 print '<th></th>';
44 print '</thead>';
45 print '<tbody>';
46 $i = 1;
47 foreach($manufacturers_array as $manufacturer_item)
49 print '<tr>';
50 print '<td><strong>'.$i.'</strong></td>';
51 print '<td>';
52 print '<a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $manufacturer_item['aircraft_manufacturer'])).'">'.$manufacturer_item['aircraft_manufacturer'].'</a>';
53 print '</td>';
54 print '<td>';
55 print $manufacturer_item['aircraft_manufacturer_count'];
56 print '</td>';
57 print '<td><a href="'.$globalURL.'/search?manufacturer='.strtolower(str_replace(" ", "-", $manufacturer_item['aircraft_manufacturer'])).'&pilot_name='.$spotter_array[0]['pilot_name'].'">'._("Search flights").'</a></td>';
58 print '</tr>';
59 $i++;
61 print '<tbody>';
62 print '</table>';
63 print '</div>';
65 print '</div>';
66 } else {
67 $title = _("Pilot");
68 require_once('header.php');
69 print '<h1>'._("Error").'</h1>';
70 print '<p>'._("Sorry, this pilot is not in the database. :(").'</p>';
73 require_once('footer.php');