From 7da34e190025d4ffd1b7193febaa621ae59f2a83 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Sun, 3 Mar 2024 08:58:56 +0100 Subject: [PATCH] [Bands] Added RAC and JCC. And some future proofing --- application/controllers/Band.php | 22 ++++++++++++---------- application/models/Bands.php | 8 +++++--- application/models/User_model.php | 2 +- application/views/bands/index.php | 8 ++++++++ assets/js/sections/bands.js | 2 ++ 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/application/controllers/Band.php b/application/controllers/Band.php index d56e7a05d..0bedbad6a 100644 --- a/application/controllers/Band.php +++ b/application/controllers/Band.php @@ -20,7 +20,7 @@ class Band extends CI_Controller { $this->load->model('bands'); $data['bands'] = $this->bands->get_all_bands_for_user(); - + // Render Page $data['page_title'] = "Bands"; $this->load->view('interface_assets/header', $data); @@ -28,7 +28,7 @@ class Band extends CI_Controller { $this->load->view('interface_assets/footer'); } - public function create() + public function create() { $this->load->model('bands'); $this->load->library('form_validation'); @@ -41,7 +41,7 @@ class Band extends CI_Controller { $this->load->view('bands/create', $data); } else - { + { $this->bands->add(); } } @@ -55,7 +55,7 @@ class Band extends CI_Controller { $band_query = $this->bands->getband($item_id_clean); $data['my_band'] = $band_query->row(); - + $data['page_title'] = "Edit Band"; $this->load->view('bands/edit', $data); @@ -122,8 +122,11 @@ class Band extends CI_Controller { $band['cq'] = $this->security->xss_clean($this->input->post('cq')); $band['dok'] = $this->security->xss_clean($this->input->post('dok')); $band['dxcc'] = $this->security->xss_clean($this->input->post('dxcc')); - $band['helvetia'] = $this->security->xss_clean($this->input->post('helvetia')); + $band['helvetia'] = $this->security->xss_clean($this->input->post('helvetia')); $band['iota'] = $this->security->xss_clean($this->input->post('iota')); + $band['jcc'] = $this->security->xss_clean($this->input->post('jcc')); + $band['pota'] = $this->security->xss_clean($this->input->post('pota')); + $band['rac'] = $this->security->xss_clean($this->input->post('rac')); $band['sig'] = $this->security->xss_clean($this->input->post('sig')); $band['sota'] = $this->security->xss_clean($this->input->post('sota')); $band['uscounties'] = $this->security->xss_clean($this->input->post('uscounties')); @@ -131,11 +134,10 @@ class Band extends CI_Controller { $band['wwff'] = $this->security->xss_clean($this->input->post('wwff')); $band['vucc'] = $this->security->xss_clean($this->input->post('vucc')); $band['waja'] = $this->security->xss_clean($this->input->post('waja')); - $band['pota'] = $this->security->xss_clean($this->input->post('pota')); - + $this->load->model('bands'); $this->bands->saveBand($id, $band); - + header('Content-Type: application/json'); echo json_encode(array('message' => 'OK')); return; @@ -144,10 +146,10 @@ class Band extends CI_Controller { 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; diff --git a/application/models/Bands.php b/application/models/Bands.php index 2a8df6cc5..3b932e756 100644 --- a/application/models/Bands.php +++ b/application/models/Bands.php @@ -260,9 +260,11 @@ class Bands extends CI_Model { 'cq' => $band['cq'] == "true" ? '1' : '0', 'dok' => $band['dok'] == "true" ? '1' : '0', 'dxcc' => $band['dxcc'] == "true" ? '1' : '0', - 'helvetia' => $band['helvetia'] == "true" ? '1' : '0', + 'helvetia' => $band['helvetia'] == "true" ? '1' : '0', 'iota' => $band['iota'] == "true" ? '1' : '0', + 'jcc' => $band['jcc'] == "true" ? '1' : '0', 'pota' => $band['pota'] == "true" ? '1' : '0', + 'rac' => $band['rac'] == "true" ? '1' : '0', 'sig' => $band['sig'] == "true" ? '1' : '0', 'sota' => $band['sota'] == "true" ? '1' : '0', 'uscounties' => $band['uscounties'] == "true" ? '1' : '0', @@ -308,8 +310,8 @@ class Bands extends CI_Model { $this->db->insert('bands', $data); } - $this->db->query("insert into bandxuser (bandid, userid, active, cq, dok, dxcc, helvetia, iota, pota, sig, sota, uscounties, was, wwff, vucc, waja) - select bands.id, " . $this->session->userdata('user_id') . ", 1, 1, 1, 1, 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);"); + $this->db->query("insert into bandxuser (bandid, userid) + select bands.id, " . $this->session->userdata('user_id') . " from bands where band ='".$data['band']."' and not exists (select 1 from bandxuser where userid = " . $this->session->userdata('user_id') . " and bandid = bands.id);"); } function getband($id) { diff --git a/application/models/User_model.php b/application/models/User_model.php index 3783f84a3..44b33b849 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -200,7 +200,7 @@ class User_Model extends CI_Model { // Add user and insert bandsettings for user $this->db->insert($this->config->item('auth_table'), $data); $insert_id = $this->db->insert_id(); - $this->db->query("insert into bandxuser (bandid, userid, active, cq, dok, dxcc, helvetia, iota, pota, sig, sota, uscounties, was, wwff, vucc, waja, rac) select bands.id, " . $insert_id . ", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 from bands;"); + $this->db->query("insert into bandxuser (bandid, userid, active) select bands.id, " . $insert_id . " from bands;"); $this->db->query("insert into paper_types (user_id,paper_name,metric,width,orientation,height) SELECT ".$insert_id.", paper_name, metric, width, orientation,height FROM paper_types where user_id = -1;"); return OK; } else { diff --git a/application/views/bands/index.php b/application/views/bands/index.php index a0c4f04ef..85bf0e3d8 100644 --- a/application/views/bands/index.php +++ b/application/views/bands/index.php @@ -4,7 +4,9 @@ $dok = 0; $dxcc = 0; $helvetia = 0; $iota = 0; +$jcc = 0; $pota = 0; +$rac = 0; $sig = 0; $sota = 0; $uscounties = 0; @@ -48,7 +50,9 @@ $wwff = 0;