From 82a39a5667c42309c20368d4ed790dfac288be57 Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 26 Jan 2022 09:18:29 +0100 Subject: [PATCH 1/2] Sort DOK by default and add type selection form --- application/controllers/Awards.php | 7 ++++- application/models/Api_model.php | 2 +- application/models/Dok.php | 16 ++++++----- application/views/awards/dok/index.php | 27 +++++++++++++++++++ application/views/interface_assets/footer.php | 2 +- 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 32bb4177..5c7d0d82 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -30,7 +30,12 @@ class Awards extends CI_Controller { $this->load->model('dok'); $this->load->model('bands'); - $data['doks'] = $this->dok->show_stats(); + if($this->input->method() === 'post') { + $postdata['doks'] = $this->input->post('doks'); + } else { + $postdata['doks'] = 'both'; + } + $data['doks'] = $this->dok->show_stats($postdata); $data['worked_bands'] = $this->bands->get_worked_bands_dok(); // Used in the view for band select diff --git a/application/models/Api_model.php b/application/models/Api_model.php index 747e1d47..93b8776e 100644 --- a/application/models/Api_model.php +++ b/application/models/Api_model.php @@ -415,7 +415,7 @@ class API_Model extends CI_Model { 'COL_CONTEST_ID' => array('Name' => 'ContestID', 'Description' => '', 'Type' => ''), 'COL_COUNTRY' => array('Name' => 'Country', 'Description' => '', 'Type' => ''), 'COL_CQZ' => array('Name' => 'CQZone', 'Description' => '', 'Type' => ''), - 'COL_DARC_DOK' => array('Name' => 'Dok', 'Description' => '', 'Type' => ''), + 'COL_DARC_DOK' => array('Name' => 'DOK', 'Description' => '', 'Type' => ''), 'COL_DISTANCE' => array('Name' => 'Distance', 'Description' => '', 'Type' => ''), 'COL_DXCC' => array('Name' => 'DXCC', 'Description' => '', 'Type' => ''), 'COL_EMAIL' => array('Name' => 'EMail', 'Description' => '', 'Type' => ''), diff --git a/application/models/Dok.php b/application/models/Dok.php index 3ebef32f..50a4a265 100644 --- a/application/models/Dok.php +++ b/application/models/Dok.php @@ -2,7 +2,7 @@ class DOK extends CI_Model { - function show_stats() { + function show_stats($postdata) { $CI =& get_instance(); $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -14,12 +14,16 @@ class DOK extends CI_Model { $this->load->model('bands'); $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $sql = "select upper(COL_DARC_DOK) as COL_DARC_DOK, COL_MODE, lcase(COL_BAND) as COL_BAND, count(COL_DARC_DOK) as cnt from ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ") AND COL_DARC_DOK IS NOT NULL AND COL_DARC_DOK != '' AND COL_DXCC = 230"; + if ($postdata['doks'] == 'dok') { + $sql .= " AND REGEXP_LIKE (COL_DARC_DOK, '^[A-Z][0-9]{2}$')"; + } else if ($postdata['doks'] == 'sdok') { + $sql .= " AND NOT REGEXP_LIKE (COL_DARC_DOK, '^[A-Z][0-9]{2}$')"; + } + $sql .= " group by COL_DARC_DOK, COL_MODE, COL_BAND"; + $sql .= " order by COL_DARC_DOK asc"; - $data = $this->db->query( - "select upper(COL_DARC_DOK) as COL_DARC_DOK, COL_MODE, lcase(COL_BAND) as COL_BAND, count(COL_DARC_DOK) as cnt - from ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ") AND COL_DARC_DOK IS NOT NULL AND COL_DARC_DOK != '' AND COL_DXCC = 230 - group by COL_DARC_DOK, COL_MODE, COL_BAND" - ); + $data = $this->db->query($sql); $results = array(); $last_dok = ""; diff --git a/application/views/awards/dok/index.php b/application/views/awards/dok/index.php index 6db1c9ef..2ec5a8b5 100644 --- a/application/views/awards/dok/index.php +++ b/application/views/awards/dok/index.php @@ -2,6 +2,33 @@

+
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+
Date: Wed, 26 Jan 2022 10:21:08 +0100 Subject: [PATCH 2/2] Make formatting a little nicer --- application/views/awards/dok/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/views/awards/dok/index.php b/application/views/awards/dok/index.php index 2ec5a8b5..aed9a0aa 100644 --- a/application/views/awards/dok/index.php +++ b/application/views/awards/dok/index.php @@ -39,7 +39,7 @@ $slot\n"; + echo " \n"; } ?> @@ -51,9 +51,9 @@ foreach($val as $band=>$count){ if (in_array($band, $worked_bands)) { if ($count == 0){ - print(""); + print(""); }else{ - printf("", str_replace("&", "%26", $dok), $band, $count); + printf("", str_replace("&", "%26", $dok), $band, $count); } } }
DOKs () $slot
  %d%d