2 require_once('require/class.Connection.php');
3 require_once('require/class.Stats.php');
4 require_once('require/class.Language.php');
6 $title = _("Statistics").' - '._("Most common Arrival Airport");
8 if (!isset($filter_name)) $filter_name = '';
9 $airline_icao = (string)filter_input(INPUT_GET
,'airline',FILTER_SANITIZE_STRING
);
10 if ($airline_icao == '' && isset($globalFilter)) {
11 if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
13 $year = filter_input(INPUT_GET
,'year',FILTER_SANITIZE_NUMBER_INT
);
14 $month = filter_input(INPUT_GET
,'month',FILTER_SANITIZE_NUMBER_INT
);
16 require_once('header.php');
17 include('statistics-sub-menu.php');
19 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
20 print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
21 print '<script type="text/javascript" src="'.$globalURL.'/js/datamaps.world.min.js"></script>';
22 print '<div class="info">
23 <h1>'._("Most common Arrival Airport").'</h1>
25 <p>'._("Below are the <strong>Top 10</strong> most common arrival airports.").'</p>';
26 print '<div id="chartAirport" class="chart" width="100%"></div>';
28 $airport_airport_array = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
30 print 'var series = [';
32 foreach($airport_airport_array as $airport_item)
34 $airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
36 $airport_data = substr($airport_data, 0, -1);
39 print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
40 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
41 print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
42 print 'var dataset = [];'."\n";
43 print 'var colorset = [];'."\n";
44 print 'colorset["defaultFill"] = "#F5F5F5";';
45 print 'series.forEach(function(item){'."\n";
46 print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
47 print 'colorset[nm] = paletteScale(cnt);';
48 print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
50 print 'var bbl = new Datamap({
51 element: document.getElementById("chartAirport"),
52 projection: "mercator", // big world map
56 borderColor: "#DEDEDE",
57 highlightBorderWidth: 2,
58 highlightFillColor: function(geo) {
59 return geo["fillColor"] || "#F5F5F5";
61 highlightBorderColor: "#B7B7B7"},
62 done: function(datamap) {
63 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
65 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
70 popupTemplate: function(geo, data) {
71 if (!data) { return ; }
72 return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
76 print '<div class="table-responsive">';
77 print '<table class="common-airport table-striped">';
80 print '<th>'._("Airport").'</th>';
81 print '<th>'._("Country").'</th>';
82 print '<th>'._("# of times").'</th>';
86 foreach($airport_airport_array as $airport_item)
89 print '<td><strong>'.$i.'</strong></td>';
91 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>';
94 print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airport_item['airport_arrival_country'])).'">'.$airport_item['airport_arrival_country'].'</a>';
96 print '<td>'.$airport_item['airport_arrival_icao_count'].'</td>';
104 require_once('footer.php');