From 587660383e3a48c8a141f8b85ab5507f76e2425c Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Thu, 26 Oct 2023 19:59:02 +0200 Subject: [PATCH] [SimpleFLE] Replaced hardcoded bands with bands from db --- application/controllers/Simplefle.php | 8 ++-- application/models/Bands.php | 24 ++++++++-- assets/js/sections/simplefle.js | 68 --------------------------- 3 files changed, 23 insertions(+), 77 deletions(-) diff --git a/application/controllers/Simplefle.php b/application/controllers/Simplefle.php index 164ba714..3c77ff2f 100644 --- a/application/controllers/Simplefle.php +++ b/application/controllers/Simplefle.php @@ -6,19 +6,19 @@ class SimpleFLE extends CI_Controller { $this->load->model('user_model'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - + $this->load->model('stations'); $this->load->model('logbook_model'); $this->load->model('modes'); $this->load->model('bands'); $data['station_profile'] = $this->stations->all_of_user(); // Used in the view for station location select - $data['bands'] = $this->bands->get_all_bands_for_user(); // Fetching Bands for FLE + $data['bands'] = $this->bands->get_all_bands(); // Fetching Bands for FLE $data['active_station_profile'] = $this->stations->find_active(); // Prepopulate active Station in Station Location Selector $data['page_title'] = "Simple Fast Log Entry"; - + $footerData = []; $footerData['scripts'] = [ 'assets/js/moment.min.js', @@ -36,4 +36,4 @@ class SimpleFLE extends CI_Controller { public function displaySyntax() { $this->load->view('simplefle/syntax_help'); } -} \ No newline at end of file +} diff --git a/application/models/Bands.php b/application/models/Bands.php index 0af87e10..b8bbf594 100644 --- a/application/models/Bands.php +++ b/application/models/Bands.php @@ -37,7 +37,7 @@ class Bands extends CI_Model { if ($award != 'None') { $this->db->where('bandxuser.'.$award, 1); } - + $result = $this->db->get()->result(); $results = array(); @@ -49,6 +49,20 @@ class Bands extends CI_Model { return $results; } + function get_all_bands() { + $this->db->from('bands'); + + $result = $this->db->get()->result(); + + $results = array(); + + foreach($result as $band) { + $results['b'.strtoupper($band->band)] = array('cw' => $band->cw, 'ssb' => $band->ssb, 'digi' => $band->data); + } + + return $results; + } + function get_user_bands_for_qso_entry($includeall = false) { $this->db->from('bands'); $this->db->join('bandxuser', 'bandxuser.bandid = bands.id'); @@ -82,7 +96,7 @@ class Bands extends CI_Model { } function get_worked_bands($award = 'None') { - + $CI =& get_instance(); $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -237,7 +251,7 @@ class Bands extends CI_Model { $clean_id = $this->security->xss_clean($id); // Delete Mode - $this->db->delete('bandxuser', array('id' => $clean_id)); + $this->db->delete('bandxuser', array('id' => $clean_id)); } function saveBand($id, $band) { @@ -287,12 +301,12 @@ class Bands extends CI_Model { $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, pota, sig, sota, uscounties, was, wwff, vucc) + $this->db->query("insert into bandxuser (bandid, userid, active, cq, dok, dxcc, iota, pota, sig, sota, uscounties, was, wwff, vucc) select bands.id, " . $this->session->userdata('user_id') . ", 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);"); } diff --git a/assets/js/sections/simplefle.js b/assets/js/sections/simplefle.js index 9c17ae98..865c2142 100644 --- a/assets/js/sections/simplefle.js +++ b/assets/js/sections/simplefle.js @@ -1,71 +1,3 @@ -var Bands = { - b160M: { - cw: "1.825", - ssb: "1.890", - digi: "1.840", - }, - b80M: { - cw: "3.532", - ssb: "3.770", - digi: "3.573", - }, - b60M: { - cw: "5.353", - ssb: "5.450", - digi: "5.357", - }, - b40M: { - cw: "7.032", - ssb: "7.100", - digi: "7.074", - }, - b30M: { - cw: "10.110", - ssb: "10.120", - digi: "10.136", - }, - b20M: { - cw: "14.032", - ssb: "14.200", - digi: "14.074", - }, - b17M: { - cw: "18.070", - ssb: "18.120", - digi: "18.104", - }, - b15M: { - cw: "21.032", - ssb: "21.200", - digi: "21.074", - }, - b12M: { - cw: "24.895", - ssb: "24.910", - digi: "24.915", - }, - b10M: { - cw: "20.032", - ssb: "28.200", - digi: "28.074", - }, - b6M: { - cw: "50.090", - ssb: "50.350", - digi: "50.313", - }, - b2M: { - cw: "144.090", - ssb: "144.250", - digi: "144.174", - }, - b70CM: { - cw: "432.050", - ssb: "432.300", - digi: "432.065", - }, -}; - var $textarea = $("textarea"); var qsodate = ""; var qsotime = "";