From 6f2e7a9dd2c408737af6a1f1068b88f74c2d18ff Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Fri, 22 Nov 2024 09:54:30 +0100 Subject: [PATCH] Reworked page. Added azimuth chart with filters --- application/controllers/Statistics.php | 20 ++- application/models/Stats.php | 53 +++++++ .../views/statistics/antennaanalytics.php | 150 ++++++++++++++---- assets/js/sections/antennastats.js | 77 ++++++++- 4 files changed, 263 insertions(+), 37 deletions(-) diff --git a/application/controllers/Statistics.php b/application/controllers/Statistics.php index 5a1014015..bc17d92c7 100644 --- a/application/controllers/Statistics.php +++ b/application/controllers/Statistics.php @@ -239,13 +239,18 @@ class Statistics extends CI_Controller { public function antennaanalytics() { $this->load->model('stats'); + $this->load->model('logbookadvanced_model'); + $this->load->model('bands'); $data = array(); $data['azelarray'] = $this->stats->azeldata(); $data['satellites'] = $this->stats->get_sats(); - + $data['bands'] = $this->bands->get_worked_bands(); + $data['modes'] = $this->logbookadvanced_model->get_modes(); + $data['sats'] = $this->bands->get_worked_sats(); + $data['orbits'] = $this->bands->get_worked_orbits(); $footerData = []; $footerData['scripts'] = [ @@ -258,4 +263,17 @@ class Statistics extends CI_Controller { $this->load->view('statistics/antennaanalytics', $data); $this->load->view('interface_assets/footer', $footerData); } + + public function get_azimuth_data() { + $band = xss_clean($this->input->post('band')); + $mode = xss_clean($this->input->post('mode')); + $sat = xss_clean($this->input->post('sat')); + $orbit = xss_clean($this->input->post('orbit')); + + $this->load->model('stats'); + $azimutharray = $this->stats->azimuthdata($band, $mode, $sat, $orbit); + + header('Content-Type: application/json'); + echo json_encode($azimutharray); + } } diff --git a/application/models/Stats.php b/application/models/Stats.php index 45cf65e66..ce9ccbade 100644 --- a/application/models/Stats.php +++ b/application/models/Stats.php @@ -703,6 +703,59 @@ $result = $this->db->query($sql); return $result->result(); } + + function azimuthdata($band, $mode, $sat, $orbit) { + $conditions = []; + $binding = []; + + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + if (!$logbooks_locations_array) { + return null; + } + + + + if ($band !== 'All') { + if($band != "SAT") { + $conditions[] = "COL_BAND = ? and COL_PROP_MODE != 'SAT'"; + $binding[] = trim($band); + } else { + $conditions[] = "COL_PROP_MODE = 'SAT'"; + if ($sat !== 'All') { + $conditions[] = "COL_SAT_NAME = ?"; + $binding[] = trim($sat); + } + } + } + + if ($mode !== 'All') { + $conditions[] = "(COL_MODE = ? or COL_SUBMODE = ?)"; + $binding[] = $mode; + $binding[] = $mode; + } + + if ($orbit !== 'All' && $orbit !== '') { + $conditions[] = "orbit = ?"; + $binding[] = $orbit; + } + + $where = trim(implode(" AND ", $conditions)); + if ($where != "") { + $where = "AND $where"; + } + + $sql = "SELECT count(*) qsos, round(COL_ANT_AZ) azimuth + FROM logbook + where station_id in (" . implode(',',$logbooks_locations_array) . ") + and coalesce(col_ant_az, '') <> '' + $where + group by round(col_ant_az)"; + + $result = $this->db->query($sql, $binding); + return $result->result(); + } } ?> diff --git a/application/views/statistics/antennaanalytics.php b/application/views/statistics/antennaanalytics.php index 29c4fc99a..a9143459a 100644 --- a/application/views/statistics/antennaanalytics.php +++ b/application/views/statistics/antennaanalytics.php @@ -5,44 +5,124 @@ echo json_encode($azelarray); ?>;