2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								class  Bands  extends  CI_Model  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  $bandslots  =  array ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 160m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 80m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 60m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 40m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 30m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 20m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 17m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 15m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 12m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 10m " => 0 , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-21 12:10:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										" 6m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 4m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 2m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 1.25m " => 0 , 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										" 70cm " => 0 , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-21 12:10:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										" 33cm " => 0 , 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										" 23cm " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 13cm " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 9cm " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 6cm " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 3cm " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" 1.25cm " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" SAT " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-05 00:26:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  get_user_bands ( $award  =  'None' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> from ( 'bands' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> join ( 'bandxuser' ,  'bandxuser.bandid = bands.id' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> where ( 'bandxuser.userid' ,  $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> where ( 'bandxuser.active' ,  1 ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $award  !=  'None' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-06 02:26:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> db -> where ( 'bandxuser.' . $award ,  1 ); 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-05 00:26:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$result  =  $this -> db -> get () -> result (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$results  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										foreach ( $result  as  $band )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											array_push ( $results ,  $band -> band ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $results ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 05:11:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  get_user_bands_for_qso_entry ( $includeall  =  false )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-09 02:12:11 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> db -> from ( 'bands' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> join ( 'bandxuser' ,  'bandxuser.bandid = bands.id' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> where ( 'bandxuser.userid' ,  $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 05:11:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( ! $includeall )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> where ( 'bandxuser.active' ,  1 ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-09 02:12:11 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> db -> where ( 'bands.bandgroup != "sat"' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$result  =  $this -> db -> get () -> result (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$results  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										foreach ( $result  as  $band )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$results [ $band -> bandgroup ][]  =  $band -> band ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $results ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-05 00:26:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  get_all_bands_for_user ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> from ( 'bands' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> join ( 'bandxuser' ,  'bandxuser.bandid = bands.id' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> where ( 'bandxuser.userid' ,  $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $this -> db -> get () -> result (); 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-04 14:49:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  all ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $this -> bandslots ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-05 00:26:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  get_worked_bands ( $award  =  'None' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										$CI  =&  get_instance (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$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  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										$location_list  =  " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// get all worked slots from database
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$data  =  $this -> db -> query ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											" SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM ` " . $this -> config -> item ( 'table_name' ) . " ` WHERE station_id in ( "  .  $location_list  .  " ) AND COL_PROP_MODE !=  \" SAT \" " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$worked_slots  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										foreach ( $data -> result ()  as  $row ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											array_push ( $worked_slots ,  $row -> COL_BAND ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$SAT_data  =  $this -> db -> query ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											" SELECT distinct LOWER(`COL_PROP_MODE`) as `COL_PROP_MODE` FROM ` " . $this -> config -> item ( 'table_name' ) . " ` WHERE station_id in ( "  .  $location_list  .  " ) AND COL_PROP_MODE =  \" SAT \" " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										foreach ( $SAT_data -> result ()  as  $row ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											array_push ( $worked_slots ,  strtoupper ( $row -> COL_PROP_MODE )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-06 02:26:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// bring worked-slots in order of defined $bandslots
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-05 00:26:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$bandslots  =  $this -> get_user_bands ( $award ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$results  =  array (); 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-05 00:26:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										foreach ( $bandslots  as  $slot )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											if ( in_array ( $slot ,  $worked_slots ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												array_push ( $results ,  $slot ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $results ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  get_worked_bands_distances ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$CI  =&  get_instance (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$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  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										$location_list  =  " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // get all worked slots from database
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  =  " SELECT distinct LOWER(COL_BAND) as COL_BAND FROM  " . $this -> config -> item ( 'table_name' ) . "  WHERE station_id in ( "  .  $location_list  .  " ) " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $data  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $worked_slots  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        foreach ( $data -> result ()  as  $row ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            array_push ( $worked_slots ,  $row -> COL_BAND ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // bring worked-slots in order of defined $bandslots
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-06 02:26:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$bandslots  =  $this -> get_user_bands (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$results  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										foreach ( $bandslots  as  $slot )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if ( in_array ( $slot ,  $worked_slots ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												array_push ( $results ,  $slot ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        return  $results ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  get_worked_sats ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$CI  =&  get_instance (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$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  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										$location_list  =  " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // get all worked sats from database
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  =  " SELECT distinct col_sat_name FROM  " . $this -> config -> item ( 'table_name' ) . "  WHERE station_id in ( "  .  $location_list  .  " ) and coalesce(col_sat_name, '') <> '' ORDER BY col_sat_name " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $data  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $worked_sats  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        foreach ( $data -> result ()  as  $row ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            array_push ( $worked_sats ,  $row -> col_sat_name ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  $worked_sats ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  get_worked_bands_dok ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$CI  =&  get_instance (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$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  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										$location_list  =  " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// get all worked slots from database
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$data  =  $this -> db -> query ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											" SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM ` " . $this -> config -> item ( 'table_name' ) . " ` WHERE station_id in ( "  .  $location_list  .  " ) AND COL_DARC_DOK IS NOT NULL AND COL_DARC_DOK != ''  AND COL_DXCC = 230  " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$worked_slots  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										foreach ( $data -> result ()  as  $row ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											array_push ( $worked_slots ,  $row -> COL_BAND ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// bring worked-slots in order of defined $bandslots
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-07 02:31:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$bandslots  =  $this -> get_user_bands ( 'dok' ); 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-06 02:26:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										$results  =  array (); 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-06 02:26:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										foreach ( $bandslots  as  $slot )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											if ( in_array ( $slot ,  $worked_slots ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												array_push ( $results ,  $slot ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $results ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-06 02:26:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  activateall ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $data  =  array ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            'active'  =>  '1' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> where ( 'bandxuser.userid' ,  $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> db -> update ( 'bandxuser' ,  $data ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    function  deactivateall ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $data  =  array ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            'active'  =>  '0' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> where ( 'bandxuser.userid' ,  $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> db -> update ( 'bandxuser' ,  $data ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  delete ( $id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Clean ID
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$clean_id  =  $this -> security -> xss_clean ( $id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Delete Mode
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> delete ( 'bandxuser' ,  array ( 'id'  =>  $clean_id ));  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  saveBand ( $id ,  $band )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $data  =  array ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'active'  	 =>  $band [ 'status' ] 		==  " true "  ?  '1'  :  '0' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'cq'  		 =>  $band [ 'cq' ]  		==  " true "  ?  '1'  :  '0' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'dok'  		 =>  $band [ 'dok' ]  		==  " true "  ?  '1'  :  '0' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'dxcc'  		 =>  $band [ 'dxcc' ]  		==  " true "  ?  '1'  :  '0' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'iota'  		 =>  $band [ 'iota' ]  		==  " true "  ?  '1'  :  '0' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'sig'  		 =>  $band [ 'sig' ]  		==  " true "  ?  '1'  :  '0' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'sota' 		 =>  $band [ 'sota' ]  		==  " true "  ?  '1'  :  '0' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'uscounties'  =>  $band [ 'uscounties' ]  ==  " true "  ?  '1'  :  '0' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'was'  		 =>  $band [ 'was' ]  		==  " true "  ?  '1'  :  '0' , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:25:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											'wwff'  		 =>  $band [ 'wwff' ]  		==  " true "  ?  '1'  :  '0' , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-06 02:26:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											'vucc' 		 =>  $band [ 'vucc' ]  		==  " true "  ?  '1'  :  '0' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> where ( 'bandxuser.userid' ,  $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> db -> where ( 'bandxuser.id' ,  $id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> db -> update ( 'bandxuser' ,  $data ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-07 01:35:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									function  add ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$data  =  array ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 00:52:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											'band'  		=>  xss_clean ( $this -> input -> post ( 'band' ,  true )), 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'bandgroup'  =>  xss_clean ( $this -> input -> post ( 'bandgroup' ,  true )), 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'ssb' 	 	=>  xss_clean ( $this -> input -> post ( 'ssbqrg' ,  true )), 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'data'  		=>  xss_clean ( $this -> input -> post ( 'dataqrg' ,  true )), 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'cw'  		=>  xss_clean ( $this -> input -> post ( 'cwqrg' ,  true )), 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-07 01:35:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> where ( 'band' ,  xss_clean ( $this -> input -> post ( 'band' ,  true ))); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$result  =  $this -> db -> get ( 'bands' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $result -> num_rows ()  ==  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										   $this -> db -> insert ( 'bands' ,  $data ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:25:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> db -> query ( " insert into bandxuser (bandid, userid, active, cq, dok, dxcc, iota, sig, sota, uscounties, was, wwff, vucc) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										select  bands . id ,  "  .  $this->session ->userdata('user_id') .  " ,  1 ,  1 ,  1 ,  1 ,  1 ,  1 ,  1 ,  1 ,  1 ,  1 ,  1  from  bands  where  band  = '".$data[' band ']."'  and  not  exists  ( select  1  from  bandxuser  where  userid  =  "  .  $this->session ->userdata('user_id') .  "  and  bandid  =  bands . id ); " );
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-07 01:35:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-07 02:18:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  getband ( $id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> where ( 'id' ,  $id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $this -> db -> get ( 'bands' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function  saveupdatedband ( $id ,  $band )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$data  =  array ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 00:52:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											'band'  		=>  $band [ 'band' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'bandgroup'  =>  $band [ 'bandgroup' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'ssb' 	 	=>  $band [ 'ssbqrg' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'data'  		=>  $band [ 'dataqrg' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'cw'  		=>  $band [ 'cwqrg' ], 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-07 02:18:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> db -> where ( 'bands.id' ,  $id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> db -> update ( 'bands' ,  $data ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:55:17 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								?>