diff --git a/application/controllers/Gridmap.php b/application/controllers/Gridmap.php index fc56ac3d..03ffe737 100644 --- a/application/controllers/Gridmap.php +++ b/application/controllers/Gridmap.php @@ -13,9 +13,8 @@ class Gridmap extends CI_Controller { $this->load->model('gridmap_model'); $data['modes'] = $this->gridmap_model->get_worked_modes(); - - - $data['bands'] = $this->bands->get_worked_bands(); + $data['bands'] = $this->bands->get_worked_bands(); + $data['sats_available'] = $this->bands->get_worked_sats(); $footerData = []; $footerData['scripts'] = [ @@ -28,151 +27,13 @@ class Gridmap extends CI_Controller { $this->load->view('interface_assets/footer', $footerData); } - public function getGrids() { - $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')); - $this->load->model('gridmap_model'); - - $array_grid_2char = array(); - $array_grid_4char = array(); - $array_grid_6char = array(); - - $array_grid_2char_confirmed = array(); - $array_grid_4char_confirmed = array(); - $array_grid_6char_confirmed = array(); - - $grid_2char = ""; - $grid_4char = ""; - $grid_6char = ""; - - $grid_2char_confirmed = ""; - $grid_4char_confirmed = ""; - $grid_6char_confirmed = ""; - - $query = $this->gridmap_model->get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl); - - if ($query && $query->num_rows() > 0) { - foreach ($query->result() as $row) { - $grid_2char_confirmed = strtoupper(substr($row->GRID_SQUARES,0,2)); - $grid_4char_confirmed = strtoupper(substr($row->GRID_SQUARES,0,4)); - if ($this->config->item('map_6digit_grids')) { - $grid_6char_confirmed = strtoupper(substr($row->GRID_SQUARES,0,6)); - } - - // Check if 2 Char is in array - if(!in_array($grid_2char_confirmed, $array_grid_2char_confirmed)){ - array_push($array_grid_2char_confirmed, $grid_2char_confirmed); - } - - if(!in_array($grid_4char_confirmed, $array_grid_4char_confirmed)){ - array_push($array_grid_4char_confirmed, $grid_4char_confirmed); - } - - if ($this->config->item('map_6digit_grids')) { - if(!in_array($grid_6char_confirmed, $array_grid_6char_confirmed)){ - array_push($array_grid_6char_confirmed, $grid_6char_confirmed); - } - } - } - } - - $query = $this->gridmap_model->get_band($band, $mode, $qsl, $lotw, $eqsl); - - if ($query && $query->num_rows() > 0) { - foreach ($query->result() as $row) { - - $grid_two = strtoupper(substr($row->GRID_SQUARES,0,2)); - $grid_four = strtoupper(substr($row->GRID_SQUARES,0,4)); - if ($this->config->item('map_6digit_grids')) { - $grid_six = strtoupper(substr($row->GRID_SQUARES,0,6)); - } - - // Check if 2 Char is in array - if(!in_array($grid_two, $array_grid_2char)){ - array_push($array_grid_2char, $grid_two); - } - - if(!in_array($grid_four, $array_grid_4char)){ - array_push($array_grid_4char, $grid_four); - } - - if ($this->config->item('map_6digit_grids')) { - if(!in_array($grid_six, $array_grid_6char)){ - array_push($array_grid_6char, $grid_six); - } - } - } - } - $query_vucc = $this->gridmap_model->get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl); - - if ($query && $query_vucc->num_rows() > 0) { - foreach ($query_vucc->result() as $row) { - - $grids = explode(",", $row->COL_VUCC_GRIDS); - - foreach($grids as $key) { - $grid_two = strtoupper(substr($key,0,2)); - $grid_four = strtoupper(substr($key,0,4)); - - // Check if 2 Char is in array - if(!in_array($grid_two, $array_grid_2char)){ - array_push($array_grid_2char, $grid_two); - } - - - if(!in_array($grid_four, $array_grid_4char)){ - array_push($array_grid_4char, $grid_four); - } - } - } - } - - // Confirmed Squares - $query_vucc = $this->gridmap_model->get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl); - - if ($query && $query_vucc->num_rows() > 0) { - foreach ($query_vucc->result() as $row) { - - $grids = explode(",", $row->COL_VUCC_GRIDS); - - foreach($grids as $key) { - $grid_2char_confirmed = strtoupper(substr($key,0,2)); - $grid_4char_confirmed = strtoupper(substr($key,0,4)); - - // Check if 2 Char is in array - if(!in_array($grid_2char_confirmed, $array_grid_2char_confirmed)){ - array_push($array_grid_2char_confirmed, $grid_2char_confirmed); - } - - - if(!in_array($grid_4char_confirmed, $array_grid_4char_confirmed)){ - array_push($array_grid_4char_confirmed, $grid_4char_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); - - $data['grid_2char'] = ($array_grid_2char); - $data['grid_4char'] = ($array_grid_4char); - $data['grid_6char'] = ($array_grid_6char); - - header('Content-Type: application/json'); - echo json_encode($data); - } - 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')); + $sat = $this->security->xss_clean($this->input->post('sat')); $this->load->model('gridmap_model'); $array_grid_2char = array(); @@ -191,7 +52,7 @@ class Gridmap extends CI_Controller { $grid_4char_confirmed = ""; $grid_6char_confirmed = ""; - $query = $this->gridmap_model->get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl); + $query = $this->gridmap_model->get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $sat); if ($query && $query->num_rows() > 0) { foreach ($query->result() as $row) { @@ -218,7 +79,7 @@ class Gridmap extends CI_Controller { } } - $query = $this->gridmap_model->get_band($band, $mode, $qsl, $lotw, $eqsl); + $query = $this->gridmap_model->get_band($band, $mode, $qsl, $lotw, $eqsl, $sat); if ($query && $query->num_rows() > 0) { foreach ($query->result() as $row) { @@ -245,7 +106,7 @@ class Gridmap extends CI_Controller { } } } - $query_vucc = $this->gridmap_model->get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl); + $query_vucc = $this->gridmap_model->get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $sat); if ($query_vucc && $query_vucc->num_rows() > 0) { foreach ($query_vucc->result() as $row) { @@ -270,7 +131,7 @@ class Gridmap extends CI_Controller { } // // Confirmed Squares - $query_vucc = $this->gridmap_model->get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl); + $query_vucc = $this->gridmap_model->get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $sat); if ($query_vucc && $query_vucc->num_rows() > 0) { foreach ($query_vucc->result() as $row) { diff --git a/application/models/Gridmap_model.php b/application/models/Gridmap_model.php index a34cfeb2..fd44b0bd 100644 --- a/application/models/Gridmap_model.php +++ b/application/models/Gridmap_model.php @@ -2,7 +2,7 @@ class Gridmap_model extends CI_Model { - function get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl) { + function get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $sat) { $CI =& get_instance(); $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -21,6 +21,9 @@ class Gridmap_model extends CI_Model { 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'"; @@ -37,7 +40,7 @@ class Gridmap_model extends CI_Model { return $this->db->query($sql); } - function get_band($band, $mode, $qsl, $lotw, $eqsl) { + function get_band($band, $mode, $qsl, $lotw, $eqsl, $sat) { $CI =& get_instance(); $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -56,6 +59,9 @@ class Gridmap_model extends CI_Model { 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'"; @@ -70,7 +76,7 @@ class Gridmap_model extends CI_Model { return $this->db->query($sql); } - function get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl) { + function get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $sat) { $CI =& get_instance(); $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -89,6 +95,9 @@ class Gridmap_model extends CI_Model { 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'"; @@ -103,7 +112,7 @@ class Gridmap_model extends CI_Model { return $this->db->query($sql); } - function get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl) { + function get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $sat) { $CI =& get_instance(); $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -119,9 +128,12 @@ class Gridmap_model extends CI_Model { .' WHERE station_id in (' .$location_list.') AND COL_VUCC_GRIDS != ""'; - if ($band != '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'"; diff --git a/application/views/gridmap/index.php b/application/views/gridmap/index.php index 534680ea..2a66f47c 100644 --- a/application/views/gridmap/index.php +++ b/application/views/gridmap/index.php @@ -40,16 +40,27 @@ echo ''."\n"; } ?> + + + + + +
diff --git a/assets/js/sections/gridmap.js b/assets/js/sections/gridmap.js index 74986cb9..f37779bb 100644 --- a/assets/js/sections/gridmap.js +++ b/assets/js/sections/gridmap.js @@ -1,3 +1,12 @@ +$('#band').change(function(){ + var band = $("#band option:selected").text(); + if (band != "SAT") { + $("#sats").prop('disabled', true); + } else { + $("#sats").prop('disabled', false); + } +}); + var map; var grid_two = ''; var grid_four = ''; @@ -25,7 +34,8 @@ function gridPlot(form) { mode: $("#mode").val(), qsl: $("#qsl").is(":checked"), lotw: $("#lotw").is(":checked"), - eqsl: $("#eqsl").is(":checked") + eqsl: $("#eqsl").is(":checked"), + sat: $("#sats").val(), }, success: function (data) { $('#plot').prop("disabled", false);