diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php
old mode 100755
new mode 100644
index 8a8b7372..0372f9cf
--- a/application/controllers/Logbook.php
+++ b/application/controllers/Logbook.php
@@ -711,6 +711,40 @@ class Logbook extends CI_Controller {
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
$this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', 'desc');
return $this->db->get();
+ }
+
+ 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);
+
}
/*
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/controllers/Timeline.php b/application/controllers/Timeline.php
index 87321556..29ee5416 100644
--- a/application/controllers/Timeline.php
+++ b/application/controllers/Timeline.php
@@ -25,26 +25,47 @@ class Timeline extends CI_Controller {
$band = 'All';
}
- if ($this->input->post('mode') != NULL) { // Band is not set when page first loads.
+ if ($this->input->post('mode') != NULL) {
$mode = $this->input->post('mode');
}
else {
$mode = 'All';
}
- if ($this->input->post('awardradio') != NULL) { // Band is not set when page first loads.
+ if ($this->input->post('awardradio') != NULL) {
$award = $this->input->post('awardradio');
}
else {
$award = 'dxcc';
}
+ if ($this->input->post('qsl') != NULL) {
+ $qsl = $this->input->post('qsl');
+ }
+ else {
+ $qsl = '0';
+ }
+
+ if ($this->input->post('lotw') != NULL) {
+ $lotw = $this->input->post('lotw');
+ }
+ else {
+ $lotw = '0';
+ }
+
+ if ($this->input->post('eqsl') != NULL) {
+ $eqsl = $this->input->post('eqsl');
+ }
+ else {
+ $eqsl = '0';
+ }
+
$this->load->model('modes');
$this->load->model('bands');
$data['modes'] = $this->modes->active();
- $data['timeline_array'] = $this->Timeline_model->get_timeline($band, $mode, $award);
+ $data['timeline_array'] = $this->Timeline_model->get_timeline($band, $mode, $award, $qsl, $lotw, $eqsl);
$data['worked_bands'] = $this->bands->get_worked_bands();
$data['bandselect'] = $band;
$data['modeselect'] = $mode;
diff --git a/application/models/Timeline_model.php b/application/models/Timeline_model.php
index 72203337..684bd732 100644
--- a/application/models/Timeline_model.php
+++ b/application/models/Timeline_model.php
@@ -3,7 +3,7 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
class Timeline_model extends CI_Model
{
- function get_timeline($band, $mode, $award) {
+ function get_timeline($band, $mode, $award, $qsl, $lotw, $eqsl) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -15,16 +15,16 @@ class Timeline_model extends CI_Model
$location_list = "'".implode("','",$logbooks_locations_array)."'";
switch ($award) {
- case 'dxcc': $result = $this->get_timeline_dxcc($band, $mode, $location_list); break;
- case 'was': $result = $this->get_timeline_was($band, $mode, $location_list); break;
- case 'iota': $result = $this->get_timeline_iota($band, $mode, $location_list); break;
- case 'waz': $result = $this->get_timeline_waz($band, $mode, $location_list); break;
+ case 'dxcc': $result = $this->get_timeline_dxcc($band, $mode, $location_list, $qsl, $lotw, $eqsl); break;
+ case 'was': $result = $this->get_timeline_was($band, $mode, $location_list, $qsl, $lotw, $eqsl); break;
+ case 'iota': $result = $this->get_timeline_iota($band, $mode, $location_list, $qsl, $lotw, $eqsl); break;
+ case 'waz': $result = $this->get_timeline_waz($band, $mode, $location_list, $qsl, $lotw, $eqsl); break;
}
return $result;
}
- public function get_timeline_dxcc($band, $mode, $location_list) {
+ public function get_timeline_dxcc($band, $mode, $location_list, $qsl, $lotw, $eqsl) {
$sql = "select min(date(COL_TIME_ON)) date, prefix, col_country, end, adif from "
.$this->config->item('table_name'). " thcv
join dxcc_entities on thcv.col_dxcc = dxcc_entities.adif
@@ -44,6 +44,8 @@ class Timeline_model extends CI_Model
$sql .= " and col_mode ='" . $mode . "'";
}
+ $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl);
+
$sql .= " group by col_dxcc, col_country
order by date desc";
@@ -52,7 +54,7 @@ class Timeline_model extends CI_Model
return $query->result();
}
- public function get_timeline_was($band, $mode, $location_list) {
+ public function get_timeline_was($band, $mode, $location_list, $qsl, $lotw, $eqsl) {
$sql = "select min(date(COL_TIME_ON)) date, col_state from "
.$this->config->item('table_name'). " thcv
where station_id in (" . $location_list . ")";
@@ -74,6 +76,8 @@ class Timeline_model extends CI_Model
$sql .= " and COL_DXCC in ('291', '6', '110')";
$sql .= " and COL_STATE in ('AK','AL','AR','AZ','CA','CO','CT','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI','WV','WY')";
+ $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl);
+
$sql .= " group by col_state
order by date desc";
@@ -82,7 +86,7 @@ class Timeline_model extends CI_Model
return $query->result();
}
- public function get_timeline_iota($band, $mode, $location_list) {
+ public function get_timeline_iota($band, $mode, $location_list, $qsl, $lotw, $eqsl) {
$sql = "select min(date(COL_TIME_ON)) date, col_iota, name, prefix from "
.$this->config->item('table_name'). " thcv
join iota on thcv.col_iota = iota.tag
@@ -102,6 +106,8 @@ class Timeline_model extends CI_Model
$sql .= " and col_mode ='" . $mode . "'";
}
+ $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl);
+
$sql .= " and col_iota <> '' group by col_iota, name, prefix
order by date desc";
@@ -110,7 +116,7 @@ class Timeline_model extends CI_Model
return $query->result();
}
- public function get_timeline_waz($band, $mode, $location_list) {
+ public function get_timeline_waz($band, $mode, $location_list, $qsl, $lotw, $eqsl) {
$sql = "select min(date(COL_TIME_ON)) date, col_cqz from "
.$this->config->item('table_name'). " thcv
where station_id in (" . $location_list . ")";
@@ -129,6 +135,8 @@ class Timeline_model extends CI_Model
$sql .= " and col_mode ='" . $mode . "'";
}
+ $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl);
+
$sql .= " and col_cqz <> '' group by col_cqz
order by date desc";
@@ -136,5 +144,39 @@ class Timeline_model extends CI_Model
return $query->result();
}
+
+
+ // Adds confirmation to query
+ function addQslToQuery($qsl, $lotw, $eqsl) {
+ $sql = '';
+ if ($lotw == 1 and $qsl == 0 and $eqsl == 0) {
+ $sql .= " and col_lotw_qsl_rcvd = 'Y'";
+ }
+
+ if ($qsl == 1 and $lotw == 0 and $eqsl == 0) {
+ $sql .= " and col_qsl_rcvd = 'Y'";
+ }
+
+ if ($eqsl == 1 and $lotw == 0 and $qsl == 0) {
+ $sql .= " and col_eqsl_qsl_rcvd = 'Y'";
+ }
+
+ if ($lotw == 1 and $qsl == 1 and $eqsl == 0) {
+ $sql .= " and (col_lotw_qsl_rcvd = 'Y' or col_qsl_rcvd = 'Y')";
+ }
+
+ if ($qsl == 1 and $lotw == 0 and $eqsl == 1) {
+ $sql .= " and (col_qsl_rcvd = 'Y' or col_eqsl_qsl_rcvd = 'Y')";
+ }
+
+ if ($eqsl == 1 and $lotw == 1 and $qsl == 0) {
+ $sql .= " and (col_eqsl_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
+ }
+
+ if ($qsl == 1 && $lotw == 1 && $eqsl == 1) {
+ $sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y' or col_eqsl_qsl_rcvd = 'Y')";
+ }
+ return $sql;
+ }
}
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php
index 3e6ebe42..baed13ac 100644
--- a/application/views/interface_assets/footer.php
+++ b/application/views/interface_assets/footer.php
@@ -855,7 +855,7 @@ function getLookupResult() {
-uri->segment(1) == "search") { ?>
+
+
+uri->segment(1) == "search") { ?>