From 690ee4dcb4dbf4ccd472ba9632431834b0a774a5 Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 25 Oct 2020 14:59:03 +0100 Subject: [PATCH 1/3] Enhanced VUCC award to also see only confirmed or worked gridsquares. The worked gridsquares has the calls in the table. --- application/controllers/Awards.php | 4 +- application/models/Logbook_model.php | 17 +--- application/models/Vucc.php | 108 ++++++++++++++++++++---- application/views/awards/vucc/band.php | 35 +++++--- application/views/awards/vucc/index.php | 4 +- 5 files changed, 123 insertions(+), 45 deletions(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 6b5364fc..c24695a5 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -164,7 +164,9 @@ class Awards extends CI_Controller { public function vucc_band(){ $this->load->model('vucc'); $band = str_replace('"', "", $this->input->get("Band")); - $data['vucc_array'] = $this->vucc->vucc_details($band); + $type = str_replace('"', "", $this->input->get("Type")); + $data['vucc_array'] = $this->vucc->vucc_details($band, $type); + $data['type'] = $type; // Render Page $data['page_title'] = "VUCC - band"; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 53464389..db2100d1 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -232,19 +232,10 @@ class Logbook_model extends CI_Model { $CI =& get_instance(); $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); - $sql = "select * from " . $this->config->item('table_name') . " where station_id =" . $station_id . " and col_gridsquare like '" . $gridsquare. "%'"; - - if ($band != 'All') { - if ($band == 'SAT') { - $sql .= " and col_prop_mode ='" . $band . "'"; - } else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and col_band ='" . $band . "'"; - } - } - - $sql .= " union "; - $sql .= "select * from " . $this->config->item('table_name') . " where station_id =" . $station_id . " and col_vucc_grids like '%" . $gridsquare. "%'"; + $sql = "select * from " . $this->config->item('table_name') . + " where station_id =" . $station_id . + " and (col_gridsquare like '" . $gridsquare. "%' + or col_vucc_grids like '%" . $gridsquare. "%')"; if ($band != 'All') { if ($band == 'SAT') { diff --git a/application/models/Vucc.php b/application/models/Vucc.php index 34f54990..732bc4fe 100644 --- a/application/models/Vucc.php +++ b/application/models/Vucc.php @@ -164,7 +164,7 @@ class VUCC extends CI_Model $sql = "select col_vucc_grids from " . $this->config->item('table_name') . " where station_id =" . $station_id . - " and (LENGTH(col_vucc_grids) > 0) "; + " and col_vucc_grids <> '' "; if ($confirmationMethod == 'both') { $sql .= " and (col_qsl_rcvd='Y' or col_lotw_qsl_rcvd='Y')"; @@ -199,7 +199,7 @@ class VUCC extends CI_Model $sql = "select distinct upper(substring(col_gridsquare, 1, 4)) gridsquare from " . $this->config->item('table_name') . " where station_id =" . $station_id . - " and (LENGTH(col_gridsquare) > 0)"; + " and col_gridsquare <> ''"; if ($confirmationMethod == 'both') { $sql .= " and (col_qsl_rcvd='Y' or col_lotw_qsl_rcvd='Y')"; @@ -228,27 +228,81 @@ class VUCC extends CI_Model /* * Makes a list of all gridsquares on chosen band with info about lotw and qsl */ - function vucc_details($band) { - $col_gridsquare_worked = $this->get_vucc_summary($band, 'none'); + function vucc_details($band, $type) { - $workedGridArray = array(); - foreach ($col_gridsquare_worked as $workedgrid) { - array_push($workedGridArray, $workedgrid['gridsquare']); + if ($type == 'worked') { + $workedGridArray = $this->getWorkedGridsList($band, 'none'); + $vuccBand = $this->removeConfirmedGrids($band, $workedGridArray); + } else if ($type == 'confirmed') { + $workedGridArray = $this->getWorkedGridsList($band, 'both'); + $vuccBand = $this->markConfirmedGrids($band, $workedGridArray); + } else { + $workedGridArray = $this->getWorkedGridsList($band, 'none'); + $vuccBand = $this->markConfirmedGrids($band, $workedGridArray); } - $col_vucc_grids_worked = $this->get_vucc_summary_col_vucc($band, 'none'); + if (count($vuccBand) == 0) { + return 0; + } else { + ksort($vuccBand); + return $vuccBand; + } + } - foreach ($col_vucc_grids_worked as $gridSplit) { + function removeConfirmedGrids($band, $workedGridArray) { + $vuccDataQsl = $this->get_vucc_summary($band, 'qsl'); + + foreach ($vuccDataQsl as $grid) { + if (($key = array_search($grid['gridsquare'], $workedGridArray)) !== false) { + unset($workedGridArray[$key]); + } + } + + $vuccDataLotw = $this->get_vucc_summary($band, 'lotw'); + + foreach ($vuccDataLotw as $grid) { + if (($key = array_search($grid['gridsquare'], $workedGridArray)) !== false) { + unset($workedGridArray[$key]); + } + } + + $col_vucc_grids_confirmed_qsl = $this->get_vucc_summary_col_vucc($band, 'lotw'); + + foreach ($col_vucc_grids_confirmed_qsl as $gridSplit) { $grids = explode(",", $gridSplit['col_vucc_grids']); foreach($grids as $key) { $grid_four = strtoupper(substr(trim($key),0,4)); - - if(!in_array($grid_four, $workedGridArray)){ - array_push($workedGridArray, $grid_four); + if (($key = array_search($grid_four, $workedGridArray)) !== false) { + unset($workedGridArray[$key]); } } } + $col_vucc_grids_confirmed_lotw = $this->get_vucc_summary_col_vucc($band, 'qsl'); + + foreach ($col_vucc_grids_confirmed_lotw as $gridSplit) { + $grids = explode(",", $gridSplit['col_vucc_grids']); + foreach($grids as $key) { + $grid_four = strtoupper(substr(trim($key),0,4)); + if (($key = array_search($grid_four, $workedGridArray)) !== false) { + unset($workedGridArray[$key]); + } + } + } + foreach ($workedGridArray as $grid) { + $this->load->model('logbook_model'); + $result = $this->logbook_model->vucc_qso_details($grid, $band); + $callsignlist = ''; + foreach($result->result() as $call) { + $callsignlist .= $call->COL_CALL . ' '; + } + $vuccBand[$grid]['call'] = $callsignlist; + } + + return $vuccBand; + } + + function markConfirmedGrids($band, $workedGridArray) { foreach ($workedGridArray as $grid) { $vuccBand[$grid]['qsl'] = ''; $vuccBand[$grid]['lotw'] = ''; @@ -286,12 +340,32 @@ class VUCC extends CI_Model } } - if (count($vuccBand) == 0) { - return 0; - } else { - ksort($vuccBand); - return $vuccBand; + return $vuccBand; + } + + function getWorkedGridsList($band, $confirmationMethod) { + + $col_gridsquare_worked = $this->get_vucc_summary($band, $confirmationMethod); + + $workedGridArray = array(); + foreach ($col_gridsquare_worked as $workedgrid) { + array_push($workedGridArray, $workedgrid['gridsquare']); } + + $col_vucc_grids_worked = $this->get_vucc_summary_col_vucc($band, $confirmationMethod); + + foreach ($col_vucc_grids_worked as $gridSplit) { + $grids = explode(",", $gridSplit['col_vucc_grids']); + foreach($grids as $key) { + $grid_four = strtoupper(substr(trim($key),0,4)); + + if(!in_array($grid_four, $workedGridArray)){ + array_push($workedGridArray, $grid_four); + } + } + } + + return $workedGridArray; } function get_station_id() { diff --git a/application/views/awards/vucc/band.php b/application/views/awards/vucc/band.php index fd724266..498b9272 100644 --- a/application/views/awards/vucc/band.php +++ b/application/views/awards/vucc/band.php @@ -9,24 +9,35 @@ # - Gridsquare - QSL - LoTW - + Gridsquare'; + + if ($type != 'worked') { + echo 'QSL + LoTW'; + } else { + echo 'Call'; + } + echo ' '; - foreach ($vucc_array as $vucc => $value) { // Fills the table with the data - echo ' + foreach ($vucc_array as $vucc => $value) { // Fills the table with the data + echo ' '. $i++ .' - '. $vucc .' - '. $value['qsl'] . ' - '. $value['lotw'] .' - '; + '. $vucc .''; + + if ($type != 'worked') { + echo ''. $value['qsl'] . ' + '. $value['lotw'] .''; + } else { + echo ''. $value['call'] .''; + } + + echo ''; } - echo ''; + echo ''; } else { echo ''; } - ?> \ No newline at end of file + ?> diff --git a/application/views/awards/vucc/index.php b/application/views/awards/vucc/index.php index bf605056..d88f8b27 100644 --- a/application/views/awards/vucc/index.php +++ b/application/views/awards/vucc/index.php @@ -13,8 +13,8 @@ $vucc) { echo ''; echo ''. $band .''; - echo '' . $vucc['worked'] . ''; - echo '' . $vucc['confirmed'] . ''; + echo ''. $vucc['worked'] .''; + echo ''. $vucc['confirmed'] .''; echo ''; } ?> From 5a380a2cf15750366b8b1358a3342d56a4d6a92c Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 25 Oct 2020 15:17:06 +0100 Subject: [PATCH 2/3] Added migration file for index on col_gridsquare and col_vucc_grids to speed up VUCC award a bit. --- application/config/migration.php | 2 +- .../migrations/053_gridsquare_index.php | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 application/migrations/053_gridsquare_index.php diff --git a/application/config/migration.php b/application/config/migration.php index 70841b48..9b82e009 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 52; +$config['migration_version'] = 53; /* |-------------------------------------------------------------------------- diff --git a/application/migrations/053_gridsquare_index.php b/application/migrations/053_gridsquare_index.php new file mode 100644 index 00000000..94610e01 --- /dev/null +++ b/application/migrations/053_gridsquare_index.php @@ -0,0 +1,24 @@ +config->item('table_name') . " (COL_GRIDSQUARE)"; + $this->db->query($sql); + + $sql = "CREATE INDEX HRD_IDX_COL_VUCC_GRIDS USING BTREE ON " . $this->config->item('table_name') ." (COL_VUCC_GRIDS)"; + $this->db->query($sql); + } + + public function down() + { + $sql = "ALTER TABLE " . $this->config->item('table_name') . " DROP INDEX HRD_IDX_COL_GRIDSQUARE"; + $this->db->query($sql); + + $sql = "ALTER TABLE " . $this->config->item('table_name') . " DROP INDEX HRD_IDX_COL_VUCC_GRIDS"; + $this->db->query($sql); + } +} \ No newline at end of file From 0ff51dfd4dccaa52fed74446794b9dc674311feb Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 25 Oct 2020 17:46:39 +0100 Subject: [PATCH 3/3] Added a line break here. Find it visually much more appealing in the table with one call on each line. --- application/models/Vucc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/models/Vucc.php b/application/models/Vucc.php index 732bc4fe..ddbb40b5 100644 --- a/application/models/Vucc.php +++ b/application/models/Vucc.php @@ -294,7 +294,7 @@ class VUCC extends CI_Model $result = $this->logbook_model->vucc_qso_details($grid, $band); $callsignlist = ''; foreach($result->result() as $call) { - $callsignlist .= $call->COL_CALL . ' '; + $callsignlist .= $call->COL_CALL . '
'; } $vuccBand[$grid]['call'] = $callsignlist; }