From 7326c7ec359aaf853c209cdf30190f5add48a33c Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 6 Sep 2022 19:35:27 +0200 Subject: [PATCH] [Bands] Can now create new band --- application/controllers/Band.php | 5 ++--- application/models/Bands.php | 15 ++++++++++++++ application/views/bands/create.php | 32 ++++++++++++++++++++++++++++++ assets/js/sections/bands.js | 28 +------------------------- 4 files changed, 50 insertions(+), 30 deletions(-) create mode 100644 application/views/bands/create.php diff --git a/application/controllers/Band.php b/application/controllers/Band.php index d590fd15..5d3bf386 100644 --- a/application/controllers/Band.php +++ b/application/controllers/Band.php @@ -33,13 +33,12 @@ class Band extends CI_Controller { $this->load->model('bands'); $this->load->library('form_validation'); - $this->form_validation->set_rules('mode', 'Mode', 'required'); - $this->form_validation->set_rules('qrgmode', 'QRG-Mode', 'required'); + $this->form_validation->set_rules('band', 'Band', 'required'); if ($this->form_validation->run() == FALSE) { $data['page_title'] = "Create Mode"; - $this->load->view('mode/create', $data); + $this->load->view('bands/create', $data); } else { diff --git a/application/models/Bands.php b/application/models/Bands.php index 36e86731..cf7e51f9 100644 --- a/application/models/Bands.php +++ b/application/models/Bands.php @@ -242,6 +242,21 @@ class Bands extends CI_Model { return true; } + function add() { + $data = array( + 'band' => xss_clean($this->input->post('band', true)), + ); + + $this->db->where('band', xss_clean($this->input->post('band', true))); + $result = $this->db->get('bands'); + + if ($result->num_rows() == 0) { + $this->db->insert('bands', $data); + } + + $this->db->query("insert into bandxuser (bandid, userid, active, cq, dok, dxcc, iota, sig, sota, uscounties, was, vucc) + select bands.id, " . $this->session->userdata('user_id') . ", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 from bands where band ='".$data['band']."' and not exists (select 1 from bandxuser where userid = " . $this->session->userdata('user_id') . " and bandid = bands.id);"); + } } ?> \ No newline at end of file diff --git a/application/views/bands/create.php b/application/views/bands/create.php new file mode 100644 index 00000000..fa55a435 --- /dev/null +++ b/application/views/bands/create.php @@ -0,0 +1,32 @@ + +
+ +
+ session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+ + + session->flashdata('notice')) { ?> +
+ session->flashdata('notice'); ?> +
+ + + load->helper('form'); ?> + + + +
+
+ + + Band name +
+ + + +
+
\ No newline at end of file diff --git a/assets/js/sections/bands.js b/assets/js/sections/bands.js index 91424736..4c35ab6e 100644 --- a/assets/js/sections/bands.js +++ b/assets/js/sections/bands.js @@ -31,7 +31,7 @@ function createBandDialog() { } function createBand(form) { - if (form.mode.value != '') { + if (form.band.value != '') { $.ajax({ url: base_url + 'index.php/band/create', type: 'post', @@ -45,32 +45,6 @@ function createBand(form) { } } -function deactivateBand(bandid) { - $.ajax({ - url: base_url + 'index.php/band/deactivate', - type: 'post', - data: { 'id': bandid }, - success: function (html) { - $(".mode_" + modeid).text('not active'); - $('.btn_' + modeid).html('Activate'); - $('.btn_' + modeid).attr('onclick', 'activateMode(' + modeid + ')') - } - }); -} - -function activateBand(bandid) { - $.ajax({ - url: base_url + 'index.php/band/activate', - type: 'post', - data: { 'id': bandid }, - success: function (html) { - $('.mode_' + modeid).text('active'); - $('.btn_' + modeid).html('Deactivate'); - $('.btn_' + modeid).attr('onclick', 'deactivateMode(' + modeid + ')') - } - }); -} - function deleteBand(id, band) { BootstrapDialog.confirm({ title: 'DANGER',