| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	Gridsquares Controller | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Gridsquares extends CI_Controller { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-27 04:50:28 +08:00
										 |  |  |     /* | 
					
						
							|  |  |  |     *   TODO List | 
					
						
							|  |  |  |     *   - Create index page | 
					
						
							|  |  |  |     *   - Band page provide a band dropdown list | 
					
						
							|  |  |  |     *   - Find somewhere in the main menu to add a button to it | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2023-05-17 07:08:11 +08:00
										 |  |  | 	function __construct() | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		parent::__construct(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Load language files
 | 
					
						
							|  |  |  | 		$this->lang->load(array( | 
					
						
							|  |  |  | 			'gridsquares', | 
					
						
							|  |  |  | 		)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-06-27 04:50:28 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 	public function index() { | 
					
						
							| 
									
										
										
										
											2021-11-18 04:53:24 +08:00
										 |  |  | 		// if there are no satellite QSOs redirect to band selection directly
 | 
					
						
							| 
									
										
										
										
											2021-11-18 04:48:44 +08:00
										 |  |  | 		$this->load->model('logbook_model'); | 
					
						
							| 
									
										
										
										
											2022-10-06 05:23:32 +08:00
										 |  |  | 		$this->load->model('bands'); | 
					
						
							| 
									
										
										
										
											2021-11-18 04:48:44 +08:00
										 |  |  | 		$total_sat = $this->logbook_model->total_sat(); | 
					
						
							|  |  |  | 		if ($total_sat->num_rows() == 0) { | 
					
						
							|  |  |  | 			redirect('gridsquares/band/2m'); | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$data['page_title'] = "Gridsquare Map"; | 
					
						
							| 
									
										
										
										
											2022-10-06 05:23:32 +08:00
										 |  |  | 		$data['sat_active'] = array_search("SAT", $this->bands->get_user_bands(), true); | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$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(); | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 		$array_grid_6char = array(); | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$array_confirmed_grid_2char = array(); | 
					
						
							|  |  |  | 		$array_confirmed_grid_4char = array(); | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 		$array_confirmed_grid_6char = array(); | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 		$grid_2char = ""; | 
					
						
							|  |  |  | 		$grid_4char = ""; | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 		$grid_6char = ""; | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 		$grid_2char_confirmed = ""; | 
					
						
							|  |  |  | 		$grid_4char_confirmed = ""; | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 		$grid_6char_confirmed = ""; | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Get Confirmed LOTW & Paper Squares (non VUCC)
 | 
					
						
							|  |  |  | 		$query = $this->gridsquares_model->get_confirmed_sat_squares(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-26 19:30:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-15 01:06:49 +08:00
										 |  |  | 		if ($query && $query->num_rows() > 0) | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			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)); | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 				if ($this->config->item('map_6digit_grids')) { | 
					
						
							|  |  |  | 					$grid_6char_confirmed = strtoupper(substr($row->SAT_SQUARE,0,6)); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				// 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);	 | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 				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);	 | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Get worked squares
 | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 		$query = $this->gridsquares_model->get_worked_sat_squares(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-15 01:06:49 +08:00
										 |  |  | 		if ($query && $query->num_rows() > 0) | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			foreach ($query->result() as $row) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$grid_two = strtoupper(substr($row->SAT_SQUARE,0,2)); | 
					
						
							|  |  |  | 				$grid_four = strtoupper(substr($row->SAT_SQUARE,0,4)); | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 				if ($this->config->item('map_6digit_grids')) { | 
					
						
							|  |  |  | 					$grid_six = strtoupper(substr($row->SAT_SQUARE,0,6)); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				// 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);	 | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 				if ($this->config->item('map_6digit_grids')) { | 
					
						
							|  |  |  | 					if(!in_array($grid_six, $array_grid_6char)){ | 
					
						
							|  |  |  | 						array_push($array_grid_6char, $grid_six);	 | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$query_vucc = $this->gridsquares_model->get_worked_sat_vucc_squares(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-15 01:06:49 +08:00
										 |  |  | 		if ($query && $query_vucc->num_rows() > 0) | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			foreach ($query_vucc->result() as $row) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$grids = explode(",", $row->COL_VUCC_GRIDS); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				foreach($grids as $key) {     | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 					$grid_two = strtoupper(substr($key,0,2)); | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 					$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);	 | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 		// Confirmed Squares
 | 
					
						
							|  |  |  | 		$query_vucc = $this->gridsquares_model->get_confirmed_sat_vucc_squares(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-15 01:06:49 +08:00
										 |  |  | 		if ($query && $query_vucc->num_rows() > 0) | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			foreach ($query_vucc->result() as $row) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$grids = explode(",", $row->COL_VUCC_GRIDS); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				foreach($grids as $key) {     | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 					$grid_2char_confirmed = strtoupper(substr($key,0,2)); | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 					$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);	 | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-09 02:30:31 +08:00
										 |  |  | 					if(!in_array($grid_4char_confirmed, $array_confirmed_grid_4char)){ | 
					
						
							|  |  |  | 						array_push($array_confirmed_grid_4char, $grid_4char_confirmed);	 | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		function js_str($s) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 		    return '"' . addcslashes($s, "\0..\37\"\\") . '"'; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		function js_array($array) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 		    $temp = array_map('js_str', $array); | 
					
						
							|  |  |  | 		    return '[' . implode(',', $temp) . ']'; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 		$data['grid_2char_confirmed'] = js_array($array_confirmed_grid_2char); | 
					
						
							|  |  |  | 		$data['grid_4char_confirmed'] = js_array($array_confirmed_grid_4char); | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 		$data['grid_6char_confirmed'] = js_array($array_confirmed_grid_6char); | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 		$data['grid_2char'] = js_array($array_grid_2char); | 
					
						
							|  |  |  | 		$data['grid_4char'] = js_array($array_grid_4char); | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 		$data['grid_6char'] = js_array($array_grid_6char); | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$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'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-29 00:32:07 +08:00
										 |  |  | 		$data['page_title'] = strtoupper($band)." Gridsquare Map"; | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$array_grid_2char = array(); | 
					
						
							|  |  |  | 		$array_grid_4char = array(); | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 		$array_grid_6char = array(); | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 		$array_grid_2char_confirmed = array(); | 
					
						
							|  |  |  | 		$array_grid_4char_confirmed = array(); | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 		$array_grid_6char_confirmed = array(); | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 		$grid_2char = ""; | 
					
						
							|  |  |  | 		$grid_4char = ""; | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 		$grid_6char = ""; | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 		$grid_2char_confirmed = ""; | 
					
						
							|  |  |  | 		$grid_4char_confirmed = ""; | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 		$grid_6char_confirmed = ""; | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$query = $this->gridsquares_model->get_band_confirmed($band); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-15 01:06:49 +08:00
										 |  |  | 		if ($query && $query->num_rows() > 0) | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			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)); | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 				if ($this->config->item('map_6digit_grids')) { | 
					
						
							|  |  |  | 					$grid_6char_confirmed = strtoupper(substr($row->GRID_SQUARES,0,6)); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				// 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);	 | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				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);	 | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 		$query = $this->gridsquares_model->get_band($band); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-15 01:06:49 +08:00
										 |  |  | 		if ($query && $query->num_rows() > 0) | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			foreach ($query->result() as $row) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$grid_two = strtoupper(substr($row->GRID_SQUARES,0,2)); | 
					
						
							|  |  |  | 				$grid_four = strtoupper(substr($row->GRID_SQUARES,0,4)); | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 				if ($this->config->item('map_6digit_grids')) { | 
					
						
							|  |  |  | 					$grid_six = strtoupper(substr($row->GRID_SQUARES,0,6)); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				// 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);	 | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 				if ($this->config->item('map_6digit_grids')) { | 
					
						
							|  |  |  | 					if(!in_array($grid_six, $array_grid_6char)){ | 
					
						
							|  |  |  | 						array_push($array_grid_6char, $grid_six);	 | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2022-10-23 03:04:33 +08:00
										 |  |  | 		$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);	 | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		function js_str($s) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 		    return '"' . addcslashes($s, "\0..\37\"\\") . '"'; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		function js_array($array) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 		    $temp = array_map('js_str', $array); | 
					
						
							|  |  |  | 		    return '[' . implode(',', $temp) . ']'; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-29 00:07:34 +08:00
										 |  |  | 		$data['grid_2char_confirmed'] = js_array($array_grid_2char_confirmed); | 
					
						
							|  |  |  | 		$data['grid_4char_confirmed'] = js_array($array_grid_4char_confirmed); | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 		$data['grid_6char_confirmed'] = js_array($array_grid_6char_confirmed); | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$data['grid_2char'] = js_array($array_grid_2char); | 
					
						
							|  |  |  | 		$data['grid_4char'] = js_array($array_grid_4char); | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | 		$data['grid_6char'] = js_array($array_grid_6char); | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 02:40:54 +08:00
										 |  |  | 		$this->load->model('bands'); | 
					
						
							|  |  |  |         $data['bands_available'] = js_array($this->bands->get_worked_bands()); | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->view('interface_assets/header', $data); | 
					
						
							|  |  |  | 		$this->load->view('gridsquares/index.php'); | 
					
						
							|  |  |  | 		$this->load->view('interface_assets/footer'); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-03-17 01:35:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-06-27 04:11:44 +08:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2020-04-02 21:59:48 +08:00
										 |  |  | } |