From ae5c93da46343f03a5dc41c91c5a897316d2ace8 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Fri, 5 Jul 2024 21:37:50 +0200 Subject: [PATCH] save the band unit and write it in session and user_options --- application/controllers/Band.php | 11 +++++++++++ assets/js/sections/bands.js | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/application/controllers/Band.php b/application/controllers/Band.php index ccde28422..3704327ec 100644 --- a/application/controllers/Band.php +++ b/application/controllers/Band.php @@ -155,4 +155,15 @@ class Band extends CI_Controller { echo json_encode(array('message' => 'OK')); return; } + + public function saveBandUnit() { + $unit = $this->security->xss_clean($this->input->post('unit')); + $band_id = $this->security->xss_clean($this->input->post('band_id')); + + $this->load->model('bands'); + $band = $this->bands->getband($band_id)->row()->band; + + $this->user_options_model->set_option('frequency', 'unit', array($band => $unit)); + $this->session->set_userdata('qrgunit_'.$band, $unit); + } } diff --git a/assets/js/sections/bands.js b/assets/js/sections/bands.js index bb6ffb0ec..16e248715 100644 --- a/assets/js/sections/bands.js +++ b/assets/js/sections/bands.js @@ -14,6 +14,12 @@ $('.bandtable tfoot').on('click', 'input[type="checkbox"]', function() { saveBandAward(clickedaward, status); }); +$('.unitselect').change(function() { + var selectedValue = $(this).val(); + var bandId = $(this).closest('td').attr('class').split('_')[1]; + saveBandUnit(selectedValue, bandId); +}); + function saveBandAward(award, status) { $.ajax({ url: base_url + 'index.php/band/saveBandAward', @@ -230,3 +236,16 @@ function saveBand(id) { } }); } + +function saveBandUnit(unit, band_id) { + $.ajax({ + url: base_url + 'index.php/band/saveBandUnit', + type: 'post', + data: { + 'band_id': band_id, + 'unit': unit + }, + success: function(html) { + } + }) +}