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] [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,