diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index d4ce1677..8829fdcb 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 2a252731..4f964137 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -841,6 +841,27 @@ 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_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')); + 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);