Completed
Push — master ( 708bc7...3d67e6 )
by Yannick
30:22
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,$filter_name,$year,$month);
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,$filter_name,$year,$month);
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
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
603
            </div>
604
        </div>
605
606
<?php
607
}
608
if ($type == 'tracker') {
609
	$flightover_array = $Stats->countAllTrackerOverCountries(true);
610
?>
611
<!--    <div class="row column">-->
612
	<div class="col-md-6">
613
            <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
614
<?php
615
	if (count($flightover_array) == 0) print _("No data available");
616
	else {
617
		print '<div id="chart10" class="chart" width="100%"></div><script>';
618
		print 'var series = [';
619
		$flightover_data = '';
620
		foreach($flightover_array as $flightover_item) {
621
			$flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],';
622
		}
623
		$flightover_data = substr($flightover_data, 0, -1);
624
		print $flightover_data;
625
		print '];';
626
		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);';
627
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
628
		print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
629
		print 'new Datamap({
630
		    element: document.getElementById("chart10"),
631
		    projection: "mercator", // big world map
632
		    fills: { defaultFill: "#F5F5F5" },
633
		    data: dataset,
634
		    responsive: true,
635
		    geographyConfig: {
636
			borderColor: "#DEDEDE",
637
			highlightBorderWidth: 2,
638
			highlightFillColor: function(geo) {
639
			    return geo["fillColor"] || "#F5F5F5";
640
			},
641
			highlightBorderColor: "#B7B7B7",
642
			done: function(datamap) {
643
			    datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
644
			    function redraw() {
645
				datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
646
			    }
647
			},
648
			popupTemplate: function(geo, data) {
649
			    if (!data) { return ; }
650
			    return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
651
			}
652
		    }
653
		});";
654
		print '</script>';
655
	}
656
?>
657
                <div class="more">
658
                    <a href="<?php print $globalURL; ?>/tracker/statistics/country" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
659
                </div>
660
            </div>
661
        </div>
662
663
<?php
664
}
665
if ($type == 'aircraft') {
666
?>
667
        <div class="row column">
668
            <div class="col-md-6">
669
<?php
670
	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
671
	if (count($airport_airport_array) > 0) {
672
		print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
673
		print '<div id="chart3" class="chart" width="100%"></div><script>';
674
		print "\n";
675
		print 'var series = [';
676
		$airport_data = '';
677
		foreach($airport_airport_array as $airport_item) {
678
			$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
679
		}
680
		$airport_data = substr($airport_data, 0, -1);
681
		print $airport_data;
682
		print '];'."\n";
683
		print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
684
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
685
		print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
686
		print 'var dataset = [];'."\n";
687
		print 'var colorset = [];'."\n";
688
		print 'colorset["defaultFill"] = "#F5F5F5";';
689
		print 'series.forEach(function(item){'."\n";
690
		print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
691
		print 'colorset[nm] = paletteScale(cnt);';
692
		print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
693
		print '});'."\n";
694
		print 'var bbl = new Datamap({
695
		    element: document.getElementById("chart3"),
696
		    projection: "mercator", // big world map
697
		    fills: colorset,
698
		    responsive: true,
699
		    geographyConfig: {
700
			borderColor: "#DEDEDE",
701
			highlightBorderWidth: 2,
702
			highlightFillColor: function(geo) {
703
			    return geo["fillColor"] || "#F5F5F5";
704
			},
705
			highlightBorderColor: "#B7B7B7"
706
		    },
707
		    done: function(datamap) {
708
			datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
709
			function redraw() {
710
			    datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
711
			}
712
		    }
713
		});
714
		bbl.bubbles(dataset,{
715
		    popupTemplate: function(geo, data) {
716
			if (!data) { return ; }
717
			return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
718
		    }
719
		});";
720
		print '</script>';
721
		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
722
		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
723
		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
724
	}
725
?>
726
            </div>
727
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
728
729
            <div class="col-md-6">
730
<?php
731
	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
732
	if (count($airport_airport_array2) > 0) {
733
		print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
734
		print '<div id="chart4" class="chart" width="100%"></div><script>';
735
		print "\n";
736
		print 'var series = [';
737
		$airport_data = '';
738
		foreach($airport_airport_array2 as $airport_item)
739
		{
740
			if (isset($airport_item['airport_arrival_longitude']) && isset($airport_item['airport_arrival_latitude'])) {
741
				$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
742
			}
743
		}
744
		$airport_data = substr($airport_data, 0, -1);
745
		print $airport_data;
746
		print '];'."\n";
747
		print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
748
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
749
		print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
750
		print 'var dataset = [];'."\n";
751
		print 'var colorset = [];'."\n";
752
		print 'colorset["defaultFill"] = "#F5F5F5";';
753
		print 'series.forEach(function(item){'."\n";
754
		print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
755
		print 'colorset[nm] = paletteScale(cnt);';
756
		print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
757
		print '});'."\n";
758
		print 'var bbl = new Datamap({
759
		    element: document.getElementById("chart4"),
760
		    projection: "mercator", // big world map
761
		    fills: colorset,
762
		    responsive: true,
763
		    geographyConfig: {
764
			borderColor: "#DEDEDE",
765
			highlightBorderWidth: 2,
766
			highlightFillColor: function(geo) {
767
			    return geo["fillColor"] || "#F5F5F5";
768
			},
769
			highlightBorderColor: "#B7B7B7"
770
		    },
771
		    done: function(datamap) {
772
			datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
773
			function redraw() {
774
			    datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
775
			}
776
		    }
777
		});
778
		bbl.bubbles(dataset,{
779
		    popupTemplate: function(geo, data) {
780
			if (!data) { return ; }
781
			return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
782
		    }
783
		});";
784
		print '</script>';
785
		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
786
		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
787
		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
788
	}
789
?>
790
            </div>
791
        </div>
792
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
793
<?php 
794
}
795
if ($type == 'aircraft') {
796
?>
797
<?php
798
	if ($year == '' && $month == '') {
799
?>
800
        <div class="row column">
801
            <div class="col-md-6">
802
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
803
<?php
804
		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
805
		if (count($year_array) == 0) print _("No data available");
806
		else {
807
			print '<div id="chart8" class="chart" width="100%"></div><script>';
808
			$year_data = '';
809
			$year_cnt = '';
810
			foreach($year_array as $year_item) {
811
				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
812
				$year_cnt .= $year_item['date_count'].',';
813
			}
814
			$year_data = "['x',".substr($year_data, 0, -1)."]";
815
			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
816
			print 'c3.generate({
817
			    bindto: "#chart8",
818
			    data: { x: "x",
819
			     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
820
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Flights"}},legend: { show: false }});';
821
			print '</script>';
822
		}
823
?>
824
                <div class="more">
825
                    <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>
826
                </div>
827
            </div>
828
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
829
            <div class="col-md-6">
830
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
831
<?php
832
		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
833
		if (count($month_array) == 0) print _("No data available");
834
		else {
835
			print '<div id="chart9" class="chart" width="100%"></div><script>';
836
			$month_data = '';
837
			$month_cnt = '';
838
			foreach($month_array as $month_item) {
839
				$month_data .= '"'.$month_item['date_name'].'",';
840
				$month_cnt .= $month_item['date_count'].',';
841
			}
842
			$month_data = "['x',".substr($month_data, 0, -1)."]";
843
			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
844
			print 'c3.generate({
845
			    bindto: "#chart9",
846
			    data: { x: "x",
847
			     columns: ['.$month_data.','.$month_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
848
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
849
			print '</script>';
850
		}
851
?>
852
                <div class="more">
853
                    <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>
854
                </div>
855
            </div>
856
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
857
858
            <div class="col-md-6">
859
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
860
<?php
861
		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
862
		if (empty($date_array)) print _("No data available");
863
		else {
864
			print '<div id="chart5" class="chart" width="100%"></div><script>';
865
			$date_data = '';
866
			$date_cnt = '';
867
			foreach($date_array as $date_item) {
868
				$date_data .= '"'.$date_item['date_name'].'",';
869
				$date_cnt .= $date_item['date_count'].',';
870
			}
871
			$date_data = "['x',".substr($date_data, 0, -1)."]";
872
			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
873
			print 'c3.generate({
874
			    bindto: "#chart5",
875
			    data: { x: "x",
876
			     columns: ['.$date_data.','.$date_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
877
			     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
878
			print '</script>';
879
		}
880
?>
881
                <div class="more">
882
                    <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>
883
                </div>
884
            </div>
885
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
886
            <div class="col-md-6">
887
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
888
<?php
889
		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
890
		if (empty($hour_array)) print _("No data available");
891
		else {
892
			print '<div id="chart6" class="chart" width="100%"></div><script>';
893
			$hour_data = '';
894
			$hour_cnt = '';
895
			foreach($hour_array as $hour_item) {
896
				$hour_data .= '"'.$hour_item['hour_name'].':00",';
897
				$hour_cnt .= $hour_item['hour_count'].',';
898
			}
899
			$hour_data = "[".substr($hour_data, 0, -1)."]";
900
			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
901
			print 'c3.generate({
902
			    bindto: "#chart6",
903
			    data: {
904
			     columns: ['.$hour_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
905
			     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});';
906
			print '</script>';
907
		}
908
?>
909
                <div class="more">
910
                    <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>
911
                </div>
912
            </div>
913
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
914
        </div>
915
<?php
916
	}
917
}
918
?>
919
<?php
920
if ($type == 'marine') {
921
?>
922
<?php
923
	if ($year == '' && $month == '') {
924
?>
925
        <div class="row column">
926
            <div class="col-md-6">
927
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
928
<?php
929
		$year_array = $Stats->countAllMarineMonthsLastYear(true,$filter_name);
930
		if (count($year_array) == 0) print _("No data available");
931
		else {
932
			print '<div id="chart8" class="chart" width="100%"></div><script>';
933
			$year_data = '';
934
			$year_cnt = '';
935
			foreach($year_array as $year_item) {
936
				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
937
				$year_cnt .= $year_item['date_count'].',';
938
			}
939
			$year_data = "['x',".substr($year_data, 0, -1)."]";
940
			$year_cnt = "['vessels',".substr($year_cnt,0,-1)."]";
941
			print 'c3.generate({
942
			    bindto: "#chart8",
943
			    data: { x: "x",
944
			     columns: ['.$year_data.','.$year_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
945
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
946
			print '</script>';
947
		}
948
?>
949
                <div class="more">
950
                    <a href="<?php print $globalURL; ?>/marine/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
951
                </div>
952
            </div>
953
            
954
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
955
            <div class="col-md-6">
956
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
957
<?php
958
		$month_array = $Stats->countAllMarineDatesLastMonth($filter_name);
959
		if (count($month_array) == 0) print _("No data available");
960
		else {
961
			print '<div id="chart9" class="chart" width="100%"></div><script>';
962
			$month_data = '';
963
			$month_cnt = '';
964
			foreach($month_array as $month_item) {
965
				$month_data .= '"'.$month_item['date_name'].'",';
966
				$month_cnt .= $month_item['date_count'].',';
967
			}
968
			$month_data = "['x',".substr($month_data, 0, -1)."]";
969
			$month_cnt = "['vessels',".substr($month_cnt,0,-1)."]";
970
			print 'c3.generate({
971
			    bindto: "#chart9",
972
			    data: { x: "x",
973
			     columns: ['.$month_data.','.$month_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
974
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
975
			print '</script>';
976
		}
977
?>
978
                <div class="more">
979
                    <a href="<?php print $globalURL; ?>/marine/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
980
                </div>
981
            </div>
982
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
983
984
            <div class="col-md-6">
985
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
986
<?php
987
		$date_array = $Stats->countAllMarineDatesLast7Days($filter_name);
988
		if (empty($date_array)) print _("No data available");
989
		else {
990
			print '<div id="chart5" class="chart" width="100%"></div><script>';
991
			$date_data = '';
992
			$date_cnt = '';
993
			foreach($date_array as $date_item) {
994
				$date_data .= '"'.$date_item['date_name'].'",';
995
				$date_cnt .= $date_item['date_count'].',';
996
			}
997
			$date_data = "['x',".substr($date_data, 0, -1)."]";
998
			$date_cnt = "['vessels',".substr($date_cnt,0,-1)."]";
999
			print 'c3.generate({
1000
			    bindto: "#chart5",
1001
			    data: { x: "x",
1002
			     columns: ['.$date_data.','.$date_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
1003
			     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
1004
			print '</script>';
1005
		}
1006
?>
1007
                <div class="more">
1008
                    <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1009
                </div>
1010
            </div>
1011
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1012
            <div class="col-md-6">
1013
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1014
<?php
1015
		$hour_array = $Stats->countAllMarineHours('hour',true,$filter_name);
1016
		if (empty($hour_array)) print _("No data available");
1017
		else {
1018
			print '<div id="chart6" class="chart" width="100%"></div><script>';
1019
			$hour_data = '';
1020
			$hour_cnt = '';
1021
			foreach($hour_array as $hour_item) {
1022
				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1023
				$hour_cnt .= $hour_item['hour_count'].',';
1024
			}
1025
			$hour_data = "[".substr($hour_data, 0, -1)."]";
1026
			$hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]";
1027
			print 'c3.generate({
1028
			    bindto: "#chart6",
1029
			    data: {
1030
			     columns: ['.$hour_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
1031
			     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Vessels"}},legend: { show: false }});';
1032
			print '</script>';
1033
		}
1034
?>
1035
                <div class="more">
1036
                    <a href="<?php print $globalURL; ?>/marine/statistics/time" 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' ?> -->
1040
        </div>
1041
<?php
1042
	}
1043
}
1044
?>
1045
<?php
1046
if ($type == 'tracker') {
1047
?>
1048
<?php
1049
	if ($year == '' && $month == '') {
1050
?>
1051
        <div class="row column">
1052
            <div class="col-md-6">
1053
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1054
<?php
1055
		$year_array = $Tracker->countAllMonthsLastYear(true);
1056
		if (count($year_array) == 0) print _("No data available");
1057
		else {
1058
			print '<div id="chart8" class="chart" width="100%"></div><script>';
1059
			$year_data = '';
1060
			$year_cnt = '';
1061
			foreach($year_array as $year_item) {
1062
				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1063
				$year_cnt .= $year_item['date_count'].',';
1064
			}
1065
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1066
			$year_cnt = "['trackers',".substr($year_cnt,0,-1)."]";
1067
			print 'c3.generate({
1068
			    bindto: "#chart8",
1069
			    data: { x: "x",
1070
			     columns: ['.$year_data.','.$year_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1071
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
1072
			print '</script>';
1073
		}
1074
?>
1075
                <div class="more">
1076
                    <a href="<?php print $globalURL; ?>/tracker/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1077
                </div>
1078
            </div>
1079
            
1080
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1081
            <div class="col-md-6">
1082
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1083
<?php
1084
		$month_array = $Tracker->countAllDatesLastMonth();
1085
		if (count($month_array) == 0) print _("No data available");
1086
		else {
1087
			print '<div id="chart9" class="chart" width="100%"></div><script>';
1088
			$month_data = '';
1089
			$month_cnt = '';
1090
			foreach($month_array as $month_item) {
1091
				$month_data .= '"'.$month_item['date_name'].'",';
1092
				$month_cnt .= $month_item['date_count'].',';
1093
			}
1094
			$month_data = "['x',".substr($month_data, 0, -1)."]";
1095
			$month_cnt = "['trackers',".substr($month_cnt,0,-1)."]";
1096
			print 'c3.generate({
1097
			    bindto: "#chart9",
1098
			    data: { x: "x",
1099
			     columns: ['.$month_data.','.$month_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1100
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
1101
			print '</script>';
1102
		}
1103
?>
1104
                <div class="more">
1105
                    <a href="<?php print $globalURL; ?>/tracker/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1106
                </div>
1107
            </div>
1108
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1109
1110
            <div class="col-md-6">
1111
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1112
<?php
1113
		$date_array = $Tracker->countAllDatesLast7Days();
1114
		if (empty($date_array)) print _("No data available");
1115
		else {
1116
			print '<div id="chart5" class="chart" width="100%"></div><script>';
1117
			$date_data = '';
1118
			$date_cnt = '';
1119
			foreach($date_array as $date_item) {
1120
				$date_data .= '"'.$date_item['date_name'].'",';
1121
				$date_cnt .= $date_item['date_count'].',';
1122
			}
1123
			$date_data = "['x',".substr($date_data, 0, -1)."]";
1124
			$date_cnt = "['trackers',".substr($date_cnt,0,-1)."]";
1125
			print 'c3.generate({
1126
			    bindto: "#chart5",
1127
			    data: { x: "x",
1128
			     columns: ['.$date_data.','.$date_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1129
			     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
1130
			print '</script>';
1131
		}
1132
?>
1133
                <div class="more">
1134
                    <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1135
                </div>
1136
            </div>
1137
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1138
            <div class="col-md-6">
1139
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1140
<?php
1141
		$hour_array = $Tracker->countAllHours('hour',true);
0 ignored issues
show
true is of type boolean, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1142
		if (empty($hour_array)) print _("No data available");
1143
		else {
1144
			print '<div id="chart6" class="chart" width="100%"></div><script>';
1145
			$hour_data = '';
1146
			$hour_cnt = '';
1147
			foreach($hour_array as $hour_item) {
1148
				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1149
				$hour_cnt .= $hour_item['hour_count'].',';
1150
			}
1151
			$hour_data = "[".substr($hour_data, 0, -1)."]";
1152
			$hour_cnt = "['trackers',".substr($hour_cnt,0,-1)."]";
1153
			print 'c3.generate({
1154
			    bindto: "#chart6",
1155
			    data: {
1156
			     columns: ['.$hour_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1157
			     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Trackers"}},legend: { show: false }});';
1158
			print '</script>';
1159
		}
1160
?>
1161
                <div class="more">
1162
                    <a href="<?php print $globalURL; ?>/tracker/statistics/time" 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' ?> -->
1166
        </div>
1167
<?php
1168
	}
1169
}
1170
?>
1171
<?php
1172
if ($type == 'satellite') {
1173
?>
1174
<?php
1175
	if ($year == '' && $month == '') {
1176
?>
1177
        <div class="row column">
1178
            <div class="col-md-6">
1179
                <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1180
<?php
1181
		$year_array = $Satellite->countAllMonthsLastYear();
1182
		if (count($year_array) == 0) print _("No data available");
1183
		else {
1184
			print '<div id="chart21" class="chart" width="100%"></div><script>';
1185
			$year_data = '';
1186
			$year_cnt = '';
1187
			foreach($year_array as $year_item) {
1188
				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1189
				$year_cnt .= $year_item['date_count'].',';
1190
			}
1191
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1192
			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1193
			print 'c3.generate({
1194
			    bindto: "#chart21",
1195
			    data: { x: "x",
1196
			     columns: ['.$year_data.','.$year_cnt.'], types: { trackers: "area"}, colors: { satellite: "#1a3151"}},
1197
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Satellite"}},legend: { show: false }});';
1198
			print '</script>';
1199
		}
1200
?>
1201
	    <!--
1202
                <div class="more">
1203
                    <a href="<?php print $globalURL; ?>/tracker/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1204
                </div>
1205
            -->
1206
            </div>
1207
            
1208
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1209
            <div class="col-md-6">
1210
                <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1211
<?php
1212
		$year_array = $Satellite->countAllYears();
1213
		if (count($year_array) == 0) print _("No data available");
1214
		else {
1215
			print '<div id="chart22" class="chart" width="100%"></div><script>';
1216
			$year_data = '';
1217
			$year_cnt = '';
1218
			foreach($year_array as $year_item) {
1219
				$year_data .= '"'.$year_item['year_name'].'-01-01'.'",';
1220
				$year_cnt .= $year_item['date_count'].',';
1221
			}
1222
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1223
			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1224
			print 'c3.generate({
1225
			    bindto: "#chart22",
1226
			    data: { x: "x",
1227
			     columns: ['.$year_data.','.$year_cnt.'], types: { trackers: "area"}, colors: { satellite: "#1a3151"}},
1228
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y"}}, y: { label: "# of Satellite"}},legend: { show: false }});';
1229
			print '</script>';
1230
		}
1231
?>
1232
	    <!--
1233
                <div class="more">
1234
                    <a href="<?php print $globalURL; ?>/tracker/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1235
                </div>
1236
            -->
1237
            </div>
1238
            
1239
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1240
        </div>
1241
<?php
1242
	}
1243
}
1244
?>
1245
<?php
1246
if ($type == 'aircraft') {
1247
?>
1248
<?php
1249
	if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
1250
?>
1251
        <div class="row column">
1252
            <div class="col-md-6">
1253
                <h2><?php echo _("Fatalities by Years"); ?></h2>
1254
<?php
1255
		$year_array = $Stats->countFatalitiesByYear();
1256
		if (count($year_array) == 0) print _("No data available");
1257
		else {
1258
			print '<div id="chart32" class="chart" width="100%"></div><script>';
1259
			$year_data = '';
1260
			$year_cnt = '';
1261
			foreach($year_array as $year_item) {
1262
				$year_data .= '"'.$year_item['year'].'-01-01",';
1263
				$year_cnt .= $year_item['count'].',';
1264
			}
1265
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1266
			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1267
			print 'c3.generate({
1268
			    bindto: "#chart32",
1269
			    data: { x: "x",
1270
			     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1271
			     axis: { x: { type: "timeseries",tick: { format: "%Y"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
1272
			print '</script>';
1273
		}
1274
?>
1275
                <div class="more">
1276
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1277
                </div>
1278
            </div>
1279
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1280
1281
        <div class="row column">
1282
            <div class="col-md-6">
1283
                <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1284
<?php
1285
		$year_array = $Stats->countFatalitiesLast12Months();
1286
		if (count($year_array) == 0) print _("No data available");
1287
		else {
1288
			print '<div id="chart33" class="chart" width="100%"></div><script>';
1289
			$year_data = '';
1290
			$year_cnt = '';
1291
			foreach($year_array as $year_item) {
1292
				$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
1293
				$year_cnt .= $year_item['count'].',';
1294
			}
1295
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1296
			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1297
			print 'c3.generate({
1298
			    bindto: "#chart33",
1299
			    data: { x: "x",
1300
			     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1301
			     axis: { x: { type: "timeseries",tick: { format: "%Y-%m"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
1302
			print '</script>';
1303
		}
1304
?>
1305
                <div class="more">
1306
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1307
                </div>
1308
            </div>
1309
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1310
<br/>
1311
<?php
1312
	}
1313
}
1314
?>
1315
<?php
1316
if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '' && (!isset($globalSatellite) || $globalSatellite === FALSE)) {
1317
?>
1318
        <div class="row column">
1319
<?php
1320
	//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
1321
	if ($year == '' && $month == '') {
1322
		if ($type == 'aircraft') {
1323
			$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
1324
		} elseif ($type == 'marine') {
1325
			$polar = $Stats->getStatsSource('polar_marine',date('Y'),date('m'),date('d'));
1326
		} elseif ($type == 'tracker') {
1327
			$polar = $Stats->getStatsSource('polar_tracker',date('Y'),date('m'),date('d'));
1328
		}
1329
	} else {
1330
		if ($type == 'aircraft') {
1331
			$polar = $Stats->getStatsSource('polar',$year,$month);
1332
		} elseif ($type == 'marine') {
1333
			$polar = $Stats->getStatsSource('polar_marine',$year,$month);
1334
		} elseif ($type == 'tracker') {
1335
			$polar = $Stats->getStatsSource('polar_tracker',$year,$month);
1336
		}
1337
	}
1338
	if (!empty($polar)) {
1339
		print '<h2>'._("Coverage pattern").'</h2>';
1340
		foreach ($polar as $eachpolar) {
1341
			unset($polar_data);
1342
			$Spotter = new Spotter();
1343
			$data = json_decode($eachpolar['source_data']);
1344
			foreach($data as $value => $key) {
1345
				$direction = $Spotter->parseDirection(($value*22.5));
1346
				$distance = $key;
1347
				$unit = 'km';
1348
				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1349
					$distance = round($distance*0.539957);
1350
					$unit = 'nm';
1351
				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1352
					$distance = round($distance*0.621371);
1353
					$unit = 'mi';
1354
				} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1355
					$distance = $distance;
1356
					$unit = 'km';
1357
				}
1358
				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1359
				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1360
			}
1361
?>
1362
            <div class="col-md-6">
1363
                <h4><?php print $eachpolar['source_name']; ?></h4>
1364
        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1365
        	<script>
1366
        	    (function() {
1367
        	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
1368
			width = Math.min(700, window.innerWidth - 10) - margin.left - margin.right,
1369
			height = Math.min(width, window.innerHeight - margin.top - margin.bottom - 20);
1370
		    var data = [
1371
				    [
1372
				    <?php print $polar_data; ?>
1373
				    ]
1374
				];
1375
		    var color = d3.scale.ordinal().range(["#EDC951","#CC333F","#00A0B0"]);
1376
		    //var color = d3.scaleOrdinal().range(["#EDC951","#CC333F","#00A0B0"]);
1377
		
1378
		    var radarChartOptions = {
1379
		      w: width,
1380
		      h: height,
1381
		      margin: margin,
1382
		      maxValue: 0.5,
1383
		      levels: 5,
1384
		      roundStrokes: true,
1385
		      color: color,
1386
		      unit: '<?php echo $unit; ?>'
1387
		    };
1388
		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1389
		    })();
1390
		</script>
1391
            </div>
1392
            <?php
1393
		}
1394
	}
1395
?>
1396
        </div>
1397
        <div class="row column">
1398
            <div class="col-md-6">
1399
<?php
1400
	//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
1401
	if ($year == '' && $month == '') {
1402
		if ($type == 'aircraft') {
1403
			$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
1404
		} elseif ($type == 'marine') {
1405
			$msg = $Stats->getStatsSource('msg_marine',date('Y'),date('m'),date('d'));
1406
		} elseif ($type == 'tracker') {
1407
			$msg = $Stats->getStatsSource('msg_tracker',date('Y'),date('m'),date('d'));
1408
		}
1409
	} else {
1410
		if ($type == 'aircraft') {
1411
			$msg = $Stats->getStatsSource('msg',$year,$month);
1412
		} elseif ($type == 'marine') {
1413
			$msg = $Stats->getStatsSource('msg_marine',$year,$month);
1414
		} elseif ($type == 'tracker') {
1415
			$msg = $Stats->getStatsSource('msg_tracker',$year,$month);
1416
		}
1417
	}
1418
	if (!empty($msg)) {
1419
		print '<h2>'._("Messages received").'</h2>';
1420
		foreach ($msg as $eachmsg) {
1421
			//$eachmsg = $msg[0];
1422
			$data = $eachmsg['source_data'];
1423
			if ($data > 500) $max = (round(($data+100)/100))*100;
1424
			else $max = 500;
1425
?>
1426
        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1427
        	<script>
1428
		      var g = new JustGage({
1429
			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
1430
			    value: <?php echo $data; ?>,
1431
			    min: 0,
1432
			    max: <?php print $max; ?>,
1433
			    valueMinFontSize: 10,
1434
			    height: 120,
1435
			    width: 220,
1436
			    symbol: ' msg/s',
1437
			    title: "<?php print $eachmsg['source_name']; ?>"
1438
			  });
1439
		</script>
1440
<?php
1441
		}
1442
	}
1443
?>
1444
            </div>
1445
        </div>
1446
        <div class="row column">
1447
<?php
1448
	//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
1449
	if ($year == '' && $month == '') {
1450
		if ($type == 'aircraft') {
1451
			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
1452
		} elseif ($type == 'marine') {
1453
			$hist = $Stats->getStatsSource('hist_marine',date('Y'),date('m'),date('d'));
1454
		} elseif ($type == 'tracker') {
1455
			$hist = $Stats->getStatsSource('hist_tracker',date('Y'),date('m'),date('d'));
1456
		}
1457
	} else {
1458
		if ($type == 'aircraft') {
1459
			$hist = $Stats->getStatsSource('hist',$year,$month);
1460
		} elseif ($type == 'marine') {
1461
			$hist = $Stats->getStatsSource('hist_marine',$year,$month);
1462
		} elseif ($type == 'tracker') {
1463
			$hist = $Stats->getStatsSource('hist_tracker',$year,$month);
1464
		}
1465
	}
1466
	foreach ($hist as $hists) {
1467
		//$hist_data = '';
1468
		$distance_data = '';
1469
		$nb_data = '';
1470
		$source = $hists['source_name'];
1471
		$hist_array = json_decode($hists['source_data']);
1472
		$unit = 'km';
1473
		foreach($hist_array as $distance => $nb) {
1474
			if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1475
				$distance = round($distance*0.539957);
1476
				$unit = 'nm';
1477
			} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1478
				$distance = round($distance*0.621371);
1479
				$unit = 'mi';
1480
			} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1481
				$distance = $distance;
1482
				$unit = 'km';
1483
			}
1484
			//$hist_data .= '[ "'.$distance.'",'.$nb.'],';
1485
			$distance_data .= '"'.$distance.'",';
1486
			$nb_data .= $nb.',';
1487
		}
1488
		//$hist_data = substr($hist_data, 0, -1);
1489
		$distance_data = "['x',".substr($distance_data, 0, -1)."]";
1490
		$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
1491
?>
1492
            <div class="col-md-6">
1493
                <h2><?php echo sprintf(_("Distance for %s"),$source); ?></h2>
1494
<?php
1495
		print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
1496
		print 'c3.generate({
1497
		    bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
1498
		    data: { x: "x",
1499
		    columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1500
		    axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
1501
		print '</script>';
1502
?>
1503
    	    </div>
1504
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1505
<?php
1506
	}
1507
?>
1508
        </div>
1509
<?php
1510
}
1511
?>
1512
    </div>
1513
</div>  
1514
1515
<?php
1516
require_once('footer.php');
1517
?>