2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Stats.php');
5 require_once('require/class.Language.php');
6 $Spotter = new Spotter();
8 if (!isset($_GET['aircraft_type'])) {
9 header('Location: '.$globalURL.'/aircraft');
12 $aircraft_type = filter_input(INPUT_GET
,'aircraft_type',FILTER_SANITIZE_STRING
);
13 $spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1","");
16 if (!empty($spotter_array))
18 $title = sprintf(_("Most Common Airlines by Country from %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']);
19 require_once('header.php');
21 print '<div class="select-item">';
22 print '<form action="'.$globalURL.'/aircraft" method="get">';
23 print '<select name="aircraft_type" class="selectpicker" data-live-search="true">';
24 print '<option></option>';
26 $aircraft_types = $Stats->getAllAircraftTypes();
27 if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
28 foreach($aircraft_types as $aircrafttype)
30 if($aircraft_type == $aircrafttype['aircraft_icao'])
32 print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
34 print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
38 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
43 if ($aircraft_type != "NA")
45 print '<div class="info column">';
46 print '<h1>'.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')</h1>';
47 print '<div><span class="label">Name</span>'.$spotter_array[0]['aircraft_name'].'</div>';
48 print '<div><span class="label">ICAO</span>'.$spotter_array[0]['aircraft_type'].'</div>';
49 print '<div><span class="label">Manufacturer</span><a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $spotter_array[0]['aircraft_manufacturer'])).'">'.$spotter_array[0]['aircraft_manufacturer'].'</a></div>';
52 print '<div class="alert alert-warning">'._("This special aircraft profile shows all flights in where the aircraft type is unknown.").'</div>';
54 include('aircraft-sub-menu.php');
55 print '<div class="column">';
56 print '<h2>'._("Most Common Airlines by Country").'</h2>';
57 print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights from <strong>%s (%s)</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>';
59 $airline_array = $Spotter->countAllAirlineCountriesByAircraft($aircraft_type);
60 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
61 print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
62 print '<script type="text/javascript" src="'.$globalURL.'/js/datamaps.world.min.js"></script>';
63 print '<div id="chartCountry" class="chart" width="100%"></div><script>';
64 print 'var series = [';
66 foreach($airline_array as $airline_item)
68 $country_data .= '[ "'.$airline_item['airline_country_iso3'].'",'.$airline_item['airline_country_count'].'],';
70 $country_data = substr($country_data, 0, -1);
73 print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
74 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
75 print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
77 element: document.getElementById("chartCountry"),
78 projection: "mercator", // big world map
79 fills: { defaultFill: "#F5F5F5" },
83 borderColor: "#DEDEDE",
84 highlightBorderWidth: 2,
85 highlightFillColor: function(geo) {
86 return geo["fillColor"] || "#F5F5F5";
88 highlightBorderColor: "#B7B7B7",
89 done: function(datamap) {
90 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
92 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
95 popupTemplate: function(geo, data) {
96 if (!data) { return ; }
97 return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
102 if (!empty($airline_array))
104 print '<div class="table-responsive">';
105 print '<table class="common-country">';
108 print '<th>'._("Country").'</th>';
109 print '<th>'._("# of times").'</th>';
113 foreach($airline_array as $airline_item)
116 print '<td><strong>'.$i.'</strong></td>';
118 print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airline_item['airline_country'])).'">'.$airline_item['airline_country'].'</a>';
121 print $airline_item['airline_country_count'];
132 $title = _("Aircraft Type");
133 require_once('header.php');
134 print '<h1>'._("Error").'</h1>';
135 print '<p>'._("Sorry, the aircraft type does not exist in this database. :(").'</p>';
137 require_once('footer.php');