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