Merge pull request #1160 from AndreasK79/uscounties_station_logbooks

[US Counties Award] Updated code to support station logbooks
This commit is contained in:
Peter Goodhall 2021-09-09 21:52:42 +01:00 committed by GitHub
commit 2c0ee14d22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 15 deletions

View File

@ -28,14 +28,18 @@ class Counties extends CI_Model
* No band split, as it only count the number of counties in the award. * No band split, as it only count the number of counties in the award.
*/ */
function get_counties_summary() { function get_counties_summary() {
$station_id = $this->get_station_id(); $CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = "select count(distinct COL_CNTY) countycountworked, coalesce(x.countycountconfirmed, 0) countycountconfirmed, thcv.COL_STATE $sql = "select count(distinct COL_CNTY) countycountworked, coalesce(x.countycountconfirmed, 0) countycountconfirmed, thcv.COL_STATE
from " . $this->config->item('table_name') . " thcv from " . $this->config->item('table_name') . " thcv
left outer join ( left outer join (
select count(distinct COL_CNTY) countycountconfirmed, COL_STATE select count(distinct COL_CNTY) countycountconfirmed, COL_STATE
from " . $this->config->item('table_name') . from " . $this->config->item('table_name') .
" where station_id =" . $station_id . " where station_id in (" . $location_list . ")" .
" and COL_DXCC in ('291', '6', '110') " and COL_DXCC in ('291', '6', '110')
and coalesce(COL_CNTY, '') <> '' and coalesce(COL_CNTY, '') <> ''
and COL_BAND != 'SAT' and COL_BAND != 'SAT'
@ -43,7 +47,7 @@ class Counties extends CI_Model
group by COL_STATE group by COL_STATE
order by COL_STATE order by COL_STATE
) x on thcv.COL_STATE = x.COL_STATE ) x on thcv.COL_STATE = x.COL_STATE
where station_id =" . $station_id . where station_id in (" . $location_list . ")" .
" and COL_DXCC in ('291', '6', '110') " and COL_DXCC in ('291', '6', '110')
and coalesce(COL_CNTY, '') <> '' and coalesce(COL_CNTY, '') <> ''
and COL_BAND != 'SAT' and COL_BAND != 'SAT'
@ -54,12 +58,6 @@ class Counties extends CI_Model
return $query->result_array(); return $query->result_array();
} }
function get_station_id() {
$CI =& get_instance();
$CI->load->model('Stations');
return $CI->Stations->find_active();
}
/* /*
* Makes a list of all counties in given state * Makes a list of all counties in given state
*/ */
@ -78,11 +76,15 @@ class Counties extends CI_Model
} }
function get_counties($state, $confirmationtype) { function get_counties($state, $confirmationtype) {
$station_id = $this->get_station_id(); $CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = "select distinct COL_CNTY, COL_STATE $sql = "select distinct COL_CNTY, COL_STATE
from " . $this->config->item('table_name') . " thcv from " . $this->config->item('table_name') . " thcv
where station_id =" . $station_id . where station_id in (" . $location_list . ")" .
" and COL_DXCC in ('291', '6', '110') " and COL_DXCC in ('291', '6', '110')
and coalesce(COL_CNTY, '') <> '' and coalesce(COL_CNTY, '') <> ''
and COL_BAND != 'SAT'"; and COL_BAND != 'SAT'";

View File

@ -2479,11 +2479,11 @@ class Logbook_model extends CI_Model {
} }
function county_qso_details($state, $county) { function county_qso_details($state, $county) {
$CI =& get_instance(); $CI =& get_instance();
$CI->load->model('Stations'); $CI->load->model('logbooks_model');
$station_id = $CI->Stations->find_active(); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$this->db->where('station_id', $station_id); $this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_STATE', $state); $this->db->where('COL_STATE', $state);
$this->db->where('COL_CNTY', $county); $this->db->where('COL_CNTY', $county);
$this->db->where('COL_PROP_MODE !=', 'SAT'); $this->db->where('COL_PROP_MODE !=', 'SAT');