From 08d90aec24e80e062b15816ce85095d98ff2b485 Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 31 Dec 2025 09:03:13 +0000 Subject: [PATCH] Introduce more granular Date-Filter for Stats-Page --- application/controllers/Statistics.php | 87 ++++--- application/models/Logbook_model.php | 66 ++--- application/models/Stats.php | 317 ++++++++++--------------- application/views/statistics/index.php | 32 ++- assets/js/sections/statistics.js | 156 +++++++++--- 5 files changed, 352 insertions(+), 306 deletions(-) diff --git a/application/controllers/Statistics.php b/application/controllers/Statistics.php index 562afe48c..7c56681dc 100644 --- a/application/controllers/Statistics.php +++ b/application/controllers/Statistics.php @@ -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; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 032b6bee6..b9f2518fe 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -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'); diff --git a/application/models/Stats.php b/application/models/Stats.php index 381ac2d93..a2bae6bf8 100644 --- a/application/models/Stats.php +++ b/application/models/Stats.php @@ -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); diff --git a/application/views/statistics/index.php b/application/views/statistics/index.php index 3aa0a8747..fc4566918 100644 --- a/application/views/statistics/index.php +++ b/application/views/statistics/index.php @@ -50,14 +50,30 @@
- +