From fddc03b4ef7dcc20381f28f304f51258a8ab8fa9 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 24 Aug 2021 20:10:07 +0200 Subject: [PATCH] [QSLPrint] Bugfix for exporting ADIF and CSV when all is selected in Station Location --- application/controllers/Qslprint.php | 8 ++++---- application/models/Adif_data.php | 2 +- application/models/Logbook_model.php | 24 +++++++++++------------- application/views/qslprint/index.php | 2 ++ application/views/qslprint/qslprint.php | 2 ++ 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/application/controllers/Qslprint.php b/application/controllers/Qslprint.php index 3de67e65..5c4391e2 100644 --- a/application/controllers/Qslprint.php +++ b/application/controllers/Qslprint.php @@ -35,8 +35,8 @@ class QSLPrint extends CI_Controller { // Set memory limit to unlimited to allow heavy usage ini_set('memory_limit', '-1'); - if ($this->uri->segment(3) == 'All') { - $station_id = NULL; + if ($this->uri->segment(3) == 'all') { + $station_id = 'All'; } else { $station_id = $this->security->xss_clean($this->uri->segment(3)); } @@ -53,8 +53,8 @@ class QSLPrint extends CI_Controller { // Set memory limit to unlimited to allow heavy usage ini_set('memory_limit', '-1'); - if ($this->uri->segment(3) == 'All') { - $station_id = NULL; + if ($this->uri->segment(3) == 'all') { + $station_id = 'All'; } else { $station_id = $this->security->xss_clean($this->uri->segment(3)); } diff --git a/application/models/Adif_data.php b/application/models/Adif_data.php index 21774729..deaa9ea4 100644 --- a/application/models/Adif_data.php +++ b/application/models/Adif_data.php @@ -25,7 +25,7 @@ class adif_data extends CI_Model { if ($station_id == NULL) { $this->db->where($this->config->item('table_name').'.station_id', $active_station_id); - } else { + } else if ($station_id != 'All') { $this->db->where($this->config->item('table_name').'.station_id', $station_id); } diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 886f7633..b13f741a 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -776,23 +776,21 @@ class Logbook_model extends CI_Model { COL_SAT_MODE, COL_QSL_RCVD, COL_COMMENT, - (CASE WHEN COL_QSL_VIA != \'\' THEN COL_QSL_VIA ELSE COL_CALL END) AS COL_ROUTING, - ADIF, - ENTITY - FROM '.$this->config->item('table_name').', dxcc_prefixes, station_profile - WHERE - COL_QSL_SENT in (\'R\', \'Q\') - and (CASE WHEN COL_QSL_VIA != \'\' THEN COL_QSL_VIA ELSE COL_CALL END) like CONCAT(dxcc_prefixes.call,\'%\') - and (end is null or end > now()) - and ' . $this->config->item('table_name') . '.station_id = station_profile.station_id'; + (select adif from dxcc_prefixes where (CASE WHEN COL_QSL_VIA != \'\' THEN COL_QSL_VIA ELSE COL_CALL END) like concat(dxcc_prefixes.`call`,\'%\') order by end limit 1) as ADIF, + (select entity from dxcc_prefixes where (CASE WHEN COL_QSL_VIA != \'\' THEN COL_QSL_VIA ELSE COL_CALL END) like concat(dxcc_prefixes.`call`,\'%\') order by end limit 1) as ENTITY, + (CASE WHEN COL_QSL_VIA != \'\' THEN COL_QSL_VIA ELSE COL_CALL END) AS COL_ROUTING + FROM '.$this->config->item('table_name').' thcv + join station_profile on thcv.station_id = station_profile.station_id + WHERE + COL_QSL_SENT in (\'R\', \'Q\')'; if ($station_id2 == NULL) { - $sql .= ' and ' . $this->config->item('table_name') . '.station_id = ' . $station_id; - } else { - $sql .= ' and ' . $this->config->item('table_name') . '.station_id = ' . $station_id2; + $sql .= ' and thcv.station_id = ' . $station_id; + } else if ($station_id2 != 'All') { + $sql .= ' and thcv.station_id = ' . $station_id2; } - $sql .= ' ORDER BY adif, col_routing'; + $sql .= ' ORDER BY ADIF, COL_ROUTING'; $query = $this->db->query($sql); return $query; diff --git a/application/views/qslprint/index.php b/application/views/qslprint/index.php index dbbc9a98..b8250c57 100644 --- a/application/views/qslprint/index.php +++ b/application/views/qslprint/index.php @@ -40,6 +40,7 @@