Completed
Push — master ( e7716d...f2edfd )
by Yannick
06:34
created

statistics-country.php (4 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 Country a flight was over");
7
require_once('header.php');
8
include('statistics-sub-menu.php'); 
9
10
print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>
11
		<div class="info">
12
	  	<h1>'._("Most common Country a flight was over").'</h1>
13
	  </div>
14
	<p>'._("Below are the <strong>Top 10</strong> most common country a flight was over.").'</p>';
15
16
$flightover_array = $Stats->countAllFlightOverCountries();
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
            	["'._("Country").'", "'._("# of times").'"], ';
24
$flightover_data = '';
25 View Code Duplication
foreach($flightover_array as $flightover_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
	$flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],';
28
}
29
$flightover_data = substr($flightover_data, 0, -1);
30
print $flightover_data;
31
print ']);
32
    
33
            var options = {
34
            	chartArea: {"width": "80%", "height": "60%"},
35
            	height:500,
36
            	 is3D: true,
37
                colors: ["#8BA9D0","#1a3151"]
38
            };
39
    
40
            //var chart = new google.visualization.PieChart(document.getElementById("chart"));
41
	    var chart = new google.visualization.GeoChart(document.getElementById("chart"));
42
            chart.draw(data, options);
43
          }
44
          $(window).resize(function(){
45
    			  drawChart();
46
    			});
47
      </script>';
48
49 View Code Duplication
if (!empty($flightover_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...
50
{
51
	print '<div class="table-responsive">';
52
	print '<table class="common-countries table-striped">';
53
	print '<thead>';
54
	print '<th></th>';
55
	print '<th>'._("Name").'</th>';
56
	print '<th>'._("# of times").'</th>';
57
	print '</thead>';
58
	print '<tbody>';
59
	$i = 1;
60
	foreach($flightover_array as $flightover_item)
61
	{
62
		print '<tr>';
63
		print '<td><strong>'.$i.'</strong></td>';
64
		print '<td>';
65
/*		print '<a href="'.$globalURL.'/ident/'.$callsign_item['callsign_icao'].'">'.$callsign_item['callsign_icao'].'</a>';
1 ignored issue
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
66
		print '</td>';
67
		print '<td>';
68
		print '<a href="'.$globalURL.'/airline/'.$callsign_item['airline_icao'].'">'.$callsign_item['airline_name'].'</a>';
69
*/
70
		print $flightover_item['flight_country'];
71
		print '</td>';
72
		print '<td>'.$flightover_item['flight_count'].'</td>';
73
		print '</tr>';
74
		$i++;
75
	}
76
	print '<tbody>';
77
	print '</table>';
78
	print '</div>';
79
}
80
81
require_once('footer.php');
82
?>
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...