diff --git a/application/models/Counties.php b/application/models/Counties.php index 7d6c55c3..15dc1575 100644 --- a/application/models/Counties.php +++ b/application/models/Counties.php @@ -28,14 +28,18 @@ class Counties extends CI_Model * No band split, as it only count the number of counties in the award. */ 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 from " . $this->config->item('table_name') . " thcv left outer join ( select count(distinct COL_CNTY) countycountconfirmed, COL_STATE 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 coalesce(COL_CNTY, '') <> '' and COL_BAND != 'SAT' @@ -43,7 +47,7 @@ class Counties extends CI_Model group by COL_STATE order by 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 coalesce(COL_CNTY, '') <> '' and COL_BAND != 'SAT' @@ -54,12 +58,6 @@ class Counties extends CI_Model 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 */ @@ -78,11 +76,15 @@ class Counties extends CI_Model } 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 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 coalesce(COL_CNTY, '') <> '' and COL_BAND != 'SAT'"; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 7ebfa410..2f979997 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -2483,11 +2483,11 @@ class Logbook_model extends CI_Model { } function county_qso_details($state, $county) { - $CI =& get_instance(); - $CI->load->model('Stations'); - $station_id = $CI->Stations->find_active(); + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $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_CNTY', $county); $this->db->where('COL_PROP_MODE !=', 'SAT');