From 8d62703b93162ea0911c9af02cd27d33b9325363 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Fri, 23 Feb 2024 15:48:55 +0100 Subject: [PATCH] fix adif county --- application/libraries/AdifHelper.php | 14 ++++++++------ application/models/Stations.php | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/application/libraries/AdifHelper.php b/application/libraries/AdifHelper.php index 440663782..e383a3415 100644 --- a/application/libraries/AdifHelper.php +++ b/application/libraries/AdifHelper.php @@ -196,11 +196,14 @@ class AdifHelper { $line .= $this->getAdifFieldLine("MY_ITU_ZONE", $qso->station_itu); - if($qso->state) { - $county = trim($qso->state) . "," . trim($qso->station_cnty); - } else { - $county = trim($qso->station_cnty); - } + $line .= $this->getAdifFieldLine("MY_STATE", $qso->state); + + // We fill county only if it has a value and it's USA, Alaska or Hawaii. Other countrys are not supported at the moment due complex adif specs + if ($qso->station_cnty && ($qso->station_dxcc == '291' || $qso->station_dxcc == '006' || $qso->station_dxcc == '110')) { + $county = trim($qso->state) . "," . trim($qso->station_cnty); + } else { + $county = ''; + } $line .= $this->getAdifFieldLine("MY_CNTY", $county); @@ -234,7 +237,6 @@ class AdifHelper { MY_NAME MY_POSTAL_CODE MY_RIG - MY_STATE MY_STREET MY_USACA_COUNTIES */ diff --git a/application/models/Stations.php b/application/models/Stations.php index abeb74eb5..d2f768c2c 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -80,6 +80,13 @@ class Stations extends CI_Model { $state = $this->input->post('station_state'); } + // Check if DXCC is USA, Alaska or Hawaii. If not true, we clear the County field due to complex adif specs + if (($this->input->post('dxcc') == 291 || $this->input->post('dxcc') == 006 || $this->input->post('dxcc') == 110) && $this->input->post('station_cnty') !="") { + $county = $this->input->post('station_cnty'); + } else { + $county = ''; + } + // Create data array with field values $data = array( 'user_id' => $this->session->userdata('user_id'), @@ -96,7 +103,7 @@ class Stations extends CI_Model { 'station_callsign' => xss_clean($this->input->post('station_callsign', true)), 'station_power' => is_numeric(xss_clean($this->input->post('station_power', true))) ? xss_clean($this->input->post('station_power', true)) : NULL, 'station_dxcc' => xss_clean($this->input->post('dxcc', true)), - 'station_cnty' => xss_clean($this->input->post('station_cnty', true)), + 'station_cnty' => $county, 'station_cq' => xss_clean($this->input->post('station_cq', true)), 'station_itu' => xss_clean($this->input->post('station_itu', true)), 'state' => $state, @@ -133,6 +140,13 @@ class Stations extends CI_Model { $state = $this->input->post('station_state'); } + // Check if DXCC is USA, Alaska or Hawaii. If not true, we clear the County field due to complex adif specs + if (($this->input->post('dxcc') == 291 || $this->input->post('dxcc') == 006 || $this->input->post('dxcc') == 110) && $this->input->post('station_cnty') !="") { + $county = $this->input->post('station_cnty'); + } else { + $county = ''; + } + $data = array( 'station_profile_name' => xss_clean($this->input->post('station_profile_name', true)), 'station_gridsquare' => xss_clean($this->input->post('gridsquare', true)), @@ -146,7 +160,7 @@ class Stations extends CI_Model { 'station_callsign' => xss_clean($this->input->post('station_callsign', true)), 'station_power' => is_numeric(xss_clean($this->input->post('station_power', true))) ? xss_clean($this->input->post('station_power', true)) : NULL, 'station_dxcc' => xss_clean($this->input->post('dxcc', true)), - 'station_cnty' => xss_clean($this->input->post('station_cnty', true)), + 'station_cnty' => $county, 'station_cq' => xss_clean($this->input->post('station_cq', true)), 'station_itu' => xss_clean($this->input->post('station_itu', true)), 'state' => $state,