From 585ecd988b533fd5b4904a28cf46c1afc4eb5cbf Mon Sep 17 00:00:00 2001 From: int2001 Date: Mon, 22 Jan 2024 16:26:19 +0000 Subject: [PATCH 1/8] New Statsview: Unique SAT-Callsigns PHP-Part --- application/controllers/Statistics.php | 14 ++ application/models/Stats.php | 169 ++++++++++++++++++++++++- application/views/statistics/index.php | 45 +++++-- 3 files changed, 215 insertions(+), 13 deletions(-) diff --git a/application/controllers/Statistics.php b/application/controllers/Statistics.php index 2647c8fcf..78d49dd32 100644 --- a/application/controllers/Statistics.php +++ b/application/controllers/Statistics.php @@ -162,6 +162,20 @@ class Statistics extends CI_Controller { echo json_encode($satstats); } + public function get_unique_sat_callsigns() { + $this->load->model('stats'); + + $result = $this->stats->unique_sat_callsigns(); + $total_qsos['qsoarray'] = $result['qsoView']; + $total_qsos['satunique'] = $result['satunique']; + $total_qsos['modeunique'] = $result['modeunique']; + $total_qsos['total'] = $result['total']; + $total_qsos['sats'] = $this->stats->get_sats(); + $total_qsos['modes'] = $this->stats->get_sat_modes(); + + $this->load->view('statistics/satuniquetable', $total_qsos); + } + public function get_unique_callsigns() { $this->load->model('stats'); diff --git a/application/models/Stats.php b/application/models/Stats.php index 8fb9bf200..26c066a06 100644 --- a/application/models/Stats.php +++ b/application/models/Stats.php @@ -71,6 +71,57 @@ return $this->db->get($this->config->item('table_name')); } + function unique_sat_callsigns() { + $qsoView = array(); + + $sats = $this->get_sats(); + $modes = $this->get_sat_modes(); + + $satunique = $this->getUniqueSatCallsigns(); + $modeunique = $this->getUniqueSatCallsignsModes(); + + // Generating the band/mode table + foreach ($sats as $sat) { + $sattotal[$sat] = 0; + foreach ($modes as $mode) { + $qsoView [$sat][$mode] = '-'; + } + } + + foreach ($satunique as $sat) { + $satcalls[$sat->sat] = $sat->calls; + } + + foreach ($modeunique as $mode) { + //if ($mode->col_submode == null) { + if ($mode->col_submode == null || $mode->col_submode == "") { + $modecalls[$mode->col_mode] = $mode->calls; + } else { + $modecalls[$mode->col_submode] = $mode->calls; + } + } + + // Populating array with worked + $workedQso = $this->getUniqueSatCallsigns(); + + foreach ($workedQso as $line) { + //if ($line->col_submode == null) { + if ($line->col_submode == null || $line->col_submode == "") { + $qsoView [$line->sat] [$line->col_mode] = $line->calls; + } else { + $qsoView [$line->sat] [$line->col_submode] = $line->calls; + } + } + + $result['qsoView'] = $qsoView; + $result['satunique'] = $satcalls; + $result['modeunique'] = $modecalls; + $result['total'] = $this->getUniqueSatCallsignsTotal(); + + return $result; + } + + function unique_callsigns() { $qsoView = array(); @@ -121,6 +172,27 @@ return $result; } + function getUniqueSatCallsigns() { + $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; + } + + $bands = array(); + + $this->db->select('count(distinct col_call) as calls, upper(col_sat_name) as sat, col_mode, coalesce(col_submode, "") col_submode', FALSE); + $this->db->where('col_prop_mode', 'SAT'); + $this->db->where('coalesce(col_sat_name,"") != ""'); + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->group_by('upper(col_sat_name), col_mode, coalesce(col_submode, "")'); + + $query = $this->db->get($this->config->item('table_name')); + + return $query->result(); + } + function getUniqueCallsigns() { $CI =& get_instance(); $CI->load->model('logbooks_model'); @@ -161,6 +233,27 @@ return $query->result(); } + function getUniqueSatCallsignsModes() { + $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; + } + + $bands = array(); + + $this->db->select('count(distinct col_call) as calls, col_mode, coalesce(col_submode, "") col_submode', FALSE); + $this->db->where('coalesce(col_sat_name,"") != ""'); + $this->db->where('col_prop_mode', 'SAT'); + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->group_by('col_mode, coalesce(col_submode, "")'); + + $query = $this->db->get($this->config->item('table_name')); + + return $query->result(); + } + function getUniqueCallsignsBands() { $CI =& get_instance(); $CI->load->model('logbooks_model'); @@ -181,6 +274,26 @@ return $query->result(); } + function getUniqueSatCallsignsTotal() { + $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; + } + + $bands = array(); + + $this->db->select('count(distinct col_call) as calls', FALSE); + $this->db->where('coalesce(col_sat_name,"") != ""'); + $this->db->where('col_prop_mode', 'SAT'); + $this->db->where_in('station_id', $logbooks_locations_array); + + $query = $this->db->get($this->config->item('table_name')); + + return $query->row(); + } + function getUniqueCallsignsTotal() { $CI =& get_instance(); $CI->load->model('logbooks_model'); @@ -257,6 +370,31 @@ return $query->result(); } + function get_sats() { + $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; + } + + $sats = array(); + + $this->db->select('distinct col_sat_name as satsort, upper(col_sat_name) as sat', FALSE); + $this->db->where('coalesce(col_sat_name,"") != ""'); + $this->db->where('col_prop_mode', 'SAT'); + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->order_by('satsort', 'asc'); + + $query = $this->db->get($this->config->item('table_name')); + + foreach($query->result() as $sat){ + array_push($sats, $sat->sat); + } + + return $sats; + } + function get_bands() { $CI =& get_instance(); $CI->load->model('logbooks_model'); @@ -281,6 +419,35 @@ return $bands; } + function get_sat_modes() { + $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; + } + + $modes = array(); + + $this->db->select('distinct col_mode, coalesce(col_submode, "") col_submode', FALSE); + $this->db->where('coalesce(col_sat_name,"") != ""'); + $this->db->where('col_prop_mode', 'SAT'); + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->order_by('col_mode, col_submode', 'ASC'); + + $query = $this->db->get($this->config->item('table_name')); + + foreach($query->result() as $mode){ + if ($mode->col_submode == null || $mode->col_submode == "") { + array_push($modes, $mode->col_mode); + } else { + array_push($modes, $mode->col_submode); + } + } + + return $modes; + } + function get_modes() { $CI =& get_instance(); $CI->load->model('logbooks_model'); @@ -310,4 +477,4 @@ } } -?> \ No newline at end of file +?> diff --git a/application/views/statistics/index.php b/application/views/statistics/index.php index e5a7c691a..951c628bf 100644 --- a/application/views/statistics/index.php +++ b/application/views/statistics/index.php @@ -87,18 +87,39 @@
-
-
- - - - - - - - - -
#Satellite# of QSO's worked
+
+ +
+
+
+
+ +
+
+ + + + + + + + +
#Satellite# of QSO's worked
+
+
+
+
+
+
+
+
From bd51761971065bf517c42000deb094fb72458124 Mon Sep 17 00:00:00 2001 From: int2001 Date: Mon, 22 Jan 2024 16:26:39 +0000 Subject: [PATCH 2/8] New Stats-View: Unique SAT Calls (JS-Part) --- assets/js/sections/statistics.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/assets/js/sections/statistics.js b/assets/js/sections/statistics.js index 3a650f8d5..d376ff342 100644 --- a/assets/js/sections/statistics.js +++ b/assets/js/sections/statistics.js @@ -30,6 +30,24 @@ $("a[href='#uniquetab']").on('shown.bs.tab', function(e) { } }); +$("a[href='#satuniquetab']").on('shown.bs.tab', function(e) { + if (!($('.satuniquetable').length > 0)) { + uniqueSatCallsigns(); + } +}); + +function uniqueSatCallsigns() { + $.ajax({ + url: base_url+'index.php/statistics/get_unique_sat_callsigns', + type: 'post', + success: function (data) { + if (data.length > 0) { + $(".satunique").html(data); + } + } + }); +} + function uniqueCallsigns() { $.ajax({ url: base_url+'index.php/statistics/get_unique_callsigns', @@ -574,4 +592,4 @@ function totalSatQsos() { } } }); -} \ No newline at end of file +} From 79adf2916666cf9eac6d2d80e4f78109acec3097 Mon Sep 17 00:00:00 2001 From: int2001 Date: Mon, 22 Jan 2024 19:58:57 +0000 Subject: [PATCH 3/8] Add missing view and remove bug at Sum --- application/models/Stats.php | 23 ++++++++++++++- .../views/statistics/satuniquetable.php | 28 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 application/views/statistics/satuniquetable.php diff --git a/application/models/Stats.php b/application/models/Stats.php index 26c066a06..3f3989b28 100644 --- a/application/models/Stats.php +++ b/application/models/Stats.php @@ -77,7 +77,7 @@ $sats = $this->get_sats(); $modes = $this->get_sat_modes(); - $satunique = $this->getUniqueSatCallsigns(); + $satunique = $this->getUniqueSatCallsignsSat(); $modeunique = $this->getUniqueSatCallsignsModes(); // Generating the band/mode table @@ -172,6 +172,27 @@ return $result; } + function getUniqueSatCallsignsSat() { + $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; + } + + $bands = array(); + + $this->db->select('count(distinct col_call) as calls, upper(col_sat_name) as sat', FALSE); + $this->db->where('col_prop_mode', 'SAT'); + $this->db->where('coalesce(col_sat_name,"") != ""'); + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->group_by('upper(col_sat_name)'); + + $query = $this->db->get($this->config->item('table_name')); + + return $query->result(); + } + function getUniqueSatCallsigns() { $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); diff --git a/application/views/statistics/satuniquetable.php b/application/views/statistics/satuniquetable.php new file mode 100644 index 000000000..855a477a0 --- /dev/null +++ b/application/views/statistics/satuniquetable.php @@ -0,0 +1,28 @@ + + + '; + echo ''; + foreach($modes as $mode) { + echo ''; + } + echo ''; + echo ' + + '; + foreach ($qsoarray as $sat => $mode) { + echo ''; + foreach ($mode as $singlemode) { + echo ''; + } + echo ''; + echo ''; + } + echo ''; + foreach($modes as $mode) { + echo ''; + } +echo ''; + echo '
' . $mode . ''.lang('statistics_total').'
'. $sat .''.$singlemode.'' . $satunique[$sat] . '
'.lang('statistics_total').'' . $modeunique[$mode] . '' . $total->calls . '
'; +} From 2d961d812e646d0eb47fe9d0634334d26ed842b0 Mon Sep 17 00:00:00 2001 From: int2001 Date: Tue, 23 Jan 2024 08:02:12 +0000 Subject: [PATCH 4/8] Added QSO-Count for SATs (JS-Part) --- assets/js/sections/statistics.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/assets/js/sections/statistics.js b/assets/js/sections/statistics.js index d376ff342..8f0cfdca9 100644 --- a/assets/js/sections/statistics.js +++ b/assets/js/sections/statistics.js @@ -24,6 +24,12 @@ $("a[href='#qsotab']").on('shown.bs.tab', function(e) { } }); +$("a[href='#satqsostab']").on('shown.bs.tab', function(e) { + if (!($('.satqsostab').length > 0)) { + totalSatQsosC(); + } +}); + $("a[href='#uniquetab']").on('shown.bs.tab', function(e) { if (!($('.uniquetable').length > 0)) { uniqueCallsigns(); @@ -72,6 +78,18 @@ function totalQsos() { }); } +function totalSatQsosC() { + $.ajax({ + url: base_url+'index.php/statistics/get_total_sat_qsos', + type: 'post', + success: function (data) { + if (data.length > 0) { + $(".satqsos").html(data); + } + } + }); +} + function totalQsosPerYear() { // using this to change color of legend and label according to background color var color = ifDarkModeThemeReturn('white', 'grey'); From 7c1466b150e30652a0aeffdb8febcaedeef5947f Mon Sep 17 00:00:00 2001 From: int2001 Date: Tue, 23 Jan 2024 08:02:28 +0000 Subject: [PATCH 5/8] Added QSO-Count for SATs (PHP-Part) --- application/controllers/Statistics.php | 15 +++++ application/models/Stats.php | 59 ++++++++++++++++++++ application/views/statistics/index.php | 7 +++ application/views/statistics/satqsotable.php | 30 ++++++++++ 4 files changed, 111 insertions(+) create mode 100644 application/views/statistics/satqsotable.php diff --git a/application/controllers/Statistics.php b/application/controllers/Statistics.php index 78d49dd32..593bda6ca 100644 --- a/application/controllers/Statistics.php +++ b/application/controllers/Statistics.php @@ -189,6 +189,21 @@ class Statistics extends CI_Controller { $this->load->view('statistics/uniquetable', $total_qsos); } + public function get_total_sat_qsos() { + $this->load->model('stats'); + + $totalqsos = array(); + + $result = $this->stats->total_sat_qsos(); + $total_qsos['qsoarray'] = $result['qsoView']; + $total_qsos['sattotal'] = $result['sattotal']; + $total_qsos['modetotal'] = $result['modetotal']; + $total_qsos['modes'] = $result['modes']; + $total_qsos['sats'] = $this->stats->get_sats(); + + $this->load->view('statistics/satqsotable', $total_qsos); + } + public function get_total_qsos() { $this->load->model('stats'); diff --git a/application/models/Stats.php b/application/models/Stats.php index 3f3989b28..c4427a331 100644 --- a/application/models/Stats.php +++ b/application/models/Stats.php @@ -334,6 +334,44 @@ return $query->row(); } + function total_sat_qsos() { + $qsoView = array(); + + $sats = $this->get_sats(); + $modes = $this->get_sat_modes(); + + $sattotal = array(); + $modetotal = array(); + // Generating the band/mode table + foreach ($sats as $sat) { + $sattotal[$sat] = 0; + foreach ($modes as $mode) { + $qsoView [$sat][$mode] = '-'; + $modetotal[$mode] = 0; + } + } + + // Populating array with worked + $workedQso = $this->modeSatQso(); + foreach ($workedQso as $line) { + if ($line->col_submode == null || $line->col_submode == "") { + $qsoView [$line->sat] [$line->col_mode] = $line->count; + $modetotal[$line->col_mode] += $line->count; + } else { + $qsoView [$line->sat] [$line->col_submode] = $line->count; + $modetotal[$line->col_submode] += $line->count; + } + $sattotal[$line->sat] += $line->count; + } + + $result['qsoView'] = $qsoView; + $result['sattotal'] = $sattotal; + $result['modetotal'] = $modetotal; + $result['modes'] = $modes; + + return $result; + } + function total_qsos() { $qsoView = array(); @@ -371,6 +409,27 @@ return $result; } + function modeSatQso() { + $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; + } + + $bands = array(); + + $this->db->select('count(*) as count, upper(col_sat_name) as sat, col_mode, coalesce(col_submode, "") col_submode', FALSE); + $this->db->where('coalesce(col_sat_name,"") != ""'); + $this->db->where('col_prop_mode', 'SAT'); + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->group_by('upper(col_sat_name), col_mode, coalesce(col_submode, "")'); + + $query = $this->db->get($this->config->item('table_name')); + + return $query->result(); + } + function modeBandQso() { $CI =& get_instance(); $CI->load->model('logbooks_model'); diff --git a/application/views/statistics/index.php b/application/views/statistics/index.php index 951c628bf..c8c9720ef 100644 --- a/application/views/statistics/index.php +++ b/application/views/statistics/index.php @@ -95,6 +95,9 @@ +
@@ -119,6 +122,10 @@
+
+
+
+
diff --git a/application/views/statistics/satqsotable.php b/application/views/statistics/satqsotable.php new file mode 100644 index 000000000..a1efade3c --- /dev/null +++ b/application/views/statistics/satqsotable.php @@ -0,0 +1,30 @@ + + + '; + echo ''; + foreach($modes as $mode) { + echo ''; + } + echo ''; + echo ' + + '; + foreach ($qsoarray as $sat => $mode) { + echo ''; + foreach ($mode as $singlemode) { + echo ''; + } + echo ''; + echo ''; + } + echo ''; + $grandtotal=0; + foreach($modes as $mode) { + echo ''; + $grandtotal += $modetotal[$mode]; + } +echo ''; + echo '
' . $mode . ''.lang('statistics_total').'
'. $sat .''.$singlemode.'' . $sattotal[$sat] . '
'.lang('statistics_total').'' . $modetotal[$mode] . '' . $grandtotal . '
'; +} From 1a4f1c4d527194ade931510b4b9ba3696c4ef76b Mon Sep 17 00:00:00 2001 From: int2001 Date: Tue, 23 Jan 2024 12:23:27 +0000 Subject: [PATCH 6/8] Changed TAB-Order to be consistent with General-Tab --- application/views/statistics/index.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/application/views/statistics/index.php b/application/views/statistics/index.php index c8c9720ef..05880c92d 100644 --- a/application/views/statistics/index.php +++ b/application/views/statistics/index.php @@ -93,10 +93,10 @@ Satellites
@@ -118,14 +118,14 @@
-
-
-
-
+
+
+
+
From e322ed0f39d5ce809c8117187ec2e128d6a103e0 Mon Sep 17 00:00:00 2001 From: int2001 Date: Tue, 23 Jan 2024 13:02:39 +0000 Subject: [PATCH 7/8] Fixed typo at js --- assets/js/sections/statistics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/sections/statistics.js b/assets/js/sections/statistics.js index 8f0cfdca9..13d6bc7fe 100644 --- a/assets/js/sections/statistics.js +++ b/assets/js/sections/statistics.js @@ -37,7 +37,7 @@ $("a[href='#uniquetab']").on('shown.bs.tab', function(e) { }); $("a[href='#satuniquetab']").on('shown.bs.tab', function(e) { - if (!($('.satuniquetable').length > 0)) { + if (!($('.satuniquetab').length > 0)) { uniqueSatCallsigns(); } }); From a405387eac5785b677f0fa28440115e1b3b59fa7 Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 24 Jan 2024 09:22:38 +0000 Subject: [PATCH 8/8] Declare band and mode-array (if no qso is there) --- application/models/Stats.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/application/models/Stats.php b/application/models/Stats.php index c4427a331..6ead78c4d 100644 --- a/application/models/Stats.php +++ b/application/models/Stats.php @@ -130,6 +130,9 @@ $bandunique = $this->getUniqueCallsignsBands(); $modeunique = $this->getUniqueCallsignsModes(); + + $modecalls=[]; + $bandcalls=[]; // Generating the band/mode table foreach ($bands as $band) {