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_type'])) {
7 header('Location: '.$globalURL.'/aircraft');
11 $aircraft_type = filter_input(INPUT_GET
,'aircraft_type',FILTER_SANITIZE_STRING
);
13 $Spotter = new Spotter();
14 $spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1","");
17 if (!empty($spotter_array))
19 $title = sprintf(_("Most Common Time of Day from %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']);
20 require_once('header.php');
21 print '<div class="select-item">';
22 print '<form action="'.$globalURL.'/aircraft" method="get">';
23 print '<select name="aircraft_type" class="selectpicker" data-live-search="true">';
24 print '<option></option>';
26 $aircraft_types = $Stats->getAllAircraftTypes();
27 if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
28 foreach($aircraft_types as $aircrafttype)
30 if($aircraft_type == $aircrafttype['aircraft_icao'])
32 print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
34 print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
38 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
43 if ($aircraft_type != "NA")
45 print '<div class="info column">';
46 print '<h1>'.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')</h1>';
47 print '<div><span class="label">Name</span>'.$spotter_array[0]['aircraft_name'].'</div>';
48 print '<div><span class="label">ICAO</span>'.$spotter_array[0]['aircraft_type'].'</div>';
49 print '<div><span class="label">Manufacturer</span><a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $spotter_array[0]['aircraft_manufacturer'])).'">'.$spotter_array[0]['aircraft_manufacturer'].'</a></div>';
52 print '<div class="alert alert-warning">'._("This special aircraft profile shows all flights in where the aircraft type is unknown.").'</div>';
54 include('aircraft-sub-menu.php');
55 print '<div class="column">';
56 print '<h2>'._("Most Common Time of Day").'</h2>';
57 print '<p>'.sprintf(_("The statistic below shows the most common time of day from <strong>%s</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>';
59 $hour_array = $Spotter->countAllHoursByAircraft($aircraft_type);
60 print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
61 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
62 print '<script type="text/javascript" src="'.$globalURL.'/js/c3.min.js"></script>';
63 print '<div id="chartHour" class="chart" width="100%"></div><script>';
67 foreach($hour_array as $hour_item)
69 while($last != $hour_item['hour_name']) {
70 $hour_data .= '"'.$last.':00",';
75 $hour_data .= '"'.$hour_item['hour_name'].':00",';
76 $hour_cnt .= $hour_item['hour_count'].',';
78 $hour_data = "[".substr($hour_data, 0, -1)."]";
79 $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
83 columns: ['.$hour_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}
86 x: { type: "category", categories: '.$hour_data.'},
87 y: { label: "# of Flights"}
89 legend: { show: false }
92 if (!empty($hour_array))
94 print '<div class="table-responsive">';
95 print '<table class="common-hour table-striped">';
97 print '<th>'._("Hour").'</th>';
98 print '<th>'._("Number").'</th>';
102 foreach($hour_array as $hour_item)
105 print '<td>'.$hour_item['hour_name'].':00</td>';
106 print '<td>'.$hour_item['hour_count'].'</td>';
116 $title = _("Aircraft Type");
117 require_once('header.php');
118 print '<h1>'._("Error").'</h1>';
119 print '<p>'._("Sorry, the aircraft type does not exist in this database. :(").'</p>';
121 require_once('footer.php');