2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								class  was  extends  CI_Model  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  $stateString  =  'AK,AL,AR,AZ,CA,CO,CT,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VA,VT,WA,WI,WV,WY' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    public  $bandslots  =  array ( " 160m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 80m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 60m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 40m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 30m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 20m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 17m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 15m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 12m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 10m " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 6m "  => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 4m "  => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 2m "  => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 70cm " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 23cm " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 13cm " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 9cm " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 6cm " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 3cm " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " 1.25cm " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " SAT " => 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    function  __construct () 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Call the Model constructor
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        parent :: __construct (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    function  get_worked_bands ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $CI  =&  get_instance (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $CI -> load -> model ( 'Stations' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $station_id  =  $CI -> Stations -> find_active (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // get all worked slots from database
 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        $data  =  $this -> db -> query ( 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            " SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM ` " . $this -> config -> item ( 'table_name' ) . " ` WHERE station_id =  " . $station_id . "  AND COL_PROP_MODE !=  \" SAT \" " 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $worked_slots  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        foreach ( $data -> result ()  as  $row ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            array_push ( $worked_slots ,  $row -> COL_BAND ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $SAT_data  =  $this -> db -> query ( 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            " SELECT distinct LOWER(`COL_PROP_MODE`) as `COL_PROP_MODE` FROM ` " . $this -> config -> item ( 'table_name' ) . " ` WHERE station_id =  " . $station_id . "  AND COL_PROP_MODE =  \" SAT \" " 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        foreach ( $SAT_data -> result ()  as  $row ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            array_push ( $worked_slots ,  strtoupper ( $row -> COL_PROP_MODE )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // bring worked-slots in order of defined $bandslots
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $results  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        foreach ( array_keys ( $this -> bandslots )  as  $slot )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if ( in_array ( $slot ,  $worked_slots ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                array_push ( $results ,  $slot ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  $results ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    function  get_was_array ( $bands ,  $postdata )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        $CI  =&  get_instance (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $CI -> load -> model ( 'Stations' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $station_id  =  $CI -> Stations -> find_active (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $stateArray  =  explode ( ',' ,  $this -> stateString ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $states  =  array ();  // Used for keeping track of which states that are not worked
 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-31 13:43:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        foreach  ( $stateArray  as  $state )  {                    // Generating array for use in the table
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $states [ $state ][ 'count' ]  =  0 ;                    // Inits each state's count
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        foreach  ( $bands  as  $band )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            foreach  ( $stateArray  as  $state )  {                    // Generating array for use in the table
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $bandWas [ $state ][ $band ]  =  '-' ;                   // Sets all to dash to indicate no result
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( $postdata [ 'worked' ]  !=  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $wasBand  =  $this -> getWasWorked ( $station_id ,  $band ,  $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                foreach  ( $wasBand  as  $line )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $bandWas [ $line -> col_state ][ $band ]  =  '<div class="alert-danger"><a href=\'was_details?State="'  .  str_replace ( " & " ,  " %26 " ,  $line -> col_state )  .  '"&Band="'  .  $band  .  '"\'>W</a></div>' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $states [ $line -> col_state ][ 'count' ] ++ ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( $postdata [ 'confirmed' ]  !=  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $wasBand  =  $this -> getWasConfirmed ( $station_id ,  $band ,  $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                foreach  ( $wasBand  as  $line )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $bandWas [ $line -> col_state ][ $band ]  =  '<div class="alert-success"><a href=\'was_details?State="'  .  str_replace ( " & " ,  " %26 " ,  $line -> col_state )  .  '"&Band="'  .  $band  .  '"\'>C</a></div>' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $states [ $line -> col_state ][ 'count' ] ++ ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // We want to remove the worked states in the list, since we do not want to display them
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( $postdata [ 'worked' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $wasBand  =  $this -> getWasWorked ( $station_id ,  $postdata [ 'band' ],  $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            foreach  ( $wasBand  as  $line )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                unset ( $bandWas [ $line -> col_state ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // We want to remove the confirmed states in the list, since we do not want to display them
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( $postdata [ 'confirmed' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $wasBand  =  $this -> getWasConfirmed ( $station_id ,  $postdata [ 'band' ],  $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            foreach  ( $wasBand  as  $line )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                unset ( $bandWas [ $line -> col_state ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( $postdata [ 'notworked' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            foreach  ( $stateArray  as  $state )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( $states [ $state ][ 'count' ]  ==  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    unset ( $bandWas [ $state ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( isset ( $bandWas ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  $bandWas ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /* 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  Function  returns  all  worked ,  but  not  confirmed  states 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  $postdata  contains  data  from  the  form ,  in  this  case  Lotw  or  QSL  are  used 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    function  getWasWorked ( $station_id ,  $band ,  $postdata )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  =  " SELECT distinct col_state FROM  "  .  $this -> config -> item ( 'table_name' )  .  "  thcv 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        where  station_id  =  "  .  $station_id ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  .=  $this -> addStateToQuery (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  .=  $this -> addBandToQuery ( $band ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $sql  .=  "  and not exists (select 1 from  " .  $this -> config -> item ( 'table_name' )  . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            "  where station_id =  " .  $station_id  . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            "  and col_state = thcv.col_state " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $sql  .=  $this -> addBandToQuery ( $band ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $sql  .=  $this -> addQslToQuery ( $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  .=  $this -> addStateToQuery (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  .=  " ) " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  $query -> result (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /* 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  Function  returns  all  confirmed  states  on  given  band  and  on  LoTW  or  QSL 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  $postdata  contains  data  from  the  form ,  in  this  case  Lotw  or  QSL  are  used 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    function  getWasConfirmed ( $station_id ,  $band ,  $postdata )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  =  " SELECT distinct col_state FROM  "  .  $this -> config -> item ( 'table_name' )  .  "  thcv 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            where  station_id  =  "  .  $station_id ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  .=  $this -> addStateToQuery (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  .=  $this -> addBandToQuery ( $band ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  .=  $this -> addQslToQuery ( $postdata ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  $query -> result (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    function  addQslToQuery ( $postdata )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  =  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( $postdata [ 'lotw' ]  !=  NULL  and  $postdata [ 'qsl' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $sql  .=  "  and col_lotw_qsl_rcvd = 'Y' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( $postdata [ 'qsl' ]  !=  NULL  and  $postdata [ 'lotw' ]  ==  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $sql  .=  "  and col_qsl_rcvd = 'Y' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( $postdata [ 'qsl' ]  !=  NULL  &&  $postdata [ 'lotw' ]  !=  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $sql  .=  "  and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  $sql ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    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 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    function  addStateToQuery ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  =  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  .=  "  and COL_DXCC in ('291', '6', '110') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  .=  "  and COL_STATE in ('AK','AL','AR','AZ','CA','CO','CT','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI','WV','WY') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  $sql ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								?>