From 68c8b3889ccc594bcabc60a5fcd55a7ecf360eeb Mon Sep 17 00:00:00 2001 From: Andreas Date: Fri, 16 Oct 2020 20:02:54 +0200 Subject: [PATCH 1/2] Fixed a couple of bugs in countries breakdown on dashboard. --- application/controllers/Dashboard.php | 15 +++++++--- application/models/Dxcc.php | 12 ++++++++ application/models/Logbook_model.php | 40 +++++++++++++++++++++------ application/views/dashboard/index.php | 10 +++---- 4 files changed, 59 insertions(+), 18 deletions(-) diff --git a/application/controllers/Dashboard.php b/application/controllers/Dashboard.php index 6c0a773e..2d868c50 100644 --- a/application/controllers/Dashboard.php +++ b/application/controllers/Dashboard.php @@ -50,10 +50,10 @@ class Dashboard extends CI_Controller { $data['month_qsos'] = $this->logbook_model->month_qsos(); $data['year_qsos'] = $this->logbook_model->year_qsos(); - $data['total_countrys'] = $this->logbook_model->total_countrys(); - $data['total_countrys_confirmed_paper'] = $this->logbook_model->total_countrys_confirmed_paper(); - $data['total_countrys_confirmed_eqsl'] = $this->logbook_model->total_countrys_confirmed_eqsl(); - $data['total_countrys_confirmed_lotw'] = $this->logbook_model->total_countrys_confirmed_lotw(); + $data['total_countries'] = $this->logbook_model->total_countries(); + $data['total_countries_confirmed_paper'] = $this->logbook_model->total_countries_confirmed_paper(); + $data['total_countries_confirmed_eqsl'] = $this->logbook_model->total_countries_confirmed_eqsl(); + $data['total_countries_confirmed_lotw'] = $this->logbook_model->total_countries_confirmed_lotw(); $data['total_qsl_sent'] = $this->logbook_model->total_qsl_sent(); $data['total_qsl_recv'] = $this->logbook_model->total_qsl_recv(); @@ -63,6 +63,13 @@ class Dashboard extends CI_Controller { $data['page_title'] = "Dashboard"; + $this->load->model('dxcc'); + $dxcc = $this->dxcc->list_current(); + + $current = $this->logbook_model->total_countries_current(); + + $data['total_countries_needed'] = count($dxcc->result()) - $current; + $this->load->view('interface_assets/header', $data); $this->load->view('dashboard/index'); $this->load->view('interface_assets/footer'); diff --git a/application/models/Dxcc.php b/application/models/Dxcc.php index 217b578d..4e0f98f9 100644 --- a/application/models/Dxcc.php +++ b/application/models/Dxcc.php @@ -168,11 +168,23 @@ class DXCC extends CI_Model { $this->db->empty_table($table); } + /* + * Fethes a list of all dxcc's, both current and deleted + */ function list() { $this->db->order_by('name', 'ASC'); return $this->db->get('dxcc_entities'); } + /* + * Fetches a list of all current dxcc's (non-deleted) + */ + function list_current() { + $this->db->where('end', null); + $this->db->order_by('name', 'ASC'); + return $this->db->get('dxcc_entities'); + } + function get_dxcc_array($dxccArray, $bands, $postdata) { $CI =& get_instance(); $CI->load->model('Stations'); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 745fdcbc..6a62fe81 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1226,19 +1226,41 @@ class Logbook_model extends CI_Model { } } - /* Return total number of countrys worked */ - function total_countrys() { + /* Return total number of countries worked */ + function total_countries() { $CI =& get_instance(); $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); - $query = $this->db->query('SELECT DISTINCT (COL_COUNTRY) FROM '.$this->config->item('table_name').' WHERE COL_COUNTRY != "Invalid" AND station_id = '.$station_id.''); + $sql = 'SELECT DISTINCT (COL_COUNTRY) FROM '.$this->config->item('table_name').' + WHERE COL_COUNTRY != "Invalid" + AND col_dxcc > 0 + AND station_id = '.$station_id ; + + $query = $this->db->query($sql); return $query->num_rows(); } - /* Return total number of countrys confirmed with paper QSL */ - function total_countrys_confirmed_paper() { + /* Return total number of countries worked */ + function total_countries_current() { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $sql = 'SELECT DISTINCT (COL_COUNTRY) FROM '.$this->config->item('table_name').' thcv + join dxcc_entities on thcv.col_dxcc = dxcc_entities.adif + WHERE COL_COUNTRY != "Invalid" + AND dxcc_entities.end is null + AND station_id = '.$station_id; + + $query = $this->db->query($sql); + + return $query->num_rows(); + } + + /* Return total number of countries confirmed with paper QSL */ + function total_countries_confirmed_paper() { $CI =& get_instance(); $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); @@ -1248,8 +1270,8 @@ class Logbook_model extends CI_Model { return $query->num_rows(); } - /* Return total number of countrys confirmed with eQSL */ - function total_countrys_confirmed_eqsl() { + /* Return total number of countries confirmed with eQSL */ + function total_countries_confirmed_eqsl() { $CI =& get_instance(); $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); @@ -1259,8 +1281,8 @@ class Logbook_model extends CI_Model { return $query->num_rows(); } - /* Return total number of countrys confirmed with LoTW */ - function total_countrys_confirmed_lotw() { + /* Return total number of countries confirmed with LoTW */ + function total_countries_confirmed_lotw() { $CI =& get_instance(); $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); diff --git a/application/views/dashboard/index.php b/application/views/dashboard/index.php index 637ca3c2..08603d66 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -119,20 +119,20 @@ lang->line('general_word_worked'); ?> - + lang->line('general_word_confirmed'); ?> - / - / - + / + / + lang->line('general_word_needed'); ?> - + From a58c91344900cf621fc3cbe2054868746a6d2109 Mon Sep 17 00:00:00 2001 From: Andreas Date: Fri, 16 Oct 2020 20:11:45 +0200 Subject: [PATCH 2/2] Fix for DXCC count on qsl/eqsl/lotw on dashboard. --- application/models/Logbook_model.php | 22 ++++++++++++++++--- application/views/view_log/partial/log.php | 2 +- .../views/view_log/partial/log_ajax.php | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 6a62fe81..74c96547 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1265,7 +1265,12 @@ class Logbook_model extends CI_Model { $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); - $query = $this->db->query('SELECT DISTINCT (COL_COUNTRY) FROM '.$this->config->item('table_name').' WHERE COL_COUNTRY != "Invalid" AND station_id = '.$station_id.' AND COL_QSL_RCVD =\'Y\''); + $sql = 'SELECT DISTINCT (COL_COUNTRY) FROM '.$this->config->item('table_name').' + WHERE COL_COUNTRY != "Invalid" + AND COL_DXCC > 0 + AND station_id = '.$station_id.' AND COL_QSL_RCVD =\'Y\''; + + $query = $this->db->query($sql); return $query->num_rows(); } @@ -1276,7 +1281,12 @@ class Logbook_model extends CI_Model { $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); - $query = $this->db->query('SELECT DISTINCT (COL_COUNTRY) FROM '.$this->config->item('table_name').' WHERE COL_COUNTRY != "Invalid" AND station_id = '.$station_id.' AND COL_EQSL_QSL_RCVD =\'Y\''); + $sql = 'SELECT DISTINCT (COL_COUNTRY) FROM '.$this->config->item('table_name').' + WHERE COL_COUNTRY != "Invalid" + AND COL_DXCC > 0 + AND station_id = '.$station_id.' AND COL_EQSL_QSL_RCVD =\'Y\''; + + $query = $this->db->query($sql); return $query->num_rows(); } @@ -1287,7 +1297,13 @@ class Logbook_model extends CI_Model { $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); - $query = $this->db->query('SELECT DISTINCT (COL_COUNTRY) FROM '.$this->config->item('table_name').' WHERE COL_COUNTRY != "Invalid" AND station_id = '.$station_id.' AND COL_LOTW_QSL_RCVD =\'Y\''); + $sql = 'SELECT DISTINCT (COL_COUNTRY) FROM '.$this->config->item('table_name').' + WHERE COL_COUNTRY != "Invalid" + AND COL_DXCC > 0 + AND station_id = '.$station_id.' + AND COL_LOTW_QSL_RCVD =\'Y\''; + + $query = $this->db->query($sql); return $query->num_rows(); } diff --git a/application/views/view_log/partial/log.php b/application/views/view_log/partial/log.php index 272e3944..b21ef4aa 100644 --- a/application/views/view_log/partial/log.php +++ b/application/views/view_log/partial/log.php @@ -1,5 +1,5 @@
- +
config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> diff --git a/application/views/view_log/partial/log_ajax.php b/application/views/view_log/partial/log_ajax.php index 1b895f79..6532976e 100644 --- a/application/views/view_log/partial/log_ajax.php +++ b/application/views/view_log/partial/log_ajax.php @@ -1,5 +1,5 @@
-
Date
+
config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?>
Date