diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 638d922c..ad3a39e7 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -347,6 +347,7 @@ class Awards extends CI_Controller { } $data['was_array'] = $this->was->get_was_array($bands, $postdata); + $data['was_summary'] = $this->was->get_was_summary($bands); // Render Page $data['page_title'] = "Awards - WAS (Worked all states)"; diff --git a/application/models/Was.php b/application/models/Was.php index 451e342d..bb10b21d 100644 --- a/application/models/Was.php +++ b/application/models/Was.php @@ -132,6 +132,67 @@ class was extends CI_Model { } } + /* + * Function gets worked and confirmed summary on each band on the active stationprofile + */ + function get_was_summary($bands) + { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + foreach ($bands as $band) { + $worked = $this->getSummaryByBand($band, $station_id); + $confirmed = $this->getSummaryByBandConfirmed($band, $station_id); + $wasSummary['worked'][$band] = $worked[0]->count; + $wasSummary['confirmed'][$band] = $confirmed[0]->count; + } + + return $wasSummary; + } + + function getSummaryByBand($band, $station_id) + { + $sql = "SELECT count(distinct thcv.col_state) as count FROM " . $this->config->item('table_name') . " thcv"; + + $sql .= " where station_id = " . $station_id; + + if ($band == 'SAT') { + $sql .= " and thcv.col_prop_mode ='" . $band . "'"; + } else { + $sql .= " and thcv.col_prop_mode !='SAT'"; + $sql .= " and thcv.col_band ='" . $band . "'"; + } + + $sql .= $this->addStateToQuery(); + + $query = $this->db->query($sql); + + return $query->result(); + } + + function getSummaryByBandConfirmed($band, $station_id) + { + $sql = "SELECT count(distinct thcv.col_state) as count FROM " . $this->config->item('table_name') . " thcv"; + + $sql .= " where station_id = " . $station_id; + + if ($band == 'SAT') { + $sql .= " and thcv.col_prop_mode ='" . $band . "'"; + } else { + $sql .= " and thcv.col_prop_mode !='SAT'"; + $sql .= " and thcv.col_band ='" . $band . "'"; + } + + $sql .= $this->addStateToQuery(); + + $sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')"; + + $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..5b0bf30d 100644 --- a/application/views/awards/was/index.php +++ b/application/views/awards/was/index.php @@ -92,8 +92,38 @@ } echo ''; } - echo ''; + echo ' +

Summary

+ + + + '; + + foreach($bands as $band) { + echo ''; + } + echo ''; + + echo ' + + + + '; + + foreach ($was_summary['worked'] as $was) { // Fills the table with the data + echo ''; + } + + echo ' + '; + foreach ($was_summary['confirmed'] as $was) { // Fills the table with the data + echo ''; + } + + echo ' +
' . $band . '
Total worked' . $was . '
Total confirmed' . $was . '
+ '; } else { echo '';