Completed
Push — master ( 72d96f...36cc69 )
by Yannick
16:46 queued 04:01
created

statistics-aircraft.php (3 issues)

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
$Stats = new Stats();
6
$title = _("Statistics").' - '._("Most common Aircraft");
7
require_once('header.php');
8
9
include('statistics-sub-menu.php');
10
print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>
11
	<div class="info">
12
	 	<h1>'._("Most common Aircraft").'</h1>
13
	</div>
14
	<p>'._("Below are the <strong>Top 10</strong> most common aircraft types.").'</p>';
15
	  
16
$aircraft_array = $Stats->countAllAircraftTypes();
17
print '<div id="chart" class="chart" width="100%"></div>
18
      	<script> 
19
      		google.load("visualization", "1", {packages:["corechart"]});
20
          google.setOnLoadCallback(drawChart);
21
          function drawChart() {
22
            var data = google.visualization.arrayToDataTable([
23
            	["'._("Aircraft").'", "'._("# of times").'"], ';
24
$aircraft_data = '';
25 View Code Duplication
foreach($aircraft_array as $aircraft_item)
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
{
27
	$aircraft_data .= '[ "'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
28
}
29
$aircraft_data = substr($aircraft_data, 0, -1);
30
print $aircraft_data;
31
print ']);
32
    
33
            var options = {
34
            	chartArea: {"width": "80%", "height": "60%"},
35
            	height:500,
36
            	 is3D: true
37
            };
38
    
39
            var chart = new google.visualization.PieChart(document.getElementById("chart"));
40
            chart.draw(data, options);
41
          }
42
          $(window).resize(function(){
43
    			  drawChart();
44
    			});
45
      </script>';
46
47 View Code Duplication
if (!empty($aircraft_array))
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
{
49
	print '<div class="table-responsive">';
50
	print '<table class="common-type table-striped">';
51
	print '<thead>';
52
	print '<th></th>';
53
	print '<th>'._("Aircraft Type").'</th>';
54
	print '<th>'._("# of times").'</th>';
55
	print '</thead>';
56
	print '<tbody>';
57
	$i = 1;
58
	foreach($aircraft_array as $aircraft_item)
59
	{
60
		print '<tr>';
61
		print '<td><strong>'.$i.'</strong></td>';
62
		print '<td>';
63
		print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>';
64
		print '</td>';
65
		print '<td>';
66
		print $aircraft_item['aircraft_icao_count'];
67
		print '</td>';
68
		print '</tr>';
69
		$i++;
70
	}
71
	print '<tbody>';
72
	print '</table>';
73
	print '</div>';
74
}
75
require_once('footer.php');
76
?>
1 ignored issue
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...