diff --git a/application/controllers/Gridsquares.php b/application/controllers/Gridsquares.php index dee4d7f1..da2ac878 100644 --- a/application/controllers/Gridsquares.php +++ b/application/controllers/Gridsquares.php @@ -35,9 +35,43 @@ class Gridsquares extends CI_Controller { $array_grid_2char = array(); $array_grid_4char = array(); + + $array_confirmed_grid_2char = array(); + $array_confirmed_grid_4char = array(); + $grid_2char = ""; $grid_4char = ""; + $grid_2char_confirmed = ""; + $grid_4char_confirmed = ""; + + + // Get Confirmed LOTW & Paper Squares (non VUCC) + $query = $this->gridsquares_model->get_confirmed_sat_squares(); + + if ($query->num_rows() > 0) + { + foreach ($query->result() as $row) + { + + $grid_2char_confirmed = strtoupper(substr($row->SAT_SQUARE,0,2)); + $grid_4char_confirmed = strtoupper(substr($row->SAT_SQUARE,0,4)); + + // Check if 2 Char is in array + if(!in_array($grid_2char_confirmed, $array_confirmed_grid_2char)){ + array_push($array_confirmed_grid_2char, $grid_2char_confirmed); + } + + + if(!in_array($grid_4char_confirmed, $array_confirmed_grid_4char)){ + array_push($array_confirmed_grid_4char, $grid_4char_confirmed); + } + + + } + } + + // Get worked squares $query = $this->gridsquares_model->get_worked_sat_squares(); if ($query->num_rows() > 0) @@ -88,6 +122,33 @@ class Gridsquares extends CI_Controller { } } + // Confirmed Squares + $query_vucc = $this->gridsquares_model->get_confirmed_sat_vucc_squares(); + + if ($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_confirmed_grid_2char)){ + array_push($array_confirmed_grid_2char, $grid_2char_confirmed); + } + + + if(!in_array($grid_2char_confirmed, $array_confirmed_grid_4char)){ + array_push($array_confirmed_grid_4char, $grid_2char_confirmed); + } + } + } + } + function js_str($s) { @@ -101,6 +162,9 @@ class Gridsquares extends CI_Controller { } + $data['grid_2char_confirmed'] = js_array($array_confirmed_grid_2char); + $data['grid_4char_confirmed'] = js_array($array_confirmed_grid_4char); + $data['grid_2char'] = js_array($array_grid_2char); $data['grid_4char'] = js_array($array_grid_4char); @@ -118,13 +182,38 @@ class Gridsquares extends CI_Controller { $data['page_title'] = "Gridsquare Map"; - $array_grid_2char = array(); $array_grid_4char = array(); + $array_grid_2char_confirmed = array(); + $array_grid_4char_confirmed = array(); + $grid_2char = ""; $grid_4char = ""; + $grid_2char_confirmed = ""; + $grid_4char_confirmed = ""; + + $query = $this->gridsquares_model->get_band_confirmed($band); + + if ($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)); + + // 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); + } + } + } + $query = $this->gridsquares_model->get_band($band); if ($query->num_rows() > 0) @@ -160,6 +249,8 @@ class Gridsquares extends CI_Controller { return '[' . implode(',', $temp) . ']'; } + $data['grid_2char_confirmed'] = js_array($array_grid_2char_confirmed); + $data['grid_4char_confirmed'] = js_array($array_grid_4char_confirmed); $data['grid_2char'] = js_array($array_grid_2char); $data['grid_4char'] = js_array($array_grid_4char); diff --git a/application/models/Gridsquares_model.php b/application/models/Gridsquares_model.php index abfa0415..285599f3 100644 --- a/application/models/Gridsquares_model.php +++ b/application/models/Gridsquares_model.php @@ -1,7 +1,7 @@ db->query('SELECT distinct substring(COL_GRIDSQUARE,1,4) as SAT_SQUARE, COL_SAT_NAME FROM '.$this->config->item('table_name').' WHERE COL_GRIDSQUARE != "" AND COL_SAT_NAME != ""'); } + + function get_confirmed_sat_squares() { + return $this->db->query('SELECT distinct substring(COL_GRIDSQUARE,1,4) as SAT_SQUARE, COL_SAT_NAME FROM '.$this->config->item('table_name').' WHERE COL_GRIDSQUARE != "" AND COL_SAT_NAME != "" AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")'); + } + + function get_confirmed_sat_vucc_squares() { + return $this->db->query('SELECT COL_VUCC_GRIDS, COL_SAT_NAME FROM '.$this->config->item('table_name').' WHERE COL_VUCC_GRIDS != "" AND COL_SAT_NAME != "" AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y") AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")'); + } + function get_worked_sat_vucc_squares() { $this->db->select('COL_PRIMARY_KEY, COL_VUCC_GRIDS, COL_SAT_NAME'); $this->db->where('COL_VUCC_GRIDS !=', ""); @@ -20,6 +29,23 @@ class Gridsquares_model extends CI_Model { } function get_band($band) { - return $this->db->query('SELECT distinct substring(COL_GRIDSQUARE,1,4) as GRID_SQUARES, COL_BAND FROM '.$this->config->item('table_name').' WHERE COL_GRIDSQUARE != "" AND COL_BAND = "'.$band.'"'); + return $this->db->query('SELECT distinct substring(COL_GRIDSQUARE,1,4) as GRID_SQUARES, COL_BAND FROM '.$this->config->item('table_name').' + WHERE COL_GRIDSQUARE != "" + AND COL_BAND = "'.$band.'" + AND COL_PROP_MODE != "SAT" + AND COL_PROP_MODE != "INTERNET" + AND COL_PROP_MODE != "ECH" + AND COL_PROP_MODE != "RPT" + '); + } + + function get_band_confirmed($band) { + return $this->db->query('SELECT distinct substring(COL_GRIDSQUARE,1,4) as GRID_SQUARES, COL_BAND FROM '.$this->config->item('table_name').' WHERE COL_GRIDSQUARE != "" AND COL_BAND = "'.$band.'" + AND COL_PROP_MODE != "SAT" + AND COL_PROP_MODE != "INTERNET" + AND COL_PROP_MODE != "ECH" + AND COL_PROP_MODE != "RPT" + AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y") + '); } } \ No newline at end of file diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 829e44ff..782c6e27 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -545,6 +545,9 @@ $(document).ready(function(){ var grid_two = ; var grid_four = ; + var grid_two_confirmed = ; + var grid_four_confirmed = ; + var maidenhead = L.maidenhead().addTo(map); diff --git a/assets/js/leaflet/L.MaidenheadColoured.js b/assets/js/leaflet/L.MaidenheadColoured.js index e440d15b..8ec183f9 100644 --- a/assets/js/leaflet/L.MaidenheadColoured.js +++ b/assets/js/leaflet/L.MaidenheadColoured.js @@ -57,8 +57,16 @@ L.Maidenhead = L.LayerGroup.extend({ for (var lon = left; lon < right; lon += (unit*2)) { for (var lat = bottom; lat < top; lat += unit) { var bounds = [[lat,lon],[lat+unit,lon+(unit*2)]]; + if(grid_two.includes(this._getLocator(lon,lat)) || grid_four.includes(this._getLocator(lon,lat))) { + + if(grid_two_confirmed.includes(this._getLocator(lon,lat)) || grid_four_confirmed.includes(this._getLocator(lon,lat))) { + + this.addLayer(L.rectangle(bounds, {color: 'rgb(144,238,144)', weight: 1, fillOpacity: 0.6, fill:true, interactive: false})); + } else { + this.addLayer(L.rectangle(bounds, {color: this.options.color, weight: 1, fillOpacity: 0.6, fill:true, interactive: false})); + } } else { this.addLayer(L.rectangle(bounds, {color: this.options.color, weight: 1, fill:false, interactive: false})); }