| 
									
										
										
										
											2023-10-30 19:15:08 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Setup_model extends CI_Model { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function getCountryCount() { | 
					
						
							| 
									
										
										
										
											2023-10-31 15:29:12 +08:00
										 |  |  | 		$sql = 'select count(*) as count from dxcc_entities'; | 
					
						
							|  |  |  | 		$query = $this->db->query($sql); | 
					
						
							| 
									
										
										
										
											2023-10-30 19:15:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-31 15:29:12 +08:00
										 |  |  | 		return $query->row()->count; | 
					
						
							| 
									
										
										
										
											2023-10-30 19:15:08 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function getLogbookCount() { | 
					
						
							|  |  |  | 		$userid = xss_clean($this->session->userdata('user_id')); | 
					
						
							| 
									
										
										
										
											2023-10-31 15:29:12 +08:00
										 |  |  | 		$sql = 'select count(*) as count from station_logbooks where user_id =' . $userid; | 
					
						
							|  |  |  | 		$query = $this->db->query($sql); | 
					
						
							| 
									
										
										
										
											2023-10-30 19:15:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-31 15:29:12 +08:00
										 |  |  | 		return $query->row()->count; | 
					
						
							| 
									
										
										
										
											2023-10-30 19:15:08 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function getLocationCount() { | 
					
						
							|  |  |  | 		$userid = xss_clean($this->session->userdata('user_id')); | 
					
						
							| 
									
										
										
										
											2023-10-31 15:29:12 +08:00
										 |  |  | 		$sql = 'select count(*) as count from station_profile where user_id =' . $userid; | 
					
						
							|  |  |  | 		$query = $this->db->query($sql); | 
					
						
							| 
									
										
										
										
											2023-10-30 19:15:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-31 15:29:12 +08:00
										 |  |  | 		return $query->row()->count; | 
					
						
							| 
									
										
										
										
											2023-10-30 19:15:08 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2025-08-10 04:24:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Consolidated method to get all setup counts in one query
 | 
					
						
							|  |  |  | 	function getAllSetupCounts() { | 
					
						
							|  |  |  | 		$userid = xss_clean($this->session->userdata('user_id')); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		$sql = "SELECT 
 | 
					
						
							|  |  |  | 			(SELECT COUNT(*) FROM dxcc_entities) as country_count, | 
					
						
							|  |  |  | 			(SELECT COUNT(*) FROM station_logbooks WHERE user_id = {$userid}) as logbook_count, | 
					
						
							|  |  |  | 			(SELECT COUNT(*) FROM station_profile WHERE user_id = {$userid}) as location_count";
 | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		$query = $this->db->query($sql); | 
					
						
							|  |  |  | 		$row = $query->row(); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		return array( | 
					
						
							|  |  |  | 			'country_count' => $row->country_count, | 
					
						
							|  |  |  | 			'logbook_count' => $row->logbook_count, | 
					
						
							|  |  |  | 			'location_count' => $row->location_count | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2023-10-30 19:15:08 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ?>
 |