2011-06-17 20:52:00 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								class  DXCC  extends  CI_Model  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/** 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									* 	Function :  mostactive 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									* 	Information :  Returns  the  most  active  band 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									**/ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  info ( $callsign ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$exceptions  =  $this -> db -> query ( ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												SELECT  * 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 05:26:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												FROM  `dxcc_exceptions` 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-17 20:52:00 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												WHERE  `prefix`  =  \ '' . $callsign . ' \ ' 
							 
						 
					
						
							
								
									
										
										
										
											2014-09-26 06:09:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												LIMIT  1 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-17 20:52:00 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											' ); 
							 
						 
					
						
							
								
									
										
										
										
											2014-09-26 06:09:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-06-17 20:52:00 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  ( $exceptions -> num_rows ()  >  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  $exceptions ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-09-26 06:09:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-06-17 20:52:00 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											$query  =  $this -> db -> query ( ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													SELECT  * 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-25 00:34:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													FROM  dxcc_entities 
							 
						 
					
						
							
								
									
										
										
										
											2014-09-26 06:09:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													WHERE  prefix  =  SUBSTRING (  \ '' . $callsign . ' \ ' ,  1 ,  LENGTH (  prefix  )  ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-17 20:52:00 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
													ORDER  BY  LENGTH (  prefix  )  DESC 
							 
						 
					
						
							
								
									
										
										
										
											2014-09-26 06:09:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													LIMIT  1 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-17 20:52:00 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												' ); 
							 
						 
					
						
							
								
									
										
										
										
											2014-09-26 06:09:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-06-17 20:52:00 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-09-26 06:09:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 01:46:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    function  search (){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        print_r ( $this -> input -> get ()); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-11-20 06:24:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  empty_table ( $table )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-09-26 06:09:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> db -> empty_table ( $table ); 
							 
						 
					
						
							
								
									
										
										
										
											2012-11-20 06:24:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-02 03:14:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-17 02:02:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									/* 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 *  Fetches  a  list  of  all  dxcc ' s ,  both  current  and  deleted 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-17 02:02:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 */ 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-02 03:14:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  list ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> order_by ( 'name' ,  'ASC' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $this -> db -> get ( 'dxcc_entities' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-17 02:02:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									/* 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  Fetches  a  list  of  all  current  dxcc ' s  ( non - deleted ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  list_current ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> where ( 'end' ,  null ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> order_by ( 'name' ,  'ASC' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $this -> db -> get ( 'dxcc_entities' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  get_dxcc_array ( $dxccArray ,  $bands ,  $postdata )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$CI  =&  get_instance (); 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$CI -> load -> model ( 'logbooks_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$logbooks_locations_array  =  $CI -> logbooks_model -> list_logbook_relationships ( $this -> session -> userdata ( 'active_station_logbook' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-15 00:11:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( ! $logbooks_locations_array )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$location_list  =  " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-18 20:51:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$qsl  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'confirmed' ]  !=  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( $postdata [ 'qsl' ]  !=  NULL  )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$qsl  .=  " Q " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( $postdata [ 'lotw' ]  !=  NULL  )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$qsl  .=  " L " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( $postdata [ 'eqsl' ]  !=  NULL  )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$qsl  .=  " E " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										foreach  ( $bands  as  $band )  {              	// Looping through bands and entities to generate the array needed for display
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											foreach  ( $dxccArray  as  $dxcc )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 18:18:40 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$dxccMatrix [ $dxcc -> adif ][ 'name' ]  =  ucwords ( strtolower ( $dxcc -> name ),  " - (/ " ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$dxccMatrix [ $dxcc -> adif ][ 'Dxccprefix' ]  =  $dxcc -> prefix ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 00:09:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  ( $postdata [ 'includedeleted' ]) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-14 22:00:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													$dxccMatrix [ $dxcc -> adif ][ 'Deleted' ]  =  isset ( $dxcc -> Enddate )  ?  1  :  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$dxccMatrix [ $dxcc -> adif ][ $band ]  =  '-' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// If worked is checked, we add worked entities to the array
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( $postdata [ 'worked' ]  !=  NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$workedDXCC  =  $this -> getDxccBandWorked ( $location_list ,  $band ,  $postdata ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												foreach  ( $workedDXCC  as  $wdxcc )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-26 06:54:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													$dxccMatrix [ $wdxcc -> dxcc ][ $band ]  =  '<div class="bg-danger awardsBgDanger" ><a href=\'javascript:displayContacts("' . str_replace ( " & " ,  " %26 " ,  $wdxcc -> name ) . '","' .  $band  .  '","' .  $postdata [ 'mode' ]  .  '","DXCC", "")\'>W</a></div>' ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// If confirmed is checked, we add confirmed entities to the array
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( $postdata [ 'confirmed' ]  !=  NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$confirmedDXCC  =  $this -> getDxccBandConfirmed ( $location_list ,  $band ,  $postdata ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												foreach  ( $confirmedDXCC  as  $cdxcc )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-26 06:54:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													$dxccMatrix [ $cdxcc -> dxcc ][ $band ]  =  '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . str_replace ( " & " ,  " %26 " ,  $cdxcc -> name ) . '","' .  $band  .  '","' .  $postdata [ 'mode' ]  .  '","DXCC","' . $qsl . '")\'>C</a></div>' ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// We want to remove the worked dxcc's in the list, since we do not want to display them
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'worked' ]  ==  NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$workedDxcc  =  $this -> getDxccWorked ( $location_list ,  $postdata ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											foreach  ( $workedDxcc  as  $wdxcc )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( array_key_exists ( $wdxcc -> dxcc ,  $dxccMatrix ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													unset ( $dxccMatrix [ $wdxcc -> dxcc ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// We want to remove the confirmed dxcc's in the list, since we do not want to display them
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'confirmed' ]  ==  NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$confirmedDxcc  =  $this -> getDxccConfirmed ( $location_list ,  $postdata ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											foreach  ( $confirmedDxcc  as  $cdxcc )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( array_key_exists ( $cdxcc -> dxcc ,  $dxccMatrix ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													unset ( $dxccMatrix [ $cdxcc -> dxcc ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-05 22:16:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( isset ( $dxccMatrix ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  $dxccMatrix ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  getDxccBandConfirmed ( $location_list ,  $band ,  $postdata )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  =  " select adif as dxcc, name from dxcc_entities
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												join  ( 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 22:50:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													select  col_dxcc  from  " . $this->config ->item('table_name'). "  thcv 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													where  station_id  in  ( "  .  $location_list  .
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												  " ) and col_dxcc > 0 " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-12 02:23:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  $this -> addBandToQuery ( $band ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-13 16:18:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'mode' ]  !=  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and (col_mode = ' "  .  $postdata [ 'mode' ]  .  " ' or col_submode = ' "  .  $postdata [ 'mode' ]  .  " ') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  $this -> addQslToQuery ( $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  "  group by col_dxcc
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												)  x  on  dxcc_entities . adif  =  x . col_dxcc " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-05 22:48:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'includedeleted' ]  ==  NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$sql  .=  "  and dxcc_entities.end is null " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  $this -> addContinentsToQuery ( $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> result (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  getDxccBandWorked ( $location_list ,  $band ,  $postdata )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  =  " select adif as dxcc, name from dxcc_entities
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												join  ( 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 22:50:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													select  col_dxcc  from  " . $this->config ->item('table_name'). "  thcv 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													where  station_id  in  ( "  .  $location_list  .
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													" ) and col_dxcc > 0 " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-12 02:23:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  $this -> addBandToQuery ( $band ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-13 16:18:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'mode' ]  !=  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and (col_mode = ' "  .  $postdata [ 'mode' ]  .  " ' or col_submode = ' "  .  $postdata [ 'mode' ]  .  " ') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  "  group by col_dxcc
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												)  x  on  dxcc_entities . adif  =  x . col_dxcc " ;;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-05 22:48:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'includedeleted' ]  ==  NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$sql  .=  "  and dxcc_entities.end is null " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  $this -> addContinentsToQuery ( $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> result (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-12 02:23:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  addBandToQuery ( $band )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  =  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( $band  !=  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( $band  ==  'SAT' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $sql  .=  "  and col_prop_mode =' "  .  $band  .  " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $sql  .=  "  and col_prop_mode !='SAT' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $sql  .=  "  and col_band =' "  .  $band  .  " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  $sql ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  fetchDxcc ( $postdata )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$CI  =&  get_instance (); 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$CI -> load -> model ( 'logbooks_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$logbooks_locations_array  =  $CI -> logbooks_model -> list_logbook_relationships ( $this -> session -> userdata ( 'active_station_logbook' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-15 00:11:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( ! $logbooks_locations_array )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$location_list  =  " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-12 02:23:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  =  " select adif, prefix, name, date(end) Enddate, date(start) Startdate, lat, `long`
 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            from  dxcc_entities " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'notworked' ]  ==  NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$sql  .=  "  join (select col_dxcc from  "  .  $this -> config -> item ( 'table_name' )  .  "  where station_id in ( "  .  $location_list  .  " ) and col_dxcc > 0 " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( $postdata [ 'band' ]  !=  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( $postdata [ 'band' ]  ==  'SAT' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													$sql  .=  "  and col_prop_mode =' "  .  $postdata [ 'band' ]  .  " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												else  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-21 14:53:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													$sql  .=  "  and col_prop_mode !='SAT' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													$sql  .=  "  and col_band =' "  .  $postdata [ 'band' ]  .  " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-13 16:18:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( $postdata [ 'mode' ]  !=  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$sql  .=  "  and (col_mode = ' "  .  $postdata [ 'mode' ]  .  " ' or col_submode = ' "  .  $postdata [ 'mode' ]  .  " ') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$sql  .=  ' group by col_dxcc) x on dxcc_entities.adif = x.col_dxcc' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  "  where 1 = 1 " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-05 22:48:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'includedeleted' ]  ==  NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$sql  .=  "  and end is null " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  $this -> addContinentsToQuery ( $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  ' order by prefix' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> result (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  getDxccWorked ( $location_list ,  $postdata )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  =  " SELECT adif as dxcc FROM dxcc_entities
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        join  ( 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-24 20:31:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            select  col_dxcc 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 22:50:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            from  " . $this->config ->item('table_name'). "  thcv 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            where  station_id  in  ( "  .  $location_list  .
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              " ) and col_dxcc > 0 " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-12 02:23:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  $this -> addBandToQuery ( $postdata [ 'band' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-13 16:18:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'mode' ]  !=  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and (col_mode = ' "  .  $postdata [ 'mode' ]  .  " ' or col_submode = ' "  .  $postdata [ 'mode' ]  .  " ') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  "  and not exists (select 1 from  " . $this -> config -> item ( 'table_name' ) . "  where station_id in ( " .  $location_list  . " ) and col_dxcc = thcv.col_dxcc and col_dxcc > 0 " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-12 02:23:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  $this -> addBandToQuery ( $postdata [ 'band' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-13 16:18:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'mode' ]  !=  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and (col_mode = ' "  .  $postdata [ 'mode' ]  .  " ' or col_submode = ' "  .  $postdata [ 'mode' ]  .  " ') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  $this -> addQslToQuery ( $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  ')' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  "  group by col_dxcc
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            )  ll  on  dxcc_entities . adif  =  ll . col_dxcc 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            where  1 = 1 " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-31 21:05:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'includedeleted' ]  ==  NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$sql  .=  "  and dxcc_entities.end is null " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  $this -> addContinentsToQuery ( $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> result (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  getDxccConfirmed ( $location_list ,  $postdata )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  =  " SELECT adif as dxcc FROM dxcc_entities
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            join  ( 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-24 20:31:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                select  col_dxcc 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 22:50:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                from  " . $this->config ->item('table_name'). "  thcv 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                where  station_id  in  ( " .  $location_list  .
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ) and col_dxcc > 0 " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-12 02:23:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  $this -> addBandToQuery ( $postdata [ 'band' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-13 16:18:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'mode' ]  !=  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and (col_mode = ' "  .  $postdata [ 'mode' ]  .  " ' or col_submode = ' "  .  $postdata [ 'mode' ]  .  " ') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  $this -> addQslToQuery ( $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  "  group by col_dxcc
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            )  ll  on  dxcc_entities . adif  =  ll . col_dxcc 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            where  1 = 1 " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-31 21:05:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'includedeleted' ]  ==  NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$sql  .=  "  and dxcc_entities.end is null " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  $this -> addContinentsToQuery ( $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> result (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Made function instead of repeating this several times
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  addQslToQuery ( $postdata )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  '' ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-18 20:51:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$qsl  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'lotw' ]  !=  NULL  ||  $postdata [ 'qsl' ]  !=  NULL  ||  $postdata [ 'eqsl' ]  !=  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  ' and (' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( $postdata [ 'qsl' ]  !=  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												array_push ( $qsl ,  " col_qsl_rcvd = 'Y' " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( $postdata [ 'lotw' ]  !=  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												array_push ( $qsl ,  " col_lotw_qsl_rcvd = 'Y' " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( $postdata [ 'eqsl' ]  !=  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												array_push ( $qsl ,  " col_eqsl_qsl_rcvd = 'Y' " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  implode ( ' or ' ,  $qsl ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  ')' ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-03 19:39:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $sql ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Made function instead of repeating this several times
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  addContinentsToQuery ( $postdata )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'Africa' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and cont <> 'AF' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'Europe' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and cont <> 'EU' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'Asia' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and cont <> 'AS' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'SouthAmerica' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and cont <> 'SA' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'NorthAmerica' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and cont <> 'NA' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'Oceania' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and cont <> 'OC' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'Antarctica' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and cont <> 'AN' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $sql ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-24 20:31:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									/* 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  Function  gets  worked  and  confirmed  summary  on  each  band  on  the  active  stationprofile 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */ 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-31 21:05:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  get_dxcc_summary ( $bands ,  $postdata ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$CI  =&  get_instance (); 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$CI -> load -> model ( 'logbooks_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$logbooks_locations_array  =  $CI -> logbooks_model -> list_logbook_relationships ( $this -> session -> userdata ( 'active_station_logbook' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-15 00:11:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( ! $logbooks_locations_array )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$location_list  =  " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-25 22:53:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										foreach  ( $bands  as  $band )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-31 21:05:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$worked  =  $this -> getSummaryByBand ( $band ,  $postdata ,  $location_list ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$confirmed  =  $this -> getSummaryByBandConfirmed ( $band ,  $postdata ,  $location_list ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$dxccSummary [ 'worked' ][ $band ]  =  $worked [ 0 ] -> count ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$dxccSummary [ 'confirmed' ][ $band ]  =  $confirmed [ 0 ] -> count ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-31 21:05:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$workedTotal  =  $this -> getSummaryByBand ( $postdata [ 'band' ],  $postdata ,  $location_list ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$confirmedTotal  =  $this -> getSummaryByBandConfirmed ( $postdata [ 'band' ],  $postdata ,  $location_list ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-14 19:03:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$dxccSummary [ 'worked' ][ 'Total' ]  =  $workedTotal [ 0 ] -> count ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$dxccSummary [ 'confirmed' ][ 'Total' ]  =  $confirmedTotal [ 0 ] -> count ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $dxccSummary ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-31 21:05:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  getSummaryByBand ( $band ,  $postdata ,  $location_list ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT count(distinct thcv.col_dxcc) as count FROM  "  .  $this -> config -> item ( 'table_name' )  .  "  thcv " ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-31 21:05:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  "  join dxcc_entities d on thcv.col_dxcc = d.adif " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  "  where station_id in ( "  .  $location_list  .  " ) and col_dxcc > 0 " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $band  ==  'SAT' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and thcv.col_prop_mode =' "  .  $band  .  " ' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-14 19:03:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}  else  if  ( $band  ==  'All' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 02:40:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> load -> model ( 'bands' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$bandslots  =  $this -> bands -> get_worked_bands ( 'dxcc' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$bandslots_list  =  " ' " . implode ( " ',' " , $bandslots ) . " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and thcv.col_band in ( "  .  $bandslots_list  .  " ) "  . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													"  and thcv.col_prop_mode !='SAT' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and thcv.col_prop_mode !='SAT' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and thcv.col_band =' "  .  $band  .  " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-31 21:05:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'mode' ]  !=  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and (col_mode = ' "  .  $postdata [ 'mode' ]  .  " ' or col_submode = ' "  .  $postdata [ 'mode' ]  .  " ') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'includedeleted' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and d.end is null " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  $this -> addContinentsToQuery ( $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> result (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-31 21:05:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  getSummaryByBandConfirmed ( $band ,  $postdata ,  $location_list ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT count(distinct thcv.col_dxcc) as count FROM  "  .  $this -> config -> item ( 'table_name' )  .  "  thcv " ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-31 21:05:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  "  join dxcc_entities d on thcv.col_dxcc = d.adif " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 02:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  .=  "  where station_id in ( "  .  $location_list  .  " ) " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $band  ==  'SAT' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and thcv.col_prop_mode =' "  .  $band  .  " ' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-14 19:03:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}  else  if  ( $band  ==  'All' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 02:40:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> load -> model ( 'bands' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$bandslots  =  $this -> bands -> get_worked_bands ( 'dxcc' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$bandslots_list  =  " ' " . implode ( " ',' " , $bandslots ) . " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and thcv.col_band in ( "  .  $bandslots_list  .  " ) "  . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													"  and thcv.col_prop_mode !='SAT' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and thcv.col_prop_mode !='SAT' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and thcv.col_band =' "  .  $band  .  " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-31 21:05:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'mode' ]  !=  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and (col_mode = ' "  .  $postdata [ 'mode' ]  .  " ' or col_submode = ' "  .  $postdata [ 'mode' ]  .  " ') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  $this -> addQslToQuery ( $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $postdata [ 'includedeleted' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and d.end is null " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  .=  $this -> addContinentsToQuery ( $postdata ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:42:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> result (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-24 20:31:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-09-02 00:49:34 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  function  lookup_country ( $country ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-25 22:53:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													SELECT  * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													FROM  dxcc_entities 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													WHERE  name  =  " '. $country .' " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													ORDER  BY  LENGTH (  prefix  )  DESC 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													LIMIT  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> row (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-17 20:52:00 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-09-26 06:09:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								?>