| 
									
										
										
										
											2023-04-12 17:58:47 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  | 	This controller contains features for Cabrillo | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Cabrillo extends CI_Controller { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-12 20:24:03 +08:00
										 |  |  | 	function __construct() { | 
					
						
							| 
									
										
										
										
											2023-04-12 17:58:47 +08:00
										 |  |  | 		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'); } | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-12 20:24:03 +08:00
										 |  |  |     public function index() { | 
					
						
							| 
									
										
										
										
											2023-04-12 17:58:47 +08:00
										 |  |  |         $data['page_title'] = "Export Cabrillo"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->load->model('Contesting_model'); | 
					
						
							| 
									
										
										
										
											2023-04-12 20:24:03 +08:00
										 |  |  |         $this->load->model('stations'); | 
					
						
							| 
									
										
										
										
											2023-04-12 17:58:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-12 20:24:03 +08:00
										 |  |  |         $data['station_profile'] = $this->stations->all_of_user(); | 
					
						
							|  |  |  |         $active_station_id = $this->stations->find_active(); | 
					
						
							|  |  |  |         $station_profile = $this->stations->profile($active_station_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$data['active_station_info'] = $station_profile->row(); | 
					
						
							| 
									
										
										
										
											2023-04-12 17:58:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$footerData = []; | 
					
						
							|  |  |  | 		$footerData['scripts'] = [ | 
					
						
							|  |  |  | 			'assets/js/sections/cabrillo.js' | 
					
						
							|  |  |  | 		]; | 
					
						
							|  |  |  |          | 
					
						
							|  |  |  |         $this->load->view('interface_assets/header', $data); | 
					
						
							|  |  |  | 		$this->load->view('cabrillo/index'); | 
					
						
							|  |  |  | 		$this->load->view('interface_assets/footer', $footerData); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function getContests() { | 
					
						
							|  |  |  | 		$this->load->model('Contesting_model'); | 
					
						
							| 
									
										
										
										
											2023-04-12 20:24:03 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $station_id = $this->security->xss_clean($this->input->post('station_id')); | 
					
						
							|  |  |  |         $year = $this->security->xss_clean($this->input->post('year')); | 
					
						
							|  |  |  | 		$result = $this->Contesting_model->get_logged_contests($station_id, $year); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		header('Content-Type: application/json'); | 
					
						
							|  |  |  | 		echo json_encode($result); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function getYears() { | 
					
						
							|  |  |  | 		$this->load->model('Contesting_model'); | 
					
						
							|  |  |  |         $station_id = $this->security->xss_clean($this->input->post('station_id')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$result = $this->Contesting_model->get_logged_years($station_id); | 
					
						
							| 
									
										
										
										
											2023-04-12 17:58:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		header('Content-Type: application/json'); | 
					
						
							|  |  |  | 		echo json_encode($result); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function getContestDates() { | 
					
						
							|  |  |  |         $this->load->model('Contesting_model'); | 
					
						
							| 
									
										
										
										
											2023-04-12 20:24:03 +08:00
										 |  |  |         $station_id = $this->security->xss_clean($this->input->post('station_id')); | 
					
						
							|  |  |  |         $year = $this->security->xss_clean($this->input->post('year')); | 
					
						
							|  |  |  |         $contestid = $this->security->xss_clean($this->input->post('contestid')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$result = $this->Contesting_model->get_contest_dates($station_id, $year, $contestid); | 
					
						
							| 
									
										
										
										
											2023-04-12 17:58:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		header('Content-Type: application/json'); | 
					
						
							|  |  |  | 		echo json_encode($result); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function export() { | 
					
						
							|  |  |  |         // Set memory limit to unlimited to allow heavy usage
 | 
					
						
							|  |  |  | 		ini_set('memory_limit', '-1'); | 
					
						
							|  |  |  |         $this->load->model('Contesting_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-12 20:24:03 +08:00
										 |  |  |         $this->load->model('stations'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-13 18:30:12 +08:00
										 |  |  |         $this->load->model('user_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-12 20:24:03 +08:00
										 |  |  |         $station_id = $this->security->xss_clean($this->input->post('station_id')); | 
					
						
							| 
									
										
										
										
											2023-04-12 17:58:47 +08:00
										 |  |  |         $contest_id = $this->security->xss_clean($this->input->post('contestid')); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-12 21:01:53 +08:00
										 |  |  |         $from = $this->security->xss_clean($this->input->post('contestdatesfrom')); | 
					
						
							|  |  |  |         $to = $this->security->xss_clean($this->input->post('contestdatesto')); | 
					
						
							| 
									
										
										
										
											2023-04-12 17:58:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-12 20:24:03 +08:00
										 |  |  |         $station = $this->stations->profile($station_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $station = $station->row(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-13 18:30:12 +08:00
										 |  |  |         $userinfo = $this->user_model->get_by_id($this->session->userdata('user_id')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $userinfo = $userinfo->row(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-12 20:24:03 +08:00
										 |  |  | 		$data['qsos'] = $this->Contesting_model->export_custom($from, $to, $contest_id, $station_id); | 
					
						
							| 
									
										
										
										
											2023-04-12 17:58:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $data['contest_id'] = $contest_id; | 
					
						
							| 
									
										
										
										
											2023-04-12 20:24:03 +08:00
										 |  |  |         $data['callsign'] = $station->station_callsign; | 
					
						
							| 
									
										
										
										
											2023-04-12 17:58:47 +08:00
										 |  |  |         $data['claimed_score'] = ''; | 
					
						
							| 
									
										
										
										
											2023-04-13 18:30:12 +08:00
										 |  |  |         $data['categoryoperator'] = $this->security->xss_clean($this->input->post('categoryoperator')); | 
					
						
							|  |  |  |         $data['categoryassisted'] = $this->security->xss_clean($this->input->post('categoryassisted')); | 
					
						
							|  |  |  |         $data['categoryband'] = $this->security->xss_clean($this->input->post('categoryband')); | 
					
						
							|  |  |  |         $data['categorymode'] = $this->security->xss_clean($this->input->post('categorymode')); | 
					
						
							|  |  |  |         $data['categorypower'] = $this->security->xss_clean($this->input->post('categorypower')); | 
					
						
							|  |  |  |         $data['categorystation'] = $this->security->xss_clean($this->input->post('categorystation')); | 
					
						
							|  |  |  |         $data['categorytransmitter'] = $this->security->xss_clean($this->input->post('categorytransmitter')); | 
					
						
							|  |  |  |         $data['categoryoverlay'] = $this->security->xss_clean($this->input->post('categoryoverlay')); | 
					
						
							|  |  |  |         $data['operators'] = $this->security->xss_clean($this->input->post('operators')); | 
					
						
							|  |  |  |         $data['club'] = $this->security->xss_clean($this->input->post('club')); | 
					
						
							|  |  |  |         $data['name'] = $userinfo->user_firstname . ' ' . $userinfo->user_lastname; | 
					
						
							|  |  |  |         $data['email'] = $userinfo->user_email; | 
					
						
							|  |  |  |         $data['address'] = $this->security->xss_clean($this->input->post('address')); | 
					
						
							|  |  |  |         $data['addresscity'] = $this->security->xss_clean($this->input->post('addresscity')); | 
					
						
							|  |  |  |         $data['addressstateprovince'] = $this->security->xss_clean($this->input->post('addressstateprovince')); | 
					
						
							|  |  |  |         $data['addresspostalcode'] = $this->security->xss_clean($this->input->post('addresspostalcode')); | 
					
						
							|  |  |  |         $data['addresscountry'] = $this->security->xss_clean($this->input->post('addresscountry')); | 
					
						
							|  |  |  |         $data['soapbox'] = $this->security->xss_clean($this->input->post('soapbox')); | 
					
						
							| 
									
										
										
										
											2023-04-12 20:24:03 +08:00
										 |  |  |         $data['gridlocator'] = $station->station_gridsquare; | 
					
						
							| 
									
										
										
										
											2023-04-12 17:58:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->view('cabrillo/export', $data); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |