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 @@
| '; + foreach($modes as $mode) { + echo ' | ' . $mode . ' | '; + } + echo ''.lang('statistics_total').' | '; + echo '
|---|---|---|
| '. $sat .' | '; + foreach ($mode as $singlemode) { + echo ''.$singlemode.' | '; + } + echo '' . $sattotal[$sat] . ' | '; + echo '
| '.lang('statistics_total').' | '; + $grandtotal=0; + foreach($modes as $mode) { + echo '' . $modetotal[$mode] . ' | '; + $grandtotal += $modetotal[$mode]; + } +echo '' . $grandtotal . ' | '; + echo '