diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index ac9bde3a..9e1f5ee4 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -128,6 +128,7 @@ class Awards extends CI_Controller { $dxcclist = $this->dxcc->fetchdxcc($postdata); $data['dxcc_array'] = $this->dxcc->get_dxcc_array($dxcclist, $bands, $postdata); + $data['dxcc_summary'] = $this->dxcc->get_dxcc_summary($bands); // Render Page $data['page_title'] = "Awards - DXCC"; diff --git a/application/models/Dxcc.php b/application/models/Dxcc.php index 6cfd44cc..adac88f0 100644 --- a/application/models/Dxcc.php +++ b/application/models/Dxcc.php @@ -463,5 +463,62 @@ class DXCC extends CI_Model { } return $sql; } + + /* + * Function gets worked and confirmed summary on each band on the active stationprofile + */ + function get_dxcc_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); + $dxccSummary['worked'][$band] = $worked[0]->count; + $dxccSummary['confirmed'][$band] = $confirmed[0]->count; + } + + return $dxccSummary; + } + + function getSummaryByBand($band, $station_id) + { + $sql = "SELECT thcv.col_band, count(distinct thcv.col_dxcc) 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 . "'"; + + } + $query = $this->db->query($sql); + + return $query->result(); + } + + function getSummaryByBandConfirmed($band, $station_id) + { + $sql = "SELECT thcv.col_band, count(distinct thcv.col_dxcc) 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 .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')"; + + $query = $this->db->query($sql); + + return $query->result(); + } } ?> diff --git a/application/views/awards/dxcc/index.php b/application/views/awards/dxcc/index.php index ca54f6f9..5f9771b0 100644 --- a/application/views/awards/dxcc/index.php +++ b/application/views/awards/dxcc/index.php @@ -1,9 +1,9 @@
'; + + foreach($bands as $band) { + echo ' | ' . $band . ' | '; + } + echo '
Total worked | '; + + foreach ($dxcc_summary['worked'] as $dxcc) { // Fills the table with the data + echo '' . $dxcc . ' | '; + } + + echo '
Total confirmed | '; + foreach ($dxcc_summary['confirmed'] as $dxcc) { // Fills the table with the data + echo '' . $dxcc . ' | '; + } + + echo '