From 349545fe480c0154265fdab57b0da135c33926c8 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Mon, 31 Oct 2022 12:25:56 +0100 Subject: [PATCH] [Search] Added tab to check for duplicate QSOs --- application/controllers/Logbook.php | 31 ++++++++++++ application/controllers/Search.php | 12 +++++ application/views/interface_assets/footer.php | 23 +++++++++ application/views/search/duplicates.php | 43 ++++++++++++++++ .../views/search/duplicates_result.php | 49 +++++++++++++++++++ application/views/search/filter.php | 3 ++ application/views/search/main.php | 3 ++ 7 files changed, 164 insertions(+) create mode 100644 application/views/search/duplicates.php create mode 100644 application/views/search/duplicates_result.php diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 78233465..cbe6aa11 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -698,7 +698,38 @@ class Logbook extends CI_Controller { } } + function search_duplicates($station_id) { + $station_id = $this->security->xss_clean($station_id); + $this->load->model('user_model'); + + if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } + + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + if (!$logbooks_locations_array) { + return null; + } + + $location_list = "'".implode("','",$logbooks_locations_array)."'"; + + $sql = 'select count(*) as occurence, COL_CALL, COL_MODE, COL_SUBMODE, station_callsign, COL_SAT_NAME, COL_BAND, min(col_time_on) Mintime, max(col_time_on) Maxtime from ' . $this->config->item('table_name') . + ' join station_profile on ' . $this->config->item('table_name') . '.station_id = station_profile.station_id where ' . $this->config->item('table_name') .'.station_id in ('. $location_list . ')'; + + if ($station_id != 'All') { + $sql .= ' and station_profile.station_id = ' . $station_id; + } + + $sql .= ' group by col_call, col_mode, COL_SUBMODE, STATION_CALLSIGN, col_band, COL_SAT_NAME having count(*) > 1 and timediff(maxtime, mintime) < 3000'; + + $query = $this->db->query($sql); + + $data['qsos'] = $query; + + $this->load->view('search/duplicates_result.php', $data); + } /* * Provide a dxcc search, returning results json encoded diff --git a/application/controllers/Search.php b/application/controllers/Search.php index b6e8dd65..024abba8 100644 --- a/application/controllers/Search.php +++ b/application/controllers/Search.php @@ -56,6 +56,18 @@ class Search extends CI_Controller { } } + // Searches for duplicate QSOs within 30m of time difference + public function duplicates() { + $this->load->model('stations'); + + $data['station_profile'] = $this->stations->all_of_user(); + $data['page_title'] = "Duplicate QSOs within 30m time difference"; + + $this->load->view('interface_assets/header', $data); + $this->load->view('search/duplicates'); + $this->load->view('interface_assets/footer'); + } + function json_result() { if(isset($_POST['search'])) { $result = $this->fetchQueryResult($_POST['search'], false); diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 3e6ebe42..665d779a 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -895,6 +895,29 @@ function getLookupResult() {