| 
									
										
										
										
											2019-08-29 03:13:24 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Qslprint_model extends CI_Model { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 19:28:50 +08:00
										 |  |  | 	function __construct() | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		parent::__construct(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-22 23:16:49 +08:00
										 |  |  | 	function mark_qsos_printed($station_id2 = NULL) { | 
					
						
							| 
									
										
										
										
											2019-09-28 05:04:49 +08:00
										 |  |  | 		$CI =& get_instance(); | 
					
						
							|  |  |  | 		$CI->load->model('Stations'); | 
					
						
							|  |  |  | 		$station_id = $CI->Stations->find_active(); | 
					
						
							| 
									
										
										
										
											2021-05-08 16:29:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-29 03:13:24 +08:00
										 |  |  | 		$data = array( | 
					
						
							|  |  |  | 	        'COL_QSLSDATE' => date('Y-m-d'), | 
					
						
							|  |  |  | 	        'COL_QSL_SENT' => "Y", | 
					
						
							|  |  |  | 	        'COL_QSL_SENT_VIA' => "B", | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-26 05:05:21 +08:00
										 |  |  | 		$this->db->where_in("COL_QSL_SENT", array("R","Q")); | 
					
						
							| 
									
										
										
										
											2021-07-22 23:16:49 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if ($station_id2 == NULL) { | 
					
						
							|  |  |  | 			$this->db->where("station_id", $station_id); | 
					
						
							| 
									
										
										
										
											2021-09-04 15:42:46 +08:00
										 |  |  | 		} else if ($station_id2 != 'All') { | 
					
						
							| 
									
										
										
										
											2021-07-22 23:16:49 +08:00
										 |  |  | 			$this->db->where("station_id", $station_id2); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-29 03:13:24 +08:00
										 |  |  | 		$this->db->update($this->config->item('table_name'), $data); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-05-08 16:29:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-22 23:16:49 +08:00
										 |  |  | 	/* | 
					
						
							|  |  |  | 	 * We list out the QSL's ready for print. | 
					
						
							|  |  |  | 	 * station_id is not provided when loading page. | 
					
						
							|  |  |  | 	 * It will be provided when calling the function when the dropdown is changed and the javascript fires | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	function get_qsos_for_print($station_id = 'All') { | 
					
						
							|  |  |  | 		if ($station_id != 'All') { | 
					
						
							|  |  |  | 			$this->db->where($this->config->item('table_name').'.station_id', $station_id); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2021-05-08 16:29:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); | 
					
						
							|  |  |  | 		$this->db->where_in('COL_QSL_SENT', array('R', 'Q')); | 
					
						
							|  |  |  | 		$this->db->order_by("COL_TIME_ON", "ASC"); | 
					
						
							|  |  |  | 		$query = $this->db->get($this->config->item('table_name')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return $query; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-05-22 14:45:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-22 23:16:49 +08:00
										 |  |  | 	function get_qsos_for_print_ajax($station_id) { | 
					
						
							|  |  |  | 		$query = $this->get_qsos_for_print($station_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return $query; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-05-22 14:45:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-22 23:16:49 +08:00
										 |  |  | 	function delete_from_qsl_queue($id) { | 
					
						
							| 
									
										
										
										
											2021-05-22 14:45:24 +08:00
										 |  |  | 		$data = array( | 
					
						
							|  |  |  | 			'COL_QSL_SENT' => "N", | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->db->where("COL_PRIMARY_KEY", $id); | 
					
						
							|  |  |  | 		$this->db->update($this->config->item('table_name'), $data); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-07-28 17:10:15 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	function add_qso_to_print_queue($id) { | 
					
						
							|  |  |  | 		$data = array( | 
					
						
							|  |  |  | 			'COL_QSL_SENT' => "R", | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->db->where("COL_PRIMARY_KEY", $id); | 
					
						
							|  |  |  | 		$this->db->update($this->config->item('table_name'), $data); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function open_qso_list($callsign) { | 
					
						
							|  |  |  | 		$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); | 
					
						
							|  |  |  | 		$this->db->where('COL_CALL like "%'.$callsign.'%"'); | 
					
						
							|  |  |  | 		$this->db->where('coalesce(COL_QSL_SENT, "") not in ("R", "Q")'); | 
					
						
							|  |  |  | 		$this->db->order_by("COL_TIME_ON", "ASC"); | 
					
						
							|  |  |  | 		$query = $this->db->get($this->config->item('table_name')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return $query; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-29 03:13:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-08 16:29:47 +08:00
										 |  |  | ?>
 |