| 
									
										
										
										
											2011-07-25 06:33:08 +08:00
										 |  |  | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Statistics extends CI_Controller { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public function index() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2011-08-20 01:24:56 +08:00
										 |  |  |         $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'); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2022-09-18 22:48:16 +08:00
										 |  |  |         }	 | 
					
						
							| 
									
										
										
										
											2019-05-14 00:37:01 +08:00
										 |  |  | 		// Render User Interface
 | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-14 00:37:01 +08:00
										 |  |  | 		// Set Page Title
 | 
					
						
							|  |  |  | 		$data['page_title'] = "Statistics"; | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		// Load Views
 | 
					
						
							|  |  |  | 		$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 		$this->load->view('statistics/index'); | 
					
						
							| 
									
										
										
										
											2019-05-14 00:37:01 +08:00
										 |  |  | 		$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2011-07-25 06:33:08 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-04-05 05:43:20 +08:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	function custom() { | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	    $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'); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2017-04-22 01:46:26 +08:00
										 |  |  | 	    $this->load->model('logbook_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-05 05:43:20 +08:00
										 |  |  | 		$data['page_title'] = "Custom Statistics"; | 
					
						
							| 
									
										
										
										
											2017-04-22 01:46:26 +08:00
										 |  |  | 		$data['modes'] = $this->logbook_model->get_modes(); | 
					
						
							| 
									
										
										
										
											2012-04-05 05:43:20 +08:00
										 |  |  | 	 | 
					
						
							|  |  |  | 		$this->load->helper(array('form', 'url')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->library('form_validation'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-24 00:35:19 +08:00
										 |  |  | 		$this->form_validation->set_rules('start_date', 'Start Date', 'required'); | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('end_date', 'End Date', 'required'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-05 05:43:20 +08:00
										 |  |  | 		if ($this->form_validation->run() == FALSE) | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2019-05-14 00:37:01 +08:00
										 |  |  | 			$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2017-04-22 01:46:26 +08:00
										 |  |  | 			$this->load->view('statistics/custom', $data); | 
					
						
							| 
									
										
										
										
											2019-05-14 00:37:01 +08:00
										 |  |  | 			$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2012-04-05 05:43:20 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2012-04-24 00:35:19 +08:00
										 |  |  | 		 | 
					
						
							|  |  |  | 			$this->load->model('stats'); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 			$data['result'] = $this->stats->result(); | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2019-05-14 00:37:01 +08:00
										 |  |  | 			$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2012-04-24 00:35:19 +08:00
										 |  |  | 			$this->load->view('statistics/custom_result'); | 
					
						
							| 
									
										
										
										
											2019-05-14 00:37:01 +08:00
										 |  |  | 			$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2012-04-05 05:43:20 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-09-18 22:48:16 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	public function get_year() { | 
					
						
							|  |  |  | 		$this->load->model('logbook_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// get data
 | 
					
						
							|  |  |  | 		$totals_year = $this->logbook_model->totals_year(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$yearstats = array(); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		$i = 0; | 
					
						
							|  |  |  | 		if ($totals_year) { | 
					
						
							|  |  |  | 			foreach($totals_year->result() as $qso_numbers) { | 
					
						
							|  |  |  | 				$yearstats[$i]['year'] = $qso_numbers->year; | 
					
						
							|  |  |  | 				$yearstats[$i++]['total'] = $qso_numbers->total; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		header('Content-Type: application/json'); | 
					
						
							|  |  |  | 		echo json_encode($yearstats); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public function get_mode() { | 
					
						
							|  |  |  | 		$this->load->model('logbook_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$modestats = array(); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		$i = 0; | 
					
						
							|  |  |  | 		$modestats[$i]['mode'] = 'ssb'; | 
					
						
							|  |  |  | 		$modestats[$i++]['total'] = $this->logbook_model->total_ssb(); | 
					
						
							|  |  |  | 		$modestats[$i]['mode'] = 'cw'; | 
					
						
							|  |  |  | 		$modestats[$i++]['total'] = $this->logbook_model->total_cw(); | 
					
						
							|  |  |  | 		$modestats[$i]['mode'] = 'fm'; | 
					
						
							|  |  |  | 		$modestats[$i++]['total'] = $this->logbook_model->total_fm(); | 
					
						
							|  |  |  | 		$modestats[$i]['mode'] = 'digi'; | 
					
						
							|  |  |  | 		$modestats[$i]['total'] = $this->logbook_model->total_digi(); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		header('Content-Type: application/json'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		echo json_encode($modestats); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public function get_band() { | 
					
						
							|  |  |  | 		$this->load->model('logbook_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$bandstats = array(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$total_bands = $this->logbook_model->total_bands(); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		$i = 0; | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		if ($total_bands) { | 
					
						
							|  |  |  | 			foreach($total_bands->result() as $qso_numbers) { | 
					
						
							|  |  |  | 				$bandstats[$i]['band'] = $qso_numbers->band; | 
					
						
							|  |  |  | 				$bandstats[$i++]['count'] = $qso_numbers->count; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		header('Content-Type: application/json'); | 
					
						
							|  |  |  | 		echo json_encode($bandstats); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public function get_sat() { | 
					
						
							|  |  |  | 		$this->load->model('logbook_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$satstats = array(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$total_sat = $this->logbook_model->total_sat(); | 
					
						
							|  |  |  | 		$i = 0; | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		if ($total_sat) { | 
					
						
							|  |  |  | 			foreach($total_sat->result() as $qso_numbers) { | 
					
						
							|  |  |  | 				$satstats[$i]['sat'] = $qso_numbers->COL_SAT_NAME; | 
					
						
							|  |  |  | 				$satstats[$i++]['count'] = $qso_numbers->count; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		header('Content-Type: application/json'); | 
					
						
							|  |  |  | 		echo json_encode($satstats); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-08-20 01:24:56 +08:00
										 |  |  | } |