From 826f30309a6e80045f0397e9ed2f6040be849ff1 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 14 Apr 2022 23:24:37 +0200 Subject: [PATCH] Add function for looking up DOK from previous QSO --- application/controllers/Lookup.php | 16 ++++++++++++++++ application/models/Logbook_model.php | 10 ++++++++++ assets/js/sections/qso.js | 8 ++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/application/controllers/Lookup.php b/application/controllers/Lookup.php index f935cb6d..f2e0dfa8 100644 --- a/application/controllers/Lookup.php +++ b/application/controllers/Lookup.php @@ -112,4 +112,20 @@ class Lookup extends CI_Controller { } + public function dok($call) { + + if($call) { + $uppercase_callsign = strtoupper($call); + } + + // DOK results from logbook + $this->load->model('logbook_model'); + + $query = $this->logbook_model->get_dok($uppercase_callsign); + + if ($query->row()) { + echo $query->row()->COL_DARC_DOK; + } + } + } diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index c3435613..5d639eb4 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -429,6 +429,16 @@ class Logbook_model extends CI_Model { } + public function get_dok($callsign){ + $this->db->select('COL_DARC_DOK'); + $this->db->where('COL_CALL', $callsign); + $this->db->order_by("COL_TIME_ON", "desc"); + $this->db->limit(1); + + return $this->db->get($this->config->item('table_name')); + + } + function add_qso($data, $skipexport = false) { if ($data['COL_DXCC'] == "Not Found"){ diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 2897775a..df194b66 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -383,8 +383,12 @@ $("#callsign").focusout(function() { var $select = $('#darc_dok').selectize(); var selectize = $select[0].selectize; if (result.dxcc.adif == '230') { - selectize.addOption({name:'N18'}); - selectize.setValue('N18', false); + $.get('lookup/dok/' + $('#callsign').val().toUpperCase(), function(result) { + if (result) { + selectize.addOption({name: result}); + selectize.setValue(result, false); + } + }); } else { selectize.clear(); }