| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class adif_data extends CI_Model { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function __construct() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // Call the Model constructor
 | 
					
						
							|  |  |  |         parent::__construct(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function export_all() { | 
					
						
							| 
									
										
										
										
											2019-09-25 06:42:01 +08:00
										 |  |  |         $this->load->model('stations'); | 
					
						
							|  |  |  |         $active_station_id = $this->stations->find_active(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->db->where('station_id', $active_station_id); | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  |         $this->db->order_by("COL_TIME_ON", "ASC");  | 
					
						
							|  |  |  |         $query = $this->db->get($this->config->item('table_name')); | 
					
						
							| 
									
										
										
										
											2020-04-08 21:53:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  |         return $query; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-04-08 22:36:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-29 03:13:24 +08:00
										 |  |  |     function export_printrequested() { | 
					
						
							| 
									
										
										
										
											2019-09-25 06:42:01 +08:00
										 |  |  |         $this->load->model('stations'); | 
					
						
							|  |  |  |         $active_station_id = $this->stations->find_active(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->db->where('station_id', $active_station_id); | 
					
						
							| 
									
										
										
										
											2020-05-26 05:05:21 +08:00
										 |  |  |         $this->db->where_in('COL_QSL_SENT', array('R', 'Q')); | 
					
						
							| 
									
										
										
										
											2019-08-29 03:13:24 +08:00
										 |  |  |         $this->db->order_by("COL_TIME_ON", "ASC");  | 
					
						
							|  |  |  |         $query = $this->db->get($this->config->item('table_name')); | 
					
						
							|  |  |  |          | 
					
						
							|  |  |  |         return $query; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-08 22:47:03 +08:00
										 |  |  |     function sat_all() { | 
					
						
							| 
									
										
										
										
											2019-09-25 06:42:01 +08:00
										 |  |  |         $this->load->model('stations'); | 
					
						
							|  |  |  |         $active_station_id = $this->stations->find_active(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 22:00:48 +08:00
										 |  |  |         $this->db->select(''.$this->config->item('table_name').'.*, station_profile.*'); | 
					
						
							|  |  |  |         $this->db->from($this->config->item('table_name')); | 
					
						
							|  |  |  |         $this->db->where($this->config->item('table_name').'.station_id', $active_station_id); | 
					
						
							|  |  |  |         $this->db->where($this->config->item('table_name').'.COL_PROP_MODE', 'SAT'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $this->db->get(); | 
					
						
							| 
									
										
										
										
											2019-04-08 22:36:23 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function satellte_lotw() { | 
					
						
							| 
									
										
										
										
											2019-09-25 06:42:01 +08:00
										 |  |  |         $this->load->model('stations'); | 
					
						
							|  |  |  |         $active_station_id = $this->stations->find_active(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 22:00:48 +08:00
										 |  |  |         $this->db->select(''.$this->config->item('table_name').'.*, station_profile.*'); | 
					
						
							|  |  |  |         $this->db->from($this->config->item('table_name')); | 
					
						
							|  |  |  |         $this->db->where($this->config->item('table_name').'.station_id', $active_station_id); | 
					
						
							|  |  |  |         $this->db->where($this->config->item('table_name').'.COL_PROP_MODE', 'SAT'); | 
					
						
							| 
									
										
										
										
											2019-04-08 22:36:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 22:00:48 +08:00
										 |  |  |         $where = $this->config->item('table_name').".COL_LOTW_QSLRDATE != ''"; | 
					
						
							| 
									
										
										
										
											2019-04-08 22:36:23 +08:00
										 |  |  |         $this->db->where($where); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 22:00:48 +08:00
										 |  |  |         $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $this->db->get(); | 
					
						
							| 
									
										
										
										
											2019-04-08 22:36:23 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2020-06-23 15:22:37 +08:00
										 |  |  |     function export_custom($from, $to, $exportLotw = false) { | 
					
						
							| 
									
										
										
										
											2019-09-25 06:42:01 +08:00
										 |  |  |         $this->load->model('stations'); | 
					
						
							|  |  |  |         $active_station_id = $this->stations->find_active(); | 
					
						
							| 
									
										
										
										
											2020-04-08 21:47:25 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $this->db->select(''.$this->config->item('table_name').'.*, station_profile.*'); | 
					
						
							|  |  |  |         $this->db->from($this->config->item('table_name')); | 
					
						
							|  |  |  |         $this->db->where($this->config->item('table_name').'.station_id', $active_station_id); | 
					
						
							| 
									
										
										
										
											2020-02-07 21:17:05 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // If date is set, we format the date and add it to the where-statement
 | 
					
						
							|  |  |  |         if ($from != 0) { | 
					
						
							|  |  |  |             $from = DateTime::createFromFormat('d/m/Y', $from); | 
					
						
							|  |  |  |             $from = $from->format('Y-m-d'); | 
					
						
							| 
									
										
										
										
											2020-04-08 21:47:25 +08:00
										 |  |  |             $this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) >= '".$from."'"); | 
					
						
							| 
									
										
										
										
											2020-02-07 21:17:05 +08:00
										 |  |  |         } | 
					
						
							|  |  |  |         if ($to != 0) { | 
					
						
							|  |  |  |             $to = DateTime::createFromFormat('d/m/Y', $to); | 
					
						
							|  |  |  |             $to = $to->format('Y-m-d'); | 
					
						
							| 
									
										
										
										
											2020-04-08 21:47:25 +08:00
										 |  |  |             $this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) <= '".$to."'"); | 
					
						
							| 
									
										
										
										
											2020-02-07 21:17:05 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-06-23 15:22:37 +08:00
										 |  |  |         if ($exportLotw) { | 
					
						
							|  |  |  |             $this->db->where($this->config->item('table_name').".COL_LOTW_QSL_SENT != 'Y'"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 21:47:25 +08:00
										 |  |  |         $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC"); | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 21:47:25 +08:00
										 |  |  |         $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $this->db->get(); | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-03-05 12:57:29 +08:00
										 |  |  |      | 
					
						
							|  |  |  |     function export_lotw() { | 
					
						
							| 
									
										
										
										
											2019-09-25 06:42:01 +08:00
										 |  |  |         $this->load->model('stations'); | 
					
						
							|  |  |  |         $active_station_id = $this->stations->find_active(); | 
					
						
							| 
									
										
										
										
											2020-04-08 21:53:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 12:57:29 +08:00
										 |  |  |          | 
					
						
							| 
									
										
										
										
											2020-04-08 21:53:20 +08:00
										 |  |  |         $this->db->select(''.$this->config->item('table_name').'.*, station_profile.*'); | 
					
						
							|  |  |  |         $this->db->from($this->config->item('table_name')); | 
					
						
							|  |  |  |         $this->db->where($this->config->item('table_name').'.station_id', $active_station_id); | 
					
						
							|  |  |  |         $this->db->where($this->config->item('table_name').".COL_LOTW_QSL_SENT != 'Y'"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $this->db->get(); | 
					
						
							| 
									
										
										
										
											2013-03-05 12:57:29 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-03-07 13:31:19 +08:00
										 |  |  |      | 
					
						
							|  |  |  |     function mark_lotw_sent($id) { | 
					
						
							|  |  |  |        $data = array( | 
					
						
							|  |  |  |        		'COL_LOTW_QSL_SENT' => 'Y' | 
					
						
							|  |  |  |     	  ); | 
					
						
							| 
									
										
										
										
											2013-03-09 08:25:47 +08:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2020-04-01 14:43:08 +08:00
										 |  |  | 		$this->db->set('COL_LOTW_QSLSDATE', 'now()', FALSE); | 
					
						
							| 
									
										
										
										
											2013-03-07 13:31:19 +08:00
										 |  |  |     	$this->db->where('COL_PRIMARY_KEY', $id); | 
					
						
							|  |  |  |     	$this->db->update($this->config->item('table_name'), $data);  | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ?>
 |