diff --git a/application/controllers/Gridsquares.php b/application/controllers/Gridsquares.php new file mode 100644 index 00000000..fac72b60 --- /dev/null +++ b/application/controllers/Gridsquares.php @@ -0,0 +1,165 @@ +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(); + + $grid_2char = ""; + $grid_4char = ""; + + $query = $this->gridsquares_model->get_worked_sat_squares(); + + if ($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)); + + // 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); + } + + + } + } + + $query_vucc = $this->gridsquares_model->get_worked_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_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); + } + } + } + } + + + 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'] = js_array($array_grid_2char); + $data['grid_4char'] = js_array($array_grid_4char); + + + + $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'] = "Gridsquare Map"; + + + $array_grid_2char = array(); + $array_grid_4char = array(); + + $grid_2char = ""; + $grid_4char = ""; + + $query = $this->gridsquares_model->get_band($band); + + if ($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)); + + // 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); + } + + + } + } + + 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'] = js_array($array_grid_2char); + $data['grid_4char'] = js_array($array_grid_4char); + + + + $this->load->view('interface_assets/header', $data); + $this->load->view('gridsquares/index.php'); + $this->load->view('interface_assets/footer'); + } + +} \ No newline at end of file diff --git a/application/models/Gridsquares_model.php b/application/models/Gridsquares_model.php new file mode 100644 index 00000000..6a767df6 --- /dev/null +++ b/application/models/Gridsquares_model.php @@ -0,0 +1,25 @@ +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_worked_sat_vucc_squares() { + $this->db->select('COL_PRIMARY_KEY, COL_VUCC_GRIDS, COL_SAT_NAME'); + $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) { + 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.'"'); + } +} \ No newline at end of file diff --git a/application/views/gridsquares/index.php b/application/views/gridsquares/index.php new file mode 100644 index 00000000..40cde226 --- /dev/null +++ b/application/views/gridsquares/index.php @@ -0,0 +1,13 @@ +