First draft seelect year at stats (PHP)

This commit is contained in:
int2001
2024-12-01 09:21:43 +00:00
parent 13353144c0
commit aeebaf2f62
4 changed files with 252 additions and 95 deletions

View File

@@ -8,19 +8,18 @@ class Statistics extends CI_Controller {
}
public function index()
{
$this->load->model('user_model');
$this->load->model('bands');
public function index() {
$this->load->model('user_model');
$this->load->model('bands');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) {
if($this->user_model->validate_session()) {
$this->user_model->clear_session();
show_error('Access denied<p>Click <a href="'.site_url('user/login').'">here</a> to log in as another user', 403);
} else {
redirect('user/login');
}
}
if(!$this->user_model->authorize($this->config->item('auth_mode'))) {
if($this->user_model->validate_session()) {
$this->user_model->clear_session();
show_error('Access denied<p>Click <a href="'.site_url('user/login').'">here</a> to log in as another user', 403);
} else {
redirect('user/login');
}
}
// Render User Interface
// Set Page Title
@@ -99,18 +98,19 @@ class Statistics extends CI_Controller {
public function get_mode() {
$this->load->model('logbook_model');
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$modestats = array();
$i = 0;
$modestats[$i]['mode'] = 'ssb';
$modestats[$i++]['total'] = $this->logbook_model->total_ssb();
$modestats[$i++]['total'] = $this->logbook_model->total_ssb($yr);
$modestats[$i]['mode'] = 'cw';
$modestats[$i++]['total'] = $this->logbook_model->total_cw();
$modestats[$i++]['total'] = $this->logbook_model->total_cw($yr);
$modestats[$i]['mode'] = 'fm';
$modestats[$i++]['total'] = $this->logbook_model->total_fm();
$modestats[$i++]['total'] = $this->logbook_model->total_fm($yr);
$modestats[$i]['mode'] = 'digi';
$modestats[$i]['total'] = $this->logbook_model->total_digi();
$modestats[$i]['total'] = $this->logbook_model->total_digi($yr);
usort($modestats, fn($a, $b) => $b['total'] <=> $a['total']);
header('Content-Type: application/json');
@@ -123,7 +123,8 @@ class Statistics extends CI_Controller {
$bandstats = array();
$total_bands = $this->logbook_model->total_bands();
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$total_bands = $this->logbook_model->total_bands($yr);
$i = 0;
@@ -143,7 +144,8 @@ class Statistics extends CI_Controller {
$satstats = array();
$total_sat = $this->logbook_model->total_sat();
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$total_sat = $this->logbook_model->total_sat($yr);
$i = 0;
if ($total_sat) {
@@ -162,13 +164,14 @@ class Statistics extends CI_Controller {
$total_qsos = array();
$result = $this->stats->unique_sat_callsigns();
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$result = $this->stats->unique_sat_callsigns($yr);
$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();
$total_qsos['sats'] = $this->stats->get_sats($yr);
$total_qsos['modes'] = $this->stats->get_sat_modes($yr);
$this->load->view('statistics/satuniquetable', $total_qsos);
}
@@ -178,12 +181,13 @@ class Statistics extends CI_Controller {
$total_qsos = array();
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$result = $this->stats->unique_callsigns();
$total_qsos['qsoarray'] = $result['qsoView'];
$total_qsos['bandunique'] = $result['bandunique'];
$total_qsos['modeunique'] = $result['modeunique'];
$total_qsos['total'] = $result['total'];
$total_qsos['bands'] = $this->stats->get_bands();
$total_qsos['bands'] = $this->stats->get_bands($yr);
$this->load->view('statistics/uniquetable', $total_qsos);
}
@@ -193,12 +197,13 @@ class Statistics extends CI_Controller {
$total_qsos = array();
$result = $this->stats->total_sat_qsos();
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$result = $this->stats->total_sat_qsos($yr);
$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();
$total_qsos['sats'] = $this->stats->get_sats($yr);
$this->load->view('statistics/satqsotable', $total_qsos);
}
@@ -208,11 +213,12 @@ class Statistics extends CI_Controller {
$total_qsos = array();
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$result = $this->stats->total_qsos();
$total_qsos['qsoarray'] = $result['qsoView'];
$total_qsos['bandtotal'] = $result['bandtotal'];
$total_qsos['modetotal'] = $result['modetotal'];
$total_qsos['bands'] = $this->stats->get_bands();
$total_qsos['bands'] = $this->stats->get_bands($yr);
$this->load->view('statistics/qsotable', $total_qsos);
}

View File

@@ -2881,7 +2881,7 @@ class Logbook_model extends CI_Model {
}
/* Return total amount of SSB QSOs logged */
function total_ssb() {
function total_ssb($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -2896,6 +2896,12 @@ class Logbook_model extends CI_Model {
$this->db->select('COUNT( * ) as count', FALSE);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where_in('COL_MODE', $mode);
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$query = $this->db->get($this->config->item('table_name'));
@@ -2907,7 +2913,7 @@ class Logbook_model extends CI_Model {
}
/* Return total number of satellite QSOs */
function total_sat() {
function total_sat($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -2921,6 +2927,12 @@ class Logbook_model extends CI_Model {
$this->db->where('COL_SAT_NAME is not null');
$this->db->where('COL_SAT_NAME !=', '');
$this->db->where('COL_PROP_MODE', 'SAT');
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->order_by('count DESC');
$this->db->group_by('COL_SAT_NAME');
$query = $this->db->get($this->config->item('table_name'));
@@ -2967,7 +2979,7 @@ class Logbook_model extends CI_Model {
}
/* Return total number of CW QSOs */
function total_cw() {
function total_cw($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -2979,6 +2991,12 @@ class Logbook_model extends CI_Model {
$this->db->select('COUNT( * ) as count', FALSE);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_MODE', 'CW');
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$query = $this->db->get($this->config->item('table_name'));
if ($query->num_rows() > 0) {
@@ -2989,7 +3007,7 @@ class Logbook_model extends CI_Model {
}
/* Return total number of FM QSOs */
function total_fm() {
function total_fm($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -3001,6 +3019,12 @@ class Logbook_model extends CI_Model {
$this->db->select('COUNT( * ) as count', FALSE);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_MODE', 'FM');
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$query = $this->db->get($this->config->item('table_name'));
if ($query->num_rows() > 0) {
@@ -3011,7 +3035,7 @@ class Logbook_model extends CI_Model {
}
/* Return total number of Digital QSOs */
function total_digi() {
function total_digi($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -3028,7 +3052,12 @@ class Logbook_model extends CI_Model {
$this->db->where('COL_MODE !=', 'CW');
$this->db->where('COL_MODE !=', 'FM');
$this->db->where('COL_MODE !=', 'AM');
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$query = $this->db->get($this->config->item('table_name'));
if ($query->num_rows() > 0) {
@@ -3045,7 +3074,7 @@ class Logbook_model extends CI_Model {
}
/* Return total number of QSOs per band */
function total_bands() {
function total_bands($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -3055,6 +3084,12 @@ class Logbook_model extends CI_Model {
$this->db->select('COL_BAND AS band, count( * ) AS count', FALSE);
$this->db->where_in('station_id', $logbooks_locations_array);
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->group_by('band');
$this->db->order_by('count', 'DESC');

View File

@@ -71,14 +71,14 @@
return $this->db->get($this->config->item('table_name'));
}
function unique_sat_callsigns() {
function unique_sat_callsigns($yr = 'All') {
$qsoView = array();
$sats = $this->get_sats();
$modes = $this->get_sat_modes();
$sats = $this->get_sats($yr);
$modes = $this->get_sat_modes($yr);
$satunique = $this->getUniqueSatCallsignsSat();
$modeunique = $this->getUniqueSatCallsignsModes();
$satunique = $this->getUniqueSatCallsignsSat($yr);
$modeunique = $this->getUniqueSatCallsignsModes($yr);
// Generating the band/mode table
foreach ($sats as $sat) {
@@ -102,7 +102,7 @@
}
// Populating array with worked
$workedQso = $this->getUniqueSatCallsigns();
$workedQso = $this->getUniqueSatCallsigns($yr);
foreach ($workedQso as $line) {
//if ($line->col_submode == null) {
@@ -116,20 +116,20 @@
$result['qsoView'] = $qsoView;
$result['satunique'] = $satcalls;
$result['modeunique'] = $modecalls;
$result['total'] = $this->getUniqueSatCallsignsTotal();
$result['total'] = $this->getUniqueSatCallsignsTotal($yr);
return $result;
}
function unique_callsigns() {
function unique_callsigns($yr = 'All') {
$qsoView = array();
$bands = $this->get_bands();
$modes = $this->get_modes();
$bands = $this->get_bands($yr);
$modes = $this->get_modes($yr);
$bandunique = $this->getUniqueCallsignsBands();
$modeunique = $this->getUniqueCallsignsModes();
$bandunique = $this->getUniqueCallsignsBands($yr);
$modeunique = $this->getUniqueCallsignsModes($yr);
$modecalls=[];
$bandcalls=[];
@@ -156,7 +156,7 @@
}
// Populating array with worked
$workedQso = $this->getUniqueCallsigns();
$workedQso = $this->getUniqueCallsigns($yr);
foreach ($workedQso as $line) {
//if ($line->col_submode == null) {
@@ -170,12 +170,12 @@
$result['qsoView'] = $qsoView;
$result['bandunique'] = $bandcalls;
$result['modeunique'] = $modecalls;
$result['total'] = $this->getUniqueCallsignsTotal();
$result['total'] = $this->getUniqueCallsignsTotal($yr);
return $result;
}
function getUniqueSatCallsignsSat() {
function getUniqueSatCallsignsSat($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -188,6 +188,12 @@
$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,"") != ""');
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('upper(col_sat_name)');
@@ -196,7 +202,7 @@
return $query->result();
}
function getUniqueSatCallsigns() {
function getUniqueSatCallsigns($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -209,6 +215,12 @@
$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,"") != ""');
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('upper(col_sat_name), col_mode, coalesce(col_submode, "")');
@@ -217,7 +229,7 @@
return $query->result();
}
function getUniqueCallsigns() {
function getUniqueCallsigns($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -228,6 +240,12 @@
$bands = array();
$this->db->select('count(distinct col_call) as calls, lower(col_band) as band, col_mode, coalesce(col_submode, "") col_submode', FALSE);
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('lower(col_band), col_mode, coalesce(col_submode, "")');
@@ -236,7 +254,7 @@
return $query->result();
}
function getUniqueCallsignsModes() {
function getUniqueCallsignsModes($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -247,6 +265,12 @@
$bands = array();
$this->db->select('count(distinct col_call) as calls, col_mode, coalesce(col_submode, "") col_submode', FALSE);
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('col_mode, coalesce(col_submode, "")');
@@ -255,7 +279,7 @@
return $query->result();
}
function getUniqueSatCallsignsModes() {
function getUniqueSatCallsignsModes($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -268,6 +292,12 @@
$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');
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('col_mode, coalesce(col_submode, "")');
@@ -276,7 +306,7 @@
return $query->result();
}
function getUniqueCallsignsBands() {
function getUniqueCallsignsBands($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -287,6 +317,12 @@
$bands = array();
$this->db->select('count(distinct col_call) as calls, col_band as band', FALSE);
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('col_band');
@@ -295,7 +331,7 @@
return $query->result();
}
function getUniqueSatCallsignsTotal() {
function getUniqueSatCallsignsTotal($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -306,6 +342,12 @@
$bands = array();
$this->db->select('count(distinct col_call) as calls', FALSE);
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where('coalesce(col_sat_name,"") != ""');
$this->db->where('col_prop_mode', 'SAT');
$this->db->where_in('station_id', $logbooks_locations_array);
@@ -315,7 +357,7 @@
return $query->row();
}
function getUniqueCallsignsTotal() {
function getUniqueCallsignsTotal($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -326,6 +368,12 @@
$bands = array();
$this->db->select('count(distinct col_call) as calls', FALSE);
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where_in('station_id', $logbooks_locations_array);
$query = $this->db->get($this->config->item('table_name'));
@@ -333,11 +381,11 @@
return $query->row();
}
function total_sat_qsos() {
function total_sat_qsos($yr = 'All') {
$qsoView = array();
$sats = $this->get_sats();
$modes = $this->get_sat_modes();
$sats = $this->get_sats($yr);
$modes = $this->get_sat_modes($yr);
$sattotal = array();
$modetotal = array();
@@ -351,7 +399,7 @@
}
// Populating array with worked
$workedQso = $this->modeSatQso();
$workedQso = $this->modeSatQso($yr);
foreach ($workedQso as $line) {
if ($line->col_submode == null || $line->col_submode == "") {
$qsoView [$line->sat] [$line->col_mode] = $line->count;
@@ -371,11 +419,11 @@
return $result;
}
function total_qsos() {
function total_qsos($yr = 'All') {
$qsoView = array();
$bands = $this->get_bands();
$modes = $this->get_modes();
$bands = $this->get_bands($yr);
$modes = $this->get_modes($yr);
$bandtotal = array();
$modetotal = array();
@@ -389,7 +437,7 @@
}
// Populating array with worked
$workedQso = $this->modeBandQso();
$workedQso = $this->modeBandQso($yr);
foreach ($workedQso as $line) {
if ($line->col_submode == null || $line->col_submode == "") {
$qsoView [$line->col_mode] [$line->band] = $line->count;
@@ -408,15 +456,15 @@
return $result;
}
function total_qsls() {
function total_qsls($yr = 'All') {
$qsoView = array();
$qsoSatView = array();
$bands = $this->get_bands();
$modes = $this->get_modes();
$bands = $this->get_bands($yr);
$modes = $this->get_modes($yr);
$sats = $this->get_sats();
$satmodes = $this->get_sat_modes();
$sats = $this->get_sats($yr);
$satmodes = $this->get_sat_modes($yr);
// Generating the band/mode table
foreach ($bands as $band) {
@@ -431,7 +479,7 @@
}
// Populating array with numbers
$workedQso = $this->modeBandQsl();
$workedQso = $this->modeBandQsl($yr);
foreach ($workedQso as $line) {
if ($line->col_submode == null || $line->col_submode == "") {
$qsoView [$line->col_mode] [$line->band] ['qso'] = $line->qsos;
@@ -463,7 +511,7 @@
}
// Populating array with numbers
$workedSatQso = $this->modeSatQsl();
$workedSatQso = $this->modeSatQsl($yr);
foreach ($workedSatQso as $line) {
if ($line->col_submode == null || $line->col_submode == "") {
$qsoSatView [$line->col_mode] [$line->sat] ['qso'] = $line->qsos;
@@ -488,56 +536,70 @@
return $result;
}
function modeBandQsl() {
function modeBandQsl($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$binding=[];
if (!$logbooks_locations_array) {
return null;
}
$sql = "select lower(col_band) as band, col_mode, coalesce(col_submode, '') col_submode,
count(*) qsos,
count(1) qsos,
count(case when COL_QSL_RCVD='Y' then 1 end) qsl,
count(case when COL_EQSL_QSL_RCVD='Y' then 1 end) eqsl,
count(case when COL_LOTW_QSL_RCVD='Y' then 1 end) lotw,
count(case when COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y' then 1 end) qrz,
count(case when COL_CLUBLOG_QSO_DOWNLOAD_STATUS='Y' then 1 end) clublog
from " . $this->config->item('table_name') . "
where station_id in (". implode(',', $logbooks_locations_array) .")
and col_prop_mode <> 'SAT'
where station_id in (". implode(',', $logbooks_locations_array) .")";
if ($yr != 'All') {
$sql.=" and COL_TIME_ON >= ? and COL_TIME_ON <= ? ";
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$binding[]=$syr;
$binding[]=$eyr;
}
$sql.=" and col_prop_mode <> 'SAT'
group by lower(col_band), col_mode, coalesce(col_submode, '')";
$result = $this->db->query($sql);
$result = $this->db->query($sql,$binding);
return $result->result();
}
function modeSatQsl() {
function modeSatQsl($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$binding=[];
if (!$logbooks_locations_array) {
return null;
}
$sql = "select upper(col_sat_name) as sat, col_mode, coalesce(col_submode, '') col_submode,
count(*) qsos,
count(1) qsos,
count(case when COL_QSL_RCVD='Y' then 1 end) qsl,
count(case when COL_EQSL_QSL_RCVD='Y' then 1 end) eqsl,
count(case when COL_LOTW_QSL_RCVD='Y' then 1 end) lotw,
count(case when COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y' then 1 end) qrz,
count(case when COL_CLUBLOG_QSO_DOWNLOAD_STATUS='Y' then 1 end) clublog
from " . $this->config->item('table_name') . "
where station_id in (". implode(',', $logbooks_locations_array) .")
and col_prop_mode = 'SAT'
where station_id in (". implode(',', $logbooks_locations_array) .")";
if ($yr != 'All') {
$sql.=" and COL_TIME_ON >= ? and COL_TIME_ON <= ? ";
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$binding[]=$syr;
$binding[]=$eyr;
}
$sql.=" and col_prop_mode = 'SAT'
and coalesce(col_sat_name, '') <> ''
group by upper(col_sat_name), col_mode, coalesce(col_submode, '')";
$result = $this->db->query($sql);
$result = $this->db->query($sql,$binding);
return $result->result();
}
function modeSatQso() {
function modeSatQso($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -547,9 +609,15 @@
$bands = array();
$this->db->select('count(*) as count, upper(col_sat_name) as sat, col_mode, coalesce(col_submode, "") col_submode', FALSE);
$this->db->select('count(1) 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');
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('upper(col_sat_name), col_mode, coalesce(col_submode, "")');
@@ -558,7 +626,7 @@
return $query->result();
}
function modeBandQso() {
function modeBandQso($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -567,6 +635,12 @@
}
$this->db->select('count(*) as count, lower(col_band) as band, col_mode, coalesce(col_submode, "") col_submode', FALSE);
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('lower(col_band), col_mode, coalesce(col_submode, "")');
@@ -575,7 +649,7 @@
return $query->result();
}
function get_sats() {
function get_sats($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -586,6 +660,12 @@
$sats = array();
$this->db->select('distinct col_sat_name as satsort, upper(col_sat_name) as sat', FALSE);
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where('coalesce(col_sat_name,"") != ""');
$this->db->where('col_prop_mode', 'SAT');
$this->db->where_in('station_id', $logbooks_locations_array);
@@ -599,7 +679,7 @@
return $sats;
}
function get_bands() {
function get_bands($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -610,6 +690,12 @@
$bands = array();
$this->db->select('distinct col_band+0 as bandsort, lower(col_band) as band', FALSE);
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->order_by('bandsort', 'desc');
@@ -634,7 +720,7 @@
return $bands;
}
function get_sat_modes() {
function get_sat_modes($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -645,6 +731,12 @@
$modes = array();
$this->db->select('distinct col_mode, coalesce(col_submode, "") col_submode', FALSE);
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where('coalesce(col_sat_name,"") != ""');
$this->db->where('col_prop_mode', 'SAT');
$this->db->where_in('station_id', $logbooks_locations_array);
@@ -663,7 +755,7 @@
return $modes;
}
function get_modes() {
function get_modes($yr = 'All') {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -674,6 +766,12 @@
$modes = array();
$this->db->select('distinct col_mode, coalesce(col_submode, "") col_submode', FALSE);
if ($yr != 'All') {
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$this->db->where('COL_TIME_ON >=', $syr);
$this->db->where('COL_TIME_ON <=', $eyr);
}
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->order_by('col_mode, col_submode', 'ASC');
@@ -690,7 +788,7 @@
return $modes;
}
function elevationdata($sat, $orbit) {
function elevationdata($sat, $orbit, $yr = 'All') {
$conditions = [];
$binding = [];
@@ -720,8 +818,15 @@
$sql = "SELECT count(*) qsos, round(COL_ANT_EL) elevation FROM ".$this->config->item('table_name')."
LEFT JOIN satellite ON satellite.name = ".$this->config->item('table_name').".COL_SAT_NAME
where station_id in (" . implode(',',$logbooks_locations_array) . ") and coalesce(col_ant_el, '') <> ''
$where
where station_id in (" . implode(',',$logbooks_locations_array) . ") and coalesce(col_ant_el, '') <> ''";
if ($yr != 'All') {
$sql.=" and COL_TIME_ON >= ? and COL_TIME_ON <= ? ";
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$binding[]=$syr;
$binding[]=$eyr;
}
$sql.=" $where
group by round(col_ant_el)
order by elevation asc";
@@ -729,7 +834,7 @@
return $result->result();
}
function azimuthdata($band, $mode, $sat, $orbit) {
function azimuthdata($band, $mode, $sat, $orbit, $yr = 'All') {
$conditions = [];
$binding = [];
@@ -773,8 +878,15 @@
FROM ".$this->config->item('table_name')."
LEFT JOIN satellite ON satellite.name = ".$this->config->item('table_name').".COL_SAT_NAME
where station_id in (" . implode(',',$logbooks_locations_array) . ")
and coalesce(col_ant_az, '') <> ''
$where
and coalesce(col_ant_az, '') <> ''";
if ($yr != 'All') {
$sql.=" and COL_TIME_ON >= ? and COL_TIME_ON <= ? ";
$syr = date($yr.'-01-01 00:00:00');
$eyr = date($yr.'-12-31 23:59:59');
$binding[]=$syr;
$binding[]=$eyr;
}
$sql.=" $where
group by round(col_ant_az)
order by azimuth asc";

View File

@@ -27,7 +27,11 @@
<?php echo $page_title; ?>
<small class="text-muted"><?= __("Explore the logbook."); ?></small>
</h2>
<select id="yr" name="yr">
<option value='All'><?= __("All"); ?></option>
<option value='2023'>2023</option>
<option value='2024'>2024</option>
</select>
<br>
<div hidden class="tabs">
<ul class="nav nav-tabs" id="myTab" role="tablist">