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
+
+
+
+
+
+
+
+