From e5a725d6e4f1d11ccfda75eff0bb7ccebc88dfe4 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 4 Feb 2025 11:01:22 +0100 Subject: [PATCH] [Quick Lookup] Added continent --- application/controllers/Lookup.php | 23 +++++++-------- application/models/Lookup_model.php | 44 ++++++++++++++++------------- application/views/lookup/index.php | 15 ++++++++++ application/views/lookup/result.php | 1 + assets/js/sections/common.js | 14 ++++++--- 5 files changed, 63 insertions(+), 34 deletions(-) diff --git a/application/controllers/Lookup.php b/application/controllers/Lookup.php index ef73a9a78..2e622f038 100644 --- a/application/controllers/Lookup.php +++ b/application/controllers/Lookup.php @@ -45,7 +45,7 @@ class Lookup extends CI_Controller { } else { $this->load->model('bands'); - if ($this->input->post('type') == 'itu') { + if ($this->input->post('type') == 'itu' || $this->input->post('type') == 'continent') { $data['bands'] = $this->bands->get_worked_bands(); } else { $data['bands'] = $this->bands->get_worked_bands(xss_clean($this->input->post('type'))); @@ -63,6 +63,7 @@ class Lookup extends CI_Controller { $data['cqz'] = xss_clean($this->input->post('cqz')); $data['wwff'] = xss_clean($this->input->post('wwff')); $data['ituz'] = xss_clean($this->input->post('ituz')); + $data['continent'] = xss_clean($this->input->post('continent')); $data['location_list'] = $location_list; $data['result'] = $this->lookup_model->getSearchResult($data); @@ -74,22 +75,22 @@ class Lookup extends CI_Controller { public function scp() { session_write_close(); $uppercase_callsign = strtoupper($this->input->post('callsign', TRUE) ?? ''); - + // SCP results from logbook $this->load->model('logbook_model'); - + $arCalls = array(); - + $query = $this->logbook_model->get_callsigns($uppercase_callsign); - + foreach ($query->result() as $row) { $normalized_call = str_replace('0', 'Ø', $row->COL_CALL); $arCalls[$normalized_call] = true; } - + // SCP results from Club Log master scp db $file = 'updates/clublog_scp.txt'; - + if (is_readable($file)) { $lines = file($file, FILE_IGNORE_NEW_LINES); $input = preg_quote($uppercase_callsign, '~'); @@ -107,10 +108,10 @@ class Lookup extends CI_Controller { log_message('error', 'Failed to copy source file ('.$src.') to new location. Check if this path has the right permission: '.$file); } } - + // SCP results from master scp https://www.supercheckpartial.com $file = 'updates/MASTER.SCP'; - + if (is_readable($file)) { $lines = file($file, FILE_IGNORE_NEW_LINES); $input = preg_quote($uppercase_callsign, '~'); @@ -128,10 +129,10 @@ class Lookup extends CI_Controller { log_message('error', 'Failed to copy source file ('.$src.') to new location. Check if this path has the right permission: '.$file); } } - + // Sort and print unique calls ksort($arCalls); - + foreach (array_keys($arCalls) as $strCall) { echo " " . $strCall . " "; } diff --git a/application/models/Lookup_model.php b/application/models/Lookup_model.php index 87d1a6b5b..dc426a8a6 100644 --- a/application/models/Lookup_model.php +++ b/application/models/Lookup_model.php @@ -39,42 +39,53 @@ class Lookup_model extends CI_Model{ /* * Builds information-where-part of query depending on what we are searching for */ - private function build_info_query($queryinfo,&$binds) { + private function build_info_query($queryinfo, &$binds) { $sqlquerytypestring=''; + if (strlen($queryinfo['grid']) > 4) { + $fixedgrid = substr($queryinfo['grid'], 0, 4); + } + else { + $fixedgrid = $queryinfo['grid']; + } + switch ($queryinfo['type']) { - case 'dxcc': + case 'dxcc': $sqlquerytypestring .= " and col_dxcc = ?"; - $binds[]=$queryinfo['dxcc']; + $binds[]=$queryinfo['dxcc']; break; - case 'iota': + case 'iota': $sqlquerytypestring .= " and col_iota = ?"; - $binds[]=$queryinfo['iota']; + $binds[]=$queryinfo['iota']; break; - case 'vucc': + case 'vucc': $sqlquerytypestring .= " and (col_gridsquare like ? or col_vucc_grids like ?)"; $binds[]='%'.$fixedgrid.'%'; - $binds[]='%'.$fixedgrid.'%'; + $binds[]='%'.$fixedgrid.'%'; break; - case 'cq': + case 'cq': $sqlquerytypestring .= " and col_cqz = ?"; $binds[]=$queryinfo['cqz']; break; - case 'was': - $sqlquerytypestring .= " and col_state = ? and COL_DXCC in ('291', '6', '110')"; + case 'was': + $sqlquerytypestring .= " and col_state = ? and COL_DXCC in ('291', '6', '110')"; $binds[]=$queryinfo['was']; break; - case 'sota': + case 'sota': $sqlquerytypestring .= " and col_sota_ref = ?"; $binds[]=$queryinfo['sota']; break; - case 'wwff': + case 'wwff': $sqlquerytypestring .= " and col_sig = 'WWFF' and col_sig_info = ?"; $binds[]=$queryinfo['wwff']; break; - case 'itu': + case 'itu': $sqlquerytypestring .= " and col_ituz = ?"; $binds[]=$queryinfo['ituz']; break; + case 'continent': + $sqlquerytypestring .= " and col_cont = ?"; + $binds[]=$queryinfo['continent']; + break; default: break; } return $sqlquerytypestring; @@ -86,12 +97,7 @@ class Lookup_model extends CI_Model{ function getQueryData($queryinfo, $confirmedtype) { // If user inputs longer grid than 4 chars, we use only the first 4 $binds=[]; - if (strlen($queryinfo['grid']) > 4) { - $fixedgrid = substr($queryinfo['grid'], 0, 4); - } - else { - $fixedgrid = $queryinfo['grid']; - } + $sqlquerytypestring = ''; diff --git a/application/views/lookup/index.php b/application/views/lookup/index.php index 3147618f1..97a884929 100644 --- a/application/views/lookup/index.php +++ b/application/views/lookup/index.php @@ -1,6 +1,7 @@
+ + + + + +