Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / statistics-month.php
blob83c0d42bf73cc4fe8e4b89a6b373ef40feb1d086
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").' - '._("Busiest Month of Last Year");
8 $type = 'aircraft';
9 if (isset($_GET['marine'])) {
10 $type = 'marine';
11 require_once('require/class.Marine.php');
12 $Marine = new Marine();
13 } elseif (isset($_GET['tracker'])) {
14 $type = 'tracker';
15 require_once('require/class.Tracker.php');
16 $Tracker = new Tracker();
18 if (!isset($filter_name)) $filter_name = '';
19 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
20 if ($airline_icao == '' && isset($globalFilter)) {
21 if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
24 require_once('header.php');
25 include('statistics-sub-menu.php');
27 print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
28 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
29 print '<script type="text/javascript" src="'.$globalURL.'/js/c3.min.js"></script>';
30 print '<div class="info">
31 <h1>'._("Busiest Day Last Month").'</h1>
32 </div>
33 <p>'._("Below is a chart that plots the busiest day during the <strong>last month</strong>.").'</p>';
35 if ($type == 'aircraft') $date_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
36 elseif ($type == 'marine') $date_array = $Marine->countAllDatesLastMonth();
37 elseif ($type == 'tracker') $date_array = $Tracker->countAllDatesLastMonth();
39 print '<div id="chart" class="chart" width="100%"></div><script>';
40 $month_data = '';
41 $month_cnt = '';
42 foreach($date_array as $month_item)
44 $month_data .= '"'.$month_item['date_name'].'",';
45 $month_cnt .= $month_item['date_count'].',';
47 $month_data = "['x',".substr($month_data, 0, -1)."]";
48 $month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
49 print 'c3.generate({
50 bindto: "#chart",
51 data: { x: "x",
52 columns: ['.$month_data.','.$month_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
53 axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "#"}},legend: { show: false }});';
54 print '</script>';
56 //$date_array = $Stats->countAllDates();
57 if (!empty($date_array))
59 foreach($date_array as $key => $row) {
60 $years[$key] = $row['date_name'];
61 $counts[$key] = $row['date_count'];
63 array_multisort($counts,SORT_DESC,$date_array);
64 print '<div class="table-responsive">';
65 print '<table class="common-date table-striped">';
66 print '<thead>';
67 print '<th></th>';
68 print '<th>'._("Date").'</th>';
69 print '<th>'._("Number").'</th>';
70 print '</thead>';
71 print '<tbody>';
72 $i = 1;
73 foreach($date_array as $date_item)
75 print '<tr>';
76 print '<td><strong>'.$i.'</strong></td>';
77 print '<td>';
78 if ($type == 'aircraft') print '<a href="'.$globalURL.'/date/'.date('Y-m-d',strtotime($date_item['date_name'])).'">'.date("l F j, Y", strtotime($date_item['date_name'])).'</a>';
79 else print '<a href="'.$globalURL.'/'.$type.'/date/'.date('Y-m-d',strtotime($date_item['date_name'])).'">'.date("l F j, Y", strtotime($date_item['date_name'])).'</a>';
80 print '</td>';
81 print '<td>';
82 print $date_item['date_count'];
83 print '</td>';
84 print '</tr>';
85 $i++;
87 print '<tbody>';
88 print '</table>';
89 print '</div>';
92 require_once('footer.php');