Add option to filter map to orbit type

This commit is contained in:
phl0
2024-04-05 15:46:57 +02:00
parent ef8e6e02c2
commit 04a4b22b25
6 changed files with 249 additions and 192 deletions

View File

@@ -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) {

View File

@@ -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';

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -57,6 +57,15 @@
<?php } else { ?>
<input id="sats" type="hidden" value="All"></input>
<?php } ?>
<label class="my-1 me-2" for="orbits"><?php echo lang('gridsquares_orbit'); ?></label>
<select class="form-select my-1 me-sm-2 w-auto" id="orbits">
<option value="All"><?php echo lang('general_word_all')?></option>
<?php
foreach($orbits as $orbit){
echo '<option value="' . $orbit . '">' . strtoupper($orbit) . '</option>'."\n";
}
?>
</select>
<label class="my-1 me-2" for="mode"><?php echo lang('gridsquares_mode'); ?></label>
<select class="form-select my-1 me-sm-2 w-auto" id="mode">
<option value="All"><?php echo lang('general_word_all')?></option>

View File

@@ -53,6 +53,7 @@ function gridPlot(form, visitor=true) {
eqsl: $("#eqsl").is(":checked"),
qrz: $("#qrz").is(":checked"),
sat: $("#sats").val(),
orbit: $("#orbits").val(),
},
success: function (data) {
$('.cohidden').show();