diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 8ec36d5be..a3e8d80cb 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -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; diff --git a/application/models/Wab.php b/application/models/Wab.php index c4b607462..0a917ddbd 100644 --- a/application/models/Wab.php +++ b/application/models/Wab.php @@ -1,14 +1,18 @@ 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; + } } diff --git a/application/views/awards/wab/index.php b/application/views/awards/wab/index.php index b04504b42..7114d9a19 100644 --- a/application/views/awards/wab/index.php +++ b/application/views/awards/wab/index.php @@ -97,7 +97,7 @@ - + diff --git a/assets/js/sections/wab.js b/assets/js/sections/wab.js index f8b5aaed1..a69c7d234 100644 --- a/assets/js/sections/wab.js +++ b/assets/js/sections/wab.js @@ -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;