From 6bfdd8a3d505e566af5101cdc516271c6f424a27 Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 5 Oct 2022 23:23:32 +0200 Subject: [PATCH 1/3] Hide SAT stuff if SAT band is disabled --- application/controllers/Activated_grids.php | 2 ++ application/controllers/Gridsquares.php | 2 ++ application/controllers/Qso.php | 3 ++- application/controllers/Statistics.php | 2 ++ application/views/activated_grids/main.php | 2 ++ application/views/gridsquares/main.php | 4 +++- application/views/qso/index.php | 2 ++ application/views/statistics/index.php | 2 ++ 8 files changed, 17 insertions(+), 2 deletions(-) diff --git a/application/controllers/Activated_grids.php b/application/controllers/Activated_grids.php index aab6ca04..2bbbaf84 100644 --- a/application/controllers/Activated_grids.php +++ b/application/controllers/Activated_grids.php @@ -19,6 +19,7 @@ class Activated_grids extends CI_Controller { public function index() { // if there are no satellite QSOs redirect to band selection directly $this->load->model('logbook_model'); + $this->load->model('bands'); $total_sat = $this->logbook_model->total_sat(); if ($total_sat->num_rows() == 0) { redirect('activated_grids/band/2m'); @@ -26,6 +27,7 @@ class Activated_grids extends CI_Controller { } $data['page_title'] = "Activated Gridsquare Map"; + $data['sat_active'] = array_search("SAT", $this->bands->get_user_bands(), true); $this->load->view('interface_assets/header', $data); $this->load->view('activated_grids/main.php'); diff --git a/application/controllers/Gridsquares.php b/application/controllers/Gridsquares.php index 0034963d..87dbafe0 100644 --- a/application/controllers/Gridsquares.php +++ b/application/controllers/Gridsquares.php @@ -19,6 +19,7 @@ class Gridsquares extends CI_Controller { public function index() { // if there are no satellite QSOs redirect to band selection directly $this->load->model('logbook_model'); + $this->load->model('bands'); $total_sat = $this->logbook_model->total_sat(); if ($total_sat->num_rows() == 0) { redirect('gridsquares/band/2m'); @@ -26,6 +27,7 @@ class Gridsquares extends CI_Controller { } $data['page_title'] = "Gridsquare Map"; + $data['sat_active'] = array_search("SAT", $this->bands->get_user_bands(), true); $this->load->view('interface_assets/header', $data); $this->load->view('gridsquares/main.php'); diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 491da78d..6652b5f7 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -37,7 +37,8 @@ class QSO extends CI_Controller { $data['dxcc'] = $this->logbook_model->fetchDxcc(); $data['iota'] = $this->logbook_model->fetchIota(); $data['modes'] = $this->modes->active(); - $data['bands'] = $this->bands->get_user_bands_for_qso_entry(); + $data['bands'] = $this->bands->get_user_bands_for_qso_entry(); + $data['sat_active'] = array_search("SAT", $this->bands->get_user_bands(), true); $this->load->library('form_validation'); diff --git a/application/controllers/Statistics.php b/application/controllers/Statistics.php index 4e3a33ec..9d187b13 100644 --- a/application/controllers/Statistics.php +++ b/application/controllers/Statistics.php @@ -5,6 +5,7 @@ class Statistics extends CI_Controller { public function index() { $this->load->model('user_model'); + $this->load->model('bands'); if(!$this->user_model->authorize($this->config->item('auth_mode'))) { if($this->user_model->validate_session()) { $this->user_model->clear_session(); @@ -17,6 +18,7 @@ class Statistics extends CI_Controller { // Set Page Title $data['page_title'] = "Statistics"; + $data['sat_active'] = array_search("SAT", $this->bands->get_user_bands(), true); // Load Views $this->load->view('interface_assets/header', $data); diff --git a/application/views/activated_grids/main.php b/application/views/activated_grids/main.php index bb753951..1858097a 100644 --- a/application/views/activated_grids/main.php +++ b/application/views/activated_grids/main.php @@ -12,7 +12,9 @@

diff --git a/application/views/gridsquares/main.php b/application/views/gridsquares/main.php index 6ed99789..511b0fa4 100644 --- a/application/views/gridsquares/main.php +++ b/application/views/gridsquares/main.php @@ -12,7 +12,9 @@

- \ No newline at end of file + diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 30e1fe6d..9cdb213d 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -21,9 +21,11 @@ lang->line('general_word_general'); ?> + + + + From ccacc244db3986c0a1837208941ff7c1242955a3 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Thu, 6 Oct 2022 11:41:01 +0200 Subject: [PATCH 2/3] [Bands] Added master checkbox for award --- application/controllers/Band.php | 12 +++++++ application/models/Bands.php | 12 +++++++ application/views/bands/index.php | 52 +++++++++++++++++++++++++------ assets/js/sections/bands.js | 22 +++++++++++++ 4 files changed, 88 insertions(+), 10 deletions(-) diff --git a/application/controllers/Band.php b/application/controllers/Band.php index acce57b8..04c6ec17 100644 --- a/application/controllers/Band.php +++ b/application/controllers/Band.php @@ -137,4 +137,16 @@ class Band extends CI_Controller { echo json_encode(array('message' => 'OK')); return; } + + public function saveBandAward() { + $award = $this->security->xss_clean($this->input->post('award')); + $status = $this->security->xss_clean($this->input->post('status')); + + $this->load->model('bands'); + $this->bands->saveBandAward($award, $status); + + header('Content-Type: application/json'); + echo json_encode(array('message' => 'OK')); + return; + } } \ No newline at end of file diff --git a/application/models/Bands.php b/application/models/Bands.php index a31582e5..f8eee324 100644 --- a/application/models/Bands.php +++ b/application/models/Bands.php @@ -260,6 +260,18 @@ class Bands extends CI_Model { $this->db->update('bandxuser', $data); + return true; + } + + function saveBandAward($award, $status) { + $data = array( + $award => $status == "true" ? '1' : '0', + ); + + $this->db->where('bandxuser.userid', $this->session->userdata('user_id')); + + $this->db->update('bandxuser', $data); + return true; } diff --git a/application/views/bands/index.php b/application/views/bands/index.php index ad01691e..ec79ddb5 100644 --- a/application/views/bands/index.php +++ b/application/views/bands/index.php @@ -1,3 +1,15 @@ +

@@ -51,16 +63,16 @@ active == 1) {echo 'checked';}?>> band;?> - cq == 1) {echo 'checked';}?>> - dok == 1) {echo 'checked';}?>> - dxcc == 1) {echo 'checked';}?>> - iota == 1) {echo 'checked';}?>> - sig == 1) {echo 'checked';}?>> - sota == 1) {echo 'checked';}?>> - uscounties == 1) {echo 'checked';}?>> - vucc == 1) {echo 'checked';}?>> - was == 1) {echo 'checked';}?>> - wwff == 1) {echo 'checked';}?>> + cq == 1) {echo 'checked'; $cq++;}?>> + dok == 1) {echo 'checked'; $dok++;}?>> + dxcc == 1) {echo 'checked'; $dxcc++;}?>> + iota == 1) {echo 'checked'; $iota++;}?>> + sig == 1) {echo 'checked'; $sig++;}?>> + sota == 1) {echo 'checked'; $sota++;}?>> + uscounties == 1) {echo 'checked'; $uscounties++;}?>> + vucc == 1) {echo 'checked'; $vucc++;}?>> + was == 1) {echo 'checked'; $was++;}?>> + wwff == 1) {echo 'checked'; $wwff++;}?>> bandgroup;?> ssb;?> data;?> @@ -75,6 +87,26 @@ + + + + 0) echo 'checked';?>> + 0) echo 'checked';?>> + 0) echo 'checked';?>> + 0) echo 'checked';?>> + 0) echo 'checked';?>> + 0) echo 'checked';?>> + 0) echo 'checked';?>> + 0) echo 'checked';?>> + 0) echo 'checked';?>> + 0) echo 'checked';?>> + + + + + + +
diff --git a/assets/js/sections/bands.js b/assets/js/sections/bands.js index 806fa529..28591992 100644 --- a/assets/js/sections/bands.js +++ b/assets/js/sections/bands.js @@ -4,6 +4,28 @@ $('.bandtable').on('click', 'input[type="checkbox"]', function() { saveBand(clickedbandid); }); +$('.bandtable tfoot').on('click', 'input[type="checkbox"]', function() { + var clickedaward = $(this).closest('th').attr("class"); + var status = $(this).is(":checked"); + clickedaward = clickedaward.replace('master_', ''); + $('[class^='+clickedaward+'_] input[type="checkbox').each(function() { + $(this).prop( "checked", status ); + }); + saveBandAward(clickedaward, status); +}); + +function saveBandAward(award, status) { + $.ajax({ + url: base_url + 'index.php/band/saveBandAward', + type: 'post', + data: {'award': award, + 'status': status, + }, + success: function (html) { + } + }); +} + $('.bandtable').DataTable({ "pageLength": 25, responsive: false, From 00ecfa8e5aefc27087fb0d1c20bcbcde73124610 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 6 Oct 2022 12:51:36 +0200 Subject: [PATCH 3/3] Only serve JS if maps are really to be displayed Signed-off-by: phl0 --- application/views/interface_assets/footer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 73e4c99a..ce0b2e0d 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1292,7 +1292,7 @@ $(document).ready(function(){ -uri->segment(1) == "gridsquares") { ?> +uri->segment(1) == "gridsquares" && !empty($this->uri->segment(2))) { ?> @@ -1435,7 +1435,7 @@ $(document).ready(function(){ -uri->segment(1) == "activated_grids") { ?> +uri->segment(1) == "activated_grids" && !empty($this->uri->segment(2))) { ?>