From 695dbc2ea2bfec275120751f5c8743ee3d1b2d77 Mon Sep 17 00:00:00 2001 From: phl0 Date: Tue, 27 Aug 2024 10:13:30 +0200 Subject: [PATCH] Lookup CQ zones in qrz/hamqth --- application/controllers/Logbook.php | 2 ++ application/libraries/Hamqth.php | 2 ++ application/libraries/Qrz.php | 2 ++ application/models/Logbook_model.php | 22 ++++++++++++++++++++++ assets/js/sections/qso.js | 6 +++++- 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 315f277c3..748a0e0a8 100644 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -115,6 +115,7 @@ class Logbook extends CI_Controller { "callsign_state" => "", "callsign_us_county" => "", "callsign_ituz" => "", + "callsign_cqz" => "", "qsl_manager" => "", "bearing" => "", "workedBefore" => false, @@ -147,6 +148,7 @@ class Logbook extends CI_Controller { $return['callsign_state'] = $this->nval($callbook['state'] ?? '', $this->logbook_model->call_state($callsign)); $return['callsign_us_county'] = $this->nval($callbook['us_county'] ?? '', $this->logbook_model->call_us_county($callsign)); $return['callsign_ituz'] = $this->nval($callbook['ituz'] ?? '', $this->logbook_model->call_ituzone($callsign)); + $return['callsign_cqz'] = $this->nval($callbook['cqz'] ?? '', $this->logbook_model->call_cqzone($callsign)); $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $band, $mode); $return['confirmed'] = $this->confirmed_grid_before($return['callsign_qra'], $band, $mode); $return['timesWorked'] = $this->logbook_model->times_worked($lookupcall); diff --git a/application/libraries/Hamqth.php b/application/libraries/Hamqth.php index bdaa98d36..c8d6c71ff 100644 --- a/application/libraries/Hamqth.php +++ b/application/libraries/Hamqth.php @@ -95,6 +95,7 @@ class Hamqth { $data['state'] = (string)$xml->search->us_state; $data['error'] = (string)$xml->session->error; $data['ituz'] = (string)$xml->search->itu; + $data['cqz'] = (string)$xml->search->cq; if ($xml->search->country == "United States") { $data['us_county'] = (string)$xml->search->us_county; @@ -114,6 +115,7 @@ class Hamqth { $data['state'] = ''; $data['error'] = (string)$xml->session->error; $data['ituz'] = ''; + $data['cqz'] = ''; $data['us_county'] = ''; diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php index 2080a8d3c..cc51b7b9b 100644 --- a/application/libraries/Qrz.php +++ b/application/libraries/Qrz.php @@ -110,6 +110,7 @@ class Qrz { $data['qslmgr'] = (string)$xml->Callsign->qslmgr; $data['image'] = (string)$xml->Callsign->image; $data['ituz'] = (string)$xml->Callsign->ituzone; + $data['cqz'] = (string)$xml->Callsign->cqzone; if ($xml->Callsign->country == "United States") { $data['us_county'] = (string)$xml->Callsign->county; @@ -130,6 +131,7 @@ class Qrz { $data['image'] = (string)$xml->Callsign->image; $data['us_county'] = ''; $data['ituz'] = ''; + $data['cqz'] = ''; } } finally { diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 8400bd964..340790af5 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1608,6 +1608,28 @@ class Logbook_model extends CI_Model { } } + function call_cqzone($callsign) { + $this->db->select('COL_CALL, COL_CQZ'); + $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); + $this->db->where('COL_CALL', $callsign); + $this->db->where('station_profile.user_id', $this->session->userdata('user_id')); + $where = "COL_CQZ != \"\""; + + $this->db->where($where); + + $this->db->order_by("COL_TIME_ON", "desc"); + $this->db->limit(1); + $query = $this->db->get($this->config->item('table_name')); + if ($query->num_rows() > 0) + { + $data = $query->row(); + $qsl_cqz = $data->COL_CQZ; + return $qsl_cqz; + } else { + return NULL; + } + } + function call_qth($callsign) { $this->db->select('COL_CALL, COL_QTH, COL_TIME_ON'); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 7767cfbe6..2d1f31477 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -895,7 +895,11 @@ $( document ).ready(function() { $('#dxcc_id').val(result.dxcc.adif).multiselect('refresh'); await updateStateDropdown('#dxcc_id', '#stateInputLabel', '#location_us_county', '#stationCntyInputEdit'); - $('#cqz').val(result.dxcc.cqz); + if (result.callsign_cqz != '') { + $('#cqz').val(result.callsign_cqz); + } else { + $('#cqz').val(result.dxcc.cqz); + } if (result.callsign_ituz != '') { $('#ituz').val(result.callsign_ituz);