From 6dcdcca0bf18a9c2173c2fcc12b715c51521ae08 Mon Sep 17 00:00:00 2001 From: AndreasK79 Date: Fri, 24 Apr 2020 23:29:01 +0200 Subject: [PATCH] Added statistics for number of days qrv each year. --- application/controllers/Dayswithqso.php | 38 +++++++++++++++++ application/models/Dayswithqso_model.php | 27 ++++++++++++ application/views/dayswithqso/index.php | 33 +++++++++++++++ application/views/interface_assets/footer.php | 41 +++++++++++++++++++ application/views/interface_assets/header.php | 2 + 5 files changed, 141 insertions(+) create mode 100644 application/controllers/Dayswithqso.php create mode 100644 application/models/Dayswithqso_model.php create mode 100644 application/views/dayswithqso/index.php diff --git a/application/controllers/Dayswithqso.php b/application/controllers/Dayswithqso.php new file mode 100644 index 00000000..32acd8d9 --- /dev/null +++ b/application/controllers/Dayswithqso.php @@ -0,0 +1,38 @@ +load->model('user_model'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + } + + public function index() + { + $this->load->model('dayswithqso_model'); + // Render Page + $data['page_title'] = "Number of days with QSOs each year"; + + $data['result'] = $this->dayswithqso_model->getDaysWithQso(); + + $this->load->view('interface_assets/header', $data); + $this->load->view('dayswithqso/index'); + $this->load->view('interface_assets/footer'); + } + + public function get_days(){ + + //load model + $this->load->model('dayswithqso_model'); + + // get data + $data = $this->dayswithqso_model->getDaysWithQso(); + header('Content-Type: application/json'); + echo json_encode($data); + } + +} \ No newline at end of file diff --git a/application/models/Dayswithqso_model.php b/application/models/Dayswithqso_model.php new file mode 100644 index 00000000..f5941ed5 --- /dev/null +++ b/application/models/Dayswithqso_model.php @@ -0,0 +1,27 @@ +load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $sql = "select year(col_qso_date) Year, count(distinct col_qso_date) Days from " + .$this->config->item('table_name'). " thcv + where station_id = " . $station_id . " and col_qso_date is not null group by year"; + + $query = $this->db->query($sql); + + return $query->result(); + } + +} \ No newline at end of file diff --git a/application/views/dayswithqso/index.php b/application/views/dayswithqso/index.php new file mode 100644 index 00000000..8f7bc49b --- /dev/null +++ b/application/views/dayswithqso/index.php @@ -0,0 +1,33 @@ +
+ +
+ +

+ + '; + + echo ''; + echo ''; + + foreach ($result as $master) { + echo ''; + } + + echo ''; + + echo ''; + echo ''; + + foreach ($result as $master) { + echo ''; + } + + echo ''; + + echo '
Year' . $master->Year . '
Days' . $master->Days . '
'; + } + ?> + + diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index b1cd656f..e8ad1670 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1013,6 +1013,47 @@ $(document).ready(function(){ +uri->segment(1) == "dayswithqso") { ?> + + + + uri->segment(1) == "distances") { ?>