From 48a8f6853db79032b4497a7d562d48edb359f2ec Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 27 Jun 2025 10:28:17 +0200 Subject: [PATCH] allow for emptying grid in LBA edit function --- application/models/Logbookadvanced_model.php | 40 +++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index 8385562d8..eecd5d4a3 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -849,26 +849,30 @@ class Logbookadvanced_model extends CI_Model { $query = $this->db->query($sql, array($value, $value2, $frequencyBand, $frequencyBandRx, json_decode($ids, true), $this->session->userdata('user_id'))); } else if ($column == 'COL_GRIDSQUARE') { - if(!$this->load->is_loaded('Qra')) { - $this->load->library('Qra'); - } - $latlng=$this->qra->qra2latlong(trim(xss_clean($value) ?? '')); - if ($latlng[1] ?? '--' != '--') { - if (strpos(trim(xss_clean($value) ?? ''), ',') !== false) { - $grid_value = null; - $vucc_value = strtoupper(preg_replace('/\s+/', '', xss_clean($value) ?? '')); - } else { - $vucc_value = null; - $grid_value = strtoupper(trim(xss_clean($value) ?? '')); + if ($value == '') { + $grid_value = null; + $vucc_value = null; + } else { + if(!$this->load->is_loaded('Qra')) { + $this->load->library('Qra'); + } + $latlng=$this->qra->qra2latlong(trim(xss_clean($value) ?? '')); + if ($latlng[1] ?? '--' != '--') { + if (strpos(trim(xss_clean($value) ?? ''), ',') !== false) { + $grid_value = null; + $vucc_value = strtoupper(preg_replace('/\s+/', '', xss_clean($value) ?? '')); + } else { + $vucc_value = null; + $grid_value = strtoupper(trim(xss_clean($value) ?? '')); + } + } - - $sql = "UPDATE ".$this->config->item('table_name')." JOIN station_profile ON ". $this->config->item('table_name').".station_id = station_profile.station_id" . - " SET " . $this->config->item('table_name').".COL_GRIDSQUARE = ?" . - ", " . $this->config->item('table_name').".COL_VUCC_GRIDS = ?" . - " WHERE " . $this->config->item('table_name').".col_primary_key in ? and station_profile.user_id = ?"; - - $query = $this->db->query($sql, array($grid_value, $vucc_value, json_decode($ids, true), $this->session->userdata('user_id'))); } + $sql = "UPDATE ".$this->config->item('table_name')." JOIN station_profile ON ". $this->config->item('table_name').".station_id = station_profile.station_id" . + " SET " . $this->config->item('table_name').".COL_GRIDSQUARE = ?" . + ", " . $this->config->item('table_name').".COL_VUCC_GRIDS = ?" . + " WHERE " . $this->config->item('table_name').".col_primary_key in ? and station_profile.user_id = ?"; + $query = $this->db->query($sql, array($grid_value, $vucc_value, json_decode($ids, true), $this->session->userdata('user_id'))); } else if ($column == 'COL_MODE') { $this->load->model('logbook_model');