save the band unit and write it in session and user_options

This commit is contained in:
HB9HIL
2024-07-05 21:37:50 +02:00
parent 44ee68c19f
commit ae5c93da46
2 changed files with 30 additions and 0 deletions

View File

@@ -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);
}
}

View File

@@ -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) {
}
})
}