From d6d0e588afcb70e0c5b0f4b8d8cf88b9c0f4a94b Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Thu, 15 Aug 2019 11:53:32 +0100 Subject: [PATCH] Added logbook qsos to the scp lookup --- application/controllers/lookup.php | 24 ++++++++++++++++-------- application/models/Logbook_model.php | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/application/controllers/lookup.php b/application/controllers/lookup.php index cf238e8e..a30a0d3a 100644 --- a/application/controllers/lookup.php +++ b/application/controllers/lookup.php @@ -13,22 +13,30 @@ class Lookup extends CI_Controller { } - public function scp($string) { + public function scp($call) { + + // SCP results from logbook + $this->load->model('logbook_model'); + + $log_calls = $this->logbook_model->get_callsigns($call); + + if($log_calls != "") { + echo $log_calls."

"; + } + + + + // SCP results from master scp db $file = 'updates/masterscp.txt'; $lines = file($file, FILE_IGNORE_NEW_LINES); - $input = preg_quote($string, '~'); + $input = preg_quote($call, '~'); $result = preg_grep('~' . $input . '~', $lines, 0); - $copy = $result; foreach ($result as &$value) { - echo $value; - - if (next($copy )) { - echo ', '; // Add comma for all elements instead of last - } + echo " ".$value. " "; } } diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 34269398..3f16c9f0 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -222,6 +222,26 @@ class Logbook_model extends CI_Model { } } + public function get_callsigns($callsign){ + $this->db->select('COL_CALL'); + $this->db->distinct(); + $this->db->like('COL_CALL', $callsign); + + $query = $this->db->get($this->config->item('table_name')); + + $result = ""; + + foreach ($query->result() as $row) + { + + $result = $result." ".$row->COL_CALL; + + } + + return $result; + + } + function add_qso($data) { if ($data['COL_DXCC'] == "Not Found"){