diff --git a/application/controllers/statistics.php b/application/controllers/statistics.php index a9d633d4..61101a7c 100644 --- a/application/controllers/statistics.php +++ b/application/controllers/statistics.php @@ -36,6 +36,8 @@ class Statistics extends CI_Controller { $data['page_title'] = "Statistics"; $data['total_digi'] = $this->logbook_model->total_digi(); + + $data['totals_year'] = $this->logbook_model->totals_year(); $data['page_title'] = "Statistics"; diff --git a/application/models/logbook_model.php b/application/models/logbook_model.php index 4279149e..0b1b922e 100644 --- a/application/models/logbook_model.php +++ b/application/models/logbook_model.php @@ -309,15 +309,23 @@ class Logbook_model extends CI_Model { return $query; } - function get_todays_qsos() { + function get_todays_qsos() { + $morning = date('Y-m-d 00:00:00'); + $night = date('Y-m-d 23:59:59'); + $query = $this->db->query('SELECT * FROM '.$this->config->item('table_name').' WHERE COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); + return $query; + } - $morning = date('Y-m-d 00:00:00'); - $night = date('Y-m-d 23:59:59'); - $query = $this->db->query('SELECT * FROM '.$this->config->item('table_name').' WHERE COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); - - return $query; - } - + function totals_year() { + $query = $this->db->query(' + SELECT DATE_FORMAT(COL_TIME_ON, \'%Y\') as \'year\', + COUNT(COL_PRIMARY_KEY) as \'total\' + FROM '.$this->config->item('table_name').' + GROUP BY DATE_FORMAT(COL_TIME_ON, \'%Y\') + '); + return $query; + } + /* Return total number of qsos */ function total_qsos() { $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').''); diff --git a/application/views/statistics/index.php b/application/views/statistics/index.php index 558521f3..dead1024 100644 --- a/application/views/statistics/index.php +++ b/application/views/statistics/index.php @@ -73,6 +73,27 @@ } +