2024-04-14 14:54:35 +02:00
< ? php
class Visitor_model extends CI_Model {
2024-11-04 01:58:02 +01:00
function get_qsos ( $num , $StationLocationsArray , $band = '' , $continent = '' , $orbit = '' , $contest = '' , $start_date = '' , $end_date = '' ) {
2024-04-14 14:54:35 +02:00
$this -> db -> select ( $this -> config -> item ( 'table_name' ) . '.*, station_profile.*' );
$this -> db -> from ( $this -> config -> item ( 'table_name' ));
$this -> db -> join ( 'station_profile' , 'station_profile.station_id = ' . $this -> config -> item ( 'table_name' ) . '.station_id' );
2024-11-03 15:09:33 +01:00
if ( $band == 'SAT' ) {
$this -> db -> join ( 'satellite' , 'satellite.name = ' . $this -> config -> item ( 'table_name' ) . '.COL_SAT_NAME' , 'left' );
}
2024-04-14 14:54:35 +02:00
2024-11-04 01:58:02 +01:00
if ( $start_date != '' ) {
$start_date = date ( 'Y-m-d' , strtotime ( $start_date ));
$this -> db -> where ( $this -> config -> item ( 'table_name' ) . '.COL_TIME_ON >=' , $start_date );
}
if ( $end_date != '' ) {
$end_date = date ( 'Y-m-d' , strtotime ( $end_date ));
$this -> db -> where ( $this -> config -> item ( 'table_name' ) . '.COL_TIME_ON <=' , $end_date );
}
2024-04-14 14:54:35 +02:00
if ( $band != '' ) {
if ( $band == 'SAT' ) {
$this -> db -> where ( $this -> config -> item ( 'table_name' ) . '.col_prop_mode' , 'SAT' );
2024-11-03 15:09:33 +01:00
if ( $orbit == 'LEO' ) {
$this -> db -> where ( 'satellite.orbit' , 'LEO' );
} else if ( $orbit == 'MEO' ) {
$this -> db -> where ( 'satellite.orbit' , 'MEO' );
} else if ( $orbit == 'GEO' ) {
$this -> db -> where ( 'satellite.orbit' , 'GEO' );
}
2024-04-14 14:54:35 +02:00
} else {
$this -> db -> where ( $this -> config -> item ( 'table_name' ) . '.col_prop_mode !="SAT"' );
$this -> db -> where ( $this -> config -> item ( 'table_name' ) . '.col_band' , $band );
}
}
2024-10-31 10:26:59 +01:00
if ( $continent != '' ) {
$this -> db -> where ( $this -> config -> item ( 'table_name' ) . '.COL_CONT' , $continent );
}
2024-11-04 01:40:28 +01:00
if ( $contest != '' ) {
$this -> db -> where ( $this -> config -> item ( 'table_name' ) . '.COL_CONTEST_ID' , $contest );
}
2024-10-31 10:26:59 +01:00
$this -> db -> group_start ();
$this -> db -> where ( " ( " . $this -> config -> item ( 'table_name' ) . " .COL_GRIDSQUARE != '' AND " . $this -> config -> item ( 'table_name' ) . " .COL_GRIDSQUARE IS NOT NULL) " );
$this -> db -> or_where ( " ( " . $this -> config -> item ( 'table_name' ) . " .COL_VUCC_GRIDS != '' AND " . $this -> config -> item ( 'table_name' ) . " .COL_VUCC_GRIDS IS NOT NULL) " );
$this -> db -> group_end ();
2024-04-14 14:54:35 +02:00
$this -> db -> where_in ( $this -> config -> item ( 'table_name' ) . '.station_id' , $StationLocationsArray );
$this -> db -> order_by ( '' . $this -> config -> item ( 'table_name' ) . '.COL_TIME_ON' , " desc " );
2024-11-10 12:05:02 +01:00
if ( $num == 'all' || $num > 5000 ) {
2024-11-10 12:03:52 +01:00
$this -> db -> limit ( '5000' );
2024-11-04 01:40:28 +01:00
return $this -> db -> get ();
} else {
$this -> db -> limit ( $num );
return $this -> db -> get ();
}
2024-04-14 14:54:35 +02:00
}
function getlastqsodate ( $slug ) {
$this -> load -> model ( 'stationsetup_model' );
$logbook_id = $this -> stationsetup_model -> public_slug_exists_logbook_id ( $slug );
$userid = $this -> stationsetup_model -> public_slug_exists_userid ( $slug );
$band = $this -> user_options_model -> get_options ( 'ExportMapOptions' , array ( 'option_name' => 'band' , 'option_key' => $slug ), $userid ) -> row () -> option_value ? ? '' ;
$sql = " select max(col_time_on) lastqso from " . $this -> config -> item ( 'table_name' ) .
" join station_profile on station_profile.station_id = " . $this -> config -> item ( 'table_name' ) . " .station_id where 1 = 1 " ;
if ( $band != '' ) {
if ( $band == 'SAT' ) {
$sql .= " and " . $this -> config -> item ( 'table_name' ) . " .col_prop_mode = 'SAT' " ;
} else {
$sql .= " and " . $this -> config -> item ( 'table_name' ) . " .col_prop_mode != 'SAT' " ;
$sql .= " and " . $this -> config -> item ( 'table_name' ) . " .col_band = ' " . $band . " ' " ;
}
}
return $this -> db -> query ( $sql );
}
2024-10-31 10:26:59 +01:00
function qso_is_confirmed ( $qso , $user_default_confirmation ) {
$confirmed = false ;
$qso = ( array ) $qso ;
if ( strpos ( $user_default_confirmation , 'Q' ) !== false ) { // QSL
if ( $qso [ 'COL_QSL_RCVD' ] == 'Y' ) { $confirmed = true ; }
}
if ( strpos ( $user_default_confirmation , 'L' ) !== false ) { // LoTW
if ( $qso [ 'COL_LOTW_QSL_RCVD' ] == 'Y' ) { $confirmed = true ; }
}
if ( strpos ( $user_default_confirmation , 'E' ) !== false ) { // eQsl
if ( $qso [ 'COL_EQSL_QSL_RCVD' ] == 'Y' ) { $confirmed = true ; }
}
if ( strpos ( $user_default_confirmation , 'Z' ) !== false ) { // QRZ
if ( $qso [ 'COL_QRZCOM_QSO_DOWNLOAD_STATUS' ] == 'Y' ) { $confirmed = true ; }
}
if ( strpos ( $user_default_confirmation , 'C' ) !== false ) { // Clublog
if ( $qso [ 'COL_CLUBLOG_QSO_DOWNLOAD_STATUS' ] == 'Y' ) { $confirmed = true ; }
}
return $confirmed ;
}
function get_user_default_confirmation ( $userid ) {
$this -> load -> model ( 'user_model' );
return $this -> user_model -> get_by_id ( $userid ) -> row () -> user_default_confirmation ? ? '' ;
}
2024-04-14 14:54:35 +02:00
}