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 if (!isset($_GET['aircraft_manufacturer'])) {
7 header('Location: '.$globalURL.'/manufacturer');
11 $Spotter = new Spotter();
12 $manufacturer = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET
,'aircraft_manufacturer',FILTER_SANITIZE_STRING
))));
13 $sort = filter_input(INPUT_GET
,'sort',FILTER_SANITIZE_STRING
);
14 $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort);
16 if (!empty($spotter_array))
18 $title = sprintf(_("Most Common Arrival Airports from %s"),$manufacturer);
20 require_once('header.php');
21 print '<div class="select-item">';
22 print '<form action="'.$globalURL.'/manufacturer" method="post">';
23 print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
25 $all_manufacturers = $Stats->getAllManufacturers();
26 if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
27 foreach($all_manufacturers as $all_manufacturer)
29 if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
31 print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
33 print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
37 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
41 print '<div class="info column">';
42 print '<h1>'.$manufacturer.'</h1>';
45 include('manufacturer-sub-menu.php');
46 print '<div class="column">';
47 print '<h2>'._("Most Common Arrival Airports").'</h2>';
48 print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights from <strong>%s</strong>."),$manufacturer).'</p>';
49 $airport_airport_array = $Spotter->countAllArrivalAirportsByManufacturer($manufacturer);
50 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
51 print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
52 print '<script type="text/javascript" src="'.$globalURL.'/js/datamaps.world.min.js"></script>';
53 print '<div id="chartAirport" class="chart" width="100%"></div>';
55 print 'var series = [';
57 foreach($airport_airport_array as $airport_item)
59 $airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
61 $airport_data = substr($airport_data, 0, -1);
64 print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
65 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
66 print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
67 print 'var dataset = [];'."\n";
68 print 'var colorset = [];'."\n";
69 print 'colorset["defaultFill"] = "#F5F5F5";';
70 print 'series.forEach(function(item){'."\n";
71 print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
72 print 'colorset[nm] = paletteScale(cnt);';
73 print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
75 print 'var bbl = new Datamap({
76 element: document.getElementById("chartAirport"),
77 projection: "mercator", // big world map
81 borderColor: "#DEDEDE",
82 highlightBorderWidth: 2,
83 highlightFillColor: function(geo) {
84 return geo["fillColor"] || "#F5F5F5";
86 highlightBorderColor: "#B7B7B7"},
87 done: function(datamap) {
88 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
90 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>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
101 print '<div class="table-responsive">';
102 print '<table class="common-airport table-striped">';
105 print '<th>'._("Airport").'</th>';
106 print '<th>'._("Country").'</th>';
107 print '<th>'._("# of times").'</th>';
112 foreach($airport_airport_array as $airport_item)
115 print '<td><strong>'.$i.'</strong></td>';
117 print '<a href="'.$globalURL.'/airport/'.$airport_item['airport_arrival_icao'].'">'.$airport_item['airport_arrival_city'].', '.$airport_item['airport_arrival_country'].' ('.$airport_item['airport_arrival_icao'].')</a>';
120 print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airport_item['airport_arrival_country'])).'">'.$airport_item['airport_arrival_country'].'</a>';
123 print $airport_item['airport_arrival_icao_count'];
125 print '<td><a href="'.$globalURL.'/search?arrival_airport_route='.$airport_item['airport_arrival_icao'].'&manufacturer='.$manufacturer.'">'._("Search flights").'</a></td>';
134 $title = _("Manufacturer");
135 require_once('header.php');
136 print '<h1>'._("Error").'</h1>';
137 print '<p>'._("Sorry, the aircraft manufacturer does not exist in this database. :(").'</p>';
140 require_once('footer.php');