From c35d0d257e137e0e4cdb7c24181107fd64debda9 Mon Sep 17 00:00:00 2001 From: Andreas Date: Mon, 8 Feb 2021 13:40:07 +0100 Subject: [PATCH] Fetches state from previous QSO. Fixes #854 --- application/controllers/Logbook.php | 1 + application/models/Logbook_model.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 4a488627..fc495f42 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -130,6 +130,7 @@ class Logbook extends CI_Controller { $return['callsign_qth'] = $this->logbook_model->call_qth($callsign); $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['bearing'] = $this->bearing($return['callsign_qra'], $measurement_base); $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 2f6fd984..a8b14aa9 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -661,6 +661,26 @@ class Logbook_model extends CI_Model { return $qsl_via; } + function call_state($callsign) { + $this->db->select('COL_CALL, COL_STATE'); + $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_state = $data->COL_STATE; + } + + return $qsl_state; + } + function call_qth($callsign) { $this->db->select('COL_CALL, COL_QTH, COL_TIME_ON'); $this->db->where('COL_CALL', $callsign);