| 
									
										
										
										
											2011-09-21 13:30:01 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class adif_data extends CI_Model { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function export_all() { | 
					
						
							| 
									
										
										
										
											2019-09-24 22:42:01 +00:00
										 |  |  |         $this->load->model('stations'); | 
					
						
							|  |  |  |         $active_station_id = $this->stations->find_active(); | 
					
						
							| 
									
										
										
										
											2020-11-23 18:52:30 +00:00
										 |  |  |         $this->db->where($this->config->item('table_name').'.station_id', $active_station_id); | 
					
						
							|  |  |  |         $this->db->order_by("COL_TIME_ON", "ASC"); | 
					
						
							|  |  |  |         $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); | 
					
						
							| 
									
										
										
										
											2011-09-21 13:30:01 +00:00
										 |  |  |         $query = $this->db->get($this->config->item('table_name')); | 
					
						
							| 
									
										
										
										
											2020-04-08 13:53:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-21 13:30:01 +00:00
										 |  |  |         return $query; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-04-08 14:36:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-22 15:16:49 +00:00
										 |  |  |     function export_printrequested($station_id = NULL) { | 
					
						
							| 
									
										
										
										
											2019-09-24 22:42:01 +00:00
										 |  |  |         $this->load->model('stations'); | 
					
						
							|  |  |  |         $active_station_id = $this->stations->find_active(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-22 15:16:49 +00:00
										 |  |  | 		if ($station_id == NULL) { | 
					
						
							|  |  |  | 			$this->db->where($this->config->item('table_name').'.station_id', $active_station_id); | 
					
						
							| 
									
										
										
										
											2021-08-24 18:10:07 +00:00
										 |  |  | 		} else if ($station_id != 'All') { | 
					
						
							| 
									
										
										
										
											2021-07-22 15:16:49 +00:00
										 |  |  | 			$this->db->where($this->config->item('table_name').'.station_id', $station_id); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-20 20:22:52 +00:00
										 |  |  |         $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); | 
					
						
							| 
									
										
										
										
											2020-05-25 21:05:21 +00:00
										 |  |  |         $this->db->where_in('COL_QSL_SENT', array('R', 'Q')); | 
					
						
							| 
									
										
										
										
											2020-12-20 20:22:52 +00:00
										 |  |  |         $this->db->order_by("COL_TIME_ON", "ASC"); | 
					
						
							| 
									
										
										
										
											2019-08-28 19:13:24 +00:00
										 |  |  |         $query = $this->db->get($this->config->item('table_name')); | 
					
						
							| 
									
										
										
										
											2020-12-20 20:22:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-28 19:13:24 +00:00
										 |  |  |         return $query; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-08 14:47:03 +00:00
										 |  |  |     function sat_all() { | 
					
						
							| 
									
										
										
										
											2019-09-24 22:42:01 +00:00
										 |  |  |         $this->load->model('stations'); | 
					
						
							|  |  |  |         $active_station_id = $this->stations->find_active(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 14:00:48 +00: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 14:36:23 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function satellte_lotw() { | 
					
						
							| 
									
										
										
										
											2019-09-24 22:42:01 +00:00
										 |  |  |         $this->load->model('stations'); | 
					
						
							|  |  |  |         $active_station_id = $this->stations->find_active(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 14:00:48 +00: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 14:36:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 14:00:48 +00:00
										 |  |  |         $where = $this->config->item('table_name').".COL_LOTW_QSLRDATE != ''"; | 
					
						
							| 
									
										
										
										
											2019-04-08 14:36:23 +00:00
										 |  |  |         $this->db->where($where); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 14:00:48 +00: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 14:36:23 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-08 13:47:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-08 19:20:05 +00:00
										 |  |  |     function export_custom($from, $to, $station_id, $exportLotw = false) { | 
					
						
							| 
									
										
										
										
											2021-11-15 18:46:20 +00:00
										 |  |  |         // be sure that station belongs to user
 | 
					
						
							|  |  |  |         $CI =& get_instance(); | 
					
						
							|  |  |  |         $CI->load->model('Stations'); | 
					
						
							|  |  |  |         if (!$CI->Stations->check_station_is_accessible($station_id)) { | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 13:47:25 +00:00
										 |  |  |         $this->db->select(''.$this->config->item('table_name').'.*, station_profile.*'); | 
					
						
							|  |  |  |         $this->db->from($this->config->item('table_name')); | 
					
						
							| 
									
										
										
										
											2021-03-08 19:20:05 +00:00
										 |  |  |         $this->db->where($this->config->item('table_name').'.station_id', $station_id); | 
					
						
							| 
									
										
										
										
											2020-02-07 13:17:05 +00: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 13:47:25 +00:00
										 |  |  |             $this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) >= '".$from."'"); | 
					
						
							| 
									
										
										
										
											2020-02-07 13:17:05 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         if ($to != 0) { | 
					
						
							|  |  |  |             $to = DateTime::createFromFormat('d/m/Y', $to); | 
					
						
							|  |  |  |             $to = $to->format('Y-m-d'); | 
					
						
							| 
									
										
										
										
											2020-04-08 13:47:25 +00:00
										 |  |  |             $this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) <= '".$to."'"); | 
					
						
							| 
									
										
										
										
											2020-02-07 13:17:05 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-06-23 07:22:37 +00:00
										 |  |  |         if ($exportLotw) { | 
					
						
							|  |  |  |             $this->db->where($this->config->item('table_name').".COL_LOTW_QSL_SENT != 'Y'"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 13:47:25 +00:00
										 |  |  |         $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC"); | 
					
						
							| 
									
										
										
										
											2011-09-21 13:30:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 13:47:25 +00:00
										 |  |  |         $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $this->db->get(); | 
					
						
							| 
									
										
										
										
											2011-09-21 13:30:01 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-03-08 19:20:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 04:57:29 +00:00
										 |  |  |     function export_lotw() { | 
					
						
							| 
									
										
										
										
											2019-09-24 22:42:01 +00:00
										 |  |  |         $this->load->model('stations'); | 
					
						
							|  |  |  |         $active_station_id = $this->stations->find_active(); | 
					
						
							| 
									
										
										
										
											2020-04-08 13:53:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-08 19:20:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 13:53:20 +00: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 04:57:29 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-03-08 19:20:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-07 05:31:19 +00:00
										 |  |  |     function mark_lotw_sent($id) { | 
					
						
							|  |  |  |        $data = array( | 
					
						
							|  |  |  |        		'COL_LOTW_QSL_SENT' => 'Y' | 
					
						
							|  |  |  |     	  ); | 
					
						
							| 
									
										
										
										
											2021-03-08 19:20:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-01 06:43:08 +00:00
										 |  |  | 		$this->db->set('COL_LOTW_QSLSDATE', 'now()', FALSE); | 
					
						
							| 
									
										
										
										
											2013-03-07 05:31:19 +00:00
										 |  |  |     	$this->db->where('COL_PRIMARY_KEY', $id); | 
					
						
							| 
									
										
										
										
											2021-03-08 19:20:05 +00:00
										 |  |  |     	$this->db->update($this->config->item('table_name'), $data); | 
					
						
							| 
									
										
										
										
											2013-03-07 05:31:19 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-03-20 10:24:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	function sig_all($type) { | 
					
						
							| 
									
										
										
										
											2021-09-09 20:29:59 +00:00
										 |  |  | 		$CI =& get_instance(); | 
					
						
							|  |  |  | 		$CI->load->model('logbooks_model'); | 
					
						
							|  |  |  | 		$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); | 
					
						
							| 
									
										
										
										
											2021-03-20 10:24:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$this->db->select(''.$this->config->item('table_name').'.*, station_profile.*'); | 
					
						
							|  |  |  | 		$this->db->from($this->config->item('table_name')); | 
					
						
							| 
									
										
										
										
											2021-09-09 20:29:59 +00:00
										 |  |  | 		$this->db->where_in($this->config->item('table_name').'.station_id', $logbooks_locations_array); | 
					
						
							| 
									
										
										
										
											2021-03-20 10:24:13 +00:00
										 |  |  | 		$this->db->where($this->config->item('table_name').'.COL_SIG', $type); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$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(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-09-21 13:30:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ?>
 |