diff --git a/application/controllers/Gridsquares.php b/application/controllers/Gridsquares.php deleted file mode 100644 index 477e78a1..00000000 --- a/application/controllers/Gridsquares.php +++ /dev/null @@ -1,403 +0,0 @@ -lang->load(array( - 'gridsquares', - )); - } - - - public function index() { - // if there are no satellite QSOs redirect to band selection directly - $this->load->model('logbook_model'); - $this->load->model('bands'); - $total_sat = $this->logbook_model->total_sat(); - if ($total_sat->num_rows() == 0) { - redirect('gridsquares/band/2m'); - return; - } - - $data['page_title'] = "Gridsquare Map"; - $data['sat_active'] = array_search("SAT", $this->bands->get_user_bands(), true); - - $this->load->view('interface_assets/header', $data); - $this->load->view('gridsquares/main.php'); - $this->load->view('interface_assets/footer'); - } - - public function satellites() - { - $this->load->model('gridsquares_model'); - - $data['page_title'] = "Satellite Gridsquare Map"; - - - $array_grid_2char = array(); - $array_grid_4char = array(); - $array_grid_6char = array(); - - - $array_confirmed_grid_2char = array(); - $array_confirmed_grid_4char = array(); - $array_confirmed_grid_6char = array(); - - $grid_2char = ""; - $grid_4char = ""; - $grid_6char = ""; - - $grid_2char_confirmed = ""; - $grid_4char_confirmed = ""; - $grid_6char_confirmed = ""; - - - // Get Confirmed LoTW & Paper Squares (non VUCC) - $query = $this->gridsquares_model->get_confirmed_sat_squares(); - - - if ($query && $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)); - if ($this->config->item('map_6digit_grids')) { - $grid_6char_confirmed = strtoupper(substr($row->SAT_SQUARE,0,6)); - } - - // 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); - } - - - if ($this->config->item('map_6digit_grids')) { - if(!in_array($grid_6char_confirmed, $array_confirmed_grid_6char)){ - array_push($array_confirmed_grid_6char, $grid_6char_confirmed); - } - } - - - } - } - - // Get worked squares - $query = $this->gridsquares_model->get_worked_sat_squares(); - - if ($query && $query->num_rows() > 0) - { - foreach ($query->result() as $row) - { - - $grid_two = strtoupper(substr($row->SAT_SQUARE,0,2)); - $grid_four = strtoupper(substr($row->SAT_SQUARE,0,4)); - if ($this->config->item('map_6digit_grids')) { - $grid_six = strtoupper(substr($row->SAT_SQUARE,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->gridsquares_model->get_worked_sat_vucc_squares(); - - 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->gridsquares_model->get_confirmed_sat_vucc_squares(); - - 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_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); - } - } - } - } - - - function js_str($s) - { - return '"' . addcslashes($s, "\0..\37\"\\") . '"'; - } - - function js_array($array) - { - $temp = array_map('js_str', $array); - return '[' . implode(',', $temp) . ']'; - } - - - $data['grid_2char_confirmed'] = js_array($array_confirmed_grid_2char); - $data['grid_4char_confirmed'] = js_array($array_confirmed_grid_4char); - $data['grid_6char_confirmed'] = js_array($array_confirmed_grid_6char); - - $data['grid_2char'] = js_array($array_grid_2char); - $data['grid_4char'] = js_array($array_grid_4char); - $data['grid_6char'] = js_array($array_grid_6char); - - - $this->load->view('interface_assets/header', $data); - $this->load->view('gridsquares/index.php'); - $this->load->view('interface_assets/footer'); - } - - - public function band($band) - { - $this->load->model('gridsquares_model'); - - $data['page_title'] = strtoupper($band)." Gridsquare Map"; - - $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->gridsquares_model->get_band_confirmed($band); - - 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->gridsquares_model->get_band($band); - - 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->gridsquares_model->get_band_worked_vucc_squares($band); - - 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->gridsquares_model->get_band_confirmed_vucc_squares($band); - - 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); - } - } - } - } - - function js_str($s) - { - return '"' . addcslashes($s, "\0..\37\"\\") . '"'; - } - - function js_array($array) - { - $temp = array_map('js_str', $array); - 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_6char_confirmed'] = js_array($array_grid_6char_confirmed); - - $data['grid_2char'] = js_array($array_grid_2char); - $data['grid_4char'] = js_array($array_grid_4char); - $data['grid_6char'] = js_array($array_grid_6char); - - $this->load->model('bands'); - $data['bands_available'] = js_array($this->bands->get_worked_bands()); - - $this->load->view('interface_assets/header', $data); - $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; - } - -} diff --git a/application/models/Gridsquares_model.php b/application/models/Gridsquares_model.php deleted file mode 100644 index 430be3ed..00000000 --- a/application/models/Gridsquares_model.php +++ /dev/null @@ -1,265 +0,0 @@ -load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } else { - $logbooks_locations_array = $StationLocationsArray; - } - - $this->db->select('distinct substring(COL_GRIDSQUARE,1,6) as SAT_SQUARE, COL_SAT_NAME', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_GRIDSQUARE !=', ''); - $this->db->where('COL_SAT_NAME !=', ''); - - return $this->db->get($this->config->item('table_name')); - } - - function get_confirmed_sat_squares($StationLocationsArray = null) { - if($StationLocationsArray == null) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } else { - $logbooks_locations_array = $StationLocationsArray; - } - - if (!$logbooks_locations_array) { - return null; - } - - $location_list = "'".implode("','",$logbooks_locations_array)."'"; - - $sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as SAT_SQUARE, COL_SAT_NAME FROM ' - . $this->config->item('table_name') - . ' WHERE station_id in (' . $location_list . ') AND COL_GRIDSQUARE != "" AND COL_SAT_NAME != "" AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")'; - - return $this->db->query($sql); - } - - - function get_confirmed_sat_vucc_squares($StationLocationsArray = null) { - if($StationLocationsArray == null) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } else { - $logbooks_locations_array = $StationLocationsArray; - } - - if (!$logbooks_locations_array) { - return null; - } - - $location_list = "'".implode("','",$logbooks_locations_array)."'"; - - $sql = 'SELECT COL_VUCC_GRIDS, COL_SAT_NAME FROM ' - . $this->config->item('table_name') - . ' WHERE station_id in (' . $location_list . ') AND 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")'; - - return $this->db->query($sql); - } - - function get_worked_sat_vucc_squares($StationLocationsArray = null) { - if($StationLocationsArray == null) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } else { - $logbooks_locations_array = $StationLocationsArray; - } - - if (!$logbooks_locations_array) { - return null; - } - - $this->db->select('COL_PRIMARY_KEY, COL_VUCC_GRIDS, COL_SAT_NAME', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_VUCC_GRIDS !=', ""); - $this->db->where('COL_SAT_NAME !=', ""); - return $this->db->get($this->config->item('table_name')); - } - - function get_band($band, $StationLocationsArray = null) { - if($StationLocationsArray == null) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } else { - $logbooks_locations_array = $StationLocationsArray; - } - - if (!$logbooks_locations_array) { - return null; - } - - $this->db->select('distinct substring(COL_GRIDSQUARE,1,6) as GRID_SQUARES, COL_BAND', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_GRIDSQUARE !=', ''); - - if ($band != 'All') { - $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=', "SAT"); - $this->db->where('COL_PROP_MODE !=', "INTERNET"); - $this->db->where('COL_PROP_MODE !=', "ECH"); - $this->db->where('COL_PROP_MODE !=', "RPT"); - $this->db->where('COL_SAT_NAME =', ""); - } - - return $this->db->get($this->config->item('table_name')); - } - - function get_band_confirmed($band, $StationLocationsArray = null) { - if($StationLocationsArray == null) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } else { - $logbooks_locations_array = $StationLocationsArray; - } - - if (!$logbooks_locations_array) { - return null; - } - - $location_list = "'".implode("','",$logbooks_locations_array)."'"; - - $sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as GRID_SQUARES, COL_BAND FROM ' - .$this->config->item('table_name') - .' WHERE station_id in (' - .$location_list.') AND COL_GRIDSQUARE != ""'; - if ($band != 'All') { - $sql .= ' 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 = ""'; - } - - $sql .= ' AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")'; - - return $this->db->query($sql); - } - - function get_band_worked_vucc_squares($band, $StationLocationsArray = null) { - if($StationLocationsArray == null) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } else { - $logbooks_locations_array = $StationLocationsArray; - } - - if (!$logbooks_locations_array) { - return null; - } - - $this->db->select('distinct COL_VUCC_GRIDS, COL_BAND', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_VUCC_GRIDS !=', ''); - - if ($band != 'All') { - $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=', "SAT"); - $this->db->where('COL_PROP_MODE !=', "INTERNET"); - $this->db->where('COL_PROP_MODE !=', "ECH"); - $this->db->where('COL_PROP_MODE !=', "RPT"); - $this->db->where('COL_SAT_NAME =', ""); - } - - return $this->db->get($this->config->item('table_name')); - } - - function get_band_confirmed_vucc_squares($band, $StationLocationsArray = null) { - if($StationLocationsArray == null) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } else { - $logbooks_locations_array = $StationLocationsArray; - } - - if (!$logbooks_locations_array) { - return null; - } - - $location_list = "'".implode("','",$logbooks_locations_array)."'"; - - $sql = 'SELECT distinct COL_VUCC_GRIDS, COL_BAND FROM ' - .$this->config->item('table_name') - .' WHERE station_id in (' - .$location_list.') AND COL_VUCC_GRIDS != ""'; - if ($band != 'All') { - $sql .= ' 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 = ""'; - } - - $sql .= ' AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")'; - - return $this->db->query($sql); - } - - function search_band($band, $gridsquare, $StationLocationsArray = null) { - if($StationLocationsArray == null) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } else { - $logbooks_locations_array = $StationLocationsArray; - } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; - - $sql = 'SELECT COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_GRIDSQUARE, COL_VUCC_GRIDS FROM ' - .$this->config->item('table_name') - .' WHERE station_id IN (' . $location_list . ') ' - . ' AND (COL_GRIDSQUARE LIKE "%'.$gridsquare.'%" or COL_VUCC_GRIDS LIKE "%'.$gridsquare.'%")'; - - if ($band != 'All') { - $sql .= ' 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 = ""'; - } - - $result = $this->db->query($sql); - - //print_r($result); - return json_encode($result->result()); - } - - function search_sat($gridsquare, $StationLocationsArray = null) { - if($StationLocationsArray == null) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - } else { - $logbooks_locations_array = $StationLocationsArray; - } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; - - $sql = 'SELECT COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_SAT_NAME, COL_GRIDSQUARE, COL_VUCC_GRIDS FROM ' . - $this->config->item('table_name'). - ' WHERE station_id IN ('.$location_list. ')' . - ' AND (COL_GRIDSQUARE LIKE "%'.$gridsquare.'%" or COL_VUCC_GRIDS LIKE "%'.$gridsquare.'%")'. - ' AND COL_PROP_MODE = "SAT"'; - - $result = $this->db->query($sql); - - //print_r($result); - return json_encode($result->result()); - } -} diff --git a/application/views/gridsquares/index.php b/application/views/gridsquares/index.php deleted file mode 100644 index 241e4838..00000000 --- a/application/views/gridsquares/index.php +++ /dev/null @@ -1,69 +0,0 @@ -