From 04a4b22b2553f8af908490b198983bbfa748985f Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 5 Apr 2024 15:46:57 +0200 Subject: [PATCH] Add option to filter map to orbit type --- application/controllers/Gridmap.php | 24 +- .../language/english/gridsquares_lang.php | 1 + application/models/Bands.php | 42 +- application/models/Gridmap_model.php | 364 +++++++++--------- application/views/gridmap/index.php | 9 + assets/js/sections/gridmap.js | 1 + 6 files changed, 249 insertions(+), 192 deletions(-) diff --git a/application/controllers/Gridmap.php b/application/controllers/Gridmap.php index 922e987c2..c32155fb2 100644 --- a/application/controllers/Gridmap.php +++ b/application/controllers/Gridmap.php @@ -16,8 +16,9 @@ class Gridmap extends CI_Controller { $data['visitor'] = false; $data['homegrid'] = explode(',', $this->stations->find_gridsquare()); - $data['modes'] = $this->gridmap_model->get_worked_modes(); + $data['modes'] = $this->gridmap_model->get_worked_modes(); $data['bands'] = $this->bands->get_worked_bands(); + $data['orbits'] = $this->bands->get_worked_orbits(); $data['sats_available'] = $this->bands->get_worked_sats(); $data['user_default_band'] = $this->session->userdata('user_default_band'); @@ -45,13 +46,14 @@ class Gridmap extends CI_Controller { } public function getGridsjs() { - $band = $this->security->xss_clean($this->input->post('band')); - $mode = $this->security->xss_clean($this->input->post('mode')); - $qsl = $this->security->xss_clean($this->input->post('qsl')); - $lotw = $this->security->xss_clean($this->input->post('lotw')); - $eqsl = $this->security->xss_clean($this->input->post('eqsl')); - $qrz = $this->security->xss_clean($this->input->post('qrz')); + $band = $this->security->xss_clean($this->input->post('band')); + $mode = $this->security->xss_clean($this->input->post('mode')); + $qsl = $this->security->xss_clean($this->input->post('qsl')); + $lotw = $this->security->xss_clean($this->input->post('lotw')); + $eqsl = $this->security->xss_clean($this->input->post('eqsl')); + $qrz = $this->security->xss_clean($this->input->post('qrz')); $sat = $this->security->xss_clean($this->input->post('sat')); + $orbit = $this->security->xss_clean($this->input->post('orbit')); $this->load->model('gridmap_model'); $array_grid_2char = array(); @@ -70,7 +72,7 @@ class Gridmap extends CI_Controller { $grid_4char_confirmed = ""; $grid_6char_confirmed = ""; - $query = $this->gridmap_model->get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat); + $query = $this->gridmap_model->get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit); if ($query && $query->num_rows() > 0) { foreach ($query->result() as $row) { @@ -97,7 +99,7 @@ class Gridmap extends CI_Controller { } } - $query = $this->gridmap_model->get_band($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat); + $query = $this->gridmap_model->get_band($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit); if ($query && $query->num_rows() > 0) { foreach ($query->result() as $row) { @@ -124,7 +126,7 @@ class Gridmap extends CI_Controller { } } } - $query_vucc = $this->gridmap_model->get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat); + $query_vucc = $this->gridmap_model->get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit); if ($query_vucc && $query_vucc->num_rows() > 0) { foreach ($query_vucc->result() as $row) { @@ -149,7 +151,7 @@ class Gridmap extends CI_Controller { } // // Confirmed Squares - $query_vucc = $this->gridmap_model->get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat); + $query_vucc = $this->gridmap_model->get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit); if ($query_vucc && $query_vucc->num_rows() > 0) { foreach ($query_vucc->result() as $row) { diff --git a/application/language/english/gridsquares_lang.php b/application/language/english/gridsquares_lang.php index 07bc32c96..f75b472b2 100644 --- a/application/language/english/gridsquares_lang.php +++ b/application/language/english/gridsquares_lang.php @@ -20,6 +20,7 @@ $lang['gridsquares_show_qsos'] = "Show QSO's"; $lang['gridsquares_show_map'] = "Show Map"; $lang['gridsquares_band'] = 'Band'; $lang['gridsquares_mode'] = 'Mode'; +$lang['gridsquares_orbit'] = 'Orbit'; $lang['gridsquares_sat'] = 'Satellite'; $lang['gridsquares_confirmation'] = 'Confirmation'; diff --git a/application/models/Bands.php b/application/models/Bands.php index 3b932e756..6e25b2e49 100644 --- a/application/models/Bands.php +++ b/application/models/Bands.php @@ -179,18 +179,42 @@ class Bands extends CI_Model { $location_list = "'".implode("','",$logbooks_locations_array)."'"; - // get all worked sats from database - $sql = "SELECT distinct col_sat_name FROM ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ") and coalesce(col_sat_name, '') <> '' ORDER BY col_sat_name"; + // get all worked sats from database + $sql = "SELECT distinct col_sat_name FROM ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ") and coalesce(col_sat_name, '') <> '' ORDER BY col_sat_name"; - $data = $this->db->query($sql); + $data = $this->db->query($sql); - $worked_sats = array(); - foreach($data->result() as $row){ - array_push($worked_sats, $row->col_sat_name); - } + $worked_sats = array(); + foreach($data->result() as $row){ + array_push($worked_sats, $row->col_sat_name); + } - return $worked_sats; - } + return $worked_sats; + } + + function get_worked_orbits() { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + if (!$logbooks_locations_array) { + return array(); + } + + $location_list = "'".implode("','",$logbooks_locations_array)."'"; + + // get all worked orbit types from database + $sql = "SELECT DISTINCT satellite.orbit AS orbit FROM ".$this->config->item('table_name')." LEFT JOIN satellite ON COL_SAT_NAME = satellite.name WHERE station_id in (" . $location_list . ") AND COL_PROP_MODE = 'SAT' AND satellite.orbit IS NOT NULL ORDER BY orbit ASC"; + + $data = $this->db->query($sql); + + $worked_orbits = array(); + foreach($data->result() as $row){ + array_push($worked_orbits, $row->orbit); + } + + return $worked_orbits; + } function get_worked_bands_dok() { $CI =& get_instance(); diff --git a/application/models/Gridmap_model.php b/application/models/Gridmap_model.php index 98bd829c1..582f161b1 100644 --- a/application/models/Gridmap_model.php +++ b/application/models/Gridmap_model.php @@ -2,201 +2,222 @@ class Gridmap_model extends CI_Model { - function get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $logbooks_locations_array = NULL) { - if ($logbooks_locations_array == NULL) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } - - if (!$logbooks_locations_array) { - return null; - } + function get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit, $logbooks_locations_array = NULL) { + if ($logbooks_locations_array == NULL) { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + } + + if (!$logbooks_locations_array) { + return null; + } $location_list = "'".implode("','",$logbooks_locations_array)."'"; $sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as GRID_SQUARES, COL_BAND FROM ' .$this->config->item('table_name') + .' LEFT JOIN `satellite` on '.$this->config->item('table_name').'.COL_SAT_NAME = satellite.name' .' WHERE station_id in (' .$location_list.') AND COL_GRIDSQUARE != ""'; - if ($band != 'All') { - if ($band == 'SAT') { - $sql .= " and col_prop_mode ='" . $band . "'"; - if ($sat != 'All') { - $sql .= " and col_sat_name ='" . $sat . "'"; - } - } - else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and col_band ='" . $band . "'"; - } - } + if ($band != 'All') { + if ($band == 'SAT') { + $sql .= " and col_prop_mode ='" . $band . "'"; + if ($sat != 'All') { + $sql .= " and col_sat_name ='" . $sat . "'"; + } + } else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and col_band ='" . $band . "'"; + } + } - if ($mode != 'All') { + if ($mode != 'All') { $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; - } + } - $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl, $qrz); - - return $this->db->query($sql); - } - - function get_band($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $logbooks_locations_array = NULL) { - if ($logbooks_locations_array == NULL) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } - - if (!$logbooks_locations_array) { - return null; - } - - $location_list = "'".implode("','",$logbooks_locations_array)."'"; - - $sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as GRID_SQUARES, COL_BAND FROM ' - .$this->config->item('table_name') - .' WHERE station_id in (' - .$location_list.') AND COL_GRIDSQUARE != ""'; - - if ($band != 'All') { - if ($band == 'SAT') { - $sql .= " and col_prop_mode ='" . $band . "'"; - if ($sat != 'All') { - $sql .= " and col_sat_name ='" . $sat . "'"; - } - } - else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and col_band ='" . $band . "'"; - } - } - - if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; - } - - return $this->db->query($sql); - } - - function get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $logbooks_locations_array = NULL) { - if ($logbooks_locations_array == NULL) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } - - if (!$logbooks_locations_array) { - return null; - } - - $location_list = "'".implode("','",$logbooks_locations_array)."'"; - - $sql = 'SELECT distinct COL_VUCC_GRIDS, COL_BAND FROM ' - .$this->config->item('table_name') - .' WHERE station_id in (' - .$location_list.') AND COL_VUCC_GRIDS != ""'; - - if ($band != 'All') { - if ($band == 'SAT') { - $sql .= " and col_prop_mode ='" . $band . "'"; - if ($sat != 'All') { - $sql .= " and col_sat_name ='" . $sat . "'"; - } - } - else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and col_band ='" . $band . "'"; - } - } - - if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; - } - - return $this->db->query($sql); - } - - function get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $logbooks_locations_array = NULL) { - if ($logbooks_locations_array == NULL) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } - - if (!$logbooks_locations_array) { - return null; - } - - - $location_list = "'".implode("','",$logbooks_locations_array)."'"; - - $sql = 'SELECT distinct COL_VUCC_GRIDS, COL_BAND FROM ' - .$this->config->item('table_name') - .' WHERE station_id in (' - .$location_list.') AND COL_VUCC_GRIDS != ""'; - - if ($band != 'All') { - if ($band == 'SAT') { - $sql .= " and col_prop_mode ='" . $band . "'"; - if ($sat != 'All') { - $sql .= " and col_sat_name ='" . $sat . "'"; - } - } - else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and col_band ='" . $band . "'"; - } - } - - if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; - } + $sql .= $this->addOrbitToQuery($orbit); $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl, $qrz); return $this->db->query($sql); } - // Adds confirmation to query - function addQslToQuery($qsl, $lotw, $eqsl, $qrz) { - $sql = ''; - if ($lotw == "true") { - $sql .= " or col_lotw_qsl_rcvd = 'Y'"; - } + function get_band($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit, $logbooks_locations_array = NULL) { + if ($logbooks_locations_array == NULL) { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + } - if ($qsl == "true") { - $sql .= " or col_qsl_rcvd = 'Y'"; - } + if (!$logbooks_locations_array) { + return null; + } - if ($eqsl == "true") { - $sql .= " or col_eqsl_qsl_rcvd = 'Y'"; - } + $location_list = "'".implode("','",$logbooks_locations_array)."'"; - if ($qrz == "true") { - $sql .= " or col_qrzcom_qso_download_status = 'Y'"; - } - if ($sql != '') { - $sql=' and (1=0 '.$sql.')'; - } - if ($sql == '') { - $sql=' and 1=0'; - } - return $sql; - } + $sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as GRID_SQUARES, COL_BAND FROM ' + .$this->config->item('table_name') + .' LEFT JOIN `satellite` on '.$this->config->item('table_name').'.COL_SAT_NAME = satellite.name' + .' WHERE station_id in (' + .$location_list.') AND COL_GRIDSQUARE != ""'; + + if ($band != 'All') { + if ($band == 'SAT') { + $sql .= " and col_prop_mode ='" . $band . "'"; + if ($sat != 'All') { + $sql .= " and col_sat_name ='" . $sat . "'"; + } + } else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and col_band ='" . $band . "'"; + } + } + + if ($mode != 'All') { + $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + } + + $sql .= $this->addOrbitToQuery($orbit); + + return $this->db->query($sql); + } + + function get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit, $logbooks_locations_array = NULL) { + if ($logbooks_locations_array == NULL) { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + } + + if (!$logbooks_locations_array) { + return null; + } + + $location_list = "'".implode("','",$logbooks_locations_array)."'"; + + $sql = 'SELECT distinct COL_VUCC_GRIDS, COL_BAND FROM ' + .$this->config->item('table_name') + .' LEFT JOIN `satellite` on '.$this->config->item('table_name').'.COL_SAT_NAME = satellite.name' + .' WHERE station_id in (' + .$location_list.') AND COL_VUCC_GRIDS != ""'; + + if ($band != 'All') { + if ($band == 'SAT') { + $sql .= " and col_prop_mode ='" . $band . "'"; + if ($sat != 'All') { + $sql .= " and col_sat_name ='" . $sat . "'"; + } + } else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and col_band ='" . $band . "'"; + } + } + + if ($mode != 'All') { + $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + } + + $sql .= $this->addOrbitToQuery($orbit); + + return $this->db->query($sql); + } + + function get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit, $logbooks_locations_array = NULL) { + if ($logbooks_locations_array == NULL) { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + } + + if (!$logbooks_locations_array) { + return null; + } + + + $location_list = "'".implode("','",$logbooks_locations_array)."'"; + + $sql = 'SELECT distinct COL_VUCC_GRIDS, COL_BAND FROM ' + .$this->config->item('table_name') + .' LEFT JOIN `satellite` on '.$this->config->item('table_name').'.COL_SAT_NAME = satellite.name' + .' WHERE station_id in (' + .$location_list.') AND COL_VUCC_GRIDS != ""'; + + if ($band != 'All') { + if ($band == 'SAT') { + $sql .= " and col_prop_mode ='" . $band . "'"; + if ($sat != 'All') { + $sql .= " and col_sat_name ='" . $sat . "'"; + } + } else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and col_band ='" . $band . "'"; + } + } + + if ($mode != 'All') { + $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + } + + $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl, $qrz); + + $sql .= $this->addOrbitToQuery($orbit); + + return $this->db->query($sql); + } + + // Adds confirmation to query + function addQslToQuery($qsl, $lotw, $eqsl, $qrz) { + $sql = ''; + if ($lotw == "true") { + $sql .= " or col_lotw_qsl_rcvd = 'Y'"; + } + + if ($qsl == "true") { + $sql .= " or col_qsl_rcvd = 'Y'"; + } + + if ($eqsl == "true") { + $sql .= " or col_eqsl_qsl_rcvd = 'Y'"; + } + + if ($qrz == "true") { + $sql .= " or col_qrzcom_qso_download_status = 'Y'"; + } + + if ($sql != '') { + $sql=' and (1=0 '.$sql.')'; + } + + if ($sql == '') { + $sql=' and 1=0'; + } + + return $sql; + } + + // Adds confirmation to query + function addOrbitToQuery($orbit) { + $sql = ''; + if ($orbit != 'All') { + $sql .= ' AND satellite.orbit = \''.$orbit.'\''; + } + + return $sql; + } /* * Get's the worked modes from the log */ function get_worked_modes() { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - - if (!$logbooks_locations_array) { - return null; - } + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + if (!$logbooks_locations_array) { + return null; + } $location_list = "'".implode("','",$logbooks_locations_array)."'"; @@ -217,8 +238,7 @@ class Gridmap_model extends CI_Model { array_push($results, $row->COL_SUBMODE); } } - - asort($results); + asort($results); return $results; } diff --git a/application/views/gridmap/index.php b/application/views/gridmap/index.php index 5a6618656..9cd65849b 100644 --- a/application/views/gridmap/index.php +++ b/application/views/gridmap/index.php @@ -57,6 +57,15 @@ + +