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 b8d0e3b5..baed13ac 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -897,6 +897,29 @@ function getLookupResult() {