Completed
Push — master ( 79cbb4...2c41c0 )
by Yannick
30:50
created

statistics.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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();
7
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');
23
}
24
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];
29
}
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;
37
	}
38
}
39
if ($type == 'aircraft' && isset($airline_name)) {
40
	$title = _("Statistics").' - '.$airline_name;
41
} else {
42
	$title = _("Statistics");
43
}
44
45
$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
46
$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
47
48
require_once('header.php');
49
50
?>
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');
72
}
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>';
78
}
79
80
?>
81
    </div>
82
<?php 
83
include('statistics-sub-menu.php'); 
84
?>
85
    <p class="global-stats">
86
<?php
87
if ($type == 'aircraft') {
88
?>
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))) {
95
?>
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
99
	}
100
	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
101
?>
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
105
	}
106
?>
107
        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
108
        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
109
<?php
110
	if ($airline_icao == '') {
111
?>
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
115
	}
116
?>
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') {
120
?>
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
124
		}
125
	}
126
	?>
127
<?php
128
} elseif ($type == 'marine') {
129
?>
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
	<span><span class="badge"><?php print number_format($Stats->countOverallMarineTypes($filter_name,$year,$month)); ?></span> <?php echo _("Types"); ?></span>
133
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
134
<?php
135
} elseif ($type == 'tracker') {
136
?>
137
	<span><span class="badge"><?php print number_format($Stats->countOverallTracker($filter_name,$year,$month)); ?></span> <?php echo _("Trackers"); ?></span>
138
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
139
	<span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes(array(),$year,$month)); ?></span> <?php echo _("Types"); ?></span>
140
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
141
<?php
142
}
143
?>
144
    </p>
145
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
146
    <div class="specific-stats">
147
<?php
148
if ($type == 'aircraft') {
149
?>
150
        <div class="row column">
151
            <div class="col-md-6">
152
                <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
153
<?php
154
	$aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
155
	if (count($aircraft_array) == 0) {
156
		print _("No data available");
157
	} else {
158
		print '<div id="chart1" class="chart" width="100%"></div><script>';
159
		$aircraft_data = '';
160
		foreach($aircraft_array as $aircraft_item) {
161
			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
162
			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
163
		}
164
		$aircraft_data = substr($aircraft_data, 0, -1);
165
		print 'var series = ['.$aircraft_data.'];';
166
		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);';
167
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
168
		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
169
		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":';
170
		print 'dataset';
171
		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}}});';
172
		print '</script>';
173
	}
174
?>
175
                <div class="more">
176
<?php
177
	if ($year != '' && $month != '') {
178
?>
179
            	    <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>
180
<?php
181
	} else {
182
?>
183
            	    <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>
184
<?php
185
	}
186
?>
187
                </div>
188
            </div>
189
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
190
<?php
191
	if ($airline_icao == '' || $airline_icao == 'all') {
192
		$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
193
		if (count($airline_array) > 0) {
194
			print '<div class="col-md-6">';
195
			print '<h2>'._("Top 10 Most Common Airline").'</h2>';
196
			print '<div id="chart2" class="chart" width="100%"></div><script>';
197
			$airline_data = '';
198
			foreach($airline_array as $airline_item) {
199
				$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
200
			}
201
			$airline_data = substr($airline_data, 0, -1);
202
			print 'var series = ['.$airline_data.'];';
203
			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);';
204
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
205
			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
206
			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":';
207
			print 'dataset';
208
			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}}});';
209
			print '</script>';
210
			if ($year != '' && $month != '') {
211
				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
213
				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214
			} else {
215
				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
216
				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
217
				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
218
			}
219
			print '</div>';
220
		}
221
?>
222
        </div>
223
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
224
<?php
225
	}
226
}
227
?>
228
<?php
229
if ($type == 'marine') {
230
?>
231
        <div class="row column">
232
            <div class="col-md-6">
233
                <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
234
<?php
235
	$marine_array = $Stats->countAllMarineTypes(true,0,'',$filter_name,$year,$month);
0 ignored issues
show
The call to Stats::countAllMarineTypes() has too many arguments starting with $year.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
236
	if (count($marine_array) == 0) print _("No data available");
237
	else {
238
		print '<div id="chart1" class="chart" width="100%"></div><script>';
239
		$marine_data = '';
240
		foreach($marine_array as $marine_item) {
241
			$marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],';
242
		}
243
		$marine_data = substr($marine_data, 0, -1);
244
		print 'var series = ['.$marine_data.'];';
245
		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);';
246
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
247
		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
248
		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":';
249
		print 'dataset';
250
		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}}});';
251
		print '</script>';
252
	}
253
?>
254
                <div class="more">
255
            	    <?php
256
            	    
257
            		if ($year != '' && $month != '') {
258
            	    ?>
259
            	    <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>
260
            	    <?php
261
            		} else {
262
            	    ?>
263
            	    <a href="<?php print $globalURL; ?>/marine/statistics/type" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
264
            	    <?php
265
            		}
266
            	    ?>
267
                </div>
268
            </div>
269
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
270
<!--	</div>-->
271
<?php
272
}
273
if ($type == 'tracker') {
274
?>
275
        <div class="row column">
276
            <div class="col-md-6">
277
                <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
278
<?php
279
	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
280
	if (count($tracker_array) == 0) print _("No data available");
281
	else {
282
		print '<div id="chart1" class="chart" width="100%"></div><script>';
283
		$tracker_data = '';
284
		foreach($tracker_array as $tracker_item) {
285
			$tracker_data .= '["'.$tracker_item['tracker_type'].'",'.$tracker_item['tracker_type_count'].'],';
286
		}
287
		$tracker_data = substr($tracker_data, 0, -1);
288
		print 'var series = ['.$tracker_data.'];';
289
		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);';
290
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
291
		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
292
		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":';
293
		print 'dataset';
294
		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}}});';
295
		print '</script>';
296
	}
297
?>
298
                <div class="more">
299
            	    <?php
300
            	    /*
301
            		if ($year != '' && $month != '') {
302
            	    ?>
303
            	    <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>
304
            	    <?php
305
            		} else {
306
            	    ?>
307
            	    <a href="<?php print $globalURL; ?>/marine/statistics/type" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
308
            	    <?php
309
            		}
310
            		*/
311
            	    ?>
312
                </div>
313
            </div>
314
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
315
<!--	</div>-->
316
<?php
317
}
318
if ($type == 'satellite') {
319
?>
320
        <div class="row column">
321
            <div class="col-md-6">
322
                <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
323
<?php
324
		$owner_array = $Satellite->countAllOwners(true);
325
		if (count($owner_array) == 0) print _("No data available");
326
		else {
327
			print '<div id="chart7" class="chart" width="100%"></div><script>';
328
			$owner_data = '';
329
			foreach($owner_array as $owner_item) {
330
				$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
331
			}
332
			$owner_data = substr($owner_data, 0, -1);
333
			print 'var series = ['.$owner_data.'];';
334
			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);';
335
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
336
			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
337
			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":';
338
			print 'dataset';
339
			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}}});';
340
			print '</script>';
341
		}
342
?>
343
               <!--
344
                <div class="more">
345
                    <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>
346
                </div>
347
                -->
348
            </div>
349
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
350
            <div class="col-md-6">
351
                <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
352
<?php
353
		$countries_array = $Satellite->countAllCountriesOwners(true);
354
		if (count($countries_array) == 0) print _("No data available");
355
		else {
356
			print '<div id="chart8" class="chart" width="100%"></div><script>';
357
			$owner_data = '';
358
			foreach($countries_array as $owner_item) {
359
				$owner_data .= '["'.$owner_item['country_name'].'",'.$owner_item['country_count'].'],';
360
			}
361
			$owner_data = substr($owner_data, 0, -1);
362
			print 'var series = ['.$owner_data.'];';
363
			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);';
364
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
365
			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
366
			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":';
367
			print 'dataset';
368
			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}}});';
369
			print '</script>';
370
		}
371
?>
372
	    <!--
373
                <div class="more">
374
                    <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>
375
                </div>
376
                -->
377
            </div>
378
            
379
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
380
²	</div>
381
        <div class="row column">
382
            <div class="col-md-6">
383
                <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
384
<?php
385
		$launch_site_array = $Satellite->countAllLaunchSite(true);
386
		if (count($launch_site_array) == 0) print _("No data available");
387
		else {
388
			print '<div id="chart9" class="chart" width="100%"></div><script>';
389
			$launch_site_data = '';
390
			foreach($launch_site_array as $launch_site_item) {
391
				$launch_site_data .= '["'.$launch_site_item['launch_site'].'",'.$launch_site_item['launch_site_count'].'],';
392
			}
393
			$launch_site_data = substr($launch_site_data, 0, -1);
394
			print 'var series = ['.$launch_site_data.'];';
395
			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);';
396
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
397
			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
398
			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":';
399
			print 'dataset';
400
			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}}});';
401
			print '</script>';
402
		}
403
?>
404
               <!--
405
                <div class="more">
406
                    <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>
407
                </div>
408
                -->
409
            </div>
410
        </div>
411
<?php
412
}
413
if ($type == 'aircraft') {
414
?>
415
        <div class="row column">
416
<?php
417
	$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
418
	//if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
419
	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
420
		if (empty($flightover_array)) {
421
			print '<div class="col-md-12">';
422
		} else {
423
			print '<div class="col-md-6">';
424
		}
425
?>
426
                <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
427
<?php
428
		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
429
		if (count($pilot_array) == 0) print _("No data available");
430
		else {
431
			print '<div id="chart7" class="chart" width="100%"></div><script>';
432
			$pilot_data = '';
433
			foreach($pilot_array as $pilot_item) {
434
				$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
435
			}
436
			$pilot_data = substr($pilot_data, 0, -1);
437
			print 'var series = ['.$pilot_data.'];';
438
			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);';
439
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
440
			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
441
			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":';
442
			print 'dataset';
443
			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}}});';
444
			print '</script>';
445
		}
446
		print '<div class="more">';
447
		print '<a href="'.$globalURL.'/statistics/pilot'; 
448
		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
449
		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
450
		print '</div>';
451
?>
452
            </div>
453
454
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
455
<?php
456
	}
457
	// else {
458
	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
459
?>
460
            <div class="col-md-6">
461
                <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
462
<?php
463
		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
464
		if (count($owner_array) == 0) print _("No data available");
465
		else {
466
			print '<div id="chart7" class="chart" width="100%"></div><script>';
467
			$owner_data = '';
468
			foreach($owner_array as $owner_item) {
469
				$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
470
			}
471
			$owner_data = substr($owner_data, 0, -1);
472
			print 'var series = ['.$owner_data.'];';
473
			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);';
474
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
475
			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
476
			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":';
477
			print 'dataset';
478
			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}}});';
479
			print '</script>';
480
		}
481
?>
482
                <div class="more">
483
                    <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>
484
                </div>
485
            </div>
486
        
487
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
488
<?php
489
	}
490
	if (!empty($flightover_array)) {
491
?>
492
            <div class="col-md-6">
493
                <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
494
<?php
495
	 //$flightover_array = $Stats->countAllFlightOverCountries();
496
		if (count($flightover_array) == 0) print _("No data available");
497
		else {
498
			print '<div id="chart10" class="chart" width="100%"></div><script>';
499
			print 'var series = [';
500
			$flightover_data = '';
501
			foreach($flightover_array as $flightover_item) {
502
				$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
503
			}
504
			$flightover_data = substr($flightover_data, 0, -1);
505
			print $flightover_data;
506
			print '];';
507
			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);';
508
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
509
			print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
510
			print 'new Datamap({
511
			    element: document.getElementById("chart10"),
512
			    projection: "mercator", // big world map
513
			    fills: { defaultFill: "#F5F5F5" },
514
			    data: dataset,
515
			    responsive: true,
516
			    geographyConfig: {
517
				borderColor: "#DEDEDE",
518
				highlightBorderWidth: 2,
519
				highlightFillColor: function(geo) {
520
				    return geo["fillColor"] || "#F5F5F5";
521
				},
522
				highlightBorderColor: "#B7B7B7",
523
				done: function(datamap) {
524
				    datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
525
				    function redraw() {
526
					datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
527
				    }
528
				},
529
				popupTemplate: function(geo, data) {
530
				    if (!data) { return ; }
531
				    return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
532
				}
533
			    }
534
			});";
535
			print '</script>';
536
		}
537
?>
538
                <div class="more">
539
                    <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>
540
                </div>
541
            </div>
542
<?php
543
	}
544
?>
545
        </div>
546
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
547
        </div>
548
<?php
549
}
550
if ($type == 'marine') {
551
	$flightover_array = $Stats->countAllMarineOverCountries(true);
552
?>
553
<!--    <div class="row column">-->
554
	<div class="col-md-6">
555
            <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
556
<?php
557
	if (count($flightover_array) == 0) print _("No data available");
558
	else {
559
		print '<div id="chart10" class="chart" width="100%"></div><script>';
560
		print 'var series = [';
561
		$flightover_data = '';
562
		foreach($flightover_array as $flightover_item) {
563
			$flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
564
		}
565
		$flightover_data = substr($flightover_data, 0, -1);
566
		print $flightover_data;
567
		print '];';
568
		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);';
569
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
570
		print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
571
		print 'new Datamap({
572
		    element: document.getElementById("chart10"),
573
		    projection: "mercator", // big world map
574
		    fills: { defaultFill: "#F5F5F5" },
575
		    data: dataset,
576
		    responsive: true,
577
		    geographyConfig: {
578
			borderColor: "#DEDEDE",
579
			highlightBorderWidth: 2,
580
			highlightFillColor: function(geo) {
581
			    return geo["fillColor"] || "#F5F5F5";
582
			},
583
			highlightBorderColor: "#B7B7B7",
584
			done: function(datamap) {
585
			    datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
586
			    function redraw() {
587
				datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
588
			    }
589
			},
590
			popupTemplate: function(geo, data) {
591
			    if (!data) { return ; }
592
			    return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
593
			}
594
		    }
595
		});";
596
		print '</script>';
597
	}
598
?>
599
                <div class="more">
600
                    <a href="<?php print $globalURL; ?>/marine/statistics/country" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
601
                </div>
602
            </div>
603
        </div>
604
605
<?php
606
}
607
if ($type == 'tracker') {
608
	$flightover_array = $Stats->countAllTrackerOverCountries(true);
609
?>
610
<!--    <div class="row column">-->
611
	<div class="col-md-6">
612
            <h2><?php echo _("Top 20 Most Common Country a Tracker 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['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],';
621
		}
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";
639
			},
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 + ")");
645
			    }
646
			},
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('');
650
			}
651
		    }
652
		});";
653
		print '</script>';
654
	}
655
?>
656
                <div class="more">
657
                    <a href="<?php print $globalURL; ?>/tracker/statistics/country" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
658
                </div>
659
            </div>
660
        </div>
661
662
<?php
663
}
664
if ($type == 'aircraft') {
665
?>
666
        <div class="row column">
667
            <div class="col-md-6">
668
<?php
669
	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
670
	if (count($airport_airport_array) > 0) {
671
		print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
672
		print '<div id="chart3" class="chart" width="100%"></div><script>';
673
		print "\n";
674
		print 'var series = [';
675
		$airport_data = '';
676
		foreach($airport_airport_array as $airport_item) {
677
			$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
678
		}
679
		$airport_data = substr($airport_data, 0, -1);
680
		print $airport_data;
681
		print '];'."\n";
682
		print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
683
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
684
		print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
685
		print 'var dataset = [];'."\n";
686
		print 'var colorset = [];'."\n";
687
		print 'colorset["defaultFill"] = "#F5F5F5";';
688
		print 'series.forEach(function(item){'."\n";
689
		print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
690
		print 'colorset[nm] = paletteScale(cnt);';
691
		print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
692
		print '});'."\n";
693
		print 'var bbl = new Datamap({
694
		    element: document.getElementById("chart3"),
695
		    projection: "mercator", // big world map
696
		    fills: colorset,
697
		    responsive: true,
698
		    geographyConfig: {
699
			borderColor: "#DEDEDE",
700
			highlightBorderWidth: 2,
701
			highlightFillColor: function(geo) {
702
			    return geo["fillColor"] || "#F5F5F5";
703
			},
704
			highlightBorderColor: "#B7B7B7"
705
		    },
706
		    done: function(datamap) {
707
			datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
708
			function redraw() {
709
			    datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
710
			}
711
		    }
712
		});
713
		bbl.bubbles(dataset,{
714
		    popupTemplate: function(geo, data) {
715
			if (!data) { return ; }
716
			return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
717
		    }
718
		});";
719
		print '</script>';
720
		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
721
		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
722
		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
723
	}
724
?>
725
            </div>
726
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
727
728
            <div class="col-md-6">
729
<?php
730
	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
731
	if (count($airport_airport_array2) > 0) {
732
		print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
733
		print '<div id="chart4" class="chart" width="100%"></div><script>';
734
		print "\n";
735
		print 'var series = [';
736
		$airport_data = '';
737
		foreach($airport_airport_array2 as $airport_item)
738
		{
739
			if (isset($airport_item['airport_arrival_longitude']) && isset($airport_item['airport_arrival_latitude'])) {
740
				$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
741
			}
742
		}
743
		$airport_data = substr($airport_data, 0, -1);
744
		print $airport_data;
745
		print '];'."\n";
746
		print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
747
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
748
		print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
749
		print 'var dataset = [];'."\n";
750
		print 'var colorset = [];'."\n";
751
		print 'colorset["defaultFill"] = "#F5F5F5";';
752
		print 'series.forEach(function(item){'."\n";
753
		print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
754
		print 'colorset[nm] = paletteScale(cnt);';
755
		print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
756
		print '});'."\n";
757
		print 'var bbl = new Datamap({
758
		    element: document.getElementById("chart4"),
759
		    projection: "mercator", // big world map
760
		    fills: colorset,
761
		    responsive: true,
762
		    geographyConfig: {
763
			borderColor: "#DEDEDE",
764
			highlightBorderWidth: 2,
765
			highlightFillColor: function(geo) {
766
			    return geo["fillColor"] || "#F5F5F5";
767
			},
768
			highlightBorderColor: "#B7B7B7"
769
		    },
770
		    done: function(datamap) {
771
			datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
772
			function redraw() {
773
			    datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
774
			}
775
		    }
776
		});
777
		bbl.bubbles(dataset,{
778
		    popupTemplate: function(geo, data) {
779
			if (!data) { return ; }
780
			return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
781
		    }
782
		});";
783
		print '</script>';
784
		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
785
		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
786
		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
787
	}
788
?>
789
            </div>
790
        </div>
791
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
792
<?php 
793
}
794
if ($type == 'aircraft') {
795
?>
796
<?php
797
	if ($year == '' && $month == '') {
798
?>
799
        <div class="row column">
800
            <div class="col-md-6">
801
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
802
<?php
803
		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
804
		if (count($year_array) == 0) print _("No data available");
805
		else {
806
			print '<div id="chart8" class="chart" width="100%"></div><script>';
807
			$year_data = '';
808
			$year_cnt = '';
809
			foreach($year_array as $year_item) {
810
				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
811
				$year_cnt .= $year_item['date_count'].',';
812
			}
813
			$year_data = "['x',".substr($year_data, 0, -1)."]";
814
			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
815
			print 'c3.generate({
816
			    bindto: "#chart8",
817
			    data: { x: "x",
818
			     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
819
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Flights"}},legend: { show: false }});';
820
			print '</script>';
821
		}
822
?>
823
                <div class="more">
824
                    <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>
825
                </div>
826
            </div>
827
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
828
            <div class="col-md-6">
829
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
830
<?php
831
		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
832
		if (count($month_array) == 0) print _("No data available");
833
		else {
834
			print '<div id="chart9" class="chart" width="100%"></div><script>';
835
			$month_data = '';
836
			$month_cnt = '';
837
			foreach($month_array as $month_item) {
838
				$month_data .= '"'.$month_item['date_name'].'",';
839
				$month_cnt .= $month_item['date_count'].',';
840
			}
841
			$month_data = "['x',".substr($month_data, 0, -1)."]";
842
			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
843
			print 'c3.generate({
844
			    bindto: "#chart9",
845
			    data: { x: "x",
846
			     columns: ['.$month_data.','.$month_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
847
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
848
			print '</script>';
849
		}
850
?>
851
                <div class="more">
852
                    <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>
853
                </div>
854
            </div>
855
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
856
857
            <div class="col-md-6">
858
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
859
<?php
860
		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
861
		if (empty($date_array)) print _("No data available");
862
		else {
863
			print '<div id="chart5" class="chart" width="100%"></div><script>';
864
			$date_data = '';
865
			$date_cnt = '';
866
			foreach($date_array as $date_item) {
867
				$date_data .= '"'.$date_item['date_name'].'",';
868
				$date_cnt .= $date_item['date_count'].',';
869
			}
870
			$date_data = "['x',".substr($date_data, 0, -1)."]";
871
			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
872
			print 'c3.generate({
873
			    bindto: "#chart5",
874
			    data: { x: "x",
875
			     columns: ['.$date_data.','.$date_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
876
			     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
877
			print '</script>';
878
		}
879
?>
880
                <div class="more">
881
                    <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>
882
                </div>
883
            </div>
884
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
885
            <div class="col-md-6">
886
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
887
<?php
888
		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
889
		if (empty($hour_array)) print _("No data available");
890
		else {
891
			print '<div id="chart6" class="chart" width="100%"></div><script>';
892
			$hour_data = '';
893
			$hour_cnt = '';
894
			foreach($hour_array as $hour_item) {
895
				$hour_data .= '"'.$hour_item['hour_name'].':00",';
896
				$hour_cnt .= $hour_item['hour_count'].',';
897
			}
898
			$hour_data = "[".substr($hour_data, 0, -1)."]";
899
			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
900
			print 'c3.generate({
901
			    bindto: "#chart6",
902
			    data: {
903
			     columns: ['.$hour_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
904
			     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});';
905
			print '</script>';
906
		}
907
?>
908
                <div class="more">
909
                    <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>
910
                </div>
911
            </div>
912
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
913
        </div>
914
<?php
915
	}
916
}
917
?>
918
<?php
919
if ($type == 'marine') {
920
?>
921
<?php
922
	if ($year == '' && $month == '') {
923
?>
924
        <div class="row column">
925
            <div class="col-md-6">
926
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
927
<?php
928
		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
929
		if (count($year_array) == 0) print _("No data available");
930
		else {
931
			print '<div id="chart8" class="chart" width="100%"></div><script>';
932
			$year_data = '';
933
			$year_cnt = '';
934
			foreach($year_array as $year_item) {
935
				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
936
				$year_cnt .= $year_item['date_count'].',';
937
			}
938
			$year_data = "['x',".substr($year_data, 0, -1)."]";
939
			$year_cnt = "['vessels',".substr($year_cnt,0,-1)."]";
940
			print 'c3.generate({
941
			    bindto: "#chart8",
942
			    data: { x: "x",
943
			     columns: ['.$year_data.','.$year_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
944
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
945
			print '</script>';
946
		}
947
?>
948
                <div class="more">
949
                    <a href="<?php print $globalURL; ?>/marine/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
950
                </div>
951
            </div>
952
            
953
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
954
            <div class="col-md-6">
955
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
956
<?php
957
		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
958
		if (count($month_array) == 0) print _("No data available");
959
		else {
960
			print '<div id="chart9" class="chart" width="100%"></div><script>';
961
			$month_data = '';
962
			$month_cnt = '';
963
			foreach($month_array as $month_item) {
964
				$month_data .= '"'.$month_item['date_name'].'",';
965
				$month_cnt .= $month_item['date_count'].',';
966
			}
967
			$month_data = "['x',".substr($month_data, 0, -1)."]";
968
			$month_cnt = "['vessels',".substr($month_cnt,0,-1)."]";
969
			print 'c3.generate({
970
			    bindto: "#chart9",
971
			    data: { x: "x",
972
			     columns: ['.$month_data.','.$month_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
973
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
974
			print '</script>';
975
		}
976
?>
977
                <div class="more">
978
                    <a href="<?php print $globalURL; ?>/marine/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
979
                </div>
980
            </div>
981
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
982
983
            <div class="col-md-6">
984
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
985
<?php
986
		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
987
		if (empty($date_array)) print _("No data available");
988
		else {
989
			print '<div id="chart5" class="chart" width="100%"></div><script>';
990
			$date_data = '';
991
			$date_cnt = '';
992
			foreach($date_array as $date_item) {
993
				$date_data .= '"'.$date_item['date_name'].'",';
994
				$date_cnt .= $date_item['date_count'].',';
995
			}
996
			$date_data = "['x',".substr($date_data, 0, -1)."]";
997
			$date_cnt = "['vessels',".substr($date_cnt,0,-1)."]";
998
			print 'c3.generate({
999
			    bindto: "#chart5",
1000
			    data: { x: "x",
1001
			     columns: ['.$date_data.','.$date_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
1002
			     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
1003
			print '</script>';
1004
		}
1005
?>
1006
                <div class="more">
1007
                    <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1008
                </div>
1009
            </div>
1010
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1011
            <div class="col-md-6">
1012
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1013
<?php
1014
		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1015
		if (empty($hour_array)) print _("No data available");
1016
		else {
1017
			print '<div id="chart6" class="chart" width="100%"></div><script>';
1018
			$hour_data = '';
1019
			$hour_cnt = '';
1020
			foreach($hour_array as $hour_item) {
1021
				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1022
				$hour_cnt .= $hour_item['hour_count'].',';
1023
			}
1024
			$hour_data = "[".substr($hour_data, 0, -1)."]";
1025
			$hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]";
1026
			print 'c3.generate({
1027
			    bindto: "#chart6",
1028
			    data: {
1029
			     columns: ['.$hour_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
1030
			     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Vessels"}},legend: { show: false }});';
1031
			print '</script>';
1032
		}
1033
?>
1034
                <div class="more">
1035
                    <a href="<?php print $globalURL; ?>/marine/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1036
                </div>
1037
            </div>
1038
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1039
        </div>
1040
<?php
1041
	}
1042
}
1043
?>
1044
<?php
1045
if ($type == 'tracker') {
1046
?>
1047
<?php
1048
	if ($year == '' && $month == '') {
1049
?>
1050
        <div class="row column">
1051
            <div class="col-md-6">
1052
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1053
<?php
1054
		$year_array = $Tracker->countAllMonthsLastYear(true);
1055
		if (count($year_array) == 0) print _("No data available");
1056
		else {
1057
			print '<div id="chart8" class="chart" width="100%"></div><script>';
1058
			$year_data = '';
1059
			$year_cnt = '';
1060
			foreach($year_array as $year_item) {
1061
				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1062
				$year_cnt .= $year_item['date_count'].',';
1063
			}
1064
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1065
			$year_cnt = "['trackers',".substr($year_cnt,0,-1)."]";
1066
			print 'c3.generate({
1067
			    bindto: "#chart8",
1068
			    data: { x: "x",
1069
			     columns: ['.$year_data.','.$year_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1070
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
1071
			print '</script>';
1072
		}
1073
?>
1074
                <div class="more">
1075
                    <a href="<?php print $globalURL; ?>/tracker/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1076
                </div>
1077
            </div>
1078
            
1079
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1080
            <div class="col-md-6">
1081
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1082
<?php
1083
		$month_array = $Tracker->countAllDatesLastMonth();
1084
		if (count($month_array) == 0) print _("No data available");
1085
		else {
1086
			print '<div id="chart9" class="chart" width="100%"></div><script>';
1087
			$month_data = '';
1088
			$month_cnt = '';
1089
			foreach($month_array as $month_item) {
1090
				$month_data .= '"'.$month_item['date_name'].'",';
1091
				$month_cnt .= $month_item['date_count'].',';
1092
			}
1093
			$month_data = "['x',".substr($month_data, 0, -1)."]";
1094
			$month_cnt = "['trackers',".substr($month_cnt,0,-1)."]";
1095
			print 'c3.generate({
1096
			    bindto: "#chart9",
1097
			    data: { x: "x",
1098
			     columns: ['.$month_data.','.$month_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1099
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
1100
			print '</script>';
1101
		}
1102
?>
1103
                <div class="more">
1104
                    <a href="<?php print $globalURL; ?>/tracker/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1105
                </div>
1106
            </div>
1107
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1108
1109
            <div class="col-md-6">
1110
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1111
<?php
1112
		$date_array = $Tracker->countAllDatesLast7Days();
1113
		if (empty($date_array)) print _("No data available");
1114
		else {
1115
			print '<div id="chart5" class="chart" width="100%"></div><script>';
1116
			$date_data = '';
1117
			$date_cnt = '';
1118
			foreach($date_array as $date_item) {
1119
				$date_data .= '"'.$date_item['date_name'].'",';
1120
				$date_cnt .= $date_item['date_count'].',';
1121
			}
1122
			$date_data = "['x',".substr($date_data, 0, -1)."]";
1123
			$date_cnt = "['trackers',".substr($date_cnt,0,-1)."]";
1124
			print 'c3.generate({
1125
			    bindto: "#chart5",
1126
			    data: { x: "x",
1127
			     columns: ['.$date_data.','.$date_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1128
			     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
1129
			print '</script>';
1130
		}
1131
?>
1132
                <div class="more">
1133
                    <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1134
                </div>
1135
            </div>
1136
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1137
            <div class="col-md-6">
1138
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1139
<?php
1140
		$hour_array = $Tracker->countAllHours('hour',true);
1141
		if (empty($hour_array)) print _("No data available");
1142
		else {
1143
			print '<div id="chart6" class="chart" width="100%"></div><script>';
1144
			$hour_data = '';
1145
			$hour_cnt = '';
1146
			foreach($hour_array as $hour_item) {
1147
				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1148
				$hour_cnt .= $hour_item['hour_count'].',';
1149
			}
1150
			$hour_data = "[".substr($hour_data, 0, -1)."]";
1151
			$hour_cnt = "['trackers',".substr($hour_cnt,0,-1)."]";
1152
			print 'c3.generate({
1153
			    bindto: "#chart6",
1154
			    data: {
1155
			     columns: ['.$hour_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1156
			     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Trackers"}},legend: { show: false }});';
1157
			print '</script>';
1158
		}
1159
?>
1160
                <div class="more">
1161
                    <a href="<?php print $globalURL; ?>/tracker/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1162
                </div>
1163
            </div>
1164
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1165
        </div>
1166
<?php
1167
	}
1168
}
1169
?>
1170
<?php
1171
if ($type == 'satellite') {
1172
?>
1173
<?php
1174
	if ($year == '' && $month == '') {
1175
?>
1176
        <div class="row column">
1177
            <div class="col-md-6">
1178
                <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1179
<?php
1180
		$year_array = $Satellite->countAllMonthsLastYear();
1181
		if (count($year_array) == 0) print _("No data available");
1182
		else {
1183
			print '<div id="chart21" class="chart" width="100%"></div><script>';
1184
			$year_data = '';
1185
			$year_cnt = '';
1186
			foreach($year_array as $year_item) {
1187
				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1188
				$year_cnt .= $year_item['date_count'].',';
1189
			}
1190
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1191
			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1192
			print 'c3.generate({
1193
			    bindto: "#chart21",
1194
			    data: { x: "x",
1195
			     columns: ['.$year_data.','.$year_cnt.'], types: { trackers: "area"}, colors: { satellite: "#1a3151"}},
1196
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Satellite"}},legend: { show: false }});';
1197
			print '</script>';
1198
		}
1199
?>
1200
	    <!--
1201
                <div class="more">
1202
                    <a href="<?php print $globalURL; ?>/tracker/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1203
                </div>
1204
            -->
1205
            </div>
1206
            
1207
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1208
            <div class="col-md-6">
1209
                <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1210
<?php
1211
		$year_array = $Satellite->countAllYears();
1212
		if (count($year_array) == 0) print _("No data available");
1213
		else {
1214
			print '<div id="chart22" class="chart" width="100%"></div><script>';
1215
			$year_data = '';
1216
			$year_cnt = '';
1217
			foreach($year_array as $year_item) {
1218
				$year_data .= '"'.$year_item['year_name'].'-01-01'.'",';
1219
				$year_cnt .= $year_item['date_count'].',';
1220
			}
1221
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1222
			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1223
			print 'c3.generate({
1224
			    bindto: "#chart22",
1225
			    data: { x: "x",
1226
			     columns: ['.$year_data.','.$year_cnt.'], types: { trackers: "area"}, colors: { satellite: "#1a3151"}},
1227
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y"}}, y: { label: "# of Satellite"}},legend: { show: false }});';
1228
			print '</script>';
1229
		}
1230
?>
1231
	    <!--
1232
                <div class="more">
1233
                    <a href="<?php print $globalURL; ?>/tracker/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1234
                </div>
1235
            -->
1236
            </div>
1237
            
1238
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1239
        </div>
1240
<?php
1241
	}
1242
}
1243
?>
1244
<?php
1245
if ($type == 'aircraft') {
1246
?>
1247
<?php
1248
	if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
1249
?>
1250
        <div class="row column">
1251
            <div class="col-md-6">
1252
                <h2><?php echo _("Fatalities by Years"); ?></h2>
1253
<?php
1254
		$year_array = $Stats->countFatalitiesByYear();
1255
		if (count($year_array) == 0) print _("No data available");
1256
		else {
1257
			print '<div id="chart32" class="chart" width="100%"></div><script>';
1258
			$year_data = '';
1259
			$year_cnt = '';
1260
			foreach($year_array as $year_item) {
1261
				$year_data .= '"'.$year_item['year'].'-01-01",';
1262
				$year_cnt .= $year_item['count'].',';
1263
			}
1264
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1265
			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1266
			print 'c3.generate({
1267
			    bindto: "#chart32",
1268
			    data: { x: "x",
1269
			     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1270
			     axis: { x: { type: "timeseries",tick: { format: "%Y"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
1271
			print '</script>';
1272
		}
1273
?>
1274
                <div class="more">
1275
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1276
                </div>
1277
            </div>
1278
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1279
1280
        <div class="row column">
1281
            <div class="col-md-6">
1282
                <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1283
<?php
1284
		$year_array = $Stats->countFatalitiesLast12Months();
1285
		if (count($year_array) == 0) print _("No data available");
1286
		else {
1287
			print '<div id="chart33" class="chart" width="100%"></div><script>';
1288
			$year_data = '';
1289
			$year_cnt = '';
1290
			foreach($year_array as $year_item) {
1291
				$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
1292
				$year_cnt .= $year_item['count'].',';
1293
			}
1294
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1295
			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1296
			print 'c3.generate({
1297
			    bindto: "#chart33",
1298
			    data: { x: "x",
1299
			     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1300
			     axis: { x: { type: "timeseries",tick: { format: "%Y-%m"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
1301
			print '</script>';
1302
		}
1303
?>
1304
                <div class="more">
1305
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1306
                </div>
1307
            </div>
1308
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1309
<br/>
1310
<?php
1311
	}
1312
}
1313
?>
1314
<?php
1315
if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '' && (!isset($globalSatellite) || $globalSatellite === FALSE)) {
1316
?>
1317
        <div class="row column">
1318
<?php
1319
	//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
1320
	if ($year == '' && $month == '') {
1321
		if ($type == 'aircraft') {
1322
			$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
1323
		} elseif ($type == 'marine') {
1324
			$polar = $Stats->getStatsSource('polar_marine',date('Y'),date('m'),date('d'));
1325
		} elseif ($type == 'tracker') {
1326
			$polar = $Stats->getStatsSource('polar_tracker',date('Y'),date('m'),date('d'));
1327
		}
1328
	} else {
1329
		if ($type == 'aircraft') {
1330
			$polar = $Stats->getStatsSource('polar',$year,$month);
1331
		} elseif ($type == 'marine') {
1332
			$polar = $Stats->getStatsSource('polar_marine',$year,$month);
1333
		} elseif ($type == 'tracker') {
1334
			$polar = $Stats->getStatsSource('polar_tracker',$year,$month);
1335
		}
1336
	}
1337
	if (!empty($polar)) {
1338
		print '<h2>'._("Coverage pattern").'</h2>';
1339
		foreach ($polar as $eachpolar) {
1340
			unset($polar_data);
1341
			$Spotter = new Spotter();
1342
			$data = json_decode($eachpolar['source_data']);
1343
			foreach($data as $value => $key) {
1344
				$direction = $Spotter->parseDirection(($value*22.5));
1345
				$distance = $key;
1346
				$unit = 'km';
1347
				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1348
					$distance = round($distance*0.539957);
1349
					$unit = 'nm';
1350
				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1351
					$distance = round($distance*0.621371);
1352
					$unit = 'mi';
1353
				} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1354
					$distance = $distance;
1355
					$unit = 'km';
1356
				}
1357
				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1358
				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1359
			}
1360
?>
1361
            <div class="col-md-6">
1362
                <h4><?php print $eachpolar['source_name']; ?></h4>
1363
        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1364
        	<script>
1365
        	    (function() {
1366
        	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
1367
			width = Math.min(700, window.innerWidth - 10) - margin.left - margin.right,
1368
			height = Math.min(width, window.innerHeight - margin.top - margin.bottom - 20);
1369
		    var data = [
1370
				    [
1371
				    <?php print $polar_data; ?>
1372
				    ]
1373
				];
1374
		    var color = d3.scale.ordinal().range(["#EDC951","#CC333F","#00A0B0"]);
1375
		    //var color = d3.scaleOrdinal().range(["#EDC951","#CC333F","#00A0B0"]);
1376
		
1377
		    var radarChartOptions = {
1378
		      w: width,
1379
		      h: height,
1380
		      margin: margin,
1381
		      maxValue: 0.5,
1382
		      levels: 5,
1383
		      roundStrokes: true,
1384
		      color: color,
1385
		      unit: '<?php echo $unit; ?>'
1386
		    };
1387
		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1388
		    })();
1389
		</script>
1390
            </div>
1391
            <?php
1392
		}
1393
	}
1394
?>
1395
        </div>
1396
        <div class="row column">
1397
            <div class="col-md-6">
1398
<?php
1399
	//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
1400
	if ($year == '' && $month == '') {
1401
		if ($type == 'aircraft') {
1402
			$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
1403
		} elseif ($type == 'marine') {
1404
			$msg = $Stats->getStatsSource('msg_marine',date('Y'),date('m'),date('d'));
1405
		} elseif ($type == 'tracker') {
1406
			$msg = $Stats->getStatsSource('msg_tracker',date('Y'),date('m'),date('d'));
1407
		}
1408
	} else {
1409
		if ($type == 'aircraft') {
1410
			$msg = $Stats->getStatsSource('msg',$year,$month);
1411
		} elseif ($type == 'marine') {
1412
			$msg = $Stats->getStatsSource('msg_marine',$year,$month);
1413
		} elseif ($type == 'tracker') {
1414
			$msg = $Stats->getStatsSource('msg_tracker',$year,$month);
1415
		}
1416
	}
1417
	if (!empty($msg)) {
1418
		print '<h2>'._("Messages received").'</h2>';
1419
		foreach ($msg as $eachmsg) {
1420
			//$eachmsg = $msg[0];
1421
			$data = $eachmsg['source_data'];
1422
			if ($data > 500) $max = (round(($data+100)/100))*100;
1423
			else $max = 500;
1424
?>
1425
        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1426
        	<script>
1427
		      var g = new JustGage({
1428
			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
1429
			    value: <?php echo $data; ?>,
1430
			    min: 0,
1431
			    max: <?php print $max; ?>,
1432
			    valueMinFontSize: 10,
1433
			    height: 120,
1434
			    width: 220,
1435
			    symbol: ' msg/s',
1436
			    title: "<?php print $eachmsg['source_name']; ?>"
1437
			  });
1438
		</script>
1439
<?php
1440
		}
1441
	}
1442
?>
1443
            </div>
1444
        </div>
1445
        <div class="row column">
1446
<?php
1447
	//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
1448
	if ($year == '' && $month == '') {
1449
		if ($type == 'aircraft') {
1450
			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
1451
		} elseif ($type == 'marine') {
1452
			$hist = $Stats->getStatsSource('hist_marine',date('Y'),date('m'),date('d'));
1453
		} elseif ($type == 'tracker') {
1454
			$hist = $Stats->getStatsSource('hist_tracker',date('Y'),date('m'),date('d'));
1455
		}
1456
	} else {
1457
		if ($type == 'aircraft') {
1458
			$hist = $Stats->getStatsSource('hist',$year,$month);
1459
		} elseif ($type == 'marine') {
1460
			$hist = $Stats->getStatsSource('hist_marine',$year,$month);
1461
		} elseif ($type == 'tracker') {
1462
			$hist = $Stats->getStatsSource('hist_tracker',$year,$month);
1463
		}
1464
	}
1465
	foreach ($hist as $hists) {
1466
		//$hist_data = '';
1467
		$distance_data = '';
1468
		$nb_data = '';
1469
		$source = $hists['source_name'];
1470
		$hist_array = json_decode($hists['source_data']);
1471
		$unit = 'km';
1472
		foreach($hist_array as $distance => $nb) {
1473
			if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1474
				$distance = round($distance*0.539957);
1475
				$unit = 'nm';
1476
			} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1477
				$distance = round($distance*0.621371);
1478
				$unit = 'mi';
1479
			} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1480
				$distance = $distance;
1481
				$unit = 'km';
1482
			}
1483
			//$hist_data .= '[ "'.$distance.'",'.$nb.'],';
1484
			$distance_data .= '"'.$distance.'",';
1485
			$nb_data .= $nb.',';
1486
		}
1487
		//$hist_data = substr($hist_data, 0, -1);
1488
		$distance_data = "['x',".substr($distance_data, 0, -1)."]";
1489
		$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
1490
?>
1491
            <div class="col-md-6">
1492
                <h2><?php echo sprintf(_("Distance for %s"),$source); ?></h2>
1493
<?php
1494
		print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
1495
		print 'c3.generate({
1496
		    bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
1497
		    data: { x: "x",
1498
		    columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1499
		    axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
1500
		print '</script>';
1501
?>
1502
    	    </div>
1503
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1504
<?php
1505
	}
1506
?>
1507
        </div>
1508
<?php
1509
}
1510
?>
1511
    </div>
1512
</div>  
1513
1514
<?php
1515
require_once('footer.php');
1516
?>