2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Language.php');
5 if (!isset($_GET['country'])) {
6 header('Location: '.$globalURL.'/country');
9 $Spotter = new Spotter();
10 $country = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET
,'country',FILTER_SANITIZE_STRING
))));
11 $sort = filter_input(INPUT_GET
,'sort',FILTER_SANITIZE_STRING
);
13 if (isset($_GET['sort'])) {
14 $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort);
16 $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", '');
19 if (!empty($spotter_array))
21 $title = sprintf(_("Most Common Time of Day from %s"),$country);
22 require_once('header.php');
23 print '<div class="select-item">';
24 print '<form action="'.$globalURL.'/country" method="post">';
25 print '<select name="country" class="selectpicker" data-live-search="true">';
26 print '<option></option>';
27 $all_countries = $Spotter->getAllCountries();
28 foreach($all_countries as $all_country)
30 if($country == $all_country['country'])
32 print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>';
34 print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'">'.$all_country['country'].'</option>';
38 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
42 if ($_GET['country'] != "NA")
44 print '<div class="info column">';
45 print '<h1>'.sprintf(_("Airports & Airlines from %s"),$country).'</h1>';
48 print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>';
51 include('country-sub-menu.php');
52 print '<div class="column">';
53 print '<h2>'._("Most Common Time of Day").'</h2>';
54 print '<p>'.sprintf(_("The statistic below shows the most common time of day of airports & airlines from <strong>%s</strong>."),$country).'</p>';
55 $hour_array = $Spotter->countAllHoursByCountry($country);
56 print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
57 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
58 print '<script type="text/javascript" src="'.$globalURL.'/js/c3.min.js"></script>';
59 print '<div id="chartHour" class="chart" width="100%"></div><script>';
63 foreach($hour_array as $hour_item)
65 while($last != $hour_item['hour_name']) {
66 $hour_data .= '"'.$last.':00",';
71 $hour_data .= '"'.$hour_item['hour_name'].':00",';
72 $hour_cnt .= $hour_item['hour_count'].',';
74 $hour_data = "['x',".substr($hour_data, 0, -1)."]";
75 $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
81 columns: ['.$hour_cnt.','.$hour_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}
84 x: { type: "timeseries", tick: { format: "%H:%M" }},
85 y: { label: "# of Flights",tick: { format: d3.format("d") }}
87 legend: { show: false }
90 if (!empty($hour_array))
92 print '<div class="table-responsive">';
93 print '<table class="common-hour table-striped">';
95 print '<th>'._("Hour").'</th>';
96 print '<th>'._("Number").'</th>';
100 foreach($hour_array as $hour_item)
103 print '<td>'.$hour_item['hour_name'].':00</td>';
104 print '<td>'.$hour_item['hour_count'].'</td>';
114 $title = _("Country");
115 require_once('header.php');
116 print '<h1>'._("Error").'</h1>';
117 print '<p>'._("Sorry, the country does not exist in this database. :(").'</p>';
120 require_once('footer.php');