diff --git a/application/controllers/Gridsquares.php b/application/controllers/Gridsquares.php index f1b94ec3..f1596c96 100644 --- a/application/controllers/Gridsquares.php +++ b/application/controllers/Gridsquares.php @@ -261,5 +261,21 @@ class Gridsquares extends CI_Controller { $this->load->view('gridsquares/index.php'); $this->load->view('interface_assets/footer'); } + + function search_band($band, $gridsquare){ + $this->load->model('gridsquares_model'); + header('Content-Type: application/json'); + $result = $this->gridsquares_model->search_band($band, $gridsquare); + + echo $result; + } + + function search_sat($gridsquare){ + $this->load->model('gridsquares_model'); + header('Content-Type: application/json'); + $result = $this->gridsquares_model->search_sat($gridsquare); + + echo $result; + } } \ No newline at end of file diff --git a/application/models/Gridsquares_model.php b/application/models/Gridsquares_model.php index d845a4b9..4a63e5de 100644 --- a/application/models/Gridsquares_model.php +++ b/application/models/Gridsquares_model.php @@ -76,4 +76,34 @@ class Gridsquares_model extends CI_Model { AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y") '); } + + function search_band($band, $gridsquare) { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $result = $this->db->query('SELECT COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE FROM '.$this->config->item('table_name').' WHERE station_id = "'.$station_id.'" AND COL_GRIDSQUARE LIKE "%'.$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_SAT_NAME = "" + '); + + //print_r($result); + return json_encode($result->result()); + } + + function search_sat($gridsquare) { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $result = $this->db->query('SELECT COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_SAT_NAME FROM '.$this->config->item('table_name').' WHERE station_id = "'.$station_id.'" AND COL_GRIDSQUARE LIKE "%'.$gridsquare.'%" + AND COL_PROP_MODE = "SAT" + '); + + //print_r($result); + return json_encode($result->result()); + } } \ No newline at end of file diff --git a/application/views/gridsquares/index.php b/application/views/gridsquares/index.php index 8c1a0094..6c46884b 100644 --- a/application/views/gridsquares/index.php +++ b/application/views/gridsquares/index.php @@ -47,23 +47,16 @@ diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index c252efd2..f8b02d1e 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -889,7 +889,38 @@ $(document).ready(function(){ var loc_4char = locator.substring(0, 4); console.log(loc_4char); console.log(map.getZoom()); + if(map.getZoom() > 5) { + var search_type = "uri->segment(2); ?>"; + if(search_type == "satellites") { + console.log("satellites search"); + var search_tags = "search_sat/" + loc_4char; + } else { + var band = "uri->segment(3); ?>"; + console.log(band); + var search_tags = "search_band/" + band + "/" + loc_4char; + } + + $.getJSON( "" + search_tags, function( data ) { + var items = []; + $.each( data, function( i, item ) { + console.log(item.COL_CALL + item.COL_SAT_NAME); + if(item.COL_SAT_NAME != undefined) { + items.push( "" + item.COL_TIME_ON + "" + item.COL_CALL + "" + item.COL_MODE + "" + item.COL_SAT_NAME + "" ); + } else { + items.push( "" + item.COL_TIME_ON + "" + item.COL_CALL + "" + item.COL_MODE + "" + item.COL_BAND + "" ); + } + }); + + $( "", { + "class": "my-new-list", + html: items.join( "" ) + }).appendTo( "body" ); + + $("#grid_results tbody").append(items.join( "" )); + + }); + $('#square_number').text(loc_4char); $('#exampleModal').modal('show'); }