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' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    function  get_was_array ( $bands ,  $postdata )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +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' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$location_list  =  " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											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 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $wasBand  =  $this -> getWasWorked ( $location_list ,  $band ,  $postdata ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                foreach  ( $wasBand  as  $line )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-27 18:11:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    $bandWas [ $line -> col_state ][ $band ]  =  '<div class="alert-danger"><a href=\'javascript:displayContacts("'  .  $line -> col_state  .  '","'  .  $band  .  '","' .  $postdata [ 'mode' ]  .  '","WAS")\'>W</a></div>' ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    $states [ $line -> col_state ][ 'count' ] ++ ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( $postdata [ 'confirmed' ]  !=  NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $wasBand  =  $this -> getWasConfirmed ( $location_list ,  $band ,  $postdata ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                foreach  ( $wasBand  as  $line )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-27 18:11:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    $bandWas [ $line -> col_state ][ $band ]  =  '<div class="alert-success"><a href=\'javascript:displayContacts("'  .  $line -> col_state  .  '","'  .  $band  .  '","' .  $postdata [ 'mode' ]  .  '","WAS")\'>C</a></div>' ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    $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 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $wasBand  =  $this -> getWasWorked ( $location_list ,  $postdata [ 'band' ],  $postdata ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            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 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $wasBand  =  $this -> getWasConfirmed ( $location_list ,  $postdata [ 'band' ],  $postdata ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            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 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-18 20:41:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /* 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  Function  gets  worked  and  confirmed  summary  on  each  band  on  the  active  stationprofile 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */ 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:23:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    function  get_was_summary ( $bands ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +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' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$location_list  =  " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-18 20:41:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:23:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        foreach  ( $bands  as  $band )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $worked  =  $this -> getSummaryByBand ( $band ,  $location_list ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $confirmed  =  $this -> getSummaryByBandConfirmed ( $band ,  $location_list ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:23:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $wasSummary [ 'worked' ][ $band ]  =  $worked [ 0 ] -> count ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $wasSummary [ 'confirmed' ][ $band ]  =  $confirmed [ 0 ] -> count ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-18 20:41:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $workedTotal  =  $this -> getSummaryByBand ( 'All' ,  $location_list ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $confirmedTotal  =  $this -> getSummaryByBandConfirmed ( 'All' ,  $location_list ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-15 18:24:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $wasSummary [ 'worked' ][ 'Total' ]  =  $workedTotal [ 0 ] -> count ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $wasSummary [ 'confirmed' ][ 'Total' ]  =  $confirmedTotal [ 0 ] -> count ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:23:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  $wasSummary ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-18 20:41:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    function  getSummaryByBand ( $band ,  $location_list ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:23:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:30:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $sql  =  " SELECT count(distinct thcv.col_state) as count FROM  "  .  $this -> config -> item ( 'table_name' )  .  "  thcv " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-18 20:41:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $sql  .=  "  where station_id in ( "  .  $location_list  .  " ) " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:23:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( $band  ==  'SAT' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $sql  .=  "  and thcv.col_prop_mode =' "  .  $band  .  " ' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-15 18:24:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  else  if  ( $band  ==  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $sql  .=  "  and thcv.col_prop_mode !='SAT' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:23:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $sql  .=  "  and thcv.col_prop_mode !='SAT' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $sql  .=  "  and thcv.col_band =' "  .  $band  .  " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-18 20:41:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $sql  .=  $this -> addStateToQuery (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:23:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  $query -> result (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    function  getSummaryByBandConfirmed ( $band ,  $location_list ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:23:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:30:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $sql  =  " SELECT count(distinct thcv.col_state) as count FROM  "  .  $this -> config -> item ( 'table_name' )  .  "  thcv " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-18 20:41:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $sql  .=  "  where station_id in ( "  .  $location_list  .  " ) " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-18 20:41:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:23:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( $band  ==  'SAT' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $sql  .=  "  and thcv.col_prop_mode =' "  .  $band  .  " ' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-15 18:24:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  else  if  ( $band  ==  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $sql  .=  "  and thcv.col_prop_mode !='SAT' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:23:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $sql  .=  "  and thcv.col_prop_mode !='SAT' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $sql  .=  "  and thcv.col_band =' "  .  $band  .  " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-18 20:41:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $sql  .=  $this -> addStateToQuery (); 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 23:23:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  .=  "  and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y') " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-18 20:41:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  $query -> result (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /* 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  Function  returns  all  worked ,  but  not  confirmed  states 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  $postdata  contains  data  from  the  form ,  in  this  case  Lotw  or  QSL  are  used 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */ 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    function  getWasWorked ( $location_list ,  $band ,  $postdata )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-24 20:31:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $sql  =  " SELECT distinct col_state FROM  "  .  $this -> config -> item ( 'table_name' )  .  "  thcv
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        where  station_id  in  ( "  .  $location_list  .  " ) " ;
 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-27 18:11:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'mode' ]  !=  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and (col_mode = ' "  .  $postdata [ 'mode' ]  .  " ' or col_submode = ' "  .  $postdata [ 'mode' ]  .  " ') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $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' )  . 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            "  where station_id in ( " .  $location_list  .  " ) "  . 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            "  and col_state = thcv.col_state " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 20:20:59 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-27 18:11:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'mode' ]  !=  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and (col_mode = ' "  .  $postdata [ 'mode' ]  .  " ' or col_submode = ' "  .  $postdata [ 'mode' ]  .  " ') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											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 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */ 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    function  getWasConfirmed ( $location_list ,  $band ,  $postdata )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-24 20:31:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $sql  =  " SELECT distinct col_state FROM  "  .  $this -> config -> item ( 'table_name' )  .  "  thcv
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 05:04:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            where  station_id  in  ( "  .  $location_list  .  " ) " ;
 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-27 18:11:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( $postdata [ 'mode' ]  !=  'All' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  .=  "  and (col_mode = ' "  .  $postdata [ 'mode' ]  .  " ' or col_submode = ' "  .  $postdata [ 'mode' ]  .  " ') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 07:36:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $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 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-07-24 20:31:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								?>