2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.SpotterArchive.php');
5 require_once('require/class.Language.php');
6 if (!isset($_GET['owner'])) {
7 header('Location: '.$globalURL.'/owner');
10 $Spotter = new Spotter();
11 $SpotterArchive = new SpotterArchive();
12 $sort = filter_input(INPUT_GET
,'sort',FILTER_SANITIZE_STRING
);
13 $owner = urldecode(filter_input(INPUT_GET
,'owner',FILTER_SANITIZE_STRING
));
14 $year = filter_input(INPUT_GET
,'year',FILTER_SANITIZE_NUMBER_INT
);
15 $month = filter_input(INPUT_GET
,'month',FILTER_SANITIZE_NUMBER_INT
);
17 if ($year != '') $filter = array_merge($filter,array('year' => $year));
18 if ($month != '') $filter = array_merge($filter,array('month' => $month));
20 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
23 $spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
25 if (!empty($spotter_array))
27 $title = sprintf(_("Most Common Time of Day of %s"),$spotter_array[0]['aircraft_owner']);
28 require_once('header.php');
29 print '<div class="info column">';
30 print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
31 // print '<div><span class="label">'._("Ident").'</span>'.$spotter_array[0]['ident'].'</div>';
32 // print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>';
35 include('owner-sub-menu.php');
36 print '<div class="column">';
37 print '<h2>'._("Most Common Time of Day").'</h2>';
38 print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
40 if ($archive === false) {
41 $hour_array = $Spotter->countAllHoursByOwner($owner,$filter);
43 $hour_array = $SpotterArchive->countAllHoursByOwner($owner,$filter);
45 print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
46 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
47 print '<script type="text/javascript" src="'.$globalURL.'/js/c3.min.js"></script>';
48 print '<div id="chartHour" class="chart" width="100%"></div><script>';
52 foreach($hour_array as $hour_item)
54 while($last != $hour_item['hour_name']) {
55 $hour_data .= '"'.$last.':00",';
60 $hour_data .= '"'.$hour_item['hour_name'].':00",';
61 $hour_cnt .= $hour_item['hour_count'].',';
63 $hour_data = "['x',".substr($hour_data, 0, -1)."]";
64 $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
70 columns: ['.$hour_cnt.','.$hour_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}
73 x: { type: "timeseries", tick: { format: "%H:%M" }},
74 y: { label: "# of Flights",tick: { format: d3.format("d") }}
76 legend: { show: false }
79 if (!empty($hour_array))
81 print '<div class="table-responsive">';
82 print '<table class="common-hour table-striped">';
84 print '<th>'._("Hour").'</th>';
85 print '<th>'._("Number").'</th>';
89 foreach($hour_array as $hour_item)
92 print '<td>'.$hour_item['hour_name'].':00</td>';
93 print '<td>'.$hour_item['hour_count'].'</td>';
104 require_once('header.php');
105 print '<h1>'._("Error").'</h1>';
106 print '<p>'._("Sorry, this owner is not in the database. :(").'</p>';
109 require_once('footer.php');