Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / owner-statistics-manufacturer.php
blobf1be21c36a2a7fc8899472ecc4e162211ad54ce6
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 $spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
24 if (!empty($spotter_array))
26 $title = sprintf(_("Most Common Aircraft Manufacturer 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 Manufacturer").'</h2>';
37 print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
39 if ($archive === false) {
40 $manufacturers_array = $Spotter->countAllAircraftManufacturerByOwner($owner,$filter);
41 } else {
42 $manufacturers_array = $SpotterArchive->countAllAircraftManufacturerByOwner($owner,$filter);
44 if (!empty($manufacturers_array))
46 print '<div class="table-responsive">';
47 print '<table class="common-manufacturer table-striped">';
48 print '<thead>';
49 print '<th></th>';
50 print '<th>'._("Aircraft Manufacturer").'</th>';
51 print '<th>'._("# of times").'</th>';
52 print '<th></th>';
53 print '</thead>';
54 print '<tbody>';
55 $i = 1;
56 foreach($manufacturers_array as $manufacturer_item)
58 print '<tr>';
59 print '<td><strong>'.$i.'</strong></td>';
60 print '<td>';
61 print '<a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $manufacturer_item['aircraft_manufacturer'])).'">'.$manufacturer_item['aircraft_manufacturer'].'</a>';
62 print '</td>';
63 print '<td>';
64 print $manufacturer_item['aircraft_manufacturer_count'];
65 print '</td>';
66 print '<td><a href="'.$globalURL.'/search?manufacturer='.strtolower(str_replace(" ", "-", $manufacturer_item['aircraft_manufacturer'])).'&owner='.$owner.'">'._("Search flights").'</a></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');