From 88c4a10d355d55d9cf502dc5494d243717bf8cc0 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 27 Jul 2021 12:11:41 +0200 Subject: [PATCH] [Awards WAS] Added mode filtering. --- application/controllers/Awards.php | 18 ++++++---- application/models/Was.php | 16 +++++++-- application/views/awards/was/index.php | 35 ++++++++++++++----- application/views/awards/was/map.php | 2 +- application/views/interface_assets/footer.php | 4 +-- 5 files changed, 55 insertions(+), 20 deletions(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index e26b82c3..87af9d77 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -274,7 +274,10 @@ class Awards extends CI_Controller { public function was() { $this->load->model('was'); + $this->load->model('modes'); + $data['worked_bands'] = $this->was->get_worked_bands(); + $data['modes'] = $this->modes->active(); // Used in the view for mode select 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 @@ -297,6 +300,7 @@ class Awards extends CI_Controller { $postdata['confirmed'] = $this->input->post('confirmed'); $postdata['notworked'] = $this->input->post('notworked'); $postdata['band'] = $this->input->post('band'); + $postdata['mode'] = $this->input->post('mode'); } else { // Setting default values at first load of page $postdata['lotw'] = 1; @@ -305,10 +309,11 @@ class Awards extends CI_Controller { $postdata['confirmed'] = 1; $postdata['notworked'] = 1; $postdata['band'] = 'All'; + $postdata['mode'] = 'All'; } $data['was_array'] = $this->was->get_was_array($bands, $postdata); - $data['was_summary'] = $this->was->get_was_summary($bands); + $data['was_summary'] = $this->was->get_was_summary($data['worked_bands']); // Render Page $data['page_title'] = "Awards - WAS (Worked All States)"; @@ -467,24 +472,23 @@ class Awards extends CI_Controller { /* function was_map - This displays the WAS map and requires the $band_type + This displays the WAS map and requires the $band_type and $mode_type */ - public function was_map($band_type) { + public function was_map($band_type, $mode_type) { $this->load->model('was'); - $data['worked_bands'] = $this->was->get_worked_bands(); + + $data['mode'] = $mode_type; $bands[] = $band_type; - $data['bands'] = $bands; // Used for displaying selected band(s) in the table in the view - $postdata['lotw'] = 1; $postdata['qsl'] = 1; $postdata['worked'] = 1; $postdata['confirmed'] = 1; $postdata['notworked'] = 1; $postdata['band'] = $band_type; - + $postdata['mode'] = $mode_type; $data['was_array'] = $this->was->get_was_array($bands, $postdata); diff --git a/application/models/Was.php b/application/models/Was.php index c6e76394..0d98cdd3 100644 --- a/application/models/Was.php +++ b/application/models/Was.php @@ -87,14 +87,14 @@ class was extends CI_Model { if ($postdata['worked'] != NULL) { $wasBand = $this->getWasWorked($station_id, $band, $postdata); foreach ($wasBand as $line) { - $bandWas[$line->col_state][$band] = '
col_state . '","' . $band . '","All","WAS")\'>W
'; + $bandWas[$line->col_state][$band] = '
col_state . '","' . $band . '","'. $postdata['mode'] . '","WAS")\'>W
'; $states[$line->col_state]['count']++; } } if ($postdata['confirmed'] != NULL) { $wasBand = $this->getWasConfirmed($station_id, $band, $postdata); foreach ($wasBand as $line) { - $bandWas[$line->col_state][$band] = '
col_state . '","' . $band . '","All","WAS")\'>C
'; + $bandWas[$line->col_state][$band] = '
col_state . '","' . $band . '","'. $postdata['mode'] . '","WAS")\'>C
'; $states[$line->col_state]['count']++; } } @@ -211,6 +211,10 @@ class was extends CI_Model { $sql = "SELECT distinct col_state FROM " . $this->config->item('table_name') . " thcv where station_id = " . $station_id; + if ($postdata['mode'] != 'All') { + $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; + } + $sql .= $this->addStateToQuery(); $sql .= $this->addBandToQuery($band); @@ -219,6 +223,10 @@ class was extends CI_Model { " where station_id = ". $station_id . " and col_state = thcv.col_state"; + if ($postdata['mode'] != 'All') { + $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; + } + $sql .= $this->addBandToQuery($band); $sql .= $this->addQslToQuery($postdata); @@ -240,6 +248,10 @@ class was extends CI_Model { $sql = "SELECT distinct col_state FROM " . $this->config->item('table_name') . " thcv where station_id = " . $station_id; + if ($postdata['mode'] != 'All') { + $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; + } + $sql .= $this->addStateToQuery(); $sql .= $this->addBandToQuery($band); diff --git a/application/views/awards/was/index.php b/application/views/awards/was/index.php index 5531b8f3..904346f8 100644 --- a/application/views/awards/was/index.php +++ b/application/views/awards/was/index.php @@ -5,7 +5,6 @@
-
Worked / Confirmed
@@ -38,11 +37,10 @@
-
-
- +
+ +
+ +
+
+
- - - + + +
@@ -99,7 +118,7 @@ '; - foreach($bands as $band) { + foreach($worked_bands as $band) { echo '' . $band . ''; } echo 'Total diff --git a/application/views/awards/was/map.php b/application/views/awards/was/map.php index 77c8fc1a..f01f6bfc 100644 --- a/application/views/awards/was/map.php +++ b/application/views/awards/was/map.php @@ -135,7 +135,7 @@ 'click' : function(event, data) { - displayContacts(data.name,$('#band2').val(), 'All', 'WAS'); + displayContacts(data.name,$('#band2').val(), $('#mode').val(), 'WAS'); } }); diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 247fb398..7eab74c4 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -23,9 +23,9 @@ function load_was_map() { BootstrapDialog.show({ - title: 'Worked All States Map ('+$('#band2').val()+')', + title: 'Worked All States Map ('+$('#band2').val()+' '+$('#mode').val()+')', cssClass: 'was-map-dialog', - message: $('
').load(site_url + '/awards/was_map/' + $('#band2').val()) + message: $('
').load(site_url + '/awards/was_map/' + $('#band2').val() + '/' + $('#mode').val()) }); }