Introduce more granular Date-Filter for Stats-Page

This commit is contained in:
int2001
2025-12-31 09:03:13 +00:00
parent 461a0f3819
commit 08d90aec24
5 changed files with 352 additions and 306 deletions

View File

@@ -68,10 +68,11 @@ class Statistics extends CI_Controller {
public function get_year_month() {
$this->load->model('logbook_model');
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$dateFrom = xss_clean($this->input->post('dateFrom'));
$dateTo = xss_clean($this->input->post('dateTo'));
// get data
$totals_month = $this->logbook_model->totals_year_month($yr);
$totals_month = $this->logbook_model->totals_year_month($dateFrom, $dateTo);
$monthstats = array();
@@ -89,16 +90,17 @@ class Statistics extends CI_Controller {
public function get_mode() {
$this->load->model('logbook_model');
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$dateFrom = xss_clean($this->input->post('dateFrom'));
$dateTo = xss_clean($this->input->post('dateTo'));
$modestats = array();
$i = 0;
$ssb = $this->logbook_model->total_ssb($yr);
$cw = $this->logbook_model->total_cw($yr);
$fm = $this->logbook_model->total_fm($yr);
$am = $this->logbook_model->total_am($yr);
$digi = $this->logbook_model->total_digi($yr);
$ssb = $this->logbook_model->total_ssb($dateFrom, $dateTo);
$cw = $this->logbook_model->total_cw($dateFrom, $dateTo);
$fm = $this->logbook_model->total_fm($dateFrom, $dateTo);
$am = $this->logbook_model->total_am($dateFrom, $dateTo);
$digi = $this->logbook_model->total_digi($dateFrom, $dateTo);
if ($ssb > 0) {
$modestats[$i]['mode'] = 'ssb';
$modestats[$i++]['total'] = $ssb;
@@ -131,8 +133,9 @@ class Statistics extends CI_Controller {
$bandstats = array();
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$total_bands = $this->logbook_model->total_bands($yr);
$dateFrom = xss_clean($this->input->post('dateFrom'));
$dateTo = xss_clean($this->input->post('dateTo'));
$total_bands = $this->logbook_model->total_bands($dateFrom, $dateTo);
$i = 0;
@@ -155,11 +158,12 @@ class Statistics extends CI_Controller {
//define stats array
$operatorstats = array();
//get year if present
$yr = xss_clean($this->input->post('yr')) ?? 'All';
//get date range if present
$dateFrom = xss_clean($this->input->post('dateFrom'));
$dateTo = xss_clean($this->input->post('dateTo'));
//load stats
$total_operators = $this->logbook_model->total_operators($yr);
$total_operators = $this->logbook_model->total_operators($dateFrom, $dateTo);
$i = 0;
@@ -181,8 +185,9 @@ class Statistics extends CI_Controller {
$satstats = array();
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$total_sat = $this->logbook_model->total_sat($yr);
$dateFrom = xss_clean($this->input->post('dateFrom'));
$dateTo = xss_clean($this->input->post('dateTo'));
$total_sat = $this->logbook_model->total_sat($dateFrom, $dateTo);
$i = 0;
if ($total_sat) {
@@ -201,14 +206,15 @@ class Statistics extends CI_Controller {
$total_qsos = array();
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$result = $this->stats->unique_sat_callsigns($yr);
$dateFrom = xss_clean($this->input->post('dateFrom'));
$dateTo = xss_clean($this->input->post('dateTo'));
$result = $this->stats->unique_sat_callsigns($dateFrom, $dateTo);
$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($yr);
$total_qsos['modes'] = $this->stats->get_sat_modes($yr);
$total_qsos['sats'] = $this->stats->get_sats($dateFrom, $dateTo);
$total_qsos['modes'] = $this->stats->get_sat_modes($dateFrom, $dateTo);
$this->load->view('statistics/satuniquetable', $total_qsos);
}
@@ -218,14 +224,15 @@ class Statistics extends CI_Controller {
$total_qsos = array();
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$result = $this->stats->unique_sat_grids($yr);
$dateFrom = xss_clean($this->input->post('dateFrom'));
$dateTo = xss_clean($this->input->post('dateTo'));
$result = $this->stats->unique_sat_grids($dateFrom, $dateTo);
$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($yr);
$total_qsos['modes'] = $this->stats->get_sat_modes($yr);
$total_qsos['sats'] = $this->stats->get_sats($dateFrom, $dateTo);
$total_qsos['modes'] = $this->stats->get_sat_modes($dateFrom, $dateTo);
$this->load->view('statistics/satuniquegridtable', $total_qsos);
}
@@ -235,13 +242,14 @@ class Statistics extends CI_Controller {
$total_qsos = array();
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$result = $this->stats->unique_callsigns($yr);
$dateFrom = xss_clean($this->input->post('dateFrom'));
$dateTo = xss_clean($this->input->post('dateTo'));
$result = $this->stats->unique_callsigns($dateFrom, $dateTo);
$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($yr);
$total_qsos['bands'] = $this->stats->get_bands($dateFrom, $dateTo);
$this->load->view('statistics/uniquetable', $total_qsos);
}
@@ -251,13 +259,14 @@ class Statistics extends CI_Controller {
$total_qsos = array();
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$result = $this->stats->total_sat_qsos($yr);
$dateFrom = xss_clean($this->input->post('dateFrom'));
$dateTo = xss_clean($this->input->post('dateTo'));
$result = $this->stats->total_sat_qsos($dateFrom, $dateTo);
$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($yr);
$total_qsos['sats'] = $this->stats->get_sats($dateFrom, $dateTo);
$this->load->view('statistics/satqsotable', $total_qsos);
}
@@ -267,12 +276,13 @@ class Statistics extends CI_Controller {
$total_qsos = array();
$yr = xss_clean($this->input->post('yr')) ?? 'All';
$result = $this->stats->total_qsos($yr);
$dateFrom = xss_clean($this->input->post('dateFrom'));
$dateTo = xss_clean($this->input->post('dateTo'));
$result = $this->stats->total_qsos($dateFrom, $dateTo);
$total_qsos['qsoarray'] = $result['qsoView'];
$total_qsos['bandtotal'] = $result['bandtotal'];
$total_qsos['modetotal'] = $result['modetotal'];
$total_qsos['bands'] = $this->stats->get_bands($yr);
$total_qsos['bands'] = $this->stats->get_bands($dateFrom, $dateTo);
$this->load->view('statistics/qsotable', $total_qsos);
}
@@ -330,9 +340,11 @@ class Statistics extends CI_Controller {
$mode = xss_clean($this->input->post('mode'));
$sat = xss_clean($this->input->post('sat'));
$orbit = xss_clean($this->input->post('orbit'));
$dateFrom = xss_clean($this->input->post('dateFrom'));
$dateTo = xss_clean($this->input->post('dateTo'));
$this->load->model('stats');
$azimutharray = $this->stats->azimuthdata($band, $mode, $sat, $orbit);
$azimutharray = $this->stats->azimuthdata($band, $mode, $sat, $orbit, $dateFrom, $dateTo);
header('Content-Type: application/json');
echo json_encode($azimutharray);
@@ -341,9 +353,11 @@ class Statistics extends CI_Controller {
public function get_elevation_data() {
$sat = xss_clean($this->input->post('sat'));
$orbit = xss_clean($this->input->post('orbit'));
$dateFrom = xss_clean($this->input->post('dateFrom'));
$dateTo = xss_clean($this->input->post('dateTo'));
$this->load->model('stats');
$elevationarray = $this->stats->elevationdata($sat, $orbit);
$elevationarray = $this->stats->elevationdata($sat, $orbit, $dateFrom, $dateTo);
header('Content-Type: application/json');
echo json_encode($elevationarray);
@@ -354,8 +368,9 @@ class Statistics extends CI_Controller {
$sat = str_replace('"', "", $this->security->xss_clean($this->input->post("Sat")));
$mode = str_replace('"', "", $this->security->xss_clean($this->input->post("Mode")));
$year = $this->security->xss_clean($this->input->post("Year"));
$data['results'] = $this->stats->sat_qsos($sat,$year,$mode);
$dateFrom = $this->security->xss_clean($this->input->post("dateFrom"));
$dateTo = $this->security->xss_clean($this->input->post("dateTo"));
$data['results'] = $this->stats->sat_qsos($sat,$dateFrom,$dateTo,$mode);
$data['page_title'] = __("Log View")." - " . __("Satellite QSOs");
$data['filter'] = $sat;

View File

@@ -3462,7 +3462,7 @@ class Logbook_model extends CI_Model {
return $query;
}
function totals_year_month($year = null) {
function totals_year_month($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -3474,22 +3474,28 @@ class Logbook_model extends CI_Model {
$location_list = implode(',', array_fill(0, count($logbooks_locations_array), '?'));
$params = $logbooks_locations_array;
if ($year === null || $year === 'All') {
// Aggregate across all years
if (empty($dateFrom) && empty($dateTo)) {
// Aggregate across all dates
$sql = "SELECT DATE_FORMAT(COL_TIME_ON, '%m') AS month, COUNT(COL_PRIMARY_KEY) AS total
FROM " . $this->config->item('table_name') . "
WHERE station_id IN ($location_list)
GROUP BY DATE_FORMAT(COL_TIME_ON, '%m')
ORDER BY month ASC";
} else {
// Filter by specific year
// Filter by date range
$sql = "SELECT DATE_FORMAT(COL_TIME_ON, '%m') AS month, COUNT(COL_PRIMARY_KEY) AS total
FROM " . $this->config->item('table_name') . "
WHERE station_id IN ($location_list)
AND DATE_FORMAT(COL_TIME_ON, '%Y') = ?
GROUP BY DATE_FORMAT(COL_TIME_ON, '%m')
WHERE station_id IN ($location_list)";
if (!empty($dateFrom)) {
$sql .= " AND DATE(COL_TIME_ON) >= ?";
$params[] = $dateFrom;
}
if (!empty($dateTo)) {
$sql .= " AND DATE(COL_TIME_ON) <= ?";
$params[] = $dateTo;
}
$sql .= " GROUP BY DATE_FORMAT(COL_TIME_ON, '%m')
ORDER BY month ASC";
$params[] = $year;
}
$query = $this->db->query($sql, $params);
@@ -3733,17 +3739,17 @@ class Logbook_model extends CI_Model {
}
}
private function where_year($yr) {
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);
private function where_date_range($dateFrom, $dateTo) {
if (!empty($dateFrom)) {
$this->db->where('DATE(COL_TIME_ON) >=', $dateFrom);
}
if (!empty($dateTo)) {
$this->db->where('DATE(COL_TIME_ON) <=', $dateTo);
}
}
/* Return total amount of SSB QSOs logged */
function total_ssb($yr = 'All') {
function total_ssb($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -3758,7 +3764,7 @@ 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);
$this->where_year($yr);
$this->where_date_range($dateFrom, $dateTo);
$query = $this->db->get($this->config->item('table_name'));
if ($query->num_rows() > 0) {
@@ -3769,7 +3775,7 @@ class Logbook_model extends CI_Model {
}
/* Return total number of satellite QSOs */
function total_sat($yr = 'All') {
function total_sat($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -3783,7 +3789,7 @@ 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');
$this->where_year($yr);
$this->where_date_range($dateFrom, $dateTo);
$this->db->order_by('count DESC');
$this->db->group_by('COL_SAT_NAME');
$query = $this->db->get($this->config->item('table_name'));
@@ -3831,7 +3837,7 @@ class Logbook_model extends CI_Model {
}
/* Return total number of CW QSOs */
function total_cw($yr = 'All') {
function total_cw($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -3843,7 +3849,7 @@ 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');
$this->where_year($yr);
$this->where_date_range($dateFrom, $dateTo);
$query = $this->db->get($this->config->item('table_name'));
if ($query->num_rows() > 0) {
@@ -3854,7 +3860,7 @@ class Logbook_model extends CI_Model {
}
/* Return total number of FM QSOs */
function total_am($yr = 'All') {
function total_am($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -3866,7 +3872,7 @@ 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', 'AM');
$this->where_year($yr);
$this->where_date_range($dateFrom, $dateTo);
$query = $this->db->get($this->config->item('table_name'));
if ($query->num_rows() > 0) {
@@ -3876,7 +3882,7 @@ class Logbook_model extends CI_Model {
}
}
function total_fm($yr = 'All') {
function total_fm($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -3888,7 +3894,7 @@ 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');
$this->where_year($yr);
$this->where_date_range($dateFrom, $dateTo);
$query = $this->db->get($this->config->item('table_name'));
if ($query->num_rows() > 0) {
@@ -3899,7 +3905,7 @@ class Logbook_model extends CI_Model {
}
/* Return total number of Digital QSOs */
function total_digi($yr = 'All') {
function total_digi($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -3916,7 +3922,7 @@ class Logbook_model extends CI_Model {
$this->db->where('COL_MODE !=', 'CW');
$this->db->where('COL_MODE !=', 'FM');
$this->db->where('COL_MODE !=', 'AM');
$this->where_year($yr);
$this->where_date_range($dateFrom, $dateTo);
$query = $this->db->get($this->config->item('table_name'));
if ($query->num_rows() > 0) {
@@ -3927,7 +3933,7 @@ class Logbook_model extends CI_Model {
}
/* Return total number of QSOs per band */
function total_bands($yr = 'All') {
function total_bands($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -3937,7 +3943,7 @@ 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);
$this->where_year($yr);
$this->where_date_range($dateFrom, $dateTo);
$this->db->group_by('band');
$this->db->order_by('count', 'DESC');
@@ -3947,7 +3953,7 @@ class Logbook_model extends CI_Model {
}
/* Return total number of QSOs per operator */
function total_operators($yr = 'All') {
function total_operators($dateFrom = null, $dateTo = null) {
//Load logbook model and get station locations
$this->load->model('logbooks_model');
@@ -3960,7 +3966,7 @@ class Logbook_model extends CI_Model {
//get statistics from database
$this->db->select('IFNULL(IF(COL_OPERATOR = "", COL_STATION_CALLSIGN, COL_OPERATOR), COL_STATION_CALLSIGN) AS operator, count( * ) AS count', FALSE);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->where_year($yr);
$this->where_date_range($dateFrom, $dateTo);
$this->db->group_by('operator');
$this->db->order_by('count', 'DESC');

View File

@@ -71,14 +71,24 @@
return $this->db->get($this->config->item('table_name'));
}
function unique_sat_grids($yr = 'All') {
// Helper method for date range filtering
private function filter_date_range($dateFrom, $dateTo) {
if (!empty($dateFrom)) {
$this->db->where('DATE(COL_TIME_ON) >=', $dateFrom);
}
if (!empty($dateTo)) {
$this->db->where('DATE(COL_TIME_ON) <=', $dateTo);
}
}
function unique_sat_grids($dateFrom = null, $dateTo = null) {
$qsoView = array();
$sats = $this->get_sats($yr);
$modes = $this->get_sat_modes($yr);
$sats = $this->get_sats($dateFrom, $dateTo);
$modes = $this->get_sat_modes($dateFrom, $dateTo);
$satunique = $this->getUniqueSatGridsSat($yr);
$modeunique = $this->getUniqueSatGridModes($yr);
$satunique = $this->getUniqueSatGridsSat($dateFrom, $dateTo);
$modeunique = $this->getUniqueSatGridModes($dateFrom, $dateTo);
// Generating the band/mode table
foreach ($sats as $sat) {
@@ -102,7 +112,7 @@
}
// Populating array with worked
$workedQso = $this->getUniqueSatGrids($yr);
$workedQso = $this->getUniqueSatGrids($dateFrom, $dateTo);
foreach ($workedQso as $line) {
//if ($line->col_submode == null) {
@@ -116,19 +126,19 @@
$result['qsoView'] = $qsoView;
$result['satunique'] = $satgrids ?? '';
$result['modeunique'] = $modegrids ?? '';
$result['total'] = $this->getUniqueSatGridsTotal($yr);
$result['total'] = $this->getUniqueSatGridsTotal($dateFrom, $dateTo);
return $result;
}
function unique_sat_callsigns($yr = 'All') {
function unique_sat_callsigns($dateFrom = null, $dateTo = null) {
$qsoView = array();
$sats = $this->get_sats($yr);
$modes = $this->get_sat_modes($yr);
$sats = $this->get_sats($dateFrom, $dateTo);
$modes = $this->get_sat_modes($dateFrom, $dateTo);
$satunique = $this->getUniqueSatCallsignsSat($yr);
$modeunique = $this->getUniqueSatCallsignsModes($yr);
$satunique = $this->getUniqueSatCallsignsSat($dateFrom, $dateTo);
$modeunique = $this->getUniqueSatCallsignsModes($dateFrom, $dateTo);
// Generating the band/mode table
foreach ($sats as $sat) {
@@ -152,7 +162,7 @@
}
// Populating array with worked
$workedQso = $this->getUniqueSatCallsigns($yr);
$workedQso = $this->getUniqueSatCallsigns($dateFrom, $dateTo);
foreach ($workedQso as $line) {
//if ($line->col_submode == null) {
@@ -164,22 +174,21 @@
}
$result['qsoView'] = $qsoView;
$result['satunique'] = $satcalls ?? '';
$result['modeunique'] = $modecalls ?? '';
$result['total'] = $this->getUniqueSatCallsignsTotal($yr);
$result['satunique'] = $satcalls;
$result['modeunique'] = $modecalls;
$result['total'] = $this->getUniqueSatCallsignsTotal($dateFrom, $dateTo);
return $result;
}
function unique_callsigns($yr = 'All') {
function unique_callsigns($dateFrom = null, $dateTo = null) {
$qsoView = array();
$bands = $this->get_bands($yr);
$modes = $this->get_modes($yr);
$bands = $this->get_bands($dateFrom, $dateTo);
$modes = $this->get_modes($dateFrom, $dateTo);
$bandunique = $this->getUniqueCallsignsBands($yr);
$modeunique = $this->getUniqueCallsignsModes($yr);
$bandunique = $this->getUniqueCallsignsBands($dateFrom, $dateTo);
$modeunique = $this->getUniqueCallsignsModes($dateFrom, $dateTo);
$modecalls=[];
$bandcalls=[];
@@ -206,7 +215,7 @@
}
// Populating array with worked
$workedQso = $this->getUniqueCallsigns($yr);
$workedQso = $this->getUniqueCallsigns($dateFrom, $dateTo);
foreach ($workedQso as $line) {
//if ($line->col_submode == null) {
@@ -220,12 +229,12 @@
$result['qsoView'] = $qsoView;
$result['bandunique'] = $bandcalls;
$result['modeunique'] = $modecalls;
$result['total'] = $this->getUniqueCallsignsTotal($yr);
$result['total'] = $this->getUniqueCallsignsTotal($dateFrom, $dateTo);
return $result;
}
function getUniqueSatGridsSat($yr = 'All') {
function getUniqueSatGridsSat($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -238,12 +247,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$query = $this->db->get($this->config->item('table_name'));
@@ -291,7 +295,7 @@
return $result;
}
function getUniqueSatCallsignsSat($yr = 'All') {
function getUniqueSatCallsignsSat($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -304,12 +308,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('upper(col_sat_name)');
@@ -319,7 +318,7 @@
}
function getUniqueSatGrids($yr = 'All') {
function getUniqueSatGrids($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -337,12 +336,7 @@
], 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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$query = $this->db->get($this->config->item('table_name'));
@@ -385,7 +379,7 @@
}
function getUniqueSatCallsigns($yr = 'All') {
function getUniqueSatCallsigns($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -398,12 +392,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('upper(col_sat_name), col_mode, coalesce(col_submode, "")');
@@ -412,7 +401,7 @@
return $query->result();
}
function getUniqueCallsigns($yr = 'All') {
function getUniqueCallsigns($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -423,12 +412,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('lower(col_band), col_mode, coalesce(col_submode, "")');
@@ -437,7 +421,7 @@
return $query->result();
}
function getUniqueCallsignsModes($yr = 'All') {
function getUniqueCallsignsModes($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -448,12 +432,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('col_mode, coalesce(col_submode, "")');
@@ -462,7 +441,7 @@
return $query->result();
}
function getUniqueSatGridModes($yr = 'All') {
function getUniqueSatGridModes($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -475,12 +454,7 @@
$this->db->select('count(distinct substr(col_gridsquare,1,4)) as grids, 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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('col_mode, coalesce(col_submode, "")');
@@ -489,7 +463,7 @@
return $query->result();
}
function getUniqueSatCallsignsModes($yr = 'All') {
function getUniqueSatCallsignsModes($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -502,12 +476,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('col_mode, coalesce(col_submode, "")');
@@ -516,7 +485,7 @@
return $query->result();
}
function getUniqueCallsignsBands($yr = 'All') {
function getUniqueCallsignsBands($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -527,12 +496,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('col_band');
@@ -541,7 +505,7 @@
return $query->result();
}
function getUniqueSatGridsTotal($yr = 'All') {
function getUniqueSatGridsTotal($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -550,12 +514,7 @@
}
$this->db->select('distinct col_gridsquare, col_vucc_grids', 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->filter_date_range($dateFrom, $dateTo);
$this->db->where('coalesce(col_sat_name,"") != ""');
$this->db->where('col_prop_mode', 'SAT');
$this->db->where_in('station_id', $logbooks_locations_array);
@@ -586,7 +545,7 @@
}
function getUniqueSatCallsignsTotal($yr = 'All') {
function getUniqueSatCallsignsTotal($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -597,12 +556,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where('coalesce(col_sat_name,"") != ""');
$this->db->where('col_prop_mode', 'SAT');
$this->db->where_in('station_id', $logbooks_locations_array);
@@ -612,7 +566,7 @@
return $query->row();
}
function getUniqueCallsignsTotal($yr = 'All') {
function getUniqueCallsignsTotal($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -623,12 +577,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$query = $this->db->get($this->config->item('table_name'));
@@ -636,11 +585,11 @@
return $query->row();
}
function total_sat_qsos($yr = 'All') {
function total_sat_qsos($dateFrom = null, $dateTo = null) {
$qsoView = array();
$sats = $this->get_sats($yr);
$modes = $this->get_sat_modes($yr);
$sats = $this->get_sats($dateFrom, $dateTo);
$modes = $this->get_sat_modes($dateFrom, $dateTo);
$sattotal = array();
$modetotal = array();
@@ -654,7 +603,7 @@
}
// Populating array with worked
$workedQso = $this->modeSatQso($yr);
$workedQso = $this->modeSatQso($dateFrom, $dateTo);
foreach ($workedQso as $line) {
if ($line->col_submode == null || $line->col_submode == "") {
$qsoView [$line->sat] [$line->col_mode] = $line->count;
@@ -674,11 +623,11 @@
return $result;
}
function total_qsos($yr = 'All') {
function total_qsos($dateFrom = null, $dateTo = null) {
$qsoView = array();
$bands = $this->get_bands($yr);
$modes = $this->get_modes($yr);
$bands = $this->get_bands($dateFrom, $dateTo);
$modes = $this->get_modes($dateFrom, $dateTo);
$bandtotal = array();
$modetotal = array();
@@ -692,7 +641,7 @@
}
// Populating array with worked
$workedQso = $this->modeBandQso($yr);
$workedQso = $this->modeBandQso($dateFrom, $dateTo);
foreach ($workedQso as $line) {
if ($line->col_submode == null || $line->col_submode == "") {
$qsoView [$line->col_mode] [$line->band] = $line->count;
@@ -711,15 +660,15 @@
return $result;
}
function total_qsls($yr = 'All') {
function total_qsls($dateFrom = null, $dateTo = null) {
$qsoView = array();
$qsoSatView = array();
$bands = $this->get_bands($yr);
$modes = $this->get_modes($yr);
$bands = $this->get_bands($dateFrom, $dateTo);
$modes = $this->get_modes($dateFrom, $dateTo);
$sats = $this->get_sats($yr);
$satmodes = $this->get_sat_modes($yr);
$sats = $this->get_sats($dateFrom, $dateTo);
$satmodes = $this->get_sat_modes($dateFrom, $dateTo);
// Generating the band/mode table
foreach ($bands as $band) {
@@ -734,7 +683,7 @@
}
// Populating array with numbers
$workedQso = $this->modeBandQsl($yr);
$workedQso = $this->modeBandQsl($dateFrom, $dateTo);
foreach ($workedQso as $line) {
if ($line->col_submode == null || $line->col_submode == "") {
$qsoView [$line->col_mode] [$line->band] ['qso'] = $line->qsos;
@@ -766,7 +715,7 @@
}
// Populating array with numbers
$workedSatQso = $this->modeSatQsl($yr);
$workedSatQso = $this->modeSatQsl($dateFrom, $dateTo);
foreach ($workedSatQso as $line) {
if ($line->col_submode == null || $line->col_submode == "") {
$qsoSatView [$line->col_mode] [$line->sat] ['qso'] = $line->qsos;
@@ -791,7 +740,7 @@
return $result;
}
function modeBandQsl($yr = 'All') {
function modeBandQsl($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$binding=[];
@@ -808,12 +757,13 @@
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) .")";
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;
if (!empty($dateFrom)) {
$sql.=" and DATE(COL_TIME_ON) >= ? ";
$binding[]=$dateFrom;
}
if (!empty($dateTo)) {
$sql.=" and DATE(COL_TIME_ON) <= ? ";
$binding[]=$dateTo;
}
$sql.=" and col_prop_mode <> 'SAT'
group by lower(col_band), col_mode, coalesce(col_submode, '')";
@@ -822,7 +772,7 @@
return $result->result();
}
function modeSatQsl($yr = 'All') {
function modeSatQsl($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$binding=[];
@@ -839,12 +789,13 @@
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) .")";
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;
if (!empty($dateFrom)) {
$sql.=" and DATE(COL_TIME_ON) >= ? ";
$binding[]=$dateFrom;
}
if (!empty($dateTo)) {
$sql.=" and DATE(COL_TIME_ON) <= ? ";
$binding[]=$dateTo;
}
$sql.=" and col_prop_mode = 'SAT'
and coalesce(col_sat_name, '') <> ''
@@ -854,7 +805,7 @@
return $result->result();
}
function modeSatQso($yr = 'All') {
function modeSatQso($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -867,12 +818,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('upper(col_sat_name), col_mode, coalesce(col_submode, "")');
@@ -881,7 +827,7 @@
return $query->result();
}
function modeBandQso($yr = 'All') {
function modeBandQso($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -890,12 +836,7 @@
}
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->group_by('lower(col_band), col_mode, coalesce(col_submode, "")');
@@ -904,7 +845,7 @@
return $query->result();
}
function get_sats($yr = 'All') {
function get_sats($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -915,12 +856,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where('coalesce(col_sat_name,"") != ""');
$this->db->where('col_prop_mode', 'SAT');
$this->db->where_in('station_id', $logbooks_locations_array);
@@ -934,7 +870,7 @@
return $sats;
}
function get_bands($yr = 'All') {
function get_bands($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -945,12 +881,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->order_by('bandsort', 'desc');
@@ -975,7 +906,7 @@
return $bands;
}
function get_sat_modes($yr = 'All') {
function get_sat_modes($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -986,12 +917,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where('coalesce(col_sat_name,"") != ""');
$this->db->where('col_prop_mode', 'SAT');
$this->db->where_in('station_id', $logbooks_locations_array);
@@ -1010,7 +936,7 @@
return $modes;
}
function get_modes($yr = 'All') {
function get_modes($dateFrom = null, $dateTo = null) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -1021,12 +947,7 @@
$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->filter_date_range($dateFrom, $dateTo);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->order_by('col_mode, col_submode', 'ASC');
@@ -1043,7 +964,7 @@
return $modes;
}
function elevationdata($sat, $orbit, $yr = 'All') {
function elevationdata($sat, $orbit, $dateFrom = null, $dateTo = null) {
$conditions = [];
$binding = [];
@@ -1074,12 +995,13 @@
$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, '') <> ''";
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;
if (!empty($dateFrom)) {
$sql.=" and DATE(COL_TIME_ON) >= ? ";
$binding[]=$dateFrom;
}
if (!empty($dateTo)) {
$sql.=" and DATE(COL_TIME_ON) <= ? ";
$binding[]=$dateTo;
}
$sql.=" $where
group by round(col_ant_el)
@@ -1089,7 +1011,7 @@
return $result->result();
}
function azimuthdata($band, $mode, $sat, $orbit, $yr = 'All') {
function azimuthdata($band, $mode, $sat, $orbit, $dateFrom = null, $dateTo = null) {
$conditions = [];
$binding = [];
@@ -1134,12 +1056,13 @@
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, '') <> ''";
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;
if (!empty($dateFrom)) {
$sql.=" and DATE(COL_TIME_ON) >= ? ";
$binding[]=$dateFrom;
}
if (!empty($dateTo)) {
$sql.=" and DATE(COL_TIME_ON) <= ? ";
$binding[]=$dateTo;
}
$sql.=" $where
group by round(col_ant_az)
@@ -1149,7 +1072,7 @@
return $result->result();
}
public function sat_qsos($sat,$year,$mode) {
public function sat_qsos($sat,$dateFrom,$dateTo,$mode) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$this->db->select('*, satellite.displayname AS sat_displayname');
@@ -1163,10 +1086,8 @@
$this->db->or_where('COL_SUBMODE', $mode);
$this->db->group_end();
}
if (($year ?? 'All') != 'All') {
$this->db->where('COL_TIME_ON >=',date($year.'-01-01 00:00:00'));
$this->db->where('COL_TIME_ON <=',date($year.'-12-31 23:59:59'));
}
// Apply date range filter
$this->filter_date_range($dateFrom, $dateTo);
$this->db->where_in($this->config->item('table_name').'.station_id', $logbooks_locations_array);
$this->db->order_by("COL_TIME_ON desc, COL_PRIMARY_KEY desc");
$this->db->limit(500);

View File

@@ -50,14 +50,30 @@
<small class="text-muted"><?= __("Explore the logbook."); ?></small>
</h2>
<br/>
<select class="form-select form-select-sm me-2 w-auto" style="display:none;" id="yr" name="yr">
<option value='All'><?= __("All Years"); ?></option>
<?php
foreach($years as $yr) {
echo '<option value="'.$yr.'">'.__("Year")." ".$yr.'</option>';
}
?>
</select>
<div class="mb-3" id="dateFilterContainer" style="display:none;">
<label class="form-label"><?= __("Date Presets") . ": " ?></label>
<div class="d-flex gap-1 d-flex flex-wrap mb-2">
<button type="button" class="btn btn-primary btn-sm flex-shrink-0" onclick="applyPreset('today')"><?= __("Today") ?></button>
<button type="button" class="btn btn-primary btn-sm flex-shrink-0" onclick="applyPreset('yesterday')"><?= __("Yesterday") ?></button>
<button type="button" class="btn btn-primary btn-sm flex-shrink-0" onclick="applyPreset('last7days')"><?= __("Last 7 Days") ?></button>
<button type="button" class="btn btn-primary btn-sm flex-shrink-0" onclick="applyPreset('last30days')"><?= __("Last 30 Days") ?></button>
<button type="button" class="btn btn-primary btn-sm flex-shrink-0" onclick="applyPreset('thismonth')"><?= __("This Month") ?></button>
<button type="button" class="btn btn-primary btn-sm flex-shrink-0" onclick="applyPreset('lastmonth')"><?= __("Last Month") ?></button>
<button type="button" class="btn btn-primary btn-sm flex-shrink-0" onclick="applyPreset('thisyear')"><?= __("This Year") ?></button>
<button type="button" class="btn btn-primary btn-sm flex-shrink-0" onclick="applyPreset('lastyear')"><?= __("Last Year") ?></button>
<button type="button" class="btn btn-danger btn-sm flex-shrink-0" onclick="resetDates()"><i class="fas fa-times"></i> <?= __("All") ?></button>
</div>
<div class="row g-2">
<div class="col-auto">
<label class="col-form-label col-form-label-sm" for="dateFrom"><?= __("Date from") ?></label>
<input name="dateFrom" id="dateFrom" type="date" class="form-control form-control-sm w-auto border border-secondary">
</div>
<div class="col-auto">
<label class="col-form-label col-form-label-sm" for="dateTo"><?= __("Date to") ?></label>
<input name="dateTo" id="dateTo" type="date" class="form-control form-control-sm w-auto border border-secondary">
</div>
</div>
</div>
<br>
<div hidden class="tabs">
<ul class="nav nav-tabs" id="myTab" role="tablist">

View File

@@ -3,86 +3,173 @@ totalQsosPerYear();
var activeTab='totalQsosPerYear()';
// Preset functionality
function applyPreset(preset) {
const dateFrom = document.getElementById('dateFrom');
const dateTo = document.getElementById('dateTo');
const today = new Date();
// Format date as YYYY-MM-DD
function formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
}
switch(preset) {
case 'today':
dateFrom.value = formatDate(today);
dateTo.value = formatDate(today);
break;
case 'yesterday':
const yesterday = new Date(today);
yesterday.setDate(yesterday.getDate() - 1);
dateFrom.value = formatDate(yesterday);
dateTo.value = formatDate(yesterday);
break;
case 'last7days':
const sevenDaysAgo = new Date(today);
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
dateFrom.value = formatDate(sevenDaysAgo);
dateTo.value = formatDate(today);
break;
case 'last30days':
const thirtyDaysAgo = new Date(today);
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);
dateFrom.value = formatDate(thirtyDaysAgo);
dateTo.value = formatDate(today);
break;
case 'thismonth':
const firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1);
dateFrom.value = formatDate(firstDayOfMonth);
dateTo.value = formatDate(today);
break;
case 'lastmonth':
const firstDayOfLastMonth = new Date(today.getFullYear(), today.getMonth() - 1, 1);
const lastDayOfLastMonth = new Date(today.getFullYear(), today.getMonth(), 0);
dateFrom.value = formatDate(firstDayOfLastMonth);
dateTo.value = formatDate(lastDayOfLastMonth);
break;
case 'thisyear':
const firstDayOfYear = new Date(today.getFullYear(), 0, 1);
dateFrom.value = formatDate(firstDayOfYear);
dateTo.value = formatDate(today);
break;
case 'lastyear':
const lastYear = today.getFullYear() - 1;
const firstDayOfLastYear = new Date(lastYear, 0, 1);
const lastDayOfLastYear = new Date(lastYear, 11, 31);
dateFrom.value = formatDate(firstDayOfLastYear);
dateTo.value = formatDate(lastDayOfLastYear);
break;
case 'alltime':
dateFrom.value = '';
dateTo.value = '';
break;
}
// Trigger refresh after applying preset
eval(activeTab);
}
// Reset dates function
function resetDates() {
const dateFrom = document.getElementById('dateFrom');
const dateTo = document.getElementById('dateTo');
dateFrom.value = '';
dateTo.value = '';
// Trigger refresh after resetting
eval(activeTab);
}
$("a[href='#satellite']").on('shown.bs.tab', function(e) {
totalSatQsos();
activeTab='totalSatQsos()';
$(".sattable").DataTable().columns.adjust();
$("#yr").show();
$("#dateFilterContainer").show();
});
$("a[href='#sattab']").on('shown.bs.tab', function(e) {
activeTab='totalSatQsos()';
totalSatQsos();
$("#yr").show();
$("#dateFilterContainer").show();
});
$("a[href='#home']").on('shown.bs.tab', function(e) {
activeTab='totalQsosPerYear()';
totalQsosPerYear();
$("#yr").hide();
$("#dateFilterContainer").show();
});
$("a[href='#yearstab']").on('shown.bs.tab', function(e) {
activeTab='totalQsosPerYear()';
totalQsosPerYear();
$("#yr").hide();
$("#dateFilterContainer").hide();
});
$("a[href='#monthstab']").on('shown.bs.tab', function(e) {
activeTab='totalQsosPerMonth()';
totalQsosPerMonth();
$("#yr").show();
$("#dateFilterContainer").show();
});
$("a[href='#bandtab']").on('shown.bs.tab', function(e) {
totalBandQsos();
activeTab='totalBandQsos()'
$("#yr").show();
activeTab='totalBandQsos()';
$("#dateFilterContainer").show();
});
$("a[href='#modetab']").on('shown.bs.tab', function(e) {
totalModeQsos();
activeTab='totalModeQsos()'
$("#yr").show();
activeTab='totalModeQsos()';
$("#dateFilterContainer").show();
});
$("a[href='#qsotab']").on('shown.bs.tab', function(e) {
totalQsos();
activeTab='totalQsos()'
$("#yr").show();
activeTab='totalQsos()';
$("#dateFilterContainer").show();
});
$("a[href='#operatorstab']").on('shown.bs.tab', function(e) {
totalOperatorQsos();
activeTab='totalOperatorQsos()'
$("#yr").show();
activeTab='totalOperatorQsos()';
$("#dateFilterContainer").show();
});
$("a[href='#satqsostab']").on('shown.bs.tab', function(e) {
totalSatQsosC();
activeTab='totalSatQsosC()'
$("#yr").show();
activeTab='totalSatQsosC()';
$("#dateFilterContainer").show();
});
$("a[href='#uniquetab']").on('shown.bs.tab', function(e) {
uniqueCallsigns();
activeTab='uniqueCallsigns()'
$("#yr").show();
activeTab='uniqueCallsigns()';
$("#dateFilterContainer").show();
});
$("a[href='#satuniquetab']").on('shown.bs.tab', function(e) {
uniqueSatCallsigns();
activeTab='uniqueSatCallsigns()'
$("#yr").show();
activeTab='uniqueSatCallsigns()';
$("#dateFilterContainer").show();
});
$("a[href='#satuniquegridtab']").on('shown.bs.tab', function(e) {
uniqueSatGrids();
activeTab='uniqueSatGrids()'
$("#yr").show();
activeTab='uniqueSatGrids()';
$("#dateFilterContainer").show();
});
$("#yr").on('change',function(e) {
$("#dateFrom, #dateTo").on('change', function(e) {
eval(activeTab);
});
@@ -90,7 +177,7 @@ function uniqueSatGrids() {
$.ajax({
url: base_url+'index.php/statistics/get_unique_sat_grids',
type: 'post',
data: { yr: $("#yr option:selected").val() },
data: { dateFrom: $('#dateFrom').val(), dateTo: $('#dateTo').val() },
success: function (data) {
$(".satuniquegrid").html('');
if (data.length > 0) {
@@ -104,7 +191,7 @@ function uniqueSatCallsigns() {
$.ajax({
url: base_url+'index.php/statistics/get_unique_sat_callsigns',
type: 'post',
data: { yr: $("#yr option:selected").val() },
data: { dateFrom: $('#dateFrom').val(), dateTo: $('#dateTo').val() },
success: function (data) {
$(".satunique").html('');
if (data.length > 0) {
@@ -118,7 +205,7 @@ function uniqueCallsigns() {
$.ajax({
url: base_url+'index.php/statistics/get_unique_callsigns',
type: 'post',
data: { yr: $("#yr option:selected").val() },
data: { dateFrom: $('#dateFrom').val(), dateTo: $('#dateTo').val() },
success: function (data) {
$(".unique").html('');
if (data.length > 0) {
@@ -132,7 +219,7 @@ function totalQsos() {
$.ajax({
url: base_url+'index.php/statistics/get_total_qsos',
type: 'post',
data: { yr: $("#yr option:selected").val() },
data: { dateFrom: $('#dateFrom').val(), dateTo: $('#dateTo').val() },
success: function (data) {
$(".qsos").html('');
if (data.length > 0) {
@@ -146,7 +233,7 @@ function totalSatQsosC() {
$.ajax({
url: base_url+'index.php/statistics/get_total_sat_qsos',
type: 'post',
data: { yr: $("#yr option:selected").val() },
data: { dateFrom: $('#dateFrom').val(), dateTo: $('#dateTo').val() },
success: function (data) {
$(".satqsos").html('');
if (data.length > 0) {
@@ -163,7 +250,7 @@ function totalQsosPerYear() {
$.ajax({
url: base_url+'index.php/statistics/get_year',
type: 'post',
data: { yr: $("#yr option:selected").val() },
data: { dateFrom: $('#dateFrom').val(), dateTo: $('#dateTo').val() },
success: function (data) {
if (data.length > 0) {
$(".years").html('');
@@ -281,7 +368,7 @@ function totalQsosPerMonth() {
$.ajax({
url: base_url+'index.php/statistics/get_year_month',
type: 'post',
data: { yr: $("#yr option:selected").val() },
data: { dateFrom: $('#dateFrom').val(), dateTo: $('#dateTo').val() },
success: function (data) {
if (data.length > 0) {
$(".months").html('');
@@ -400,7 +487,7 @@ function totalModeQsos() {
$.ajax({
url: base_url+'index.php/statistics/get_mode',
type: 'post',
data: { yr: $("#yr option:selected").val() },
data: { dateFrom: $('#dateFrom').val(), dateTo: $('#dateTo').val() },
success: function (data) {
if (data.length > 0) {
$(".mode").html('');
@@ -531,7 +618,7 @@ function totalBandQsos() {
$.ajax({
url: base_url+'index.php/statistics/get_band',
type: 'post',
data: { yr: $("#yr option:selected").val() },
data: { dateFrom: $('#dateFrom').val(), dateTo: $('#dateTo').val() },
success: function (data) {
if (data.length > 0) {
$(".band").html('');
@@ -674,7 +761,7 @@ function totalOperatorQsos() {
$.ajax({
url: base_url+'index.php/statistics/get_operators',
type: 'post',
data: { yr: $("#yr option:selected").val() },
data: { dateFrom: $('#dateFrom').val(), dateTo: $('#dateTo').val() },
success: function (data) {
if (data.length > 0) {
$(".operators").html('');
@@ -817,7 +904,7 @@ function totalSatQsos() {
$.ajax({
url: base_url+'index.php/statistics/get_sat',
type: 'post',
data: { yr: $("#yr option:selected").val() },
data: { dateFrom: $('#dateFrom').val(), dateTo: $('#dateTo').val() },
success: function (data) {
$(".satsummary").html('');
if (data.length > 0) {
@@ -964,7 +1051,8 @@ function displaySatQsos(sat,mode) {
var ajax_data = ({
'Sat': sat,
'Mode': mode,
'Year': $("#yr option:selected").val(),
'dateFrom': $("#dateFrom").val(),
'dateTo': $("#dateTo").val(),
})
modalloading=true;
$.ajax({