From be72a332b647a973180357b191eb9ae48ff4e981 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Thu, 8 Sep 2022 20:12:11 +0200 Subject: [PATCH] [Bands] QSO entry band/bandrx dropdown is now fetched from db --- application/controllers/Qso.php | 2 + application/models/Bands.php | 18 +++++++ application/views/qso/index.php | 84 ++++++++------------------------- 3 files changed, 40 insertions(+), 64 deletions(-) diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 5ffeac2d..f8a11276 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -26,6 +26,7 @@ class QSO extends CI_Controller { $this->load->model('logbook_model'); $this->load->model('user_model'); $this->load->model('modes'); + $this->load->model('bands'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } $data['active_station_profile'] = $this->stations->find_active(); @@ -37,6 +38,7 @@ class QSO extends CI_Controller { $data['dxcc'] = $this->logbook_model->fetchDxcc(); $data['iota'] = $this->logbook_model->fetchIota(); $data['modes'] = $this->modes->active(); + $data['bands'] = $this->bands->get_user_bands_for_qso_entry(); $this->load->library('form_validation'); diff --git a/application/models/Bands.php b/application/models/Bands.php index 2015aa57..209aa1a0 100644 --- a/application/models/Bands.php +++ b/application/models/Bands.php @@ -49,6 +49,24 @@ class Bands extends CI_Model { return $results; } + function get_user_bands_for_qso_entry() { + $this->db->from('bands'); + $this->db->join('bandxuser', 'bandxuser.bandid = bands.id'); + $this->db->where('bandxuser.userid', $this->session->userdata('user_id')); + $this->db->where('bandxuser.active', 1); + $this->db->where('bands.bandgroup != "sat"'); + + $result = $this->db->get()->result(); + + $results = array(); + + foreach($result as $band) { + $results[$band->bandgroup][] = $band->band; + } + + return $results; + } + function get_all_bands_for_user() { $this->db->from('bands'); $this->db->join('bandxuser', 'bandxuser.bandid = bands.id'); diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 24949967..30e1fe6d 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -91,38 +91,16 @@ @@ -208,38 +186,16 @@