From c95edbb18595657fc5420270c77d62f668e3ddbb Mon Sep 17 00:00:00 2001 From: phl0 Date: Mon, 20 Jan 2025 10:29:02 +0100 Subject: [PATCH] Implement GEO/MEO/LEO logic for callstats --- application/controllers/Callstats.php | 11 ++--- application/models/Callstats_model.php | 59 ++++++++++++++------------ application/views/callstats/index.php | 56 ++++++++++++------------ assets/js/sections/callstats.js | 26 ++++++------ 4 files changed, 80 insertions(+), 72 deletions(-) diff --git a/application/controllers/Callstats.php b/application/controllers/Callstats.php index f3c0d49d6..b813a60d1 100644 --- a/application/controllers/Callstats.php +++ b/application/controllers/Callstats.php @@ -36,7 +36,7 @@ class Callstats extends CI_Controller if ($this->input->post('propagation') != NULL) { // Propagation is not set when page first loads. $propagation = $this->input->post('propagation',true); } else { - $propagation = 'All'; + $propagation = ''; } if ($this->input->post('mincount') != NULL) { // mincount is not set when page first loads. @@ -45,10 +45,10 @@ class Callstats extends CI_Controller $mincount = 2; } - if ($this->input->post('leogeo') != NULL) { // orbit is not set when page first loads. - $orbit = $this->input->post('leogeo',true); + if ($this->input->post('orbit') != NULL) { // orbit is not set when page first loads. + $orbit = $this->input->post('orbit',true); } else { - $orbit = 'both'; + $orbit = 'All'; } @@ -61,6 +61,7 @@ class Callstats extends CI_Controller $data['sats'] = $this->bands->get_worked_sats(); $data['worked_bands'] = $this->bands->get_worked_bands(); $data['worked_modes'] = $this->Callstats_model->get_worked_modes(); + $data['orbits'] = $this->bands->get_worked_orbits(); $data['mincount'] = $mincount; $data['maxactivatedgrids'] = $this->Callstats_model->get_max_qsos(); $data['orbit'] = $orbit; @@ -97,7 +98,7 @@ class Callstats extends CI_Controller // Render Page $data['page_title'] = __("Log View"); - $data['filter'] = $searchphrase.__(" and band ").$band . __(" and mode ").$mode . __(" and satellite ").$sat . __(" and orbit ").$orbit . __(" and propagation ").$propagation; + $data['filter'] = $searchphrase.__(" and band ").$band; if ($band == 'SAT') { if ($sat != 'All' && $sat != null) { $data['filter'] .= __(" and sat ").$sat; diff --git a/application/models/Callstats_model.php b/application/models/Callstats_model.php index 898df9351..cde44b4eb 100644 --- a/application/models/Callstats_model.php +++ b/application/models/Callstats_model.php @@ -10,7 +10,7 @@ class Callstats_model extends CI_Model { $this->logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); } - function get_activators($band, $mode, $propagation, $mincount, $leogeo, $sat) { + function get_activators($band, $mode, $propagation, $mincount, $orbit, $sat) { if ($mincount == '' || $mincount == 0 || !is_numeric($mincount)) { $mincount = 2; @@ -27,39 +27,37 @@ class Callstats_model extends CI_Model { `col_call` as `call`, COUNT(*) as `count` from " . $this->config->item('table_name') . " + left join satellite on ".$this->config->item('table_name').".COL_SAT_NAME = satellite.name where station_id in (" . $location_list . ")"; if ($band != 'All') { - $binding[] = $band; if ($band == 'SAT') { - switch ($leogeo) { - case 'both': - $sql .= " and col_prop_mode = ?"; - break; - case 'leo': - $sql .= " and col_prop_mode = ?"; - $sql .= " and col_sat_name != 'QO-100'"; - break; - case 'geo': - $sql .= " and col_prop_mode = ?"; - $sql .= " and col_sat_name = 'QO-100'"; - break; - default: - $sql .= " and col_prop_mode = ?"; - break; - } - if ($sat != 'All') { + $sql .= " and col_prop_mode = ? "; + $binding[] = $band; + if ($sat != 'All' && $sat != '') { $sql .= " and col_sat_name = ?"; $binding[] = $sat; } } else { - $sql .= " and col_prop_mode != 'SAT'"; - $sql .= " and COL_BAND = ?"; + if ($propagation == 'None') { + $sql .= " and (trim(col_prop_mode) = '' or col_prop_mode is null)"; + } elseif ($propagation == 'NoSAT') { + $sql .= " and col_prop_mode != 'SAT'"; + } elseif ($propagation != '') { + $sql .= " and col_prop_mode = ?"; + $binding[] = $propagation; + } + $sql .= " and col_band = ?"; + $binding[] = $band; + } + } else { + if ($propagation == 'None') { + $sql .= " and (trim(col_prop_mode) = '' or col_prop_mode is null)"; + } elseif ($propagation == 'NoSAT') { + $sql .= " and col_prop_mode != 'SAT'"; + } elseif ($propagation != '') { + $sql .= " and col_prop_mode = ?"; + $binding[] = $propagation; } - } - - if (($propagation ?? 'All') != 'All') { - $this->db->where("COL_PROP_MODE = ?"); - $binding[] = $propagation; } if ($mode != 'All') { @@ -68,6 +66,11 @@ class Callstats_model extends CI_Model { $binding[] = $mode; } + if ($orbit != 'All') { + $sql .= " AND satellite.orbit = ?"; + $binding[] = $orbit; + } + $sql .= " group by `col_call` having `count` >= ? @@ -158,11 +161,11 @@ class Callstats_model extends CI_Model { } } - if ($orbit != 'both') { + if ($orbit != 'All') { $this->db->where('orbit', $orbit); } - if ($propagation != 'All') { + if ($propagation != '') { if ($propagation == 'None') { $this->db->where('COL_PROP_MODE', ''); } else if ($propagation == 'NoSAT') { diff --git a/application/views/callstats/index.php b/application/views/callstats/index.php index efec67669..3eae4fd4f 100644 --- a/application/views/callstats/index.php +++ b/application/views/callstats/index.php @@ -3,18 +3,20 @@
-
- -
- -
+
+ +
+ +
- - + +
@@ -57,7 +64,7 @@
- @@ -133,9 +140,6 @@ function write_activators($activators_array, $band, $mode, $sat, $orbit, $propag if ($band == '') { $band = 'All'; } - if ($orbit == '') { - $orbit = 'both'; - } $i = 1; echo ' diff --git a/assets/js/sections/callstats.js b/assets/js/sections/callstats.js index 924fe4b26..d6b0a8343 100644 --- a/assets/js/sections/callstats.js +++ b/assets/js/sections/callstats.js @@ -17,27 +17,27 @@ $(document).ready(function () { let bandselect = $('#band'); - showHideLeoGeo(bandselect); + showHideOrbit(bandselect); bandselect.change(function () { - showHideLeoGeo(bandselect); + showHideOrbit(bandselect); }); }); -function showHideLeoGeo(bandselect) { +function showHideOrbit(bandselect) { if (bandselect.val() == "SAT") { - $("#leogeoselect").show(); - $("#leogeolabel").show(); + $("#orbitselect").show(); + $("#orbitlabel").show(); $("#satlabel").show(); $("#satselect").show(); } else { - $("#leogeoselect select").val("All"); - $("#leogeolabel select").val("both"); + $("#orbitselect select").val("All"); + $("#orbitlabel select").val("All"); $("#satlabel select").val("All"); $("#satselect select").val("All"); - $("#leogeoselect").hide(); - $("#leogeolabel").hide(); + $("#orbitselect").hide(); + $("#orbitlabel").hide(); $("#satlabel").hide(); $("#satselect").hide(); } @@ -45,13 +45,13 @@ function showHideLeoGeo(bandselect) { function displayCallstatsContacts(call, band, mode, sat, orbit, propagation) { var data = { - Searchphrase: call, - Band: band, + Searchphrase: call, + Band: band, Mode: mode, Propagation: propagation, - Sat: sat, + Sat: sat, Orbit: orbit - }; + }; $.ajax({ url: base_url + "index.php/callstats/qso_details_callstats",