From c8b999659c0ac7086952b43e7b273a717ea4cd9b Mon Sep 17 00:00:00 2001 From: Andreas Date: Tue, 18 Aug 2020 14:41:16 +0200 Subject: [PATCH] Added summary on the WAS award page. --- application/controllers/Awards.php | 1 + application/models/Was.php | 33 ++++++++++++++++++++++++++ application/views/awards/was/index.php | 31 +++++++++++++++++++++++- 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index d1e4d9cf..ac9bde3a 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -346,6 +346,7 @@ class Awards extends CI_Controller { } $data['was_array'] = $this->was->get_was_array($bands, $postdata); + $data['was_summary'] = $this->was->get_was_summary(); // Render Page $data['page_title'] = "Awards - WAS (Worked all states)"; diff --git a/application/models/Was.php b/application/models/Was.php index 451e342d..0e63d42a 100644 --- a/application/models/Was.php +++ b/application/models/Was.php @@ -132,6 +132,39 @@ class was extends CI_Model { } } + /* + * Function gets worked and confirmed summary on each band on the active stationprofile + */ + function get_was_summary() { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $stateArray = explode(',', $this->stateString); + + $states = array(); // Used for keeping track of which states that are not worked + + $sql = "SELECT thcv.col_band, count(distinct thcv.col_state) as count, coalesce (cfmwas.count, 0) as cfmwas FROM " . $this->config->item('table_name') . " thcv"; + + $sql .= " left outer join ( + select col_band, count(distinct col_state) as count from " . $this->config->item('table_name') . " thcv"; + $sql .= " where station_id = " . $station_id; + $sql .= $this->addStateToQuery(); + + $sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y') + group by col_band"; + $sql .= ") cfmwas on thcv.col_band = cfmwas.col_band "; + + $sql .= " where station_id = " . $station_id; + + $sql .= $this->addStateToQuery(); + $sql .= " group by thcv.col_band order by thcv.col_band+0 desc"; + + $query = $this->db->query($sql); + + return $query->result(); + } + /* * Function returns all worked, but not confirmed states * $postdata contains data from the form, in this case Lotw or QSL are used diff --git a/application/views/awards/was/index.php b/application/views/awards/was/index.php index 2afa5450..b6ec561d 100644 --- a/application/views/awards/was/index.php +++ b/application/views/awards/was/index.php @@ -92,8 +92,37 @@ } echo ''; } - echo ''; + echo ' +

Summary

+ + + + '; + + foreach ($was_summary as $was) { // Fills the table with the data + echo ''; + } + + echo ' + + + + '; + + foreach ($was_summary as $was) { // Fills the table with the data + echo ''; + } + + echo ' + '; + foreach ($was_summary as $was) { // Fills the table with the data + echo ''; + } + + echo ' +
' . $was->col_band . '
Total worked' . $was->count . '
Total confirmed' . $was->cfmwas . '
+ '; } else { echo '';