diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 45b9e538..529e667c 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -449,4 +449,32 @@ class Awards extends CI_Controller { $this->load->view('awards/counties/index'); $this->load->view('interface_assets/footer'); } + + public function counties_details() { + $this->load->model('counties'); + $state = str_replace('"', "", $this->input->get("State")); + $type = str_replace('"', "", $this->input->get("Type")); + $data['counties_array'] = $this->counties->counties_details($state, $type); + $data['type'] = $type; + + // Render Page + $data['page_title'] = "US Counties"; + $data['filter'] = $type . " counties in state ".$state; + $this->load->view('interface_assets/header', $data); + $this->load->view('awards/counties/details'); + $this->load->view('interface_assets/footer'); + } + + public function counties_details_ajax(){ + $this->load->model('logbook_model'); + + $state = str_replace('"', "", $this->input->post("State")); + $county = str_replace('"', "", $this->input->post("County")); + $data['results'] = $this->logbook_model->county_qso_details($state, $county); + + // Render Page + $data['page_title'] = "Log View - Counties"; + $data['filter'] = "county " . $state; + $this->load->view('awards/details', $data); + } } diff --git a/application/models/Counties.php b/application/models/Counties.php index 8cdce8fb..7df46527 100644 --- a/application/models/Counties.php +++ b/application/models/Counties.php @@ -3,8 +3,7 @@ class Counties extends CI_Model { - function __construct() - { + function __construct() { // Call the Model constructor parent::__construct(); } @@ -36,8 +35,8 @@ class Counties extends CI_Model left outer join ( select count(distinct COL_CNTY) countycountconfirmed, COL_STATE from " . $this->config->item('table_name') . - " where station_id =" . $station_id . - " and COL_DXCC in ('291', '6', '110') + " where station_id =" . $station_id . + " and COL_DXCC in ('291', '6', '110') and coalesce(COL_CNTY, '') <> '' and COL_BAND != 'SAT' and (col_qsl_rcvd='Y' or col_eqsl_qsl_rcvd='Y') @@ -45,7 +44,7 @@ class Counties extends CI_Model order by COL_STATE ) x on thcv.COL_STATE = x.COL_STATE where station_id =" . $station_id . - " and COL_DXCC in ('291', '6', '110') + " and COL_DXCC in ('291', '6', '110') and coalesce(COL_CNTY, '') <> '' and COL_BAND != 'SAT' group by thcv.COL_STATE @@ -60,4 +59,46 @@ class Counties extends CI_Model $CI->load->model('Stations'); return $CI->Stations->find_active(); } + + /* + * Makes a list of all counties in given state + */ + function counties_details($state, $type) { + if ($type == 'worked') { + $counties = $this->get_counties($state, 'none'); + } else if ($type == 'confirmed') { + $counties = $this->get_counties($state, 'confirmed'); + } + if (!isset($counties)) { + return 0; + } else { + ksort($counties); + return $counties; + } + } + + function get_counties($state, $confirmationtype) { + $station_id = $this->get_station_id(); + + $sql = "select distinct COL_CNTY, COL_STATE + from " . $this->config->item('table_name') . " thcv + where station_id =" . $station_id . + " and COL_DXCC in ('291', '6', '110') + and coalesce(COL_CNTY, '') <> '' + and COL_BAND != 'SAT'"; + + if ($state != 'All') { + $sql .= " and COL_STATE = '" . $state . "'"; + } + + if ($confirmationtype != 'none') { + $sql .= " and (col_qsl_rcvd='Y' or col_eqsl_qsl_rcvd='Y')"; + } + + $sql .= " order by thcv.COL_STATE"; + + $query = $this->db->query($sql); + return $query->result_array(); + } + } diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index aaae4a4d..aa924505 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -2257,6 +2257,20 @@ class Logbook_model extends CI_Model { return "Updated"; } + + function county_qso_details($state, $county) { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $this->db->where('station_id', $station_id); + $this->db->where('COL_STATE', $state); + $this->db->where('COL_CNTY', $county); + $this->db->where('COL_PROP_MODE !=', 'SAT'); + + return $this->db->get($this->config->item('table_name')); + } + } function validateADIFDate($date, $format = 'Ymd') @@ -2264,4 +2278,8 @@ function validateADIFDate($date, $format = 'Ymd') $d = DateTime::createFromFormat($format, $date); return $d && $d->format($format) == $date; } + + + ?> + diff --git a/application/views/awards/counties/details.php b/application/views/awards/counties/details.php new file mode 100644 index 00000000..f313456c --- /dev/null +++ b/application/views/awards/counties/details.php @@ -0,0 +1,27 @@ +