| 
									
										
										
										
											2020-08-14 00:24:07 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class LotwCert extends CI_Model { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function __construct() | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		// Call the Model constructor
 | 
					
						
							|  |  |  | 		parent::__construct(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-14 00:28:22 +08:00
										 |  |  | 	/* | 
					
						
							|  |  |  | 	|-------------------------------------------------------------------------- | 
					
						
							|  |  |  | 	| Function: lotw_certs | 
					
						
							|  |  |  | 	|-------------------------------------------------------------------------- | 
					
						
							|  |  |  | 	|  | 
					
						
							|  |  |  | 	| Returns all lotw_certs for a selected user via the $user_id parameter | 
					
						
							|  |  |  | 	| | 
					
						
							|  |  |  | 	*/ | 
					
						
							| 
									
										
										
										
											2020-08-14 00:24:07 +08:00
										 |  |  | 	function lotw_certs($user_id) { | 
					
						
							|  |  |  | 		$this->db->where('user_id', $user_id); | 
					
						
							| 
									
										
										
										
											2020-08-18 00:02:54 +08:00
										 |  |  | 		$this->db->group_by("callsign"); | 
					
						
							|  |  |  | 		$this->db->order_by('cert_dxcc', 'ASC'); | 
					
						
							| 
									
										
										
										
											2020-08-14 00:24:07 +08:00
										 |  |  | 		$query = $this->db->get('lotw_certs'); | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 		return $query; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-08-18 00:02:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-25 22:53:20 +08:00
										 |  |  | 	function lotw_cert_details($callsign) { | 
					
						
							| 
									
										
										
										
											2020-08-23 05:26:04 +08:00
										 |  |  | 		$this->db->where('callsign', $callsign); | 
					
						
							|  |  |  | 		$query = $this->db->get('lotw_certs'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return $query->row(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-18 00:02:54 +08:00
										 |  |  | 	function find_cert($callsign, $user_id) { | 
					
						
							|  |  |  | 		$this->db->where('user_id', $user_id); | 
					
						
							|  |  |  | 		$this->db->where('callsign', $callsign); | 
					
						
							|  |  |  | 		$query = $this->db->get('lotw_certs'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return $query->num_rows(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function store_certficiate($user_id, $callsign, $dxcc, $date_created, $date_expires, $cert_key) { | 
					
						
							|  |  |  | 		$data = array( | 
					
						
							|  |  |  | 		    'user_id' => $user_id, | 
					
						
							|  |  |  | 		    'callsign' => $callsign, | 
					
						
							|  |  |  | 		    'cert_dxcc' => $dxcc, | 
					
						
							|  |  |  | 		    'date_created' => $date_created, | 
					
						
							|  |  |  | 		    'date_expires' => $date_expires, | 
					
						
							|  |  |  | 		    'cert_key' => $cert_key, | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->db->insert('lotw_certs', $data); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function update_certficiate($user_id, $callsign, $dxcc, $date_created, $date_expires, $cert_key) { | 
					
						
							|  |  |  | 		$data = array( | 
					
						
							|  |  |  | 		    'cert_dxcc' => $dxcc, | 
					
						
							|  |  |  | 		    'date_created' => $date_created, | 
					
						
							|  |  |  | 		    'date_expires' => $date_expires, | 
					
						
							|  |  |  | 		    'cert_key' => $cert_key, | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->db->where('user_id', $user_id); | 
					
						
							|  |  |  | 		$this->db->where('callsign', $callsign); | 
					
						
							|  |  |  | 		$this->db->update('lotw_certs', $data); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function delete_certficiate($user_id, $lotw_cert_id) { | 
					
						
							|  |  |  | 		$this->db->where('lotw_cert_id', $lotw_cert_id); | 
					
						
							|  |  |  | 		$this->db->where('user_id', $user_id); | 
					
						
							|  |  |  | 		$this->db->delete('lotw_certs'); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-08-14 00:24:07 +08:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	function empty_table($table) { | 
					
						
							|  |  |  | 		$this->db->empty_table($table);  | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ?>
 |