diff --git a/application/config/migration.php b/application/config/migration.php index 7c48317f..0768e86d 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 66; +$config['migration_version'] = 67; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 36abd6a5..02748542 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -213,14 +213,13 @@ class Awards extends CI_Controller { } public function cq(){ - $this->load->model('cq'); - $zones = array(); - foreach($this->cq->get_zones() as $row){ - array_push($zones, intval($row->COL_CQZ)); - } - $data['cqz'] = $zones; + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $data['worked_bands'] = $this->cq->get_worked_bands(); + $this->load->model('cq'); + + $data['worked_bands'] = $this->cq->get_worked_bands($station_id); if ($this->input->post('band') != NULL) { // Band is not set when page first loads. if ($this->input->post('band') == 'All') { // Did the user specify a band? If not, use all bands @@ -253,8 +252,8 @@ class Awards extends CI_Controller { $postdata['band'] = 'All'; } - $data['cq_array'] = $this->cq->get_cq_array($bands, $postdata); - $data['cq_summary'] = $this->cq->get_cq_summary($bands); + $data['cq_array'] = $this->cq->get_cq_array($bands, $postdata, $station_id); + $data['cq_summary'] = $this->cq->get_cq_summary($data['worked_bands'], $station_id); // Render page $data['page_title'] = "Awards - CQ Magazine"; diff --git a/application/migrations/067_aidd_index_cqz_prop.php b/application/migrations/067_aidd_index_cqz_prop.php new file mode 100644 index 00000000..79698faf --- /dev/null +++ b/application/migrations/067_aidd_index_cqz_prop.php @@ -0,0 +1,24 @@ +config->item('table_name')." ADD INDEX `HRD_IDX_COL_CQZ` (`COL_CQZ`);"; + $this->db->query($sql); + $sql = "ALTER TABLE ".$this->config->item('table_name')." ADD INDEX `HRD_IDX_COL_PROP_MODE` (`COL_PROP_MODE`);"; + $this->db->query($sql); + } + + public function down() + { + + } +} diff --git a/application/models/Cq.php b/application/models/Cq.php index 1acea86c..43cba558 100644 --- a/application/models/Cq.php +++ b/application/models/Cq.php @@ -15,7 +15,7 @@ class CQ extends CI_Model{ $data = $this->db->query( "select COL_CQZ, count(COL_CQZ) from ".$this->config->item('table_name')." - where COL_CQZ is not null and station_id = ".$station_id." + where COL_CQZ is not null and station_id = ".$station_id." group by COL_CQZ order by COL_CQZ" ); @@ -45,12 +45,8 @@ class CQ extends CI_Model{ "SAT" => 0, ); - function get_worked_bands() + function get_worked_bands($station_id) { - $CI =& get_instance(); - $CI->load->model('Stations'); - $station_id = $CI->Stations->find_active(); - // 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 . " AND COL_PROP_MODE != \"SAT\"" @@ -78,11 +74,7 @@ class CQ extends CI_Model{ return $results; } - function get_cq_array($bands, $postdata) { - $CI =& get_instance(); - $CI->load->model('Stations'); - $station_id = $CI->Stations->find_active(); - + function get_cq_array($bands, $postdata, $station_id) { $cqZ = array(); // Used for keeping track of which states that are not worked for ($i = 1; $i <= 40; $i++) { @@ -146,7 +138,7 @@ class CQ extends CI_Model{ * $postdata contains data from the form, in this case Lotw or QSL are used */ function getCQWorked($station_id, $band, $postdata) { - $sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv + $sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv where station_id = " . $station_id . " and col_cqz <> ''"; $sql .= $this->addBandToQuery($band); @@ -171,7 +163,7 @@ class CQ extends CI_Model{ * $postdata contains data from the form, in this case Lotw or QSL are used */ function getCQConfirmed($station_id, $band, $postdata) { - $sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv + $sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv where station_id = " . $station_id . " and col_cqz <> ''"; $sql .= $this->addBandToQuery($band); @@ -215,11 +207,7 @@ class CQ extends CI_Model{ /* * Function gets worked and confirmed summary on each band on the active stationprofile */ - function get_cq_summary($bands) { - $CI =& get_instance(); - $CI->load->model('Stations'); - $station_id = $CI->Stations->find_active(); - + function get_cq_summary($bands, $station_id) { foreach ($bands as $band) { $worked = $this->getSummaryByBand($band, $station_id); $confirmed = $this->getSummaryByBandConfirmed($band, $station_id); diff --git a/application/views/awards/cq/index.php b/application/views/awards/cq/index.php index c4374fd8..5dee09c5 100644 --- a/application/views/awards/cq/index.php +++ b/application/views/awards/cq/index.php @@ -134,8 +134,8 @@
- - + +
@@ -172,7 +172,7 @@ '; - foreach($bands as $band) { + foreach($worked_bands as $band) { echo '' . $band . ''; } echo 'Total