| 
									
										
										
										
											2020-10-05 03:41:01 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | defined('BASEPATH') OR exit('No direct script access allowed'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Accumulated 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
 | 
					
						
							|  |  |  |         $data['page_title'] = "Accumulated statistics"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->load->model('Accumulate_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $data['worked_bands'] = $this->Accumulate_model->get_worked_bands(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-08 17:45:41 +08:00
										 |  |  |         $this->load->model('modes'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $data['modes'] = $this->modes->active(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-05 03:41:01 +08:00
										 |  |  |         $this->load->view('interface_assets/header', $data); | 
					
						
							|  |  |  |         $this->load->view('accumulate/index'); | 
					
						
							|  |  |  |         $this->load->view('interface_assets/footer'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 03:12:14 +08:00
										 |  |  |     /* | 
					
						
							|  |  |  |      * Used for ajax-call in javascript to fetch the data and insert into table and chart | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function get_accumulated_data(){ | 
					
						
							|  |  |  |         //load model
 | 
					
						
							|  |  |  |         $this->load->model('accumulate_model'); | 
					
						
							|  |  |  |         $band = $this->input->post('Band'); | 
					
						
							|  |  |  |         $award = $this->input->post('Award'); | 
					
						
							| 
									
										
										
										
											2020-10-08 17:45:41 +08:00
										 |  |  |         $mode = $this->input->post('Mode'); | 
					
						
							|  |  |  |         $period = $this->input->post('Period'); | 
					
						
							| 
									
										
										
										
											2020-10-07 03:12:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // get data
 | 
					
						
							| 
									
										
										
										
											2020-10-08 17:45:41 +08:00
										 |  |  |         $data = $this->accumulate_model->get_accumulated_data($band, $award, $mode, $period); | 
					
						
							| 
									
										
										
										
											2020-10-07 03:12:14 +08:00
										 |  |  |         header('Content-Type: application/json'); | 
					
						
							|  |  |  |         echo json_encode($data); | 
					
						
							| 
									
										
										
										
											2020-10-05 03:41:01 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |