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');
10 $Spotter = new Spotter();
11 $manufacturer = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET
,'aircraft_manufacturer',FILTER_SANITIZE_STRING
))));
12 $sort = filter_input(INPUT_GET
,'sort',FILTER_SANITIZE_STRING
);
13 $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort);
15 if (!empty($spotter_array))
17 $title = sprintf(_("Most Common Departure Airports from %s"),$manufacturer);
19 require_once('header.php');
20 print '<div class="select-item">';
21 print '<form action="'.$globalURL.'/manufacturer" method="post">';
22 print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
24 $all_manufacturers = $Stats->getAllManufacturers();
25 if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
26 foreach($all_manufacturers as $all_manufacturer)
28 if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
30 print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
32 print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
36 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
40 print '<div class="info column">';
41 print '<h1>'.$manufacturer.'</h1>';
44 include('manufacturer-sub-menu.php');
45 print '<div class="column">';
46 print '<h2>'._("Most Common Departure Airports").'</h2>';
47 print '<p>'.sprintf(_("The statistic below shows all departure airports of flights from <strong>%s</strong>."),$manufacturer).'</p>';
48 $airport_airport_array = $Spotter->countAllDepartureAirportsByManufacturer($manufacturer);
49 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
50 print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
51 print '<script type="text/javascript" src="'.$globalURL.'/js/datamaps.world.min.js"></script>';
52 print '<div id="chartAirport" class="chart" width="100%"></div>';
54 print 'var series = [';
56 foreach($airport_airport_array as $airport_item)
58 $airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
60 $airport_data = substr($airport_data, 0, -1);
63 print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
64 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
65 print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
66 print 'var dataset = [];'."\n";
67 print 'var colorset = [];'."\n";
68 print 'colorset["defaultFill"] = "#F5F5F5";';
69 print 'series.forEach(function(item){'."\n";
70 print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
71 print 'colorset[nm] = paletteScale(cnt);';
72 print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
74 print 'var bbl = new Datamap({
75 element: document.getElementById("chartAirport"),
76 projection: "mercator", // big world map
80 borderColor: "#DEDEDE",
81 highlightBorderWidth: 2,
82 highlightFillColor: function(geo) {
83 return geo["fillColor"] || "#F5F5F5";
85 highlightBorderColor: "#B7B7B7"},
86 done: function(datamap) {
87 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
89 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
94 popupTemplate: function(geo, data) {
95 if (!data) { return ; }
96 return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
100 print '<div class="table-responsive">';
101 print '<table class="common-airport table-striped">';
104 print '<th>'._("Airport").'</th>';
105 print '<th>'._("Country").'</th>';
106 print '<th>'._("# of times").'</th>';
111 foreach($airport_airport_array as $airport_item)
114 print '<td><strong>'.$i.'</strong></td>';
116 print '<a href="'.$globalURL.'/airport/'.$airport_item['airport_departure_icao'].'">'.$airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')</a>';
119 print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airport_item['airport_departure_country'])).'">'.$airport_item['airport_departure_country'].'</a>';
122 print $airport_item['airport_departure_icao_count'];
124 print '<td><a href="'.$globalURL.'/search?departure_airport_route='.$airport_item['airport_departure_icao'].'&manufacturer='.$manufacturer.'">'._("Search flights").'</a></td>';
133 $title = _("Manufacturer");
134 require_once('header.php');
135 print '<h1>'._("Error").'</h1>';
136 print '<p>'._("Sorry, the aircraft manufacturer does not exist in this database. :(").'</p>';
139 require_once('footer.php');