2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Stats.php');
5 require_once('require/class.Language.php');
6 if (!isset($_GET['aircraft_manufacturer'])) {
7 header('Location: '.$globalURL.'/manufacturer');
10 $Spotter = new Spotter();
11 $manufacturer = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET
,'aircraft_manufacturer',FILTER_SANITIZE_STRING
))));
13 $sort = filter_input(INPUT_GET
,'sort',FILTER_SANITIZE_STRING
);
14 $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort);
16 if (!empty($spotter_array))
18 $title = sprintf(_("Most Common Time of Day from %s"),$manufacturer);
19 require_once('header.php');
20 print '<div class="select-item">';
21 print '<form action="'.$globalURL.'/manufacturer" method="post">';
22 print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
24 $all_manufacturers = $Stats->getAllManufacturers();
25 if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
26 foreach($all_manufacturers as $all_manufacturer)
28 if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
30 print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
32 print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
36 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
40 print '<div class="info column">';
41 print '<h1>'.$manufacturer.'</h1>';
44 include('manufacturer-sub-menu.php');
45 print '<div class="column">';
46 print '<h2>'._("Most Common Time of Day").'</h2>';
47 print '<p>'.sprintf(_("The statistic below shows the most common time of day from <strong>%s</strong>."),$manufacturer).'</p>';
49 $hour_array = $Spotter->countAllHoursByManufacturer($manufacturer);
50 print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
51 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
52 print '<script type="text/javascript" src="'.$globalURL.'/js/c3.min.js"></script>';
53 print '<div id="chartHour" class="chart" width="100%"></div><script>';
57 foreach($hour_array as $hour_item)
59 while($last != $hour_item['hour_name']) {
60 $hour_data .= '"'.$last.':00",';
65 $hour_data .= '"'.$hour_item['hour_name'].':00",';
66 $hour_cnt .= $hour_item['hour_count'].',';
68 $hour_data = "['x',".substr($hour_data, 0, -1)."]";
69 $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
75 columns: ['.$hour_cnt.','.$hour_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}
78 x: { type: "timeseries", tick: { format: "%H:%M" }},
79 y: { label: "# of Flights",tick: { format: d3.format("d") }}
81 legend: { show: false }
84 if (!empty($hour_array))
86 print '<div class="table-responsive">';
87 print '<table class="common-hour table-striped">';
89 print '<th>'._("Hour").'</th>';
90 print '<th>'._("Number").'</th>';
94 foreach($hour_array as $hour_item)
97 print '<td>'.$hour_item['hour_name'].':00</td>';
98 print '<td>'.$hour_item['hour_count'].'</td>';
108 $title = _("Manufacturer");
109 require_once('header.php');
110 print '<h1>'._("Error").'</h1>';
111 print '<p>'._("Sorry, the aircraft manufacturer does not exist in this database. :(").'</p>';
114 require_once('footer.php');