From 1bedfbb919648b04f67bf49fbd65f8dfcec8129e Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Thu, 6 Jan 2022 19:35:08 +0100 Subject: [PATCH] [CQ Award] Added filtering to the summary --- application/controllers/Awards.php | 2 +- application/models/Cq.php | 26 +++++++++++++++++--------- application/views/awards/cq/index.php | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 5549dd2e..6ef3cda4 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -278,7 +278,7 @@ class Awards extends CI_Controller { if ($logbooks_locations_array) { $location_list = "'".implode("','",$logbooks_locations_array)."'"; $data['cq_array'] = $this->cq->get_cq_array($bands, $postdata, $location_list); - $data['cq_summary'] = $this->cq->get_cq_summary($data['worked_bands'], $location_list); + $data['cq_summary'] = $this->cq->get_cq_summary($bands, $postdata, $location_list); } else { $location_list = null; $data['cq_array'] = null; diff --git a/application/models/Cq.php b/application/models/Cq.php index 6ebdb2b8..86c452a3 100644 --- a/application/models/Cq.php +++ b/application/models/Cq.php @@ -162,16 +162,16 @@ class CQ extends CI_Model{ /* * Function gets worked and confirmed summary on each band on the active stationprofile */ - function get_cq_summary($bands, $location_list) { + function get_cq_summary($bands, $postdata, $location_list) { foreach ($bands as $band) { - $worked = $this->getSummaryByBand($band, $location_list); - $confirmed = $this->getSummaryByBandConfirmed($band, $location_list); + $worked = $this->getSummaryByBand($band, $postdata, $location_list); + $confirmed = $this->getSummaryByBandConfirmed($band, $postdata, $location_list); $cqSummary['worked'][$band] = $worked[0]->count; $cqSummary['confirmed'][$band] = $confirmed[0]->count; } - $workedTotal = $this->getSummaryByBand('All', $location_list); - $confirmedTotal = $this->getSummaryByBandConfirmed('All', $location_list); + $workedTotal = $this->getSummaryByBand($postdata['band'], $postdata, $location_list); + $confirmedTotal = $this->getSummaryByBandConfirmed($postdata['band'], $postdata, $location_list); $cqSummary['worked']['Total'] = $workedTotal[0]->count; $cqSummary['confirmed']['Total'] = $confirmedTotal[0]->count; @@ -179,7 +179,7 @@ class CQ extends CI_Model{ return $cqSummary; } - function getSummaryByBand($band, $location_list) { + function getSummaryByBand($band, $postdata, $location_list) { $sql = "SELECT count(distinct thcv.col_cqz) as count FROM " . $this->config->item('table_name') . " thcv"; $sql .= " where station_id in (" . $location_list . ') and col_cqz > 0'; @@ -191,14 +191,18 @@ class CQ extends CI_Model{ } else { $sql .= " and thcv.col_prop_mode !='SAT'"; $sql .= " and thcv.col_band ='" . $band . "'"; - } + + if ($postdata['mode'] != 'All') { + $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; + } + $query = $this->db->query($sql); return $query->result(); } - function getSummaryByBandConfirmed($band, $location_list){ + function getSummaryByBandConfirmed($band, $postdata, $location_list){ $sql = "SELECT count(distinct thcv.col_cqz) as count FROM " . $this->config->item('table_name') . " thcv"; $sql .= " where station_id in (" . $location_list . ') and col_cqz > 0'; @@ -212,7 +216,11 @@ class CQ extends CI_Model{ $sql .= " and thcv.col_band ='" . $band . "'"; } - $sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')"; + if ($postdata['mode'] != 'All') { + $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; + } + + $sql .= $this->addQslToQuery($postdata); $query = $this->db->query($sql); diff --git a/application/views/awards/cq/index.php b/application/views/awards/cq/index.php index 85031bb1..c56ad86e 100644 --- a/application/views/awards/cq/index.php +++ b/application/views/awards/cq/index.php @@ -192,7 +192,7 @@ '; - foreach($worked_bands as $band) { + foreach($bands as $band) { echo '' . $band . ''; } echo 'Total