From fb7c448b582db3a9a2ae32791b3fd6784ab8b16d Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 12 Jul 2023 17:30:15 +0200 Subject: [PATCH] Also use VUCC_GRIDS from LoTW cnfm to update QSO record --- application/controllers/Lotw.php | 10 ++++++-- application/models/Logbook_model.php | 36 +++++++++++++++------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 1f9a9bca..d26fb5a4 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -512,6 +512,12 @@ class Lotw extends CI_Controller { $qsl_gridsquare = ""; } + if (isset($record['vucc_grids'])) { + $qsl_vucc_grids = $record['vucc_grids']; + } else { + $qsl_vucc_grids = ""; + } + if (isset($record['iota'])) { $iota = $record['iota']; } else { @@ -536,7 +542,7 @@ class Lotw extends CI_Controller { $ituz = ""; } - $lotw_status = $this->logbook_model->lotw_update($time_on, $record['call'], $record['band'], $qsl_date, $record['qsl_rcvd'], $state, $qsl_gridsquare, $iota, $cnty, $cqz, $ituz, $record['station_callsign']); + $lotw_status = $this->logbook_model->lotw_update($time_on, $record['call'], $record['band'], $qsl_date, $record['qsl_rcvd'], $state, $qsl_gridsquare, $qsl_vucc_grids, $iota, $cnty, $cqz, $ituz, $record['station_callsign']); $table .= ""; $table .= "".$record['station_callsign'].""; @@ -546,7 +552,7 @@ class Lotw extends CI_Controller { $table .= "".$record['qsl_rcvd'].""; $table .= "".$qsl_date.""; $table .= "".$state.""; - $table .= "".$qsl_gridsquare.""; + $table .= "".($qsl_gridsquare != '' ? $qsl_gridsquare : $qsl_vucc_grids).""; $table .= "".$iota.""; $table .= "QSO Record: ".$status[0].""; $table .= "LoTW Record: ".$lotw_status.""; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 7fb081e0..ed811f01 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -2636,7 +2636,7 @@ class Logbook_model extends CI_Model { } } - function lotw_update($datetime, $callsign, $band, $qsl_date, $qsl_status, $state, $qsl_gridsquare, $iota, $cnty, $cqz, $ituz, $station_callsign) { + function lotw_update($datetime, $callsign, $band, $qsl_date, $qsl_status, $state, $qsl_gridsquare, $qsl_vucc_grids, $iota, $cnty, $cqz, $ituz, $station_callsign) { $data = array( 'COL_LOTW_QSLRDATE' => $qsl_date, @@ -2670,24 +2670,28 @@ class Logbook_model extends CI_Model { $this->db->update($this->config->item('table_name'), $data); unset($data); - if($qsl_gridsquare != "") { + if($qsl_gridsquare != "" || $qsl_vucc_grids != "") { $data = array( - 'COL_GRIDSQUARE' => $qsl_gridsquare, 'COL_DISTANCE' => 0 ); - $this->db->select('station_profile.station_gridsquare as station_gridsquare'); - $this->db->where('date_format(COL_TIME_ON, \'%Y-%m-%d %H:%i\') = "'.$datetime.'"'); - $this->db->where('COL_CALL', $callsign); - $this->db->where('COL_BAND', $band); - $this->db->join('station_profile', $this->config->item('table_name').'.station_id = station_profile.station_id', 'left outer'); - $this->db->limit(1); - $query = $this->db->get($this->config->item('table_name')); - $row = $query->row(); - if (isset($row)) { - $station_gridsquare = $row->station_gridsquare; - $this->load->library('Qra'); - - $data['COL_DISTANCE'] = $this->qra->distance($station_gridsquare, $qsl_gridsquare, 'K'); + if ($qsl_gridsquare != "") { + $data['COL_GRIDSQUARE'] = $qsl_gridsquare; + $this->db->select('station_profile.station_gridsquare as station_gridsquare'); + $this->db->where('date_format(COL_TIME_ON, \'%Y-%m-%d %H:%i\') = "'.$datetime.'"'); + $this->db->where('COL_CALL', $callsign); + $this->db->where('COL_BAND', $band); + $this->db->join('station_profile', $this->config->item('table_name').'.station_id = station_profile.station_id', 'left outer'); + $this->db->limit(1); + $query = $this->db->get($this->config->item('table_name')); + $row = $query->row(); + if (isset($row)) { + $station_gridsquare = $row->station_gridsquare; + $this->load->library('Qra'); + + $data['COL_DISTANCE'] = $this->qra->distance($station_gridsquare, $qsl_gridsquare, 'K'); + } + } elseif ($qsl_vucc_grids != "") { + $data['COL_VUCC_GRIDS'] = $qsl_vucc_grids; } $this->db->where('date_format(COL_TIME_ON, \'%Y-%m-%d %H:%i\') = "'.$datetime.'"');