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 by Country");
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
);
15 require_once('header.php');
16 include('statistics-sub-menu.php');
18 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
19 print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
20 print '<script type="text/javascript" src="'.$globalURL.'/js/datamaps.world.min.js"></script>';
21 print '<div class="info">
22 <h1>'._("Most common Arrival Airport by Country").'</h1>
24 <p>'._("Below are the <strong>Top 10</strong> most common countries of all the arrival airports.").'</p>';
25 print '<div id="chartCountry" class="chart" width="100%"></div>';
27 $airport_country_array = $Stats->countAllArrivalCountries(true,$airline_icao,$filter_name,$year,$month);
29 print 'var series = [';
31 foreach($airport_country_array as $airport_item)
33 $country_data .= '[ "'.$airport_item['airport_arrival_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],';
35 $country_data = substr($country_data, 0, -1);
38 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);';
39 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
40 print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
42 element: document.getElementById("chartCountry"),
43 projection: "mercator", // big world map
44 fills: { defaultFill: "#F5F5F5" },
48 borderColor: "#DEDEDE",
49 highlightBorderWidth: 2,
50 highlightFillColor: function(geo) {
51 return geo["fillColor"] || "#F5F5F5";
53 highlightBorderColor: "#B7B7B7",
54 done: function(datamap) {
55 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
57 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
60 popupTemplate: function(geo, data) {
61 if (!data) { return ; }
62 return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
68 print '<div class="table-responsive">';
69 print '<table class="common-country table-striped">';
72 print '<th>'._("Country").'</th>';
73 print '<th>'._("# of times").'</th>';
77 foreach($airport_country_array as $airport_item)
80 print '<td><strong>'.$i.'</strong></td>';
82 print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airport_item['airport_arrival_country'])).'">'.$airport_item['airport_arrival_country'].'</a>';
85 print $airport_item['airport_arrival_country_count'];
94 require_once('footer.php');