| 
									
										
										
										
											2012-11-14 09:44:23 +08:00
										 |  |  | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-26 21:19:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-14 09:44:23 +08:00
										 |  |  | class Logbook extends CI_Controller { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 	function index() | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 				$this->load->model('user_model'); | 
					
						
							|  |  |  | 				if(!$this->user_model->authorize($this->config->item('auth_mode'))) { | 
					
						
							|  |  |  | 						if($this->user_model->validate_session()) { | 
					
						
							|  |  |  | 								$this->user_model->clear_session(); | 
					
						
							|  |  |  | 								show_error('Access denied<p>Click <a href="'.site_url('user/login').'">here</a> to log in as another user', 403); | 
					
						
							|  |  |  | 						} else { | 
					
						
							|  |  |  | 								redirect('user/login'); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->library('pagination'); | 
					
						
							|  |  |  | 		$config['base_url'] = base_url().'index.php/logbook/index/'; | 
					
						
							|  |  |  | 		$config['total_rows'] = $this->db->count_all($this->config->item('table_name')); | 
					
						
							|  |  |  | 		$config['per_page'] = '25'; | 
					
						
							|  |  |  | 		$config['num_links'] = 6; | 
					
						
							|  |  |  | 		$config['full_tag_open'] = ''; | 
					
						
							|  |  |  | 		$config['full_tag_close'] = ''; | 
					
						
							|  |  |  | 		$config['cur_tag_open'] = '<strong class="active"><a href="">'; | 
					
						
							|  |  |  | 		$config['cur_tag_close'] = '</a></strong>'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->pagination->initialize($config); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		//load the model and get results
 | 
					
						
							|  |  |  | 		$this->load->model('logbook_model'); | 
					
						
							|  |  |  | 		$data['results'] = $this->logbook_model->get_qsos($config['per_page'],$this->uri->segment(3)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Calculate Lat/Lng from Locator to use on Maps
 | 
					
						
							|  |  |  | 		if($this->session->userdata('user_locator')) { | 
					
						
							|  |  |  | 				$this->load->library('qra'); | 
					
						
							|  |  |  | 				$qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator')); | 
					
						
							|  |  |  | 				$data['qra'] = "set"; | 
					
						
							|  |  |  | 				$data['qra_lat'] = $qra_position[0]; | 
					
						
							|  |  |  | 				$data['qra_lng'] = $qra_position[1]; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 				$data['qra'] = "none"; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// load the view
 | 
					
						
							|  |  |  | 		$data['page_title'] = "Logbook"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-14 23:46:16 +08:00
										 |  |  | 		$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 		$this->load->view('view_log/index'); | 
					
						
							| 
									
										
										
										
											2019-05-14 23:46:16 +08:00
										 |  |  | 		$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-13 16:34:02 +08:00
										 |  |  | 	function jsonentity($adif) { | 
					
						
							|  |  |  |         $this->load->model('user_model'); | 
					
						
							|  |  |  |         if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $return['dxcc'] = $this->getentity($adif); | 
					
						
							| 
									
										
										
										
											2020-04-14 01:23:19 +08:00
										 |  |  |         header('Content-Type: application/json'); | 
					
						
							| 
									
										
										
										
											2020-04-13 16:34:02 +08:00
										 |  |  |         echo json_encode($return, JSON_PRETTY_PRINT); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-16 19:25:31 +08:00
										 |  |  | 	function json($callsign, $type, $band, $mode) | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		$this->load->model('user_model'); | 
					
						
							|  |  |  | 		if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-30 04:11:35 +08:00
										 |  |  | 		// Convert - in Callsign to / Used for URL processing
 | 
					
						
							|  |  |  | 		$callsign = str_replace("-","/",$callsign); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-21 21:02:50 +08:00
										 |  |  | 		// Check if callsign is an LOTW User
 | 
					
						
							|  |  |  | 			$lotw_member = ""; | 
					
						
							|  |  |  | 			$lotw_file_name = "./updates/lotw_users.csv"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (file_exists($lotw_file_name)) { | 
					
						
							|  |  |  | 				$f = fopen($lotw_file_name, "r"); | 
					
						
							|  |  |  | 		        $result = false; | 
					
						
							|  |  |  | 		        while ($row = fgetcsv($f)) { | 
					
						
							|  |  |  | 		            if ($row[0] == strtoupper($callsign)) { | 
					
						
							|  |  |  | 		                $result = $row[0]; | 
					
						
							|  |  |  | 		                $lotw_member = "active"; | 
					
						
							|  |  |  | 		                break; | 
					
						
							|  |  |  | 		            } | 
					
						
							|  |  |  | 		        } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		        if($lotw_member != "active") { | 
					
						
							|  |  |  | 		        	$lotw_member = "not found"; | 
					
						
							|  |  |  | 		        } | 
					
						
							|  |  |  | 		        fclose($f); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 			    $lotw_member = "not found"; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Check Database for all other data
 | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 		$this->load->model('logbook_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$return = [ | 
					
						
							|  |  |  | 			"dxcc" => false, | 
					
						
							|  |  |  | 			"callsign_name" => "", | 
					
						
							|  |  |  | 			"callsign_qra"  => "", | 
					
						
							|  |  |  | 			"callsign_qth"  => "", | 
					
						
							|  |  |  | 			"callsign_iota" => "", | 
					
						
							| 
									
										
										
										
											2020-03-08 00:36:21 +08:00
										 |  |  | 			"callsign_state" => "", | 
					
						
							| 
									
										
										
										
											2020-03-08 00:46:31 +08:00
										 |  |  | 			"callsign_us_county" => "", | 
					
						
							| 
									
										
										
										
											2019-06-17 18:15:05 +08:00
										 |  |  | 			"qsl_manager" => "", | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 			"bearing" 		=> "", | 
					
						
							| 
									
										
										
										
											2019-06-16 23:37:26 +08:00
										 |  |  | 			"workedBefore" => false, | 
					
						
							|  |  |  | 			"lotw_member" => $lotw_member, | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 		]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-14 07:14:39 +08:00
										 |  |  | 		$return['dxcc'] = $this->dxcheck($callsign); | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 		$return['partial'] = $this->partial($callsign); | 
					
						
							| 
									
										
										
										
											2019-02-26 21:19:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Do we have local data for the Callsign?
 | 
					
						
							|  |  |  | 	if($this->logbook_model->call_name($callsign) != null) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2020-09-15 02:24:57 +08:00
										 |  |  |         if ($this->session->userdata('user_measurement_base') == NULL) { | 
					
						
							|  |  |  |              $measurement_base = $this->config->item('measurement_base'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             $measurement_base = $this->session->userdata('user_measurement_base'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-26 21:19:52 +08:00
										 |  |  | 		$return['callsign_name'] = $this->logbook_model->call_name($callsign); | 
					
						
							|  |  |  | 		$return['callsign_qra'] = $this->logbook_model->call_qra($callsign); | 
					
						
							|  |  |  | 		$return['callsign_qth'] = $this->logbook_model->call_qth($callsign); | 
					
						
							|  |  |  | 		$return['callsign_iota'] = $this->logbook_model->call_iota($callsign); | 
					
						
							| 
									
										
										
										
											2019-06-17 18:15:05 +08:00
										 |  |  | 		$return['qsl_manager'] = $this->logbook_model->call_qslvia($callsign); | 
					
						
							| 
									
										
										
										
											2020-09-15 02:24:57 +08:00
										 |  |  | 		$return['bearing'] = $this->bearing($return['callsign_qra'], $measurement_base); | 
					
						
							| 
									
										
										
										
											2019-08-16 19:25:31 +08:00
										 |  |  | 		$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode); | 
					
						
							| 
									
										
										
										
											2019-06-14 07:14:39 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if ($return['callsign_qra'] != "") { | 
					
						
							|  |  |  | 			$return['latlng'] = $this->qralatlng($return['callsign_qra']); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-26 21:19:52 +08:00
										 |  |  | 		echo json_encode($return, JSON_PRETTY_PRINT); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-16 23:37:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-26 21:19:52 +08:00
										 |  |  | 	if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		// Lookup using QRZ
 | 
					
						
							|  |  |  | 		$this->load->library('qrz'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if(!$this->session->userdata('qrz_session_key')) { | 
					
						
							|  |  |  | 			$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password')); | 
					
						
							|  |  |  | 			$this->session->set_userdata('qrz_session_key', $qrz_session_key); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key')); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		// Load the HamQTH library
 | 
					
						
							|  |  |  | 		$this->load->library('hamqth'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if(!$this->session->userdata('hamqth_session_key')) { | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 			$hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password')); | 
					
						
							|  |  |  | 			$this->session->set_userdata('hamqth_session_key', $hamqth_session_key); | 
					
						
							| 
									
										
										
										
											2019-02-26 21:19:52 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key')); | 
					
						
							| 
									
										
										
										
											2020-03-04 11:37:16 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// If HamQTH session has expired, start a new session and retry the search.
 | 
					
						
							|  |  |  | 		if($callbook['error'] == "Session does not exist or expired") { | 
					
						
							|  |  |  | 			$hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password')); | 
					
						
							|  |  |  | 			$this->session->set_userdata('hamqth_session_key', $hamqth_session_key); | 
					
						
							|  |  |  | 			$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key')); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-02-26 21:19:52 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-26 22:20:47 +08:00
										 |  |  | 	if (isset($callbook)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		$return['callsign_name'] = $callbook['name']; | 
					
						
							|  |  |  | 		$return['callsign_qra'] = $callbook['gridsquare']; | 
					
						
							|  |  |  | 		$return['callsign_qth'] = $callbook['city']; | 
					
						
							|  |  |  | 		$return['callsign_iota'] = $callbook['iota']; | 
					
						
							| 
									
										
										
										
											2020-03-08 00:36:21 +08:00
										 |  |  | 		$return['callsign_state'] = $callbook['state']; | 
					
						
							| 
									
										
										
										
											2020-03-08 00:46:31 +08:00
										 |  |  | 		$return['callsign_us_county'] = $callbook['us_county']; | 
					
						
							| 
									
										
										
										
											2020-03-08 00:36:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-30 22:44:09 +08:00
										 |  |  | 		if(isset($callbook['qslmgr'])) { | 
					
						
							|  |  |  | 			$return['qsl_manager'] = $callbook['qslmgr']; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-06-14 07:14:39 +08:00
										 |  |  | 		if ($return['callsign_qra'] != "") { | 
					
						
							|  |  |  | 			$return['latlng'] = $this->qralatlng($return['callsign_qra']); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-08-16 19:25:31 +08:00
										 |  |  | 		$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode); | 
					
						
							| 
									
										
										
										
											2019-02-26 22:20:47 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-09-15 02:24:57 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if ($this->session->userdata('user_measurement_base') == NULL) { | 
					
						
							|  |  |  |         $measurement_base = $this->config->item('measurement_base'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         $measurement_base = $this->session->userdata('user_measurement_base'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$return['bearing'] = $this->bearing($return['callsign_qra'], $measurement_base); | 
					
						
							| 
									
										
										
										
											2019-02-26 21:19:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	echo json_encode($return, JSON_PRETTY_PRINT); | 
					
						
							| 
									
										
										
										
											2019-06-16 23:37:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-26 21:19:52 +08:00
										 |  |  | 	return; | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-16 19:25:31 +08:00
										 |  |  | 	function worked_grid_before($gridsquare, $type, $band, $mode) | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		if (strlen($gridsquare) < 4) | 
					
						
							|  |  |  | 			return false;  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-27 04:11:10 +08:00
										 |  |  | 		$CI =& get_instance(); | 
					
						
							|  |  |  |     	$CI->load->model('Stations'); | 
					
						
							|  |  |  |     	$station_id = $CI->Stations->find_active(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-16 19:25:31 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if($type == "SAT") { | 
					
						
							|  |  |  | 			$this->db->where('COL_PROP_MODE', 'SAT');  | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			$this->db->where('COL_MODE', $mode);  | 
					
						
							|  |  |  | 			$this->db->where('COL_BAND', $band);  | 
					
						
							|  |  |  | 			$this->db->where('COL_PROP_MODE !=','SAT'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-09-27 03:31:16 +08:00
										 |  |  |     	$this->db->where('station_id', $station_id);  | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 		$this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4)); | 
					
						
							| 
									
										
										
										
											2019-09-27 04:26:20 +08:00
										 |  |  | 		$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "desc"); | 
					
						
							|  |  |  | 		$this->db->limit(1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$query = $this->db->get($this->config->item('table_name')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 		foreach ($query->result() as $workedBeforeRow) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			return true; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-16 19:06:19 +08:00
										 |  |  | 	/* | 
					
						
							|  |  |  | 	*	Function: jsonlookupgrid | 
					
						
							|  |  |  | 	* | 
					
						
							|  |  |  | 	* 	Usage: Used to look up gridsquares when creating a QSO to check whether its needed or not  | 
					
						
							| 
									
										
										
										
											2019-08-16 19:11:46 +08:00
										 |  |  | 	*	the $type variable is only used for satellites, set this to SAT. | 
					
						
							|  |  |  | 	* | 
					
						
							| 
									
										
										
										
											2019-08-16 19:06:19 +08:00
										 |  |  | 	*/ | 
					
						
							|  |  |  | 	function jsonlookupgrid($gridsquare, $type, $band, $mode) { | 
					
						
							|  |  |  | 		$return = [ | 
					
						
							|  |  |  | 			"workedBefore" => false, | 
					
						
							|  |  |  | 		]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-27 04:11:10 +08:00
										 |  |  | 		$CI =& get_instance(); | 
					
						
							|  |  |  |     	$CI->load->model('Stations'); | 
					
						
							|  |  |  |     	$station_id = $CI->Stations->find_active(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-16 19:06:19 +08:00
										 |  |  | 		if($type == "SAT") { | 
					
						
							|  |  |  | 			$this->db->where('COL_PROP_MODE', 'SAT');  | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			$this->db->where('COL_MODE', $mode);  | 
					
						
							|  |  |  | 			$this->db->where('COL_BAND', $band);  | 
					
						
							|  |  |  | 			$this->db->where('COL_PROP_MODE !=','SAT'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-27 03:31:16 +08:00
										 |  |  |     	$this->db->where('station_id', $station_id);  | 
					
						
							|  |  |  |     	 | 
					
						
							| 
									
										
										
										
											2019-08-16 19:06:19 +08:00
										 |  |  | 		$this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4)); | 
					
						
							|  |  |  | 		$query = $this->db->get($this->config->item('table_name'), 1, 0); | 
					
						
							|  |  |  | 		foreach ($query->result() as $workedBeforeRow) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			$return['workedBefore'] = true; | 
					
						
							| 
									
										
										
										
											2019-10-14 04:42:41 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		header('Content-Type: application/json'); | 
					
						
							|  |  |  | 		echo json_encode($return, JSON_PRETTY_PRINT); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function jsonlookupdxcc($country, $type, $band, $mode) { | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		$return = [ | 
					
						
							|  |  |  | 			"workedBefore" => false, | 
					
						
							|  |  |  | 		]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$CI =& get_instance(); | 
					
						
							|  |  |  |     	$CI->load->model('Stations'); | 
					
						
							|  |  |  |     	$station_id = $CI->Stations->find_active(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if($type == "SAT") { | 
					
						
							|  |  |  | 			$this->db->where('COL_PROP_MODE', 'SAT');  | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			$this->db->where('COL_MODE', $mode);  | 
					
						
							|  |  |  | 			$this->db->where('COL_BAND', $band);  | 
					
						
							|  |  |  | 			$this->db->where('COL_PROP_MODE !=','SAT'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     	$this->db->where('station_id', $station_id);  | 
					
						
							|  |  |  |     	$this->db->where('COL_COUNTRY', urldecode($country));  | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | 		$query = $this->db->get($this->config->item('table_name'), 1, 0); | 
					
						
							|  |  |  | 		foreach ($query->result() as $workedBeforeRow) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			$return['workedBefore'] = true; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		header('Content-Type: application/json'); | 
					
						
							|  |  |  | 		echo json_encode($return, JSON_PRETTY_PRINT); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function jsonlookupcallsign($callsign, $type, $band, $mode) { | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2021-01-30 04:20:01 +08:00
										 |  |  | 		// Convert - in Callsign to / Used for URL processing
 | 
					
						
							|  |  |  | 		$callsign = str_replace("-","/",$callsign); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-14 04:42:41 +08:00
										 |  |  | 		$return = [ | 
					
						
							|  |  |  | 			"workedBefore" => false, | 
					
						
							|  |  |  | 		]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$CI =& get_instance(); | 
					
						
							|  |  |  |     	$CI->load->model('Stations'); | 
					
						
							|  |  |  |     	$station_id = $CI->Stations->find_active(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if($type == "SAT") { | 
					
						
							|  |  |  | 			$this->db->where('COL_PROP_MODE', 'SAT');  | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			$this->db->where('COL_MODE', $mode);  | 
					
						
							|  |  |  | 			$this->db->where('COL_BAND', $band);  | 
					
						
							|  |  |  | 			$this->db->where('COL_PROP_MODE !=','SAT'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     	$this->db->where('station_id', $station_id);  | 
					
						
							|  |  |  |     	$this->db->where('COL_CALL', strtoupper($callsign));  | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | 		$query = $this->db->get($this->config->item('table_name'), 1, 0); | 
					
						
							|  |  |  | 		foreach ($query->result() as $workedBeforeRow) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			$return['workedBefore'] = true; | 
					
						
							| 
									
										
										
										
											2019-08-16 19:06:19 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		header('Content-Type: application/json'); | 
					
						
							|  |  |  | 		echo json_encode($return, JSON_PRETTY_PRINT); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Used to generate maps for displaying on /logbook/ */ | 
					
						
							|  |  |  | 	function qso_map() { | 
					
						
							|  |  |  | 		$this->load->model('logbook_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->library('qra'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$data['qsos'] = $this->logbook_model->get_qsos($this->uri->segment(3),$this->uri->segment(4)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		echo "{\"markers\": ["; | 
					
						
							|  |  |  | 		$count = 1; | 
					
						
							|  |  |  | 		foreach ($data['qsos']->result() as $row) { | 
					
						
							|  |  |  | 			if($row->COL_GRIDSQUARE != null) { | 
					
						
							|  |  |  | 				$stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE); | 
					
						
							|  |  |  | 				if($count != 1) { | 
					
						
							|  |  |  | 					echo ","; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if($row->COL_SAT_NAME != null) { | 
					
						
							| 
									
										
										
										
											2020-11-18 01:40:55 +08:00
										 |  |  | 						echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}"; | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2020-11-18 01:40:55 +08:00
										 |  |  | 						echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}"; | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$count++; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$query = $this->db->query(' | 
					
						
							|  |  |  | 					SELECT * | 
					
						
							| 
									
										
										
										
											2019-06-25 00:34:01 +08:00
										 |  |  | 					FROM dxcc_entities | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 					WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) ) | 
					
						
							|  |  |  | 					ORDER BY LENGTH( prefix ) DESC | 
					
						
							|  |  |  | 					LIMIT 1 | 
					
						
							|  |  |  | 				'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				foreach ($query->result() as $dxcc) { | 
					
						
							|  |  |  | 					if($count != 1) { | 
					
						
							|  |  |  | 					echo ","; | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2020-11-18 01:40:55 +08:00
										 |  |  | 					echo "{\"lat\":\"".$dxcc->lat."\",\"lng\":\"".$dxcc->long."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}"; | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 					$count++; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		echo "]"; | 
					
						
							|  |  |  | 		echo "}"; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-05-26 01:43:32 +08:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 	function view($id) { | 
					
						
							|  |  |  | 		$this->load->model('user_model'); | 
					
						
							|  |  |  | 				if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->library('qra'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 06:10:59 +08:00
										 |  |  | 		$this->load->model('logbook_model'); | 
					
						
							|  |  |  | 		$data['query'] = $this->logbook_model->get_qso($id); | 
					
						
							| 
									
										
										
										
											2020-09-15 02:24:57 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if ($this->session->userdata('user_measurement_base') == NULL) { | 
					
						
							|  |  |  |             $data['measurement_base'] = $this->config->item('measurement_base'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             $data['measurement_base'] = $this->session->userdata('user_measurement_base'); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-09-13 20:42:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-29 06:20:03 +08:00
										 |  |  |         $this->load->model('Qsl_model'); | 
					
						
							|  |  |  |         $data['qslimages'] = $this->Qsl_model->getQslForQsoId($id); | 
					
						
							| 
									
										
										
										
											2020-11-03 01:23:41 +08:00
										 |  |  | 		$data['max_upload'] = ini_get('upload_max_filesize'); | 
					
						
							| 
									
										
										
										
											2019-05-26 01:43:32 +08:00
										 |  |  | 		$this->load->view('interface_assets/mini_header', $data); | 
					
						
							|  |  |  | 		$this->load->view('view_log/qso'); | 
					
						
							|  |  |  | 		$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-09-27 04:26:20 +08:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 	function partial($id) { | 
					
						
							|  |  |  | 		$this->load->model('user_model'); | 
					
						
							|  |  |  | 				if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } | 
					
						
							|  |  |  | 				 | 
					
						
							| 
									
										
										
										
											2019-09-27 04:26:20 +08:00
										 |  |  | 		$html = ""; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-24 14:51:30 +08:00
										 |  |  | 	    $this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*'); | 
					
						
							| 
									
										
										
										
											2019-09-27 04:26:20 +08:00
										 |  |  | 	    $this->db->from($this->config->item('table_name')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	    $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); | 
					
						
							|  |  |  | 	    $this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', "desc"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->db->like($this->config->item('table_name').'.COL_CALL', $id); | 
					
						
							|  |  |  | 		$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "desc"); | 
					
						
							| 
									
										
										
										
											2019-05-21 20:44:22 +08:00
										 |  |  | 		$this->db->limit(5); | 
					
						
							| 
									
										
										
										
											2019-09-27 04:26:20 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$query = $this->db->get(); | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if ($query->num_rows() > 0) | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2019-05-21 20:44:22 +08:00
										 |  |  | 			$html .= "<div class=\"table-responsive\">"; | 
					
						
							|  |  |  | 			$html .= "<table class=\"table\">"; | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 				$html .= "<tr>"; | 
					
						
							|  |  |  | 					$html .= "<td>Date</td>"; | 
					
						
							|  |  |  | 					$html .= "<td>Callsign</td>"; | 
					
						
							| 
									
										
										
										
											2019-09-27 04:26:20 +08:00
										 |  |  | 					$html .= "<td>RST (S)</td>"; | 
					
						
							|  |  |  | 					$html .= "<td>RST (R)</td>"; | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 					$html .= "<td>Band</td>"; | 
					
						
							|  |  |  | 					$html .= "<td>Mode</td>"; | 
					
						
							| 
									
										
										
										
											2019-10-13 03:23:58 +08:00
										 |  |  | 					$html .= "<td>QSL</td>"; | 
					
						
							| 
									
										
										
										
											2019-09-27 04:26:20 +08:00
										 |  |  | 					$html .= "<td></td>"; | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 				$html .= "</tr>"; | 
					
						
							|  |  |  | 			foreach ($query->result() as $row) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				$html .= "<tr>"; | 
					
						
							| 
									
										
										
										
											2020-02-21 19:40:05 +08:00
										 |  |  | 					$html .= "<td>".date($this->config->item('qso_date_format').' H:i',strtotime($row->COL_TIME_ON))."</td>"; | 
					
						
							| 
									
										
										
										
											2019-06-25 21:28:59 +08:00
										 |  |  | 					$html .= "<td>".str_replace("0","Ø",strtoupper($row->COL_CALL))."</td>"; | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 					$html .= "<td>".$row->COL_RST_SENT."</td>"; | 
					
						
							|  |  |  | 					$html .= "<td>".$row->COL_RST_RCVD."</td>"; | 
					
						
							|  |  |  | 					if($row->COL_SAT_NAME != null) { | 
					
						
							|  |  |  | 									$html .= "<td>".$row->COL_SAT_NAME."</td>"; | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 								$html .= "<td>".$row->COL_BAND."</td>"; | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2020-05-24 14:51:30 +08:00
										 |  |  | 					if ($row->COL_SUBMODE==null) | 
					
						
							|  |  |  | 						$html .= "<td>".$row->COL_MODE."</td>"; | 
					
						
							|  |  |  | 					else | 
					
						
							|  |  |  | 						$html .= "<td>".$row->COL_SUBMODE."</td>"; | 
					
						
							| 
									
										
										
										
											2019-10-13 03:23:58 +08:00
										 |  |  | 					$html .= "<td class=\"qsl\">"; | 
					
						
							|  |  |  | 					$html .= "<span class=\"qsl-"; | 
					
						
							|  |  |  | 					switch ($row->COL_QSL_SENT) { | 
					
						
							|  |  |  | 						case "Y": | 
					
						
							|  |  |  | 							$html .= "green"; | 
					
						
							|  |  |  | 							break; | 
					
						
							| 
									
										
										
										
											2020-05-26 05:05:21 +08:00
										 |  |  | 						case "Q": | 
					
						
							|  |  |  | 							$html .= "yellow"; | 
					
						
							|  |  |  | 							break; | 
					
						
							| 
									
										
										
										
											2019-10-13 03:23:58 +08:00
										 |  |  | 						case "R": | 
					
						
							|  |  |  | 							$html .= "yellow"; | 
					
						
							|  |  |  | 							break; | 
					
						
							| 
									
										
										
										
											2020-05-26 05:05:21 +08:00
										 |  |  | 						case "I": | 
					
						
							|  |  |  | 							echo "grey"; | 
					
						
							|  |  |  | 							break; | 
					
						
							| 
									
										
										
										
											2019-10-13 03:23:58 +08:00
										 |  |  | 						default: | 
					
						
							|  |  |  | 						   $html .= "red"; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					$html .= "\">▲</span>"; | 
					
						
							|  |  |  | 					$html .= "<span class=\"qsl-"; | 
					
						
							|  |  |  | 					switch ($row->COL_QSL_RCVD) { | 
					
						
							|  |  |  | 						case "Y": | 
					
						
							|  |  |  | 							$html .= "green"; | 
					
						
							|  |  |  | 							break; | 
					
						
							| 
									
										
										
										
											2020-05-26 05:05:21 +08:00
										 |  |  | 						case "Q": | 
					
						
							|  |  |  | 							$html .= "yellow"; | 
					
						
							|  |  |  | 							break; | 
					
						
							| 
									
										
										
										
											2019-10-13 03:23:58 +08:00
										 |  |  | 						case "R": | 
					
						
							|  |  |  | 							$html .= "yellow"; | 
					
						
							|  |  |  | 							break; | 
					
						
							| 
									
										
										
										
											2020-05-26 05:05:21 +08:00
										 |  |  | 						case "I": | 
					
						
							|  |  |  | 							echo "grey"; | 
					
						
							|  |  |  | 							break; | 
					
						
							| 
									
										
										
										
											2019-10-13 03:23:58 +08:00
										 |  |  | 						default: | 
					
						
							|  |  |  | 						   $html .= "red"; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					$html .= "\">▼</span>"; | 
					
						
							|  |  |  | 					$html .= "</td>"; | 
					
						
							| 
									
										
										
										
											2019-09-27 04:26:20 +08:00
										 |  |  | 					$html .= "<td><span class=\"badge badge-info\">".$row->station_callsign."</span></td>"; | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 				$html .= "</tr>"; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			$html .= "</table>"; | 
					
						
							| 
									
										
										
										
											2019-05-21 20:44:22 +08:00
										 |  |  | 			$html .= "</div>"; | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 			return $html; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 				if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) { | 
					
						
							|  |  |  | 					// Lookup using QRZ
 | 
					
						
							|  |  |  | 					$this->load->library('qrz'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					if(!$this->session->userdata('qrz_session_key')) { | 
					
						
							|  |  |  | 						$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password')); | 
					
						
							|  |  |  | 						$this->session->set_userdata('qrz_session_key', $qrz_session_key); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					$data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key')); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// There's no hamli integration? Disabled for now.
 | 
					
						
							|  |  |  | 				/*else { | 
					
						
							|  |  |  | 					// Lookup using hamli
 | 
					
						
							|  |  |  | 					$this->load->library('hamli'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					$data['callsign'] = $this->hamli->callsign($id); | 
					
						
							|  |  |  | 				}*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$data['id'] = strtoupper($id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				return $this->load->view('search/result', $data, true); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function search_result($id="") { | 
					
						
							|  |  |  | 		$this->load->model('user_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-24 14:51:30 +08:00
										 |  |  |    		$this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*'); | 
					
						
							| 
									
										
										
										
											2019-09-25 06:10:59 +08:00
										 |  |  |      | 
					
						
							|  |  |  |     	$this->db->from($this->config->item('table_name')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     	$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); | 
					
						
							|  |  |  |     		 | 
					
						
							|  |  |  | 		$this->db->like(''.$this->config->item('table_name').'.COL_CALL', $id); | 
					
						
							|  |  |  | 		$this->db->or_like(''.$this->config->item('table_name').'.COL_GRIDSQUARE', $id); | 
					
						
							|  |  |  | 		$this->db->or_like(''.$this->config->item('table_name').'.COL_VUCC_GRIDS', $id); | 
					
						
							|  |  |  | 		$this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', 'desc'); | 
					
						
							|  |  |  | 		$query = $this->db->get(); | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if ($query->num_rows() > 0) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			$data['results'] = $query; | 
					
						
							| 
									
										
										
										
											2020-09-25 02:22:09 +08:00
										 |  |  | 			$this->load->view('view_log/partial/log_ajax.php', $data); | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 		} else { | 
					
						
							|  |  |  | 			$this->load->model('search'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			$iota_search = $this->search->callsign_iota($id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if ($iota_search->num_rows() > 0) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				$data['results'] = $iota_search; | 
					
						
							| 
									
										
										
										
											2020-09-25 02:22:09 +08:00
										 |  |  | 				$this->load->view('view_log/partial/log_ajax.php', $data); | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) { | 
					
						
							|  |  |  | 					// Lookup using QRZ
 | 
					
						
							|  |  |  | 					$this->load->library('qrz'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					if(!$this->session->userdata('qrz_session_key')) { | 
					
						
							|  |  |  | 						$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password')); | 
					
						
							|  |  |  | 						$this->session->set_userdata('qrz_session_key', $qrz_session_key); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					$data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key')); | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					// Lookup using hamli
 | 
					
						
							|  |  |  | 					$this->load->library('hamli'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					$data['callsign'] = $this->hamli->callsign($id); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$data['id'] = strtoupper($id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$this->load->view('search/result', $data); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* | 
					
						
							|  |  |  | 	 * Provide a dxcc search, returning results json encoded | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	function local_find_dxcc($call = "", $date = "") { | 
					
						
							|  |  |  | 		$this->load->model("logbook_model"); | 
					
						
							|  |  |  | 		if ($date == ''){ | 
					
						
							|  |  |  | 			$date = date("Y-m-d"); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		$ans = $this->logbook_model->check_dxcc_stored_proc($call, $date); | 
					
						
							|  |  |  | 		print json_encode($ans); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-14 07:14:39 +08:00
										 |  |  | 	function dxcheck($call = "", $date = "") { | 
					
						
							|  |  |  | 		$this->load->model("logbook_model"); | 
					
						
							|  |  |  | 		if ($date == ''){ | 
					
						
							|  |  |  | 			$date = date("Y-m-d"); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		$ans = $this->logbook_model->dxcc_lookup($call, $date); | 
					
						
							|  |  |  | 		return $ans; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-13 16:34:02 +08:00
										 |  |  |     function getentity($adif) { | 
					
						
							|  |  |  |         $this->load->model("logbook_model"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $entity = $this->logbook_model->get_entity($adif); | 
					
						
							|  |  |  |         return $entity; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-21 20:44:22 +08:00
										 |  |  | 	/* return station bearing */ | 
					
						
							|  |  |  | 	function searchbearing($locator) { | 
					
						
							|  |  |  | 			$this->load->library('Qra'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if($locator != null) { | 
					
						
							|  |  |  | 				if($this->session->userdata('user_locator') != null){ | 
					
						
							|  |  |  | 					$mylocator = $this->session->userdata('user_locator'); | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					$mylocator = $this->config->item('locator'); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-15 02:24:57 +08:00
										 |  |  |                 if ($this->session->userdata('user_measurement_base') == NULL) { | 
					
						
							|  |  |  |                     $measurement_base = $this->config->item('measurement_base'); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 else { | 
					
						
							|  |  |  |                     $measurement_base = $this->session->userdata('user_measurement_base'); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$bearing = $this->qra->bearing($mylocator, $locator, $measurement_base); | 
					
						
							| 
									
										
										
										
											2019-05-21 20:44:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				echo $bearing; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			return ""; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 	/* return station bearing */ | 
					
						
							| 
									
										
										
										
											2019-06-24 21:57:48 +08:00
										 |  |  | 	function bearing($locator, $unit = 'M') { | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 			$this->load->library('Qra'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-21 20:44:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 			if($locator != null) { | 
					
						
							|  |  |  | 				if($this->session->userdata('user_locator') != null){ | 
					
						
							|  |  |  | 					$mylocator = $this->session->userdata('user_locator'); | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					$mylocator = $this->config->item('locator'); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-21 20:44:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-24 21:57:48 +08:00
										 |  |  | 				$bearing = $this->qra->bearing($mylocator, $locator, $unit); | 
					
						
							| 
									
										
										
										
											2019-02-27 05:08:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				return $bearing; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			return ""; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-06-14 07:14:39 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	function qralatlng($qra) { | 
					
						
							|  |  |  | 		$this->load->library('Qra'); | 
					
						
							|  |  |  | 		$latlng = $this->qra->qra2latlong($qra); | 
					
						
							|  |  |  | 		return $latlng; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function qralatlngjson($qra) { | 
					
						
							|  |  |  | 		$this->load->library('Qra'); | 
					
						
							|  |  |  | 		$latlng = $this->qra->qra2latlong($qra); | 
					
						
							|  |  |  | 		print json_encode($latlng); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-06-17 21:29:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-13 20:42:49 +08:00
										 |  |  |     function get_qsos($num, $offset) { | 
					
						
							|  |  |  |         $this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*'); | 
					
						
							|  |  |  |         $this->db->from($this->config->item('table_name')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); | 
					
						
							|  |  |  |         $this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', "desc"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->db->limit($num); | 
					
						
							|  |  |  |         $this->db->offset($offset); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $this->db->get(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-17 21:29:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-18 01:40:55 +08:00
										 |  |  | } |