From 2554e097a35bf0cae18e73e46974359298c567ba Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Sat, 2 Aug 2025 22:48:28 +0100 Subject: [PATCH] Revert "Fix Hamsat VUCC grids issue - improve grid checking logic for satellite QSOs" This reverts commit 341abf97e65d332883771c082c7c9261bfd61646, reversing changes made to a449c07098dc49725ea00a5b2aba0349e9313ce3. --- application/models/Logbook_model.php | 50 ++++------------------------ 1 file changed, 7 insertions(+), 43 deletions(-) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 8325fa68..0b7e394d 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -2075,60 +2075,24 @@ class Logbook_model extends CI_Model $logbooks_locations_array = $StationLocationsArray; } - $grid_4char = substr(strtoupper($grid), 0, 4); - - // First check COL_GRIDSQUARE for exact match $this->db->select('COL_GRIDSQUARE'); $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('UPPER(SUBSTRING(COL_GRIDSQUARE, 1, 4))', $grid_4char); + $this->db->group_start(); + $this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($grid, 0, 4)); + $this->db->or_like('SUBSTRING(COL_VUCC_GRIDS, 1, 4)', substr($grid, 0, 4)); + $this->db->group_end(); if ($band != null && $band != 'SAT') { $this->db->where('COL_BAND', $band); } else if ($band == 'SAT') { + // Where col_sat_name is not empty $this->db->where('COL_SAT_NAME !=', ''); } - $this->db->limit('1'); + $this->db->limit('2'); $query = $this->db->get($this->config->item('table_name')); - - if ($query->num_rows() > 0) { - return $query->num_rows(); - } - - // If not found in COL_GRIDSQUARE, check COL_VUCC_GRIDS - $this->db->select('COL_VUCC_GRIDS'); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_VUCC_GRIDS IS NOT NULL'); - $this->db->where('COL_VUCC_GRIDS !=', ''); - if ($band != null && $band != 'SAT') { - $this->db->where('COL_BAND', $band); - } else if ($band == 'SAT') { - $this->db->where('COL_SAT_NAME !=', ''); - } - - $vucc_query = $this->db->get($this->config->item('table_name')); - - // Check each VUCC grids field manually - foreach ($vucc_query->result_array() as $row) { - if (!empty($row['COL_VUCC_GRIDS'])) { - $grids = explode(",", $row['COL_VUCC_GRIDS']); - foreach ($grids as $vucc_grid) { - $vucc_grid = trim($vucc_grid); - if (strlen($vucc_grid) >= 4) { - $vucc_grid_4char = strtoupper(substr($vucc_grid, 0, 4)); - // Only match if: - // 1. The first 4 characters match, AND - // 2. The VUCC grid is either exactly 4 chars OR exactly 6 chars (valid grid formats) - if ($vucc_grid_4char === $grid_4char && (strlen($vucc_grid) == 4 || strlen($vucc_grid) == 6)) { - return 1; - } - } - } - } - } - - return 0; + return $query->num_rows(); }