Add orbit type to activated gridsquares

This commit is contained in:
phl0
2024-04-08 15:03:32 +02:00
parent 192397ef5f
commit d86474c2ce
5 changed files with 198 additions and 162 deletions

View File

@@ -6,11 +6,11 @@ class Activated_gridmap extends CI_Controller {
parent::__construct();
}
public function index() {
public function index() {
$data['page_title'] = "Activated Gridsquare Map";
$this->load->model('bands');
$this->load->model('activated_gridmap_model');
$this->load->model('bands');
$this->load->model('activated_gridmap_model');
$this->load->model('stations');
$data['visitor'] = false;
@@ -18,6 +18,7 @@ class Activated_gridmap extends CI_Controller {
$data['modes'] = $this->activated_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');
@@ -32,7 +33,7 @@ class Activated_gridmap extends CI_Controller {
$data['gridsquares_gridsquares_not_confirmed'] = lang('gridsquares_gridsquares_not_confirmed');
$data['gridsquares_gridsquares_total_activated'] = lang('gridsquares_gridsquares_total_activated');
$footerData = [];
$footerData = [];
$footerData['scripts'] = [
'assets/js/leaflet/geocoding.js',
'assets/js/leaflet/L.MaidenheadColouredGridMap.js',
@@ -45,13 +46,14 @@ class Activated_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('activated_gridmap_model');
$array_grid_2char = array();
@@ -70,7 +72,7 @@ class Activated_gridmap extends CI_Controller {
$grid_4char_confirmed = "";
$grid_6char_confirmed = "";
$query = $this->activated_gridmap_model->get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat);
$query = $this->activated_gridmap_model->get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit);
if ($query && $query->num_rows() > 0) {
foreach ($query->result() as $row) {
@@ -100,7 +102,7 @@ class Activated_gridmap extends CI_Controller {
}
}
$query = $this->activated_gridmap_model->get_band($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat);
$query = $this->activated_gridmap_model->get_band($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit);
if ($query && $query->num_rows() > 0) {
foreach ($query->result() as $row) {
@@ -130,7 +132,7 @@ class Activated_gridmap extends CI_Controller {
}
}
}
$query_vucc = $this->activated_gridmap_model->get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat);
$query_vucc = $this->activated_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) {
@@ -155,7 +157,7 @@ class Activated_gridmap extends CI_Controller {
}
// // Confirmed Squares
$query_vucc = $this->activated_gridmap_model->get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat);
$query_vucc = $this->activated_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) {
@@ -179,7 +181,7 @@ class Activated_gridmap extends CI_Controller {
}
}
$data['grid_2char_confirmed'] = ($array_grid_2char_confirmed);
$data['grid_2char_confirmed'] = ($array_grid_2char_confirmed);
$data['grid_4char_confirmed'] = ($array_grid_4char_confirmed);
$data['grid_6char_confirmed'] = ($array_grid_6char_confirmed);
@@ -187,7 +189,7 @@ class Activated_gridmap extends CI_Controller {
$data['grid_4char'] = ($array_grid_4char);
$data['grid_6char'] = ($array_grid_6char);
header('Content-Type: application/json');
echo json_encode($data);
}
header('Content-Type: application/json');
echo json_encode($data);
}
}

View File

@@ -2,191 +2,208 @@
class Activated_gridmap_model extends CI_Model {
function get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
function get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit) {
$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;
}
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = 'SELECT DISTINCT station_gridsquare AS GRID_SQUARES, COL_BAND FROM '
. 'station_profile JOIN '.$this->config->item('table_name').' on '.$this->config->item('table_name').'.station_id = station_profile.station_id '
. 'WHERE station_profile.station_gridsquare != "" '
. 'AND station_profile.station_id in ('.$location_list.')';
$sql = 'SELECT DISTINCT station_gridsquare AS GRID_SQUARES, COL_BAND FROM '
. 'station_profile JOIN '.$this->config->item('table_name').' on '.$this->config->item('table_name').'.station_id = station_profile.station_id '
.' LEFT JOIN `satellite` on '.$this->config->item('table_name').'.COL_SAT_NAME = satellite.name '
. 'WHERE station_profile.station_gridsquare != "" '
. 'AND station_profile.station_id in ('.$location_list.')';
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);
$sql .= $this->addOrbitToQuery($orbit);
$sql .= $this->addQslToQuery($qsl, $lotw, $eqsl, $qrz);
return $this->db->query($sql);
}
function get_band($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
function get_band($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit) {
$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;
}
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = 'SELECT DISTINCT station_gridsquare AS GRID_SQUARES, COL_BAND FROM '
. 'station_profile JOIN '.$this->config->item('table_name').' on '.$this->config->item('table_name').'.station_id = station_profile.station_id '
. 'WHERE station_profile.station_gridsquare != "" '
. 'AND station_profile.station_id in ('.$location_list.')';
$sql = 'SELECT DISTINCT station_gridsquare AS GRID_SQUARES, COL_BAND FROM '
. 'station_profile JOIN '.$this->config->item('table_name').' on '.$this->config->item('table_name').'.station_id = station_profile.station_id '
.' LEFT JOIN `satellite` on '.$this->config->item('table_name').'.COL_SAT_NAME = satellite.name '
. 'WHERE station_profile.station_gridsquare != "" '
. 'AND station_profile.station_id in ('.$location_list.')';
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 . "')";
}
}
return $this->db->query($sql);
}
$sql .= $this->addOrbitToQuery($orbit);
function get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
return $this->db->query($sql);
}
if (!$logbooks_locations_array) {
return null;
}
function get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$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 null;
return $this->db->query($sql);
}
function get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat) {
$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;
}
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') {
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 null;
return $this->db->query($sql);
}
function get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit) {
$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);
$sql .= $this->addQslToQuery($qsl, $lotw, $eqsl, $qrz);
return null;
return null;
return $this->db->query($sql);
}
// Adds confirmation to query
function addQslToQuery($qsl, $lotw, $eqsl, $qrz) {
$sql = '';
if ($lotw == "true") {
$sql .= " or col_lotw_qsl_sent = 'Y'";
}
function addQslToQuery($qsl, $lotw, $eqsl, $qrz) {
$sql = '';
if ($lotw == "true") {
$sql .= " or col_lotw_qsl_sent = 'Y'";
}
if ($qsl == "true") {
$sql .= " or col_qsl_sent = 'Y'";
}
if ($qsl == "true") {
$sql .= " or col_qsl_sent = 'Y'";
}
if ($eqsl == "true") {
$sql .= " or col_eqsl_qsl_sent = 'Y'";
}
if ($eqsl == "true") {
$sql .= " or col_eqsl_qsl_sent = 'Y'";
}
if ($qrz == "true") {
$sql .= " or col_qrzcom_qso_upload_status = 'Y'";
}
if ($sql != '') {
$sql='and (1=0 '.$sql.')';
}
return $sql;
}
if ($qrz == "true") {
$sql .= " or col_qrzcom_qso_upload_status = 'Y'";
}
if ($sql != '') {
$sql='and (1=0 '.$sql.')';
}
return $sql;
}
// Adds orbit type to query
function addOrbitToQuery($orbit) {
$sql = '';
if ($orbit != 'All') {
$sql .= ' AND satellite.orbit = \''.$orbit.'\'';
}
/*
* Get's the worked modes from the log
*/
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)."'";
@@ -208,7 +225,7 @@ class Activated_gridmap_model extends CI_Model {
}
}
asort($results);
asort($results);
return $results;
}

View File

@@ -197,7 +197,7 @@ class Gridmap_model extends CI_Model {
return $sql;
}
// Adds confirmation to query
// Adds orbit type to query
function addOrbitToQuery($orbit) {
$sql = '';
if ($orbit != 'All') {

View File

@@ -412,6 +412,14 @@ class Logbook_model extends CI_Model {
case 'VUCC':
if ($searchmode == 'activated') {
$this->db->where("station_gridsquare like '%" . $searchphrase . "%'");
if ($band == 'SAT' && $type == 'VUCC') {
if ($sat != 'All' && $sat != null) {
$this->db->where("COL_SAT_NAME = '$sat'");
}
if ($orbit != 'All' && $orbit != null) {
$this->db->where("satellite.orbit = '$orbit'");
}
}
} else {
$this->db->where("(COL_GRIDSQUARE like '" . $searchphrase . "%' OR COL_VUCC_GRIDS like '%" . $searchphrase ."%')");
if ($band == 'SAT' && $type == 'VUCC') {

View File

@@ -27,6 +27,15 @@
<?php } else { ?>
<input id="sats" type="hidden" value="All"></input>
<?php } ?>
<label class="my-1 me-2" id="orbitslabel" for="orbits" <?php if ($user_default_band != "SAT") { ?>style="display: none;"<?php } ?>><?php echo lang('gridsquares_orbit'); ?></label>
<select class="form-select my-1 me-sm-2 w-auto" id="orbits" <?php if ($user_default_band != "SAT") { ?>style="display: none;"<?php } ?>>
<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>