| 
									
										
										
										
											2020-02-18 17:49:27 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | defined('BASEPATH') OR exit('No direct script access allowed'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Distances extends CI_Controller { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function __construct() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         parent::__construct(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->load->model('user_model'); | 
					
						
							|  |  |  |         if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function index() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // Render Page
 | 
					
						
							| 
									
										
										
										
											2020-12-22 17:33:08 +08:00
										 |  |  |         $data['page_title'] = "Distances Worked"; | 
					
						
							| 
									
										
										
										
											2020-02-18 17:49:27 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-13 22:55:17 +08:00
										 |  |  |         $this->load->model('bands'); | 
					
						
							| 
									
										
										
										
											2024-09-03 06:03:06 +08:00
										 |  |  |         $this->load->model('gridmap_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-13 22:55:17 +08:00
										 |  |  |         $data['bands_available'] = $this->bands->get_worked_bands_distances(); | 
					
						
							|  |  |  |         $data['sats_available'] = $this->bands->get_worked_sats(); | 
					
						
							| 
									
										
										
										
											2024-09-03 06:03:06 +08:00
										 |  |  |         $data['modes'] = $this->gridmap_model->get_worked_modes(); | 
					
						
							|  |  |  |         $data['powers'] = $this->bands->get_worked_powers(); | 
					
						
							| 
									
										
										
										
											2020-02-18 17:49:27 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $this->load->view('interface_assets/header', $data); | 
					
						
							|  |  |  |         $this->load->view('distances/index'); | 
					
						
							|  |  |  |         $this->load->view('interface_assets/footer'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function get_distances(){ | 
					
						
							|  |  |  |         // POST data
 | 
					
						
							|  |  |  |         $postData = $this->input->post(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //load model
 | 
					
						
							|  |  |  |         $this->load->model('Distances_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-20 18:55:55 +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'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-18 17:49:27 +08:00
										 |  |  |         // get data
 | 
					
						
							| 
									
										
										
										
											2020-11-20 18:55:55 +08:00
										 |  |  |         $data = $this->Distances_model->get_distances($postData, $measurement_base); | 
					
						
							| 
									
										
										
										
											2020-02-18 17:49:27 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return json_encode($data); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-10-05 21:31:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function test_distance(){ | 
					
						
							|  |  |  |         // POST data
 | 
					
						
							|  |  |  |         $postdata['band'] = "sat"; | 
					
						
							|  |  |  |         $postdata['sat'] = "All"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //load model
 | 
					
						
							|  |  |  |         $this->load->model('Distances_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ($this->session->userdata('user_measurement_base') == NULL) { | 
					
						
							|  |  |  |             $measurement_base = $this->config->item('measurement_base'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             $measurement_base = $this->session->userdata('user_measurement_base'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // get data
 | 
					
						
							|  |  |  |         $data = $this->Distances_model->get_distances($postdata, $measurement_base); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return json_encode($data); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-07-17 00:10:11 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	public function getDistanceQsos(){ | 
					
						
							|  |  |  | 		$this->load->model('distances_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$distance = $this->security->xss_clean($this->input->post('distance')); | 
					
						
							|  |  |  | 		$band = $this->security->xss_clean($this->input->post('band')); | 
					
						
							|  |  |  | 		$sat = $this->security->xss_clean($this->input->post('sat')); | 
					
						
							| 
									
										
										
										
											2024-09-03 06:03:06 +08:00
										 |  |  | 		$mode = $this->security->xss_clean($this->input->post('mode')); | 
					
						
							|  |  |  | 		$power = $this->security->xss_clean($this->input->post('pwr')); | 
					
						
							| 
									
										
										
										
											2024-11-17 23:31:27 +08:00
										 |  |  | 		$propag = $this->security->xss_clean($this->input->post('propag')); | 
					
						
							| 
									
										
										
										
											2024-09-03 06:03:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-17 23:31:27 +08:00
										 |  |  | 		$data['results'] = $this->distances_model->qso_details($distance, $band, $sat, $mode, $power, $propag); | 
					
						
							| 
									
										
										
										
											2023-07-17 00:10:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-03 06:03:06 +08:00
										 |  |  |         // Render Page
 | 
					
						
							|  |  |  |         if (strtolower($band) == 'all') $band = lang('statistics_distances_bands_all'); | 
					
						
							|  |  |  |         (strtolower($mode) == 'all') ? $mode = lang('statistics_distances_modes_all') : $mode = strtoupper($mode); | 
					
						
							|  |  |  |         switch (strtolower($power)) { | 
					
						
							|  |  |  |             case 'all': | 
					
						
							|  |  |  |                 $power = lang('statistics_distances_bands_all'); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case '': | 
					
						
							|  |  |  |                 $power = lang('general_word_undefined'); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 $power .= 'W'; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-07-17 00:10:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-17 23:31:27 +08:00
										 |  |  |         switch (strtolower($propag)) { | 
					
						
							|  |  |  |             case 'all': | 
					
						
							|  |  |  |                 $propag = lang('general_word_all'); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case '': | 
					
						
							|  |  |  |                 $propag = lang('general_word_undefined'); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 $propag = lang("gen_hamradio_propagation_$propag"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-17 00:10:11 +08:00
										 |  |  | 		$data['page_title'] = "Log View - " . $distance; | 
					
						
							| 
									
										
										
										
											2024-11-17 23:31:27 +08:00
										 |  |  | 		$data['filter'] = lang('statistics_distances_qsos_with') . " " . $distance . lang('statistics_distances_and_band') . " " . $band . lang('statistics_distances_and_mode') . $mode . lang('statistics_distances_and_power') . $power . lang('statistics_distances_and_propagation') . $propag; | 
					
						
							| 
									
										
										
										
											2023-07-17 00:10:11 +08:00
										 |  |  | 		$this->load->view('awards/details', $data); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |