Added filtering

This commit is contained in:
Andreas Kristiansen
2024-04-20 15:51:08 +02:00
parent 411bbeddcd
commit 39380ad5ce
4 changed files with 105 additions and 26 deletions

View File

@@ -1530,17 +1530,24 @@ class Awards extends CI_Controller {
}
public function wab_map() {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$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');
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$this->load->model('wab');
$bands[] = 'All';
if ($logbooks_locations_array) {
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$wab_array = $this->wab->get_wab_array($bands, $location_list);
$wab_array = $this->wab->get_wab_array($band, $location_list, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit);
} else {
$location_list = null;
$wab_array = null;

View File

@@ -1,14 +1,18 @@
<?php
class Wab extends CI_Model{
class Wab extends CI_Model {
function get_wab_array($band, $location_list) {
function __construct() {
$this->load->library('Genfunctions');
}
function get_wab_array($band, $location_list, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit) {
$worked = array();
$confirmed = array();
$worked = $this->getWabWorked($location_list, $band);
$worked = $this->getWabWorked($location_list, $band, $mode, $sat, $orbit);
$confirmed = $this->getWabConfirmed($location_list, $band);
$confirmed = $this->getWabConfirmed($location_list, $band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit);
$wabarray = array();
@@ -40,10 +44,24 @@ class Wab extends CI_Model{
* Function returns all worked, but not confirmed states
* $postdata contains data from the form, in this case Lotw or QSL are used
*/
function getWabWorked($location_list, $band) {
function getWabWorked($location_list, $band, $mode, $sat, $orbit) {
$sql = "SELECT distinct col_sig_info FROM " . $this->config->item('table_name') . " thcv
where station_id in (" . $location_list . ") and col_sig = 'WAB' and coalesce(col_sig_info, '') <> ''";
$sql .= $this->genfunctions->addBandToQuery($band);
if ($band == 'SAT') {
if ($sat != 'All') {
$sql .= " and col_sat_name ='" . $sat . "'";
}
}
if ($mode != 'All') {
$sql .= " and (col_mode = '" . $mode . "' or col_submode = '" . $mode . "')";
}
$sql .= $this->addOrbitToQuery($orbit);
$query = $this->db->query($sql);
return $query->result();
@@ -53,28 +71,68 @@ class Wab extends CI_Model{
* Function returns all confirmed states on given band and on LoTW or QSL
* $postdata contains data from the form, in this case Lotw or QSL are used
*/
function getWabConfirmed($location_list, $bands) {
function getWabConfirmed($location_list, $band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit) {
$sql = "SELECT distinct col_sig_info FROM " . $this->config->item('table_name') . " thcv
where station_id in (" . $location_list . ") and col_sig = 'WAB' and coalesce(col_sig_info, '') <> ''";
$sql .= $this->addQslToQuery();
$sql .= $this->genfunctions->addBandToQuery($band);
if ($band == 'SAT') {
if ($sat != 'All') {
$sql .= " and col_sat_name ='" . $sat . "'";
}
}
if ($mode != 'All') {
$sql .= " and (col_mode = '" . $mode . "' or col_submode = '" . $mode . "')";
}
$sql .= $this->addOrbitToQuery($orbit);
$sql .= $this->addQslToQuery($qsl, $lotw, $eqsl, $qrz);
$query = $this->db->query($sql);
return $query->result();
}
function addQslToQuery() {
$sql = 'and (';
$qsl = array();
array_push($qsl, "col_qsl_rcvd = 'Y'");
array_push($qsl, "col_lotw_qsl_rcvd = 'Y'");
//array_push($qsl, "col_eqsl_qsl_rcvd = 'Y'");
$sql .= implode(' or ', $qsl);
$sql .= ')';
return $sql;
}
function addQslToQuery($qsl, $lotw, $eqsl, $qrz) {
$sql = '';
$qslarray = array();
if ($qrz != NULL || $lotw != NULL || $qsl != NULL || $eqsl != NULL) {
$sql .= ' and (';
if ($qsl != NULL) {
array_push($qslarray, "col_qsl_rcvd = 'Y'");
}
if ($lotw != NULL) {
array_push($qslarray, "col_lotw_qsl_rcvd = 'Y'");
}
if ($eqsl != NULL) {
array_push($qslarray, "col_eqsl_qsl_rcvd = 'Y'");
}
if ($qrz != NULL) {
array_push($qslarray, "COL_QRZCOM_QSO_DOWNLOAD_STATUS = 'Y'");
}
if (count($qslarray) > 0) {
$sql .= implode(' or ', $qslarray);
} else {
$sql .= '1=0';
}
$sql .= ')';
} else {
$sql.=' and 1=0';
}
return $sql;
}
// Adds orbit type to query
function addOrbitToQuery($orbit) {
$sql = '';
if ($orbit != 'All') {
$sql .= ' AND satellite.orbit = \''.$orbit.'\'';
}
return $sql;
}
}

View File

@@ -97,7 +97,7 @@
</div>
</div>
<button id="plot" type="button" name="plot" class="btn btn-primary me-1 ld-ext-right ld-ext-right-plot" onclick="gridPlot(this.form)"><?php echo lang('gridsquares_button_plot'); ?><div class="ld ld-ring ld-spin"></div></button>
<button id="plot" type="button" name="plot" class="btn btn-primary me-1 ld-ext-right ld-ext-right-plot" onclick="plotmap()"><?php echo lang('gridsquares_button_plot'); ?><div class="ld ld-ring ld-spin"></div></button>
</form>
</div>

View File

@@ -7,11 +7,22 @@ var wab_squares = $.ajax({
}
})
$.when(wab_squares).done(function() {
function plotmap() {
$(".ld-ext-right-plot").addClass('running');
$(".ld-ext-right-plot").prop('disabled', true);
$('#plot').prop("disabled", true);
$.ajax({
url: site_url + '/awards/wab_map',
type: 'post',
data: {
band: $("#band").val(),
mode: $("#mode").val(),
qsl: $("#qsl").is(":checked"),
lotw: $("#lotw").is(":checked"),
eqsl: $("#eqsl").is(":checked"),
qrz: $("#qrz").is(":checked"),
sat: $("#sats").val(),
orbit: $("#orbits").val(),
},
success: function (data) {
wabmap(data);
@@ -19,9 +30,12 @@ $.when(wab_squares).done(function() {
error: function (data) {
},
})
})
}
function wabmap(data) {
$(".ld-ext-right-plot").removeClass('running');
$(".ld-ext-right-plot").prop('disabled', false);
$('#plot').prop("disabled", false);
var map = L.map('wabmap').setView([51.5074, -0.1278], 9);
var confirmedcount = 0;
var workedcount = 0;