From ced69b8ea49f2dffe76cdd8fb11efd0be4e52696 Mon Sep 17 00:00:00 2001 From: phl0 Date: Sat, 16 Apr 2022 22:07:13 +0200 Subject: [PATCH 1/2] Fill US county from callbook / logbook --- application/controllers/Logbook.php | 1 + application/models/Logbook_model.php | 22 ++++++++++++++++++++++ assets/js/sections/qso.js | 12 ++++++++++++ 3 files changed, 35 insertions(+) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index a2c94ec4..9297d0e1 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -149,6 +149,7 @@ class Logbook extends CI_Controller { $return['callsign_iota'] = $this->logbook_model->call_iota($callsign); $return['qsl_manager'] = $this->logbook_model->call_qslvia($callsign); $return['callsign_state'] = $this->logbook_model->call_state($callsign); + $return['callsign_us_county'] = $this->logbook_model->call_us_county($callsign); $return['bearing'] = $this->bearing($return['callsign_qra'], $measurement_base, $station_id); $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode); if ($this->session->userdata('user_show_qrz_image')) { diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 5d639eb4..be355f97 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -841,6 +841,28 @@ class Logbook_model extends CI_Model { return $qsl_state; } + function call_us_county($callsign) { + $this->db->select('COL_CALL, COL_CNTY'); + $this->db->where('COL_CALL', $callsign); + $where = "COL_NAME != \"\""; + + $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')); + $name = ""; + if ($query->num_rows() > 0) + { + $data = $query->row(); + $qsl_county = $data->COL_CNTY; + } + + // Strip state identifier + $qsl_county = substr($qsl_county, (strpos($qsl_county, ',')+1)); + return $qsl_county; + } + function call_qth($callsign) { $this->db->select('COL_CALL, COL_QTH, COL_TIME_ON'); $this->db->where('COL_CALL', $callsign); diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index df194b66..83a28c43 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -289,6 +289,9 @@ function reset_fields() { var $select = $('#darc_dok').selectize(); var selectize = $select[0].selectize; selectize.clear(); + $select = $('#stationCntyInput').selectize(); + selectize = $select[0].selectize; + selectize.clear(); mymap.setView(pos, 12); mymap.removeLayer(markers); @@ -472,6 +475,15 @@ $("#callsign").focusout(function() { $("#input_usa_state").val(result.callsign_state).trigger('change'); } + /* + * Update county with returned value + */ + if( $('#stationCntyInput').has('option').length == 0 && result.callsign_us_county != "") { + var $select = $('#stationCntyInput').selectize(); + var selectize = $select[0].selectize; + selectize.addOption({name: result.callsign_us_county}); + selectize.setValue(result.callsign_us_county, false); + } if($('#iota_ref').val() == "") { $('#iota_ref').val(result.callsign_iota); From 9e4c6c6e728baae05510754dc2ac364fa4ed1972 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Sun, 29 May 2022 20:01:44 +0200 Subject: [PATCH 2/2] US County - fixed query --- application/models/Logbook_model.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index be355f97..d6435aab 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -844,14 +844,13 @@ class Logbook_model extends CI_Model { function call_us_county($callsign) { $this->db->select('COL_CALL, COL_CNTY'); $this->db->where('COL_CALL', $callsign); - $where = "COL_NAME != \"\""; + $where = "COL_CNTY != \"\""; $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')); - $name = ""; if ($query->num_rows() > 0) { $data = $query->row();