2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.SpotterArchive.php');
5 require_once('require/class.Language.php');
6 if (!isset($_GET['owner'])) {
7 header('Location: '.$globalURL.'/owner');
10 $Spotter = new Spotter();
11 $SpotterArchive = new SpotterArchive();
12 $sort = filter_input(INPUT_GET
,'sort',FILTER_SANITIZE_STRING
);
13 $owner = urldecode(filter_input(INPUT_GET
,'owner',FILTER_SANITIZE_STRING
));
14 $year = filter_input(INPUT_GET
,'year',FILTER_SANITIZE_NUMBER_INT
);
15 $month = filter_input(INPUT_GET
,'month',FILTER_SANITIZE_NUMBER_INT
);
17 if ($year != '') $filter = array_merge($filter,array('year' => $year));
18 if ($month != '') $filter = array_merge($filter,array('month' => $month));
20 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
23 $spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
25 if (!empty($spotter_array))
27 $title = sprintf(_("Most Common Departure Airports of %s"),$spotter_array[0]['aircraft_owner']);
28 require_once('header.php');
29 print '<div class="info column">';
30 print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
31 // print '<div><span class="label">'._("Ident").'</span>'.$spotter_array[0]['ident'].'</div>';
32 // print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>';
35 include('owner-sub-menu.php');
36 print '<div class="column">';
37 print '<h2>'._("Most Common Departure Airports").'</h2>';
38 print '<p>'.sprintf(_("The statistic below shows all departure airports of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
39 if ($archive === false) {
40 $airport_airport_array = $Spotter->countAllDepartureAirportsByOwner($owner,$filter);
42 $airport_airport_array = $SpotterArchive->countAllDepartureAirportsByOwner($owner,$filter);
44 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
45 print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
46 print '<script type="text/javascript" src="'.$globalURL.'/js/datamaps.world.min.js"></script>';
47 print '<div id="chartAirport" class="chart" width="100%"></div>';
49 print 'var series = [';
51 foreach($airport_airport_array as $airport_item)
53 $airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
55 $airport_data = substr($airport_data, 0, -1);
58 print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
59 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
60 print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([2,20]);'."\n";
61 print 'var dataset = [];'."\n";
62 print 'var colorset = [];'."\n";
63 print 'colorset["defaultFill"] = "#F5F5F5";';
64 print 'series.forEach(function(item){'."\n";
65 print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
66 print 'colorset[nm] = paletteScale(cnt);';
67 print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
69 print 'var bbl = new Datamap({
70 element: document.getElementById("chartAirport"),
71 projection: "mercator", // big world map
75 borderColor: "#DEDEDE",
76 highlightBorderWidth: 2,
77 highlightFillColor: function(geo) {
78 return geo["fillColor"] || "#F5F5F5";
80 highlightBorderColor: "#B7B7B7"},
81 done: function(datamap) {
82 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
84 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
89 popupTemplate: function(geo, data) {
90 if (!data) { return ; }
91 return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
95 print '<div class="table-responsive">';
96 print '<table class="common-airport table-striped">';
99 print '<th>'._("Airport").'</th>';
100 print '<th>'._("Country").'</th>';
101 print '<th>'._("# of times").'</th>';
106 foreach($airport_airport_array as $airport_item)
109 print '<td><strong>'.$i.'</strong></td>';
111 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>';
114 print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airport_item['airport_departure_country'])).'">'.$airport_item['airport_departure_country'].'</a>';
117 print $airport_item['airport_departure_icao_count'];
119 print '<td><a href="'.$globalURL.'/search?departure_airport_route='.$airport_item['airport_departure_icao'].'&owner='.$owner.'">'._("Search flights").'</a></td>';
129 require_once('header.php');
130 print '<h1>'._("Error").'</h1>';
131 print '<p>'._("Sorry, this owner is not in the database. :(").'</p>';
134 require_once('footer.php');