| 
									
										
										
										
											2020-10-29 06:20:03 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | class Qsl_model extends CI_Model { | 
					
						
							|  |  |  |     function __construct() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // Call the Model constructor
 | 
					
						
							|  |  |  |         parent::__construct(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function getQsoWithQslList() { | 
					
						
							|  |  |  |         $CI =& get_instance(); | 
					
						
							|  |  |  |         $CI->load->model('Stations'); | 
					
						
							|  |  |  |         $station_id = $CI->Stations->find_active(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->db->select('*'); | 
					
						
							|  |  |  |         $this->db->from($this->config->item('table_name')); | 
					
						
							|  |  |  |         $this->db->join('qsl_images', 'qsl_images.qsoid = ' . $this->config->item('table_name') . '.col_primary_key'); | 
					
						
							|  |  |  |         $this->db->where('station_id', $station_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $this->db->get(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function getQslForQsoId($id) { | 
					
						
							|  |  |  |         // Clean ID
 | 
					
						
							|  |  |  |         $clean_id = $this->security->xss_clean($id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->db->select('*'); | 
					
						
							|  |  |  |         $this->db->from('qsl_images'); | 
					
						
							|  |  |  |         $this->db->where('qsoid', $clean_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $this->db->get()->result(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function saveQsl($qsoid, $filename) { | 
					
						
							|  |  |  |         $data = array( | 
					
						
							|  |  |  |             'qsoid' => $qsoid, | 
					
						
							|  |  |  |             'filename' => $filename | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->db->insert('qsl_images', $data); | 
					
						
							| 
									
										
										
										
											2020-11-01 19:36:02 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return $this->db->insert_id(); | 
					
						
							| 
									
										
										
										
											2020-10-29 06:20:03 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function deleteQsl($id) { | 
					
						
							|  |  |  |         // Clean ID
 | 
					
						
							|  |  |  |         $clean_id = $this->security->xss_clean($id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // Delete Mode
 | 
					
						
							|  |  |  |         $this->db->delete('qsl_images', array('id' => $clean_id)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function getFilename($id) { | 
					
						
							|  |  |  |         // Clean ID
 | 
					
						
							|  |  |  |         $clean_id = $this->security->xss_clean($id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->db->select('filename'); | 
					
						
							|  |  |  |         $this->db->from('qsl_images'); | 
					
						
							|  |  |  |         $this->db->where('id', $clean_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $this->db->get(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |