diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 5490b62b..38becef5 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -91,35 +91,17 @@ class Awards extends CI_Controller { } public function dxcc_details(){ - $a = $this->input->get(); - $q = ""; - foreach ($a as $key => $value) { - $q .= $key."=".$value.("(and)"); - } - $q = substr($q, 0, strlen($q)-13); - - $arguments["query"] = $q; - $arguments["fields"] = ''; - $arguments["format"] = "json"; - $arguments["limit"] = ''; - $arguments["order"] = ''; - - // print_r($arguments); - // return; - - // Load the API and Logbook models - $this->load->model('api_model'); + $this->load->model('logbook_model'); - // Call the parser within the API model to build the query - $query = $this->api_model->select_parse($arguments); - // Execute the query, and retrieve the results - $data = $this->logbook_model->api_search_query($query); + $country = str_replace('"', "", $this->input->get("Country")); + $band = str_replace('"', "", $this->input->get("Band")); + $data['results'] = $this->logbook_model->dxcc_qso_details($country, $band); - // Render Page + // Render Page $data['page_title'] = "Log View - DXCC"; - $data['filter'] = str_replace("(and)", ", ", $q);//implode(", ", array_keys($a)); + $data['filter'] = "country ".$country. " and ".$band; $this->load->view('interface_assets/header', $data); $this->load->view('awards/dxcc/details'); $this->load->view('interface_assets/footer'); diff --git a/application/models/Dxcc.php b/application/models/Dxcc.php index 232c52a5..2b315629 100644 --- a/application/models/Dxcc.php +++ b/application/models/Dxcc.php @@ -21,7 +21,9 @@ class DXCC extends CI_Model { "9cm"=>0, "6cm"=>0, "3cm"=>0, - "1.25cm"=>0); + "1.25cm"=>0, + "SAT"=>0, + ); function __construct() { @@ -37,13 +39,21 @@ class DXCC extends CI_Model { // get all worked slots from database $data = $this->db->query( - "SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `".$this->config->item('table_name')."` WHERE station_id = ".$station_id."" + "SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `".$this->config->item('table_name')."` WHERE station_id = ".$station_id." AND COL_PROP_MODE != \"SAT\"" ); $worked_slots = array(); foreach($data->result() as $row){ array_push($worked_slots, $row->COL_BAND); } + $SAT_data = $this->db->query( + "SELECT distinct LOWER(`COL_PROP_MODE`) as `COL_PROP_MODE` FROM `".$this->config->item('table_name')."` WHERE station_id = ".$station_id." AND COL_PROP_MODE = \"SAT\"" + ); + + foreach($SAT_data->result() as $row){ + array_push($worked_slots, strtoupper($row->COL_PROP_MODE)); + } + // bring worked-slots in order of defined $bandslots $results = array(); @@ -52,6 +62,7 @@ class DXCC extends CI_Model { array_push($results, $slot); } } + return $results; } @@ -63,7 +74,7 @@ class DXCC extends CI_Model { $data = $this->db->query( "select COL_COUNTRY, COL_MODE, lcase(COL_BAND) as COL_BAND, count(COL_COUNTRY) as cnt from ".$this->config->item('table_name')." - where station_id = ".$station_id." + where station_id = ".$station_id." AND COL_PROP_MODE != \"SAT\" group by COL_COUNTRY, COL_MODE, COL_BAND" ); @@ -86,6 +97,32 @@ class DXCC extends CI_Model { $results[$row->COL_COUNTRY][$row->COL_BAND] += $row->cnt; } + // Satellite DXCC + + $satellite_data = $this->db->query( + "select COL_COUNTRY, COL_MODE, COL_PROP_MODE as COL_PROP_MODE, count(COL_COUNTRY) as cnt + from ".$this->config->item('table_name')." + where station_id = ".$station_id." AND COL_PROP_MODE = \"SAT\" + group by COL_COUNTRY, COL_PROP_MODE" + ); + + foreach($satellite_data->result() as $row){ + if ($last_country != $row->COL_COUNTRY){ + // new row + $results[$row->COL_COUNTRY] = $this->bandslots; + $last_country = $row->COL_COUNTRY; + } + + // update stats + if (!isset($results[$row->COL_COUNTRY])) + $results[$row->COL_COUNTRY] = []; + + if (!isset($results[$row->COL_COUNTRY][$row->COL_PROP_MODE])) + $results[$row->COL_COUNTRY][$row->COL_PROP_MODE] = 0; + + $results[$row->COL_COUNTRY][$row->COL_PROP_MODE] += $row->cnt; + } + // print_r($results); // return; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index eef35d88..8aed6401 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -174,6 +174,22 @@ class Logbook_model extends CI_Model { } } + public function dxcc_qso_details($country, $band){ + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $this->db->where('station_id', $station_id); + $this->db->where('COL_COUNTRY', $country); + if($band != "SAT") { + $this->db->where('COL_BAND', $band); + } else { + $this->db->where('COL_PROP_MODE', "SAT"); + } + + return $this->db->get($this->config->item('table_name')); + } + public function get_callsigns($callsign){ $this->db->select('COL_CALL'); $this->db->distinct();