Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / statistics.php
blob05a34b6c8f1bf2b56a644bdd7c23e67ee6f3cfc8
1 <?php
2 require_once('require/class.Connection.php');
3 require_once('require/class.Stats.php');
4 require_once('require/class.Language.php');
5 $beginpage = microtime(true);
6 $Stats = new Stats();
8 $type = 'aircraft';
9 if (isset($_GET['tracker'])) {
10 require_once('require/class.Tracker.php');
11 $Tracker = new Tracker();
12 $type = 'tracker';
13 } elseif (isset($_GET['marine'])) {
14 require_once('require/class.Marine.php');
15 $Marine = new Marine();
16 $type = 'marine';
17 } elseif (isset($_GET['satellite'])) {
18 require_once('require/class.Satellite.php');
19 $Satellite = new Satellite();
20 $type = 'satellite';
21 } else {
22 require_once('require/class.Spotter.php');
25 if (!isset($filter_name)) $filter_name = '';
26 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
27 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28 if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
30 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
31 $Spotter = new Spotter();
32 $airline_info = $Spotter->getAllAirlineInfo($airline_icao);
33 if (isset($airline_info[0]['name'])) {
34 $airline_name = $airline_info[0]['name'];
35 } elseif (strpos($airline_icao,'alliance_') !== FALSE) {
36 $alliance_name = $airline_icao;
39 if ($type == 'aircraft' && isset($airline_name)) {
40 $title = _("Statistics").' - '.$airline_name;
41 } else {
42 $title = _("Statistics");
45 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
46 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
48 require_once('header.php');
51 <link href="<?php echo $globalURL; ?>/css/c3.min.css" rel="stylesheet" type="text/css">
52 <!--<script type="text/javascript" src="https://d3js.org/d3.v4.min.js"></script>-->
53 <!--<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>-->
54 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/d3.min.js"></script>
55 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/c3.min.js"></script>
56 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/d3pie.min.js"></script>
57 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/radarChart.js"></script>
58 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/raphael-2.1.4.min.js"></script>
59 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/justgage.js"></script>
60 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/topojson.v2.min.js"></script>
61 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62 <div class="column">
63 <div class="info">
64 <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
65 <?php
66 if ($type == 'aircraft') {
67 $last_update = $Stats->getLastStatsUpdate();
68 } elseif ($type == 'marine') {
69 $last_update = $Stats->getLastStatsUpdate('last_update_stats_marine');
70 } elseif ($type == 'tracker') {
71 $last_update = $Stats->getLastStatsUpdate('last_update_stats_tracker');
73 if (isset($last_update[0]['value'])) {
74 date_default_timezone_set('UTC');
75 $lastupdate = strtotime($last_update[0]['value']);
76 if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
77 print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
81 </div>
82 <?php
83 include('statistics-sub-menu.php');
85 <p class="global-stats">
86 <?php
87 if ($type == 'aircraft') {
89 <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
90 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
91 <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
92 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
93 <?php
94 if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
96 <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
97 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
98 <?php
100 if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
102 <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
103 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
104 <?php
107 <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircraft types"); ?></span>
108 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
109 <?php
110 if ($airline_icao == '') {
112 <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
113 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
114 <?php
117 <?php
118 if (!(isset($globalVA) && $globalVA) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS) && !(isset($globalVAM) && $globalVAM)) {
119 if ($airline_icao == '' || $airline_icao == 'all') {
121 <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
122 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
123 <?php
127 <?php
128 } elseif ($type == 'marine') {
130 <span><span class="badge"><?php print number_format($Stats->countOverallMarine($filter_name,$year,$month)); ?></span> <?php echo _("Vessels"); ?></span>
131 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
132 <?php
133 if (isset($globalVM) && $globalVM) {
135 <span><span class="badge"><?php print number_format($Marine->countOverallMarineTypes($filter_name,$year,$month)); ?></span> <?php echo _("Types"); ?></span>
136 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
137 <span><span class="badge"><?php print number_format($Marine->countOverallMarineRaces($filter_name,$year,$month)); ?></span> <?php echo _("Races"); ?></span>
138 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
139 <span><span class="badge"><?php print number_format($Marine->countOverallMarineCaptains($filter_name,$year,$month)); ?></span> <?php echo _("Captains"); ?></span>
140 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
141 <?php
142 } else {
144 <span><span class="badge"><?php print number_format($Stats->countOverallMarineTypes($filter_name,$year,$month)); ?></span> <?php echo _("Types"); ?></span>
145 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
146 <?php
148 } elseif ($type == 'tracker') {
150 <span><span class="badge"><?php print number_format($Stats->countOverallTracker($filter_name,$year,$month)); ?></span> <?php echo _("Trackers"); ?></span>
151 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
152 <span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes(array(),$year,$month)); ?></span> <?php echo _("Types"); ?></span>
153 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
154 <?php
157 </p>
158 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
159 <div class="specific-stats">
160 <?php
161 if ($type == 'aircraft') {
163 <div class="row column">
164 <div class="col-md-6">
165 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
166 <?php
167 $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
168 if (count($aircraft_array) == 0) {
169 print _("No data available");
170 } else {
171 print '<div id="chart1" class="chart" width="100%"></div><script>';
172 $aircraft_data = '';
173 foreach($aircraft_array as $aircraft_item) {
174 if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
175 else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
177 $aircraft_data = substr($aircraft_data, 0, -1);
178 print 'var series = ['.$aircraft_data.'];';
179 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);';
180 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
181 print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
182 print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
183 print 'dataset';
184 print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
185 print '</script>';
188 <div class="more">
189 <?php
190 if ($year != '' && $month != '') {
192 <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
193 <?php
194 } else {
196 <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
197 <?php
200 </div>
201 </div>
202 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
203 <?php
204 if ($airline_icao == '' || $airline_icao == 'all') {
205 $airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
206 if (count($airline_array) > 0) {
207 print '<div class="col-md-6">';
208 print '<h2>'._("Top 10 Most Common Airline").'</h2>';
209 print '<div id="chart2" class="chart" width="100%"></div><script>';
210 $airline_data = '';
211 foreach($airline_array as $airline_item) {
212 $airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
214 $airline_data = substr($airline_data, 0, -1);
215 print 'var series = ['.$airline_data.'];';
216 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);';
217 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
218 print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
219 print 'var airlinescnt = new d3pie("chart2",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
220 print 'dataset';
221 print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
222 print '</script>';
223 if ($year != '' && $month != '') {
224 print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
225 if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
226 print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
227 } else {
228 print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
229 if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
230 print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
232 print '</div>';
235 </div>
236 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
237 <?php
241 <?php
242 if ($type == 'marine') {
244 <div class="row column">
245 <div class="col-md-6">
246 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
247 <?php
248 $marine_array = $Stats->countAllMarineTypes(true,$filter_name,$year,$month);
249 if (count($marine_array) == 0) print _("No data available");
250 else {
251 print '<div id="chart1" class="chart" width="100%"></div><script>';
252 $marine_data = '';
253 foreach($marine_array as $marine_item) {
254 $marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],';
256 $marine_data = substr($marine_data, 0, -1);
257 print 'var series = ['.$marine_data.'];';
258 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);';
259 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
260 print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
261 print 'var marinetype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
262 print 'dataset';
263 print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
264 print '</script>';
267 <div class="more">
268 <?php
270 if ($year != '' && $month != '') {
272 <a href="<?php print $globalURL; ?>/marine/statistics/type/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
273 <?php
274 } else {
276 <a href="<?php print $globalURL; ?>/marine/statistics/type" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
277 <?php
280 </div>
281 </div>
282 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
283 <!-- </div>-->
284 <?php
285 if (isset($globalVM) && $globalVM) {
287 <div class="col-md-6">
288 <h2><?php echo _("Top 10 Races Number of Participants"); ?></h2>
289 <?php
290 $marine_array = $Marine->countAllCaptainsByRaces(true,$filter_name,$year,$month);
291 if (count($marine_array) == 0) print _("No data available");
292 else {
293 print '<div id="chart991" class="chart" width="100%"></div><script>';
294 $marine_data = '';
295 foreach($marine_array as $marine_item) {
296 $marine_data .= '["'.$marine_item['marine_race_name'].'",'.$marine_item['marine_captain_count'].'],';
298 $marine_data = substr($marine_data, 0, -1);
299 print 'var series = ['.$marine_data.'];';
300 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);';
301 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
302 print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
303 print 'var marinetype = new d3pie("chart991",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
304 print 'dataset';
305 print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3,"format":"value"},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#98e8e3","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
306 print '</script>';
309 <div class="more">
310 <?php
311 if ($year != '' && $month != '') {
313 <a href="<?php print $globalURL; ?>/marine/statistics/race/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
314 <?php
315 } else {
317 <a href="<?php print $globalURL; ?>/marine/statistics/race" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
318 <?php
321 </div>
322 </div>
323 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
324 </div>
325 <div class="row column">
327 <?php
330 if ($type == 'tracker') {
332 <div class="row column">
333 <div class="col-md-6">
334 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
335 <?php
336 $tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
337 if (count($tracker_array) == 0) print _("No data available");
338 else {
339 print '<div id="chart1" class="chart" width="100%"></div><script>';
340 $tracker_data = '';
341 foreach($tracker_array as $tracker_item) {
342 $tracker_data .= '["'.$tracker_item['tracker_type'].'",'.$tracker_item['tracker_type_count'].'],';
344 $tracker_data = substr($tracker_data, 0, -1);
345 print 'var series = ['.$tracker_data.'];';
346 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);';
347 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
348 print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
349 print 'var trackertype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
350 print 'dataset';
351 print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
352 print '</script>';
355 <div class="more">
356 <?php
358 if ($year != '' && $month != '') {
360 <a href="<?php print $globalURL; ?>/tracker/statistics/type/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
361 <?php
362 } else {
364 <a href="<?php print $globalURL; ?>/tracker/statistics/type" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
365 <?php
369 </div>
370 </div>
371 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
372 <!-- </div>-->
373 <?php
375 if ($type == 'satellite') {
377 <div class="row column">
378 <div class="col-md-6">
379 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
380 <?php
381 $owner_array = $Satellite->countAllOwners(true);
382 if (count($owner_array) == 0) print _("No data available");
383 else {
384 print '<div id="chart7" class="chart" width="100%"></div><script>';
385 $owner_data = '';
386 foreach($owner_array as $owner_item) {
387 $owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
389 $owner_data = substr($owner_data, 0, -1);
390 print 'var series = ['.$owner_data.'];';
391 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);';
392 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
393 print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
394 print 'var ownercnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
395 print 'dataset';
396 print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
397 print '</script>';
400 <!--
401 <div class="more">
402 <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
403 </div>
405 </div>
406 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
407 <div class="col-md-6">
408 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
409 <?php
410 $countries_array = $Satellite->countAllCountriesOwners(true);
411 if (count($countries_array) == 0) print _("No data available");
412 else {
413 print '<div id="chart8" class="chart" width="100%"></div><script>';
414 $owner_data = '';
415 foreach($countries_array as $owner_item) {
416 $owner_data .= '["'.$owner_item['country_name'].'",'.$owner_item['country_count'].'],';
418 $owner_data = substr($owner_data, 0, -1);
419 print 'var series = ['.$owner_data.'];';
420 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);';
421 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
422 print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
423 print 'var ownercnt = new d3pie("chart8",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
424 print 'dataset';
425 print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
426 print '</script>';
429 <!--
430 <div class="more">
431 <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
432 </div>
434 </div>
436 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
437 ² </div>
438 <div class="row column">
439 <div class="col-md-6">
440 <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
441 <?php
442 $launch_site_array = $Satellite->countAllLaunchSite(true);
443 if (count($launch_site_array) == 0) print _("No data available");
444 else {
445 print '<div id="chart9" class="chart" width="100%"></div><script>';
446 $launch_site_data = '';
447 foreach($launch_site_array as $launch_site_item) {
448 $launch_site_data .= '["'.$launch_site_item['launch_site'].'",'.$launch_site_item['launch_site_count'].'],';
450 $launch_site_data = substr($launch_site_data, 0, -1);
451 print 'var series = ['.$launch_site_data.'];';
452 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);';
453 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
454 print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
455 print 'var ownercnt = new d3pie("chart9",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
456 print 'dataset';
457 print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
458 print '</script>';
461 <!--
462 <div class="more">
463 <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
464 </div>
466 </div>
467 </div>
468 <?php
470 if ($type == 'aircraft') {
472 <div class="row column">
473 <?php
474 $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
475 //if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
476 if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
477 if (empty($flightover_array)) {
478 print '<div class="col-md-12">';
479 } else {
480 print '<div class="col-md-6">';
483 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
484 <?php
485 $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
486 if (count($pilot_array) == 0) print _("No data available");
487 else {
488 print '<div id="chart7" class="chart" width="100%"></div><script>';
489 $pilot_data = '';
490 foreach($pilot_array as $pilot_item) {
491 $pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
493 $pilot_data = substr($pilot_data, 0, -1);
494 print 'var series = ['.$pilot_data.'];';
495 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);';
496 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
497 print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
498 print 'var pilotcnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
499 print 'dataset';
500 print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
501 print '</script>';
503 print '<div class="more">';
504 print '<a href="'.$globalURL.'/statistics/pilot';
505 if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
506 print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
507 print '</div>';
509 </div>
511 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
512 <?php
514 // else {
515 if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
517 <div class="col-md-6">
518 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
519 <?php
520 $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
521 if (count($owner_array) == 0) print _("No data available");
522 else {
523 print '<div id="chart7" class="chart" width="100%"></div><script>';
524 $owner_data = '';
525 foreach($owner_array as $owner_item) {
526 $owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
528 $owner_data = substr($owner_data, 0, -1);
529 print 'var series = ['.$owner_data.'];';
530 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);';
531 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
532 print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
533 print 'var ownercnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
534 print 'dataset';
535 print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
536 print '</script>';
539 <div class="more">
540 <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
541 </div>
542 </div>
544 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
545 <?php
547 if (!empty($flightover_array)) {
549 <div class="col-md-6">
550 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
551 <?php
552 //$flightover_array = $Stats->countAllFlightOverCountries();
553 if (count($flightover_array) == 0) print _("No data available");
554 else {
555 print '<div id="chart10" class="chart" width="100%"></div><script>';
556 print 'var series = [';
557 $flightover_data = '';
558 foreach($flightover_array as $flightover_item) {
559 $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
561 $flightover_data = substr($flightover_data, 0, -1);
562 print $flightover_data;
563 print '];';
564 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);';
565 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
566 print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
567 print 'new Datamap({
568 element: document.getElementById("chart10"),
569 projection: "mercator", // big world map
570 fills: { defaultFill: "#F5F5F5" },
571 data: dataset,
572 responsive: true,
573 geographyConfig: {
574 borderColor: "#DEDEDE",
575 highlightBorderWidth: 2,
576 highlightFillColor: function(geo) {
577 return geo["fillColor"] || "#F5F5F5";
579 highlightBorderColor: "#B7B7B7",
580 done: function(datamap) {
581 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
582 function redraw() {
583 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
586 popupTemplate: function(geo, data) {
587 if (!data) { return ; }
588 return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
591 });";
592 print '</script>';
595 <div class="more">
596 <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
597 </div>
598 </div>
599 <?php
602 </div>
603 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
604 </div>
605 <?php
607 if ($type == 'marine') {
608 $flightover_array = $Stats->countAllMarineOverCountries(true,$filter_name,$year,$month);
610 <!-- <div class="row column">-->
611 <div class="col-md-6">
612 <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
613 <?php
614 if (count($flightover_array) == 0) print _("No data available");
615 else {
616 print '<div id="chart10" class="chart" width="100%"></div><script>';
617 print 'var series = [';
618 $flightover_data = '';
619 foreach($flightover_array as $flightover_item) {
620 $flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
622 $flightover_data = substr($flightover_data, 0, -1);
623 print $flightover_data;
624 print '];';
625 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);';
626 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
627 print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
628 print 'new Datamap({
629 element: document.getElementById("chart10"),
630 projection: "mercator", // big world map
631 fills: { defaultFill: "#F5F5F5" },
632 data: dataset,
633 responsive: true,
634 geographyConfig: {
635 borderColor: "#DEDEDE",
636 highlightBorderWidth: 2,
637 highlightFillColor: function(geo) {
638 return geo["fillColor"] || "#F5F5F5";
640 highlightBorderColor: "#B7B7B7",
641 done: function(datamap) {
642 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
643 function redraw() {
644 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
647 popupTemplate: function(geo, data) {
648 if (!data) { return ; }
649 return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
652 });";
653 print '</script>';
656 <div class="more">
657 <a href="<?php print $globalURL; ?>/marine/statistics/country" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
658 </div>
659 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
660 </div>
661 </div>
663 <?php
665 if ($type == 'tracker') {
666 $flightover_array = $Stats->countAllTrackerOverCountries(true);
668 <!-- <div class="row column">-->
669 <div class="col-md-6">
670 <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
671 <?php
672 if (count($flightover_array) == 0) print _("No data available");
673 else {
674 print '<div id="chart10" class="chart" width="100%"></div><script>';
675 print 'var series = [';
676 $flightover_data = '';
677 foreach($flightover_array as $flightover_item) {
678 $flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],';
680 $flightover_data = substr($flightover_data, 0, -1);
681 print $flightover_data;
682 print '];';
683 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);';
684 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
685 print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
686 print 'new Datamap({
687 element: document.getElementById("chart10"),
688 projection: "mercator", // big world map
689 fills: { defaultFill: "#F5F5F5" },
690 data: dataset,
691 responsive: true,
692 geographyConfig: {
693 borderColor: "#DEDEDE",
694 highlightBorderWidth: 2,
695 highlightFillColor: function(geo) {
696 return geo["fillColor"] || "#F5F5F5";
698 highlightBorderColor: "#B7B7B7",
699 done: function(datamap) {
700 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
701 function redraw() {
702 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
705 popupTemplate: function(geo, data) {
706 if (!data) { return ; }
707 return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
710 });";
711 print '</script>';
714 <div class="more">
715 <a href="<?php print $globalURL; ?>/tracker/statistics/country" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
716 </div>
717 </div>
718 </div>
720 <?php
722 if ($type == 'aircraft') {
724 <div class="row column">
725 <div class="col-md-6">
726 <?php
727 $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
728 if (count($airport_airport_array) > 0) {
729 print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
730 print '<div id="chart3" class="chart" width="100%"></div><script>';
731 print "\n";
732 print 'var series = [';
733 $airport_data = '';
734 foreach($airport_airport_array as $airport_item) {
735 $airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
737 $airport_data = substr($airport_data, 0, -1);
738 print $airport_data;
739 print '];'."\n";
740 print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
741 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
742 print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
743 print 'var dataset = [];'."\n";
744 print 'var colorset = [];'."\n";
745 print 'colorset["defaultFill"] = "#F5F5F5";';
746 print 'series.forEach(function(item){'."\n";
747 print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
748 print 'colorset[nm] = paletteScale(cnt);';
749 print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
750 print '});'."\n";
751 print 'var bbl = new Datamap({
752 element: document.getElementById("chart3"),
753 projection: "mercator", // big world map
754 fills: colorset,
755 responsive: true,
756 geographyConfig: {
757 borderColor: "#DEDEDE",
758 highlightBorderWidth: 2,
759 highlightFillColor: function(geo) {
760 return geo["fillColor"] || "#F5F5F5";
762 highlightBorderColor: "#B7B7B7"
764 done: function(datamap) {
765 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
766 function redraw() {
767 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
771 bbl.bubbles(dataset,{
772 popupTemplate: function(geo, data) {
773 if (!data) { return ; }
774 return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
776 });";
777 print '</script>';
778 print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure';
779 if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
780 print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
783 </div>
784 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
786 <div class="col-md-6">
787 <?php
788 $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
789 if (count($airport_airport_array2) > 0) {
790 print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
791 print '<div id="chart4" class="chart" width="100%"></div><script>';
792 print "\n";
793 print 'var series = [';
794 $airport_data = '';
795 foreach($airport_airport_array2 as $airport_item)
797 if (isset($airport_item['airport_arrival_longitude']) && isset($airport_item['airport_arrival_latitude'])) {
798 $airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
801 $airport_data = substr($airport_data, 0, -1);
802 print $airport_data;
803 print '];'."\n";
804 print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
805 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
806 print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
807 print 'var dataset = [];'."\n";
808 print 'var colorset = [];'."\n";
809 print 'colorset["defaultFill"] = "#F5F5F5";';
810 print 'series.forEach(function(item){'."\n";
811 print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
812 print 'colorset[nm] = paletteScale(cnt);';
813 print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
814 print '});'."\n";
815 print 'var bbl = new Datamap({
816 element: document.getElementById("chart4"),
817 projection: "mercator", // big world map
818 fills: colorset,
819 responsive: true,
820 geographyConfig: {
821 borderColor: "#DEDEDE",
822 highlightBorderWidth: 2,
823 highlightFillColor: function(geo) {
824 return geo["fillColor"] || "#F5F5F5";
826 highlightBorderColor: "#B7B7B7"
828 done: function(datamap) {
829 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
830 function redraw() {
831 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
835 bbl.bubbles(dataset,{
836 popupTemplate: function(geo, data) {
837 if (!data) { return ; }
838 return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
840 });";
841 print '</script>';
842 print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
843 if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
844 print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
847 </div>
848 </div>
849 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
850 <?php
852 if ($type == 'aircraft') {
854 <?php
855 if ($year == '' && $month == '') {
857 <div class="row column">
858 <div class="col-md-6">
859 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
860 <?php
861 $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
862 if (count($year_array) == 0) print _("No data available");
863 else {
864 print '<div id="chart8" class="chart" width="100%"></div><script>';
865 $year_data = '';
866 $year_cnt = '';
867 foreach($year_array as $year_item) {
868 $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
869 $year_cnt .= $year_item['date_count'].',';
871 $year_data = "['x',".substr($year_data, 0, -1)."]";
872 $year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
873 print 'c3.generate({
874 bindto: "#chart8",
875 data: { x: "x",
876 columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
877 axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Flights"}},legend: { show: false }});';
878 print '</script>';
881 <div class="more">
882 <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
883 </div>
884 </div>
885 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
886 <div class="col-md-6">
887 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
888 <?php
889 $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
890 if (count($month_array) == 0) print _("No data available");
891 else {
892 print '<div id="chart9" class="chart" width="100%"></div><script>';
893 $month_data = '';
894 $month_cnt = '';
895 foreach($month_array as $month_item) {
896 $month_data .= '"'.$month_item['date_name'].'",';
897 $month_cnt .= $month_item['date_count'].',';
899 $month_data = "['x',".substr($month_data, 0, -1)."]";
900 $month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
901 print 'c3.generate({
902 bindto: "#chart9",
903 data: { x: "x",
904 columns: ['.$month_data.','.$month_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
905 axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
906 print '</script>';
909 <div class="more">
910 <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
911 </div>
912 </div>
913 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
915 <div class="col-md-6">
916 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
917 <?php
918 $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
919 if (empty($date_array)) print _("No data available");
920 else {
921 print '<div id="chart5" class="chart" width="100%"></div><script>';
922 $date_data = '';
923 $date_cnt = '';
924 foreach($date_array as $date_item) {
925 $date_data .= '"'.$date_item['date_name'].'",';
926 $date_cnt .= $date_item['date_count'].',';
928 $date_data = "['x',".substr($date_data, 0, -1)."]";
929 $date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
930 print 'c3.generate({
931 bindto: "#chart5",
932 data: { x: "x",
933 columns: ['.$date_data.','.$date_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
934 axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
935 print '</script>';
938 <div class="more">
939 <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
940 </div>
941 </div>
942 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
943 <div class="col-md-6">
944 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
945 <?php
946 $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
947 if (empty($hour_array)) print _("No data available");
948 else {
949 print '<div id="chart6" class="chart" width="100%"></div><script>';
950 $hour_data = '';
951 $hour_cnt = '';
952 foreach($hour_array as $hour_item) {
953 $hour_data .= '"'.$hour_item['hour_name'].':00",';
954 $hour_cnt .= $hour_item['hour_count'].',';
956 $hour_data = "[".substr($hour_data, 0, -1)."]";
957 $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
958 print 'c3.generate({
959 bindto: "#chart6",
960 data: {
961 columns: ['.$hour_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
962 axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});';
963 print '</script>';
966 <div class="more">
967 <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
968 </div>
969 </div>
970 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
971 </div>
972 <?php
976 <?php
977 if ($type == 'marine') {
979 <?php
980 if ($year == '' && $month == '') {
982 <div class="row column">
983 <div class="col-md-6">
984 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
985 <?php
986 $year_array = $Stats->countAllMarineMonthsLastYear(true,$filter_name);
987 if (count($year_array) == 0) print _("No data available");
988 else {
989 print '<div id="chart8" class="chart" width="100%"></div><script>';
990 $year_data = '';
991 $year_cnt = '';
992 foreach($year_array as $year_item) {
993 $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
994 $year_cnt .= $year_item['date_count'].',';
996 $year_data = "['x',".substr($year_data, 0, -1)."]";
997 $year_cnt = "['vessels',".substr($year_cnt,0,-1)."]";
998 print 'c3.generate({
999 bindto: "#chart8",
1000 data: { x: "x",
1001 columns: ['.$year_data.','.$year_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
1002 axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
1003 print '</script>';
1006 <div class="more">
1007 <a href="<?php print $globalURL; ?>/marine/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1008 </div>
1009 </div>
1011 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1012 <div class="col-md-6">
1013 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1014 <?php
1015 $month_array = $Stats->countAllMarineDatesLastMonth($filter_name);
1016 if (count($month_array) == 0) print _("No data available");
1017 else {
1018 print '<div id="chart9" class="chart" width="100%"></div><script>';
1019 $month_data = '';
1020 $month_cnt = '';
1021 foreach($month_array as $month_item) {
1022 $month_data .= '"'.$month_item['date_name'].'",';
1023 $month_cnt .= $month_item['date_count'].',';
1025 $month_data = "['x',".substr($month_data, 0, -1)."]";
1026 $month_cnt = "['vessels',".substr($month_cnt,0,-1)."]";
1027 print 'c3.generate({
1028 bindto: "#chart9",
1029 data: { x: "x",
1030 columns: ['.$month_data.','.$month_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
1031 axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
1032 print '</script>';
1035 <div class="more">
1036 <a href="<?php print $globalURL; ?>/marine/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1037 </div>
1038 </div>
1039 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1041 <div class="col-md-6">
1042 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1043 <?php
1044 $date_array = $Stats->countAllMarineDatesLast7Days($filter_name);
1045 if (empty($date_array)) print _("No data available");
1046 else {
1047 print '<div id="chart5" class="chart" width="100%"></div><script>';
1048 $date_data = '';
1049 $date_cnt = '';
1050 foreach($date_array as $date_item) {
1051 $date_data .= '"'.$date_item['date_name'].'",';
1052 $date_cnt .= $date_item['date_count'].',';
1054 $date_data = "['x',".substr($date_data, 0, -1)."]";
1055 $date_cnt = "['vessels',".substr($date_cnt,0,-1)."]";
1056 print 'c3.generate({
1057 bindto: "#chart5",
1058 data: { x: "x",
1059 columns: ['.$date_data.','.$date_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
1060 axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
1061 print '</script>';
1064 <div class="more">
1065 <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1066 </div>
1067 </div>
1068 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1069 <div class="col-md-6">
1070 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1071 <?php
1072 $hour_array = $Stats->countAllMarineHours('hour',true,$filter_name);
1073 if (empty($hour_array)) print _("No data available");
1074 else {
1075 print '<div id="chart6" class="chart" width="100%"></div><script>';
1076 $hour_data = '';
1077 $hour_cnt = '';
1078 foreach($hour_array as $hour_item) {
1079 $hour_data .= '"'.$hour_item['hour_name'].':00",';
1080 $hour_cnt .= $hour_item['hour_count'].',';
1082 $hour_data = "[".substr($hour_data, 0, -1)."]";
1083 $hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]";
1084 print 'c3.generate({
1085 bindto: "#chart6",
1086 data: {
1087 columns: ['.$hour_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
1088 axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Vessels"}},legend: { show: false }});';
1089 print '</script>';
1092 <div class="more">
1093 <a href="<?php print $globalURL; ?>/marine/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1094 </div>
1095 </div>
1096 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1097 </div>
1098 <?php
1102 <?php
1103 if ($type == 'tracker') {
1105 <?php
1106 if ($year == '' && $month == '') {
1108 <div class="row column">
1109 <div class="col-md-6">
1110 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1111 <?php
1112 $year_array = $Stats->countAllTrackerMonthsLastYear(true);
1113 if (count($year_array) == 0) print _("No data available");
1114 else {
1115 print '<div id="chart8" class="chart" width="100%"></div><script>';
1116 $year_data = '';
1117 $year_cnt = '';
1118 foreach($year_array as $year_item) {
1119 $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1120 $year_cnt .= $year_item['date_count'].',';
1122 $year_data = "['x',".substr($year_data, 0, -1)."]";
1123 $year_cnt = "['trackers',".substr($year_cnt,0,-1)."]";
1124 print 'c3.generate({
1125 bindto: "#chart8",
1126 data: { x: "x",
1127 columns: ['.$year_data.','.$year_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1128 axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
1129 print '</script>';
1132 <div class="more">
1133 <a href="<?php print $globalURL; ?>/tracker/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1134 </div>
1135 </div>
1137 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1138 <div class="col-md-6">
1139 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1140 <?php
1141 $month_array = $Stats->countAllTrackerDatesLastMonth();
1142 if (count($month_array) == 0) print _("No data available");
1143 else {
1144 print '<div id="chart9" class="chart" width="100%"></div><script>';
1145 $month_data = '';
1146 $month_cnt = '';
1147 foreach($month_array as $month_item) {
1148 $month_data .= '"'.$month_item['date_name'].'",';
1149 $month_cnt .= $month_item['date_count'].',';
1151 $month_data = "['x',".substr($month_data, 0, -1)."]";
1152 $month_cnt = "['trackers',".substr($month_cnt,0,-1)."]";
1153 print 'c3.generate({
1154 bindto: "#chart9",
1155 data: { x: "x",
1156 columns: ['.$month_data.','.$month_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1157 axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
1158 print '</script>';
1161 <div class="more">
1162 <a href="<?php print $globalURL; ?>/tracker/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1163 </div>
1164 </div>
1165 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1167 <div class="col-md-6">
1168 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1169 <?php
1170 $date_array = $Stats->countAllTrackerDatesLast7Days();
1171 if (empty($date_array)) print _("No data available");
1172 else {
1173 print '<div id="chart5" class="chart" width="100%"></div><script>';
1174 $date_data = '';
1175 $date_cnt = '';
1176 foreach($date_array as $date_item) {
1177 $date_data .= '"'.$date_item['date_name'].'",';
1178 $date_cnt .= $date_item['date_count'].',';
1180 $date_data = "['x',".substr($date_data, 0, -1)."]";
1181 $date_cnt = "['trackers',".substr($date_cnt,0,-1)."]";
1182 print 'c3.generate({
1183 bindto: "#chart5",
1184 data: { x: "x",
1185 columns: ['.$date_data.','.$date_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1186 axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
1187 print '</script>';
1190 <div class="more">
1191 <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1192 </div>
1193 </div>
1194 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1195 <div class="col-md-6">
1196 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1197 <?php
1198 $hour_array = $Stats->countAllTrackerHours('hour',true);
1199 if (empty($hour_array)) print _("No data available");
1200 else {
1201 print '<div id="chart6" class="chart" width="100%"></div><script>';
1202 $hour_data = '';
1203 $hour_cnt = '';
1204 foreach($hour_array as $hour_item) {
1205 $hour_data .= '"'.$hour_item['hour_name'].':00",';
1206 $hour_cnt .= $hour_item['hour_count'].',';
1208 $hour_data = "[".substr($hour_data, 0, -1)."]";
1209 $hour_cnt = "['trackers',".substr($hour_cnt,0,-1)."]";
1210 print 'c3.generate({
1211 bindto: "#chart6",
1212 data: {
1213 columns: ['.$hour_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1214 axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Trackers"}},legend: { show: false }});';
1215 print '</script>';
1218 <div class="more">
1219 <a href="<?php print $globalURL; ?>/tracker/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1220 </div>
1221 </div>
1222 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1223 </div>
1224 <?php
1228 <?php
1229 if ($type == 'satellite') {
1231 <?php
1232 if ($year == '' && $month == '') {
1234 <div class="row column">
1235 <div class="col-md-6">
1236 <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1237 <?php
1238 $year_array = $Satellite->countAllMonthsLastYear();
1239 if (count($year_array) == 0) print _("No data available");
1240 else {
1241 print '<div id="chart21" class="chart" width="100%"></div><script>';
1242 $year_data = '';
1243 $year_cnt = '';
1244 foreach($year_array as $year_item) {
1245 $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1246 $year_cnt .= $year_item['date_count'].',';
1248 $year_data = "['x',".substr($year_data, 0, -1)."]";
1249 $year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1250 print 'c3.generate({
1251 bindto: "#chart21",
1252 data: { x: "x",
1253 columns: ['.$year_data.','.$year_cnt.'], types: { trackers: "area"}, colors: { satellite: "#1a3151"}},
1254 axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Satellite"}},legend: { show: false }});';
1255 print '</script>';
1258 <!--
1259 <div class="more">
1260 <a href="<?php print $globalURL; ?>/tracker/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1261 </div>
1263 </div>
1265 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1266 <div class="col-md-6">
1267 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1268 <?php
1269 $year_array = $Satellite->countAllYears();
1270 if (count($year_array) == 0) print _("No data available");
1271 else {
1272 print '<div id="chart22" class="chart" width="100%"></div><script>';
1273 $year_data = '';
1274 $year_cnt = '';
1275 foreach($year_array as $year_item) {
1276 $year_data .= '"'.$year_item['year_name'].'-01-01'.'",';
1277 $year_cnt .= $year_item['date_count'].',';
1279 $year_data = "['x',".substr($year_data, 0, -1)."]";
1280 $year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1281 print 'c3.generate({
1282 bindto: "#chart22",
1283 data: { x: "x",
1284 columns: ['.$year_data.','.$year_cnt.'], types: { trackers: "area"}, colors: { satellite: "#1a3151"}},
1285 axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y"}}, y: { label: "# of Satellite"}},legend: { show: false }});';
1286 print '</script>';
1289 <!--
1290 <div class="more">
1291 <a href="<?php print $globalURL; ?>/tracker/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1292 </div>
1294 </div>
1296 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1297 </div>
1298 <?php
1302 <?php
1303 if ($type == 'aircraft') {
1305 <?php
1306 if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
1308 <div class="row column">
1309 <div class="col-md-6">
1310 <h2><?php echo _("Fatalities by Years"); ?></h2>
1311 <?php
1312 $year_array = $Stats->countFatalitiesByYear();
1313 if (count($year_array) == 0) print _("No data available");
1314 else {
1315 print '<div id="chart32" class="chart" width="100%"></div><script>';
1316 $year_data = '';
1317 $year_cnt = '';
1318 foreach($year_array as $year_item) {
1319 $year_data .= '"'.$year_item['year'].'-01-01",';
1320 $year_cnt .= $year_item['count'].',';
1322 $year_data = "['x',".substr($year_data, 0, -1)."]";
1323 $year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1324 print 'c3.generate({
1325 bindto: "#chart32",
1326 data: { x: "x",
1327 columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1328 axis: { x: { type: "timeseries",tick: { format: "%Y"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
1329 print '</script>';
1332 <div class="more">
1333 <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1334 </div>
1335 </div>
1336 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1338 <div class="row column">
1339 <div class="col-md-6">
1340 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1341 <?php
1342 $year_array = $Stats->countFatalitiesLast12Months();
1343 if (count($year_array) == 0) print _("No data available");
1344 else {
1345 print '<div id="chart33" class="chart" width="100%"></div><script>';
1346 $year_data = '';
1347 $year_cnt = '';
1348 foreach($year_array as $year_item) {
1349 $year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
1350 $year_cnt .= $year_item['count'].',';
1352 $year_data = "['x',".substr($year_data, 0, -1)."]";
1353 $year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1354 print 'c3.generate({
1355 bindto: "#chart33",
1356 data: { x: "x",
1357 columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1358 axis: { x: { type: "timeseries",tick: { format: "%Y-%m"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
1359 print '</script>';
1362 <div class="more">
1363 <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1364 </div>
1365 </div>
1366 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1367 <br/>
1368 <?php
1372 <?php
1373 if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '' && (!isset($globalSatellite) || $globalSatellite === FALSE)) {
1375 <div class="row column">
1376 <?php
1377 //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
1378 if ($year == '' && $month == '') {
1379 if ($type == 'aircraft') {
1380 $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
1381 } elseif ($type == 'marine') {
1382 $polar = $Stats->getStatsSource('polar_marine',date('Y'),date('m'),date('d'));
1383 } elseif ($type == 'tracker') {
1384 $polar = $Stats->getStatsSource('polar_tracker',date('Y'),date('m'),date('d'));
1386 } else {
1387 if ($type == 'aircraft') {
1388 $polar = $Stats->getStatsSource('polar',$year,$month);
1389 } elseif ($type == 'marine') {
1390 $polar = $Stats->getStatsSource('polar_marine',$year,$month);
1391 } elseif ($type == 'tracker') {
1392 $polar = $Stats->getStatsSource('polar_tracker',$year,$month);
1395 if (!empty($polar)) {
1396 print '<h2>'._("Coverage pattern").'</h2>';
1397 foreach ($polar as $eachpolar) {
1398 unset($polar_data);
1399 $Spotter = new Spotter();
1400 $data = json_decode($eachpolar['source_data']);
1401 foreach($data as $value => $key) {
1402 $direction = $Spotter->parseDirection(($value*22.5));
1403 $distance = $key;
1404 $unit = 'km';
1405 if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1406 $distance = round($distance*0.539957);
1407 $unit = 'nm';
1408 } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1409 $distance = round($distance*0.621371);
1410 $unit = 'mi';
1411 } elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1412 $distance = $distance;
1413 $unit = 'km';
1415 if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1416 else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1419 <div class="col-md-6">
1420 <h4><?php print $eachpolar['source_name']; ?></h4>
1421 <div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1422 <script>
1423 (function() {
1424 var margin = {top: 100, right: 100, bottom: 100, left: 100},
1425 width = Math.min(700, window.innerWidth - 10) - margin.left - margin.right,
1426 height = Math.min(width, window.innerHeight - margin.top - margin.bottom - 20);
1427 var data = [
1429 <?php print $polar_data; ?>
1432 var color = d3.scale.ordinal().range(["#EDC951","#CC333F","#00A0B0"]);
1433 //var color = d3.scaleOrdinal().range(["#EDC951","#CC333F","#00A0B0"]);
1435 var radarChartOptions = {
1436 w: width,
1437 h: height,
1438 margin: margin,
1439 maxValue: 0.5,
1440 levels: 5,
1441 roundStrokes: true,
1442 color: color,
1443 unit: '<?php echo $unit; ?>'
1445 RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1446 })();
1447 </script>
1448 </div>
1449 <?php
1453 </div>
1454 <div class="row column">
1455 <div class="col-md-6">
1456 <?php
1457 //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
1458 if ($year == '' && $month == '') {
1459 if ($type == 'aircraft') {
1460 $msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
1461 } elseif ($type == 'marine') {
1462 $msg = $Stats->getStatsSource('msg_marine',date('Y'),date('m'),date('d'));
1463 } elseif ($type == 'tracker') {
1464 $msg = $Stats->getStatsSource('msg_tracker',date('Y'),date('m'),date('d'));
1466 } else {
1467 if ($type == 'aircraft') {
1468 $msg = $Stats->getStatsSource('msg',$year,$month);
1469 } elseif ($type == 'marine') {
1470 $msg = $Stats->getStatsSource('msg_marine',$year,$month);
1471 } elseif ($type == 'tracker') {
1472 $msg = $Stats->getStatsSource('msg_tracker',$year,$month);
1475 if (!empty($msg)) {
1476 print '<h2>'._("Messages received").'</h2>';
1477 foreach ($msg as $eachmsg) {
1478 //$eachmsg = $msg[0];
1479 $data = $eachmsg['source_data'];
1480 if ($data > 500) $max = (round(($data+100)/100))*100;
1481 else $max = 500;
1483 <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1484 <script>
1485 var g = new JustGage({
1486 id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
1487 value: <?php echo $data; ?>,
1488 min: 0,
1489 max: <?php print $max; ?>,
1490 valueMinFontSize: 10,
1491 height: 120,
1492 width: 220,
1493 symbol: ' msg/s',
1494 title: "<?php print $eachmsg['source_name']; ?>"
1496 </script>
1497 <?php
1501 </div>
1502 </div>
1503 <div class="row column">
1504 <?php
1505 //$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
1506 if ($year == '' && $month == '') {
1507 if ($type == 'aircraft') {
1508 $hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
1509 } elseif ($type == 'marine') {
1510 $hist = $Stats->getStatsSource('hist_marine',date('Y'),date('m'),date('d'));
1511 } elseif ($type == 'tracker') {
1512 $hist = $Stats->getStatsSource('hist_tracker',date('Y'),date('m'),date('d'));
1514 } else {
1515 if ($type == 'aircraft') {
1516 $hist = $Stats->getStatsSource('hist',$year,$month);
1517 } elseif ($type == 'marine') {
1518 $hist = $Stats->getStatsSource('hist_marine',$year,$month);
1519 } elseif ($type == 'tracker') {
1520 $hist = $Stats->getStatsSource('hist_tracker',$year,$month);
1523 foreach ($hist as $hists) {
1524 //$hist_data = '';
1525 $distance_data = '';
1526 $nb_data = '';
1527 $source = $hists['source_name'];
1528 $hist_array = json_decode($hists['source_data']);
1529 $unit = 'km';
1530 foreach($hist_array as $distance => $nb) {
1531 if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1532 $distance = round($distance*0.539957);
1533 $unit = 'nm';
1534 } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1535 $distance = round($distance*0.621371);
1536 $unit = 'mi';
1537 } elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1538 $distance = $distance;
1539 $unit = 'km';
1541 //$hist_data .= '[ "'.$distance.'",'.$nb.'],';
1542 $distance_data .= '"'.$distance.'",';
1543 $nb_data .= $nb.',';
1545 //$hist_data = substr($hist_data, 0, -1);
1546 $distance_data = "['x',".substr($distance_data, 0, -1)."]";
1547 $nb_data = "['flights',".substr($nb_data, 0, -1)."]";
1549 <div class="col-md-6">
1550 <h2><?php echo sprintf(_("Distance for %s"),$source); ?></h2>
1551 <?php
1552 print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
1553 print 'c3.generate({
1554 bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
1555 data: { x: "x",
1556 columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1557 axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
1558 print '</script>';
1560 </div>
1561 <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1562 <?php
1565 </div>
1566 <?php
1569 </div>
1570 </div>
1572 <?php
1573 require_once('footer.php');