From b1a68d6c611bc733c6acf697e900edadf8782df5 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Mon, 14 Apr 2025 20:10:11 +0100 Subject: [PATCH] Improved callbook error when not defined --- application/controllers/Logbook.php | 1242 +++++++++++++++------------ 1 file changed, 680 insertions(+), 562 deletions(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 4f8546f2..2ed4684b 100644 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -1,7 +1,8 @@ -load->model('user_model'); - if($this->user_model->validate_session() == 0) { + if ($this->user_model->validate_session() == 0) { // user is not logged in redirect('user/login'); } $this->load->model('stations'); // If environment is set to development then show the debug toolbar - if(ENVIRONMENT == 'development') { - $this->output->enable_profiler(TRUE); - } + if (ENVIRONMENT == 'development') { + $this->output->enable_profiler(TRUE); + } $this->load->model('logbook_model'); $this->load->library('pagination'); - $config['base_url'] = base_url().'index.php/logbook/index/'; + $config['base_url'] = base_url() . 'index.php/logbook/index/'; $config['total_rows'] = $this->logbook_model->total_qsos(); $config['per_page'] = '25'; $config['num_links'] = 6; @@ -48,25 +49,25 @@ class Logbook extends CI_Controller { $this->pagination->initialize($config); //load the model and get results - $data['results'] = $this->logbook_model->get_qsos($config['per_page'],$this->uri->segment(3)); + $data['results'] = $this->logbook_model->get_qsos($config['per_page'], $this->uri->segment(3)); - if(!$data['results']) { + if (!$data['results']) { $this->session->set_flashdata('notice', lang('error_no_logbook_found') . ' Station Logbooks'); } // Calculate Lat/Lng from Locator to use on Maps - if($this->session->userdata('user_locator')) { - $this->load->library('qra'); - $qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator')); - if (isset($qra_position[0]) and isset($qra_position[1])) { - $data['qra'] = "set"; - $data['qra_lat'] = $qra_position[0]; - $data['qra_lng'] = $qra_position[1]; - } else { - $data['qra'] = "none"; - } - } else { + if ($this->session->userdata('user_locator')) { + $this->load->library('qra'); + $qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator')); + if (isset($qra_position[0]) and isset($qra_position[1])) { + $data['qra'] = "set"; + $data['qra_lat'] = $qra_position[0]; + $data['qra_lng'] = $qra_position[1]; + } else { $data['qra'] = "none"; + } + } else { + $data['qra'] = "none"; } @@ -77,17 +78,19 @@ class Logbook extends CI_Controller { $this->load->view('interface_assets/header', $data); $this->load->view('view_log/index'); $this->load->view('interface_assets/footer'); - } - function jsonentity($adif) { - $this->load->model('user_model'); - if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } + function jsonentity($adif) + { + $this->load->model('user_model'); + if (!$this->user_model->authorize($this->config->item('auth_mode'))) { + return; + } - $return['dxcc'] = $this->getentity($adif); - header('Content-Type: application/json'); - echo json_encode($return, JSON_PRETTY_PRINT); - } + $return['dxcc'] = $this->getentity($adif); + header('Content-Type: application/json'); + echo json_encode($return, JSON_PRETTY_PRINT); + } function json($tempcallsign, $temptype, $tempband, $tempmode, $tempstation_id = null) { @@ -99,21 +102,23 @@ class Logbook extends CI_Controller { $station_id = $this->security->xss_clean($tempstation_id); $this->load->model('user_model'); - if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } + if (!$this->user_model->authorize($this->config->item('auth_mode'))) { + return; + } // Convert - in Callsign to / Used for URL processing - $callsign = str_replace("-","/",$callsign); - $callsign = str_replace("Ø","0",$callsign); + $callsign = str_replace("-", "/", $callsign); + $callsign = str_replace("Ø", "0", $callsign); // Check if callsign is an LoTW User // Check Database for all other data $this->load->model('logbook_model'); - $lotw_days=$this->logbook_model->check_last_lotw($callsign); + $lotw_days = $this->logbook_model->check_last_lotw($callsign); if ($lotw_days != null) { - $lotw_member="active"; + $lotw_member = "active"; } else { - $lotw_member="not found"; + $lotw_member = "not found"; } $return = [ @@ -137,8 +142,8 @@ class Logbook extends CI_Controller { $return['dxcc'] = $this->dxcheck($callsign); - $lookupcall=$this->get_plaincall($callsign); - + $lookupcall = $this->get_plaincall($callsign); + $return['partial'] = $this->partial($lookupcall); $callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('use_fullname')); @@ -183,16 +188,17 @@ class Logbook extends CI_Controller { return; } - function get_plaincall($callsign) { - $split_callsign=explode('/',$callsign); - if (count($split_callsign)==1) { // case F0ABC --> return cel 0 // + function get_plaincall($callsign) + { + $split_callsign = explode('/', $callsign); + if (count($split_callsign) == 1) { // case F0ABC --> return cel 0 // $lookupcall = $split_callsign[0]; - } else if (count($split_callsign)==3) { // case EA/F0ABC/P --> return cel 1 // + } else if (count($split_callsign) == 3) { // case EA/F0ABC/P --> return cel 1 // $lookupcall = $split_callsign[1]; } else { // case F0ABC/P --> return cel 0 OR case EA/FOABC --> retunr 1 (normaly not exist) // - if (in_array(strtoupper($split_callsign[1]), array('P','M','MM','QRP','0','1','2','3','4','5','6','7','8','9'))) { + if (in_array(strtoupper($split_callsign[1]), array('P', 'M', 'MM', 'QRP', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'))) { $lookupcall = $split_callsign[0]; - } else if (strlen($split_callsign[1])>3) { // Last Element longer than 3 chars? Take that as call + } else if (strlen($split_callsign[1]) > 3) { // Last Element longer than 3 chars? Take that as call $lookupcall = $split_callsign[1]; } else { // Last Element up to 3 Chars? Take first element as Call $lookupcall = $split_callsign[0]; @@ -202,11 +208,13 @@ class Logbook extends CI_Controller { } // Returns $val2 first if it has value, even if it is null or empty string, if not return $val1. - function nval($val1, $val2) { + function nval($val1, $val2) + { return (($val2 ?? "") === "" ? ($val1 ?? "") : ($val2 ?? "")); } - function confirmed_grid_before($gridsquare, $type, $band, $mode) { + function confirmed_grid_before($gridsquare, $type, $band, $mode) + { if (strlen($gridsquare) < 4) return false; @@ -214,36 +222,36 @@ class Logbook extends CI_Controller { $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); $user_default_confirmation = $this->session->userdata('user_default_confirmation'); - if(!empty($logbooks_locations_array)) { - $extrawhere=''; + if (!empty($logbooks_locations_array)) { + $extrawhere = ''; if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) { - $extrawhere="COL_QSL_RCVD='Y'"; + $extrawhere = "COL_QSL_RCVD='Y'"; } if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'L') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; + if ($extrawhere != '') { + $extrawhere .= " OR"; } - $extrawhere.=" COL_LOTW_QSL_RCVD='Y'"; + $extrawhere .= " COL_LOTW_QSL_RCVD='Y'"; } if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'E') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; + if ($extrawhere != '') { + $extrawhere .= " OR"; } - $extrawhere.=" COL_EQSL_QSL_RCVD='Y'"; + $extrawhere .= " COL_EQSL_QSL_RCVD='Y'"; } if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Z') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; + if ($extrawhere != '') { + $extrawhere .= " OR"; } - $extrawhere.=" COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'"; + $extrawhere .= " COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'"; } - if($type == "SAT") { + if ($type == "SAT") { $this->db->where('COL_PROP_MODE', 'SAT'); if ($extrawhere != '') { - $this->db->where('('.$extrawhere.')'); + $this->db->where('(' . $extrawhere . ')'); } else { $this->db->where("1=0"); } @@ -251,9 +259,9 @@ class Logbook extends CI_Controller { $this->load->model('logbook_model'); $this->db->where('COL_MODE', $this->logbook_model->get_main_mode_from_mode($mode)); $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=','SAT'); + $this->db->where('COL_PROP_MODE !=', 'SAT'); if ($extrawhere != '') { - $this->db->where('('.$extrawhere.')'); + $this->db->where('(' . $extrawhere . ')'); } else { $this->db->where("1=0"); } @@ -261,7 +269,7 @@ class Logbook extends CI_Controller { $this->db->where_in('station_id', $logbooks_locations_array); $this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4)); - $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "desc"); + $this->db->order_by($this->config->item('table_name') . ".COL_TIME_ON", "desc"); $this->db->limit(1); @@ -283,26 +291,24 @@ class Logbook extends CI_Controller { $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - if(!empty($logbooks_locations_array)) { - if($type == "SAT") { + if (!empty($logbooks_locations_array)) { + if ($type == "SAT") { $this->db->where('COL_PROP_MODE', 'SAT'); } else { $this->db->where('COL_MODE', $this->logbook_model->get_main_mode_from_mode($mode)); $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=','SAT'); - + $this->db->where('COL_PROP_MODE !=', 'SAT'); } $this->db->where_in('station_id', $logbooks_locations_array); $this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4)); - $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "desc"); + $this->db->order_by($this->config->item('table_name') . ".COL_TIME_ON", "desc"); $this->db->limit(1); $query = $this->db->get($this->config->item('table_name')); - foreach ($query->result() as $workedBeforeRow) - { + foreach ($query->result() as $workedBeforeRow) { return true; } } @@ -316,63 +322,62 @@ class Logbook extends CI_Controller { * the $type variable is only used for satellites, set this to SAT. * */ - function jsonlookupgrid($gridsquare, $type, $band, $mode) { + function jsonlookupgrid($gridsquare, $type, $band, $mode) + { $return = [ "workedBefore" => false, "confirmed" => false, ]; $user_default_confirmation = $this->session->userdata('user_default_confirmation'); - $this->load->model('logbooks_model'); - $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - if($type == "SAT") { + if ($type == "SAT") { $this->db->where('COL_PROP_MODE', 'SAT'); } else { $this->load->model('logbook_model'); $this->db->where('COL_MODE', $this->logbook_model->get_main_mode_from_mode($mode)); $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=','SAT'); - + $this->db->where('COL_PROP_MODE !=', 'SAT'); } $this->db->where_in('station_id', $logbooks_locations_array); $this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4)); $query = $this->db->get($this->config->item('table_name'), 1, 0); - foreach ($query->result() as $workedBeforeRow) - { + foreach ($query->result() as $workedBeforeRow) { $return['workedBefore'] = true; } - $extrawhere=''; + $extrawhere = ''; if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) { - $extrawhere="COL_QSL_RCVD='Y'"; + $extrawhere = "COL_QSL_RCVD='Y'"; } if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'L') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; + if ($extrawhere != '') { + $extrawhere .= " OR"; } - $extrawhere.=" COL_LOTW_QSL_RCVD='Y'"; + $extrawhere .= " COL_LOTW_QSL_RCVD='Y'"; } if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'E') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; + if ($extrawhere != '') { + $extrawhere .= " OR"; } - $extrawhere.=" COL_EQSL_QSL_RCVD='Y'"; + $extrawhere .= " COL_EQSL_QSL_RCVD='Y'"; } if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Z') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; + if ($extrawhere != '') { + $extrawhere .= " OR"; } - $extrawhere.=" COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'"; + $extrawhere .= " COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'"; } - if($type == "SAT") { + if ($type == "SAT") { $this->db->where('COL_PROP_MODE', 'SAT'); if ($extrawhere != '') { - $this->db->where('('.$extrawhere.')'); + $this->db->where('(' . $extrawhere . ')'); } else { $this->db->where("1=0"); } @@ -380,9 +385,9 @@ class Logbook extends CI_Controller { $this->load->model('logbook_model'); $this->db->where('COL_MODE', $this->logbook_model->get_main_mode_from_mode($mode)); $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=','SAT'); + $this->db->where('COL_PROP_MODE !=', 'SAT'); if ($extrawhere != '') { - $this->db->where('('.$extrawhere.')'); + $this->db->where('(' . $extrawhere . ')'); } else { $this->db->where("1=0"); } @@ -393,7 +398,7 @@ class Logbook extends CI_Controller { $this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4)); $query = $this->db->get($this->config->item('table_name'), 1, 0); foreach ($query->result() as $workedBeforeRow) { - $return['confirmed']=true; + $return['confirmed'] = true; } header('Content-Type: application/json'); @@ -402,7 +407,8 @@ class Logbook extends CI_Controller { return; } - function jsonlookupdxcc($country, $type, $band, $mode) { + function jsonlookupdxcc($country, $type, $band, $mode) + { $return = [ "workedBefore" => false, @@ -414,54 +420,52 @@ class Logbook extends CI_Controller { $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); $this->load->model('logbook_model'); - if(!empty($logbooks_locations_array)) { - if($type == "SAT") { + if (!empty($logbooks_locations_array)) { + if ($type == "SAT") { $this->db->where('COL_PROP_MODE', 'SAT'); } else { $this->db->where('COL_MODE', $this->logbook_model->get_main_mode_from_mode($mode)); $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=','SAT'); - + $this->db->where('COL_PROP_MODE !=', 'SAT'); } $this->db->where_in('station_id', $logbooks_locations_array); $this->db->where('COL_COUNTRY', urldecode($country)); $query = $this->db->get($this->config->item('table_name'), 1, 0); - foreach ($query->result() as $workedBeforeRow) - { + foreach ($query->result() as $workedBeforeRow) { $return['workedBefore'] = true; } - $extrawhere=''; + $extrawhere = ''; if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) { - $extrawhere="COL_QSL_RCVD='Y'"; + $extrawhere = "COL_QSL_RCVD='Y'"; } if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'L') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; + if ($extrawhere != '') { + $extrawhere .= " OR"; } - $extrawhere.=" COL_LOTW_QSL_RCVD='Y'"; + $extrawhere .= " COL_LOTW_QSL_RCVD='Y'"; } if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'E') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; + if ($extrawhere != '') { + $extrawhere .= " OR"; } - $extrawhere.=" COL_EQSL_QSL_RCVD='Y'"; + $extrawhere .= " COL_EQSL_QSL_RCVD='Y'"; } if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Z') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; + if ($extrawhere != '') { + $extrawhere .= " OR"; } - $extrawhere.=" COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'"; + $extrawhere .= " COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'"; } - if($type == "SAT") { + if ($type == "SAT") { $this->db->where('COL_PROP_MODE', 'SAT'); if ($extrawhere != '') { - $this->db->where('('.$extrawhere.')'); + $this->db->where('(' . $extrawhere . ')'); } else { $this->db->where("1=0"); } @@ -469,9 +473,9 @@ class Logbook extends CI_Controller { $this->load->model('logbook_model'); $this->db->where('COL_MODE', $this->logbook_model->get_main_mode_from_mode($mode)); $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=','SAT'); + $this->db->where('COL_PROP_MODE !=', 'SAT'); if ($extrawhere != '') { - $this->db->where('('.$extrawhere.')'); + $this->db->where('(' . $extrawhere . ')'); } else { $this->db->where("1=0"); } @@ -482,7 +486,7 @@ class Logbook extends CI_Controller { $query = $this->db->get($this->config->item('table_name'), 1, 0); foreach ($query->result() as $workedBeforeRow) { - $return['confirmed']=true; + $return['confirmed'] = true; } @@ -500,10 +504,11 @@ class Logbook extends CI_Controller { } } - function jsonlookupcallsign($callsign, $type, $band, $mode) { + function jsonlookupcallsign($callsign, $type, $band, $mode) + { // Convert - in Callsign to / Used for URL processing - $callsign = str_replace("-","/",$callsign); + $callsign = str_replace("-", "/", $callsign); $return = [ "workedBefore" => false, @@ -515,54 +520,52 @@ class Logbook extends CI_Controller { $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); $this->load->model('logbook_model'); - if(!empty($logbooks_locations_array)) { - if($type == "SAT") { + if (!empty($logbooks_locations_array)) { + if ($type == "SAT") { $this->db->where('COL_PROP_MODE', 'SAT'); } else { $this->db->where('COL_MODE', $this->logbook_model->get_main_mode_from_mode($mode)); $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=','SAT'); - + $this->db->where('COL_PROP_MODE !=', 'SAT'); } $this->db->where_in('station_id', $logbooks_locations_array); $this->db->where('COL_CALL', strtoupper($callsign)); $query = $this->db->get($this->config->item('table_name'), 1, 0); - foreach ($query->result() as $workedBeforeRow) - { + foreach ($query->result() as $workedBeforeRow) { $return['workedBefore'] = true; } - $extrawhere=''; + $extrawhere = ''; if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) { - $extrawhere="COL_QSL_RCVD='Y'"; + $extrawhere = "COL_QSL_RCVD='Y'"; } if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'L') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; + if ($extrawhere != '') { + $extrawhere .= " OR"; } - $extrawhere.=" COL_LOTW_QSL_RCVD='Y'"; + $extrawhere .= " COL_LOTW_QSL_RCVD='Y'"; } if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'E') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; + if ($extrawhere != '') { + $extrawhere .= " OR"; } - $extrawhere.=" COL_EQSL_QSL_RCVD='Y'"; + $extrawhere .= " COL_EQSL_QSL_RCVD='Y'"; } if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Z') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; + if ($extrawhere != '') { + $extrawhere .= " OR"; } - $extrawhere.=" COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'"; + $extrawhere .= " COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'"; } - if($type == "SAT") { + if ($type == "SAT") { $this->db->where('COL_PROP_MODE', 'SAT'); if ($extrawhere != '') { - $this->db->where('('.$extrawhere.')'); + $this->db->where('(' . $extrawhere . ')'); } else { $this->db->where("1=0"); } @@ -570,9 +573,9 @@ class Logbook extends CI_Controller { $this->load->model('logbook_model'); $this->db->where('COL_MODE', $this->logbook_model->get_main_mode_from_mode($mode)); $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=','SAT'); + $this->db->where('COL_PROP_MODE !=', 'SAT'); if ($extrawhere != '') { - $this->db->where('('.$extrawhere.')'); + $this->db->where('(' . $extrawhere . ')'); } else { $this->db->where("1=0"); } @@ -597,11 +600,14 @@ class Logbook extends CI_Controller { } } - function view($id) { + function view($id) + { $this->load->library('DxccFlag'); $this->load->model('user_model'); - if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } + if (!$this->user_model->authorize($this->config->item('auth_mode'))) { + return; + } $this->load->library('qra'); $this->load->library('subdivisions'); @@ -609,88 +615,89 @@ class Logbook extends CI_Controller { $this->load->model('logbook_model'); $data['query'] = $this->logbook_model->get_qso($id); $data['dxccFlag'] = $this->dxccflag->get($data['query']->result()[0]->COL_DXCC); - - if ($this->session->userdata('user_measurement_base') == NULL) { - $data['measurement_base'] = $this->config->item('measurement_base'); - } - else { - $data['measurement_base'] = $this->session->userdata('user_measurement_base'); - } - $this->load->model('Qsl_model'); - $this->load->model('Sstv_model'); - $data['qslimages'] = $this->Qsl_model->getQslForQsoId($id); - $data['sstvimages'] = $this->Sstv_model->getSstvForQsoId($id); - $data['primary_subdivision'] = $this->subdivisions->get_primary_subdivision_name($data['query']->result()[0]->COL_DXCC); - $data['secondary_subdivision'] = $this->subdivisions->get_secondary_subdivision_name($data['query']->result()[0]->COL_DXCC); + if ($this->session->userdata('user_measurement_base') == NULL) { + $data['measurement_base'] = $this->config->item('measurement_base'); + } else { + $data['measurement_base'] = $this->session->userdata('user_measurement_base'); + } + + $this->load->model('Qsl_model'); + $this->load->model('Sstv_model'); + $data['qslimages'] = $this->Qsl_model->getQslForQsoId($id); + $data['sstvimages'] = $this->Sstv_model->getSstvForQsoId($id); + $data['primary_subdivision'] = $this->subdivisions->get_primary_subdivision_name($data['query']->result()[0]->COL_DXCC); + $data['secondary_subdivision'] = $this->subdivisions->get_secondary_subdivision_name($data['query']->result()[0]->COL_DXCC); $data['max_upload'] = ini_get('upload_max_filesize'); $this->load->view('interface_assets/mini_header', $data); $this->load->view('view_log/qso'); $this->load->view('interface_assets/footer'); } - function partial($id) { + function partial($id) + { $this->load->model('user_model'); - if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } + if (!$this->user_model->authorize($this->config->item('auth_mode'))) { + return; + } $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); $html = ""; - if(!empty($logbooks_locations_array)) { - $this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_FREQ, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, '.$this->config->item('table_name').'.COL_MY_GRIDSQUARE, '.$this->config->item('table_name').'.COL_CONTEST_ID, '.$this->config->item('table_name').'.COL_STATE, '.$this->config->item('table_name').'.COL_QRZCOM_QSO_UPLOAD_STATUS, '.$this->config->item('table_name').'.COL_QRZCOM_QSO_DOWNLOAD_STATUS, station_profile.*'); + if (!empty($logbooks_locations_array)) { + $this->db->select('' . $this->config->item('table_name') . '.COL_CALL, ' . $this->config->item('table_name') . '.COL_BAND, ' . $this->config->item('table_name') . '.COL_FREQ, ' . $this->config->item('table_name') . '.COL_TIME_ON, ' . $this->config->item('table_name') . '.COL_RST_RCVD, ' . $this->config->item('table_name') . '.COL_RST_SENT, ' . $this->config->item('table_name') . '.COL_MODE, ' . $this->config->item('table_name') . '.COL_SUBMODE, ' . $this->config->item('table_name') . '.COL_PRIMARY_KEY, ' . $this->config->item('table_name') . '.COL_SAT_NAME, ' . $this->config->item('table_name') . '.COL_GRIDSQUARE, ' . $this->config->item('table_name') . '.COL_QSL_RCVD, ' . $this->config->item('table_name') . '.COL_EQSL_QSL_RCVD, ' . $this->config->item('table_name') . '.COL_EQSL_QSL_SENT, ' . $this->config->item('table_name') . '.COL_QSL_SENT, ' . $this->config->item('table_name') . '.COL_STX, ' . $this->config->item('table_name') . '.COL_STX_STRING, ' . $this->config->item('table_name') . '.COL_SRX, ' . $this->config->item('table_name') . '.COL_SRX_STRING, ' . $this->config->item('table_name') . '.COL_LOTW_QSL_SENT, ' . $this->config->item('table_name') . '.COL_LOTW_QSL_RCVD, ' . $this->config->item('table_name') . '.COL_VUCC_GRIDS, ' . $this->config->item('table_name') . '.COL_MY_GRIDSQUARE, ' . $this->config->item('table_name') . '.COL_CONTEST_ID, ' . $this->config->item('table_name') . '.COL_STATE, ' . $this->config->item('table_name') . '.COL_QRZCOM_QSO_UPLOAD_STATUS, ' . $this->config->item('table_name') . '.COL_QRZCOM_QSO_DOWNLOAD_STATUS, 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'); + $this->db->join('station_profile', 'station_profile.station_id = ' . $this->config->item('table_name') . '.station_id'); $this->db->where_in('station_profile.station_id', $logbooks_locations_array); $this->db->group_start(); - $this->db->where($this->config->item('table_name').'.COL_CALL', $id); - $this->db->or_like($this->config->item('table_name').'.COL_CALL', '/'.$id,'before'); - $this->db->or_like($this->config->item('table_name').'.COL_CALL', $id.'/','after'); - $this->db->or_like($this->config->item('table_name').'.COL_CALL', '/'.$id.'/'); + $this->db->where($this->config->item('table_name') . '.COL_CALL', $id); + $this->db->or_like($this->config->item('table_name') . '.COL_CALL', '/' . $id, 'before'); + $this->db->or_like($this->config->item('table_name') . '.COL_CALL', $id . '/', 'after'); + $this->db->or_like($this->config->item('table_name') . '.COL_CALL', '/' . $id . '/'); $this->db->group_end(); - $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "desc"); + $this->db->order_by($this->config->item('table_name') . ".COL_TIME_ON", "desc"); $this->db->limit(5); $query = $this->db->get(); } - if (!empty($logbooks_locations_array) && $query->num_rows() > 0) - { + if (!empty($logbooks_locations_array) && $query->num_rows() > 0) { $html .= "
"; $html .= ""; - $html .= ""; - $html .= ""; - $html .= ""; - $html .= $this->part_table_header_col($this, $this->session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')); - $html .= $this->part_table_header_col($this, $this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')); - $html .= $this->part_table_header_col($this, $this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')); - $html .= $this->part_table_header_col($this, $this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')); - switch($this->session->userdata('user_previous_qsl_type')) { - case 0: - $html .= ""; - break; - case 1: - $html .= ""; - break; - case 2: - $html .= ""; - break; - case 4: - $html .= ""; - break; - default: - $html .= ""; - break; - } - $html .= ""; - $html .= ""; + $html .= ""; + $html .= ""; + $html .= ""; + $html .= $this->part_table_header_col($this, $this->session->userdata('user_column1') == "" ? 'Mode' : $this->session->userdata('user_column1')); + $html .= $this->part_table_header_col($this, $this->session->userdata('user_column2') == "" ? 'RSTS' : $this->session->userdata('user_column2')); + $html .= $this->part_table_header_col($this, $this->session->userdata('user_column3') == "" ? 'RSTR' : $this->session->userdata('user_column3')); + $html .= $this->part_table_header_col($this, $this->session->userdata('user_column4') == "" ? 'Band' : $this->session->userdata('user_column4')); + switch ($this->session->userdata('user_previous_qsl_type')) { + case 0: + $html .= ""; + break; + case 1: + $html .= ""; + break; + case 2: + $html .= ""; + break; + case 4: + $html .= ""; + break; + default: + $html .= ""; + break; + } + $html .= ""; + $html .= ""; // Get Date format - if($this->session->userdata('user_date_format')) { + if ($this->session->userdata('user_date_format')) { // If Logged in and session exists $custom_date_format = $this->session->userdata('user_date_format'); } else { @@ -698,218 +705,220 @@ class Logbook extends CI_Controller { $custom_date_format = $this->config->item('qso_date_format'); } - foreach ($query->result() as $row) - { + foreach ($query->result() as $row) { $timestamp = strtotime($row->COL_TIME_ON); $html .= ""; - $html .= ""; - $html .= ""; - $html .= $this->part_table_col($row, $this->session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')); - $html .= $this->part_table_col($row, $this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')); - $html .= $this->part_table_col($row, $this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')); - $html .= $this->part_table_col($row, $this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')); - if ($this->session->userdata('user_previous_qsl_type') == 1) { - $html .= ""; - } else if ($this->session->userdata('user_previous_qsl_type') == 2) { - $html .= ""; - } else if ($this->session->userdata('user_previous_qsl_type') == 4) { - $html .= ""; - } else { - $html .= ""; + $html .= ""; + $html .= ""; + $html .= $this->part_table_col($row, $this->session->userdata('user_column1') == "" ? 'Mode' : $this->session->userdata('user_column1')); + $html .= $this->part_table_col($row, $this->session->userdata('user_column2') == "" ? 'RSTS' : $this->session->userdata('user_column2')); + $html .= $this->part_table_col($row, $this->session->userdata('user_column3') == "" ? 'RSTR' : $this->session->userdata('user_column3')); + $html .= $this->part_table_col($row, $this->session->userdata('user_column4') == "" ? 'Band' : $this->session->userdata('user_column4')); + if ($this->session->userdata('user_previous_qsl_type') == 1) { + $html .= ""; + $html .= "\">▲"; + $html .= "COL_LOTW_QSL_RCVD) { + case "Y": + $html .= "green"; + break; + default: + $html .= "red"; + } + $html .= "\">▼"; + $html .= ""; + } else if ($this->session->userdata('user_previous_qsl_type') == 2) { + $html .= ""; + } else if ($this->session->userdata('user_previous_qsl_type') == 4) { + $html .= ""; + } else { + $html .= ""; + } + $html .= ""; $html .= ""; } $html .= "
DateCallsign".lang('gen_hamradio_qsl')."".lang('lotw_short')."".lang('eqsl_short')."QRZ".lang('gen_hamradio_qsl')."
DateCallsign" . lang('gen_hamradio_qsl') . "" . lang('lotw_short') . "" . lang('eqsl_short') . "QRZ" . lang('gen_hamradio_qsl') . "
".date($custom_date_format, $timestamp). date(' H:i',strtotime($row->COL_TIME_ON)) . "" . str_replace('0','Ø',strtoupper($row->COL_CALL)) . ""; - $html .= "COL_LOTW_QSL_SENT) { - case "Y": - $html .= "green"; - break; - default: - $html .= "red"; - } - $html .= "\">▲"; - $html .= "COL_LOTW_QSL_RCVD) { - case "Y": - $html .= "green"; - break; - default: - $html .= "red"; - } - $html .= "\">▼"; - $html .= ""; - $html .= "COL_EQSL_QSL_SENT) { - case "Y": - $html .= "green"; - break; - default: - $html .= "red"; - } - $html .= "\">▲"; - $html .= "COL_EQSL_QSL_RCVD) { - case "Y": - $html .= "green"; - break; - default: - $html .= "red"; - } - $html .= "\">▼"; - $html .= ""; - $html .= "COL_QRZCOM_QSO_UPLOAD_STATUS) { - case "Y": - $html .= "green"; - break; - default: - $html .= "red"; - } - $html .= "\">▲"; - $html .= "COL_QRZCOM_QSO_DOWNLOAD_STATUS) { - case "Y": - $html .= "green"; - break; - default: - $html .= "red"; - } - $html .= "\">▼"; - $html .= ""; - $html .= "COL_QSL_SENT) { - case "Y": - $html .= "green"; - break; - case "Q": - $html .= "yellow"; - break; - case "R": - $html .= "yellow"; - break; - case "I": - $html .= "grey"; - break; - default: - $html .= "red"; - } - $html .= "\">▲"; - $html .= "COL_QSL_RCVD) { - case "Y": - $html .= "green"; - break; - case "Q": - $html .= "yellow"; - break; - case "R": - $html .= "yellow"; - break; - case "I": - $html .= "grey"; - break; - default: - $html .= "red"; - } - $html .= "\">▼"; - $html .= "" . date($custom_date_format, $timestamp) . date(' H:i', strtotime($row->COL_TIME_ON)) . "" . str_replace('0', 'Ø', strtoupper($row->COL_CALL)) . ""; + $html .= "COL_LOTW_QSL_SENT) { + case "Y": + $html .= "green"; + break; + default: + $html .= "red"; } - $html .= "".$row->station_callsign.""; + $html .= "COL_EQSL_QSL_SENT) { + case "Y": + $html .= "green"; + break; + default: + $html .= "red"; + } + $html .= "\">▲"; + $html .= "COL_EQSL_QSL_RCVD) { + case "Y": + $html .= "green"; + break; + default: + $html .= "red"; + } + $html .= "\">▼"; + $html .= ""; + $html .= "COL_QRZCOM_QSO_UPLOAD_STATUS) { + case "Y": + $html .= "green"; + break; + default: + $html .= "red"; + } + $html .= "\">▲"; + $html .= "COL_QRZCOM_QSO_DOWNLOAD_STATUS) { + case "Y": + $html .= "green"; + break; + default: + $html .= "red"; + } + $html .= "\">▼"; + $html .= ""; + $html .= "COL_QSL_SENT) { + case "Y": + $html .= "green"; + break; + case "Q": + $html .= "yellow"; + break; + case "R": + $html .= "yellow"; + break; + case "I": + $html .= "grey"; + break; + default: + $html .= "red"; + } + $html .= "\">▲"; + $html .= "COL_QSL_RCVD) { + case "Y": + $html .= "green"; + break; + case "Q": + $html .= "yellow"; + break; + case "R": + $html .= "yellow"; + break; + case "I": + $html .= "grey"; + break; + default: + $html .= "red"; + } + $html .= "\">▼"; + $html .= "" . $row->station_callsign . "
"; $html .= "
"; return $html; } else { - // if session data callbook_type is qrz - if ($this->session->userdata('callbook_type') == "QRZ") { - // Lookup using QRZ - $this->load->library('qrz'); + // if session data callbook_type is qrz + if ($this->session->userdata('callbook_type') == "QRZ") { + // Lookup using QRZ + $this->load->library('qrz'); - // Load the encryption library - $this->load->library('encryption'); + // Load the encryption library + $this->load->library('encryption'); - // Decrypt the password - $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); + // Decrypt the password + $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); - if(!$this->session->userdata('qrz_session_key')) { - $qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password); - $this->session->set_userdata('qrz_session_key', $qrz_session_key); - } + if (!$this->session->userdata('qrz_session_key')) { + $qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password); + $this->session->set_userdata('qrz_session_key', $qrz_session_key); + } + $callsign['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname')); + + if (empty($callsign['callsign']['callsign'])) { + $qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password); + $this->session->set_userdata('qrz_session_key', $qrz_session_key); $callsign['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname')); + } + if (isset($callsign['callsign']['dxcc'])) { + $this->load->model('logbook_model'); + $entity = $this->logbook_model->get_entity($callsign['callsign']['dxcc']); + $callsign['callsign']['dxcc_name'] = $entity['name']; + } + } elseif ($this->session->userdata('callbook_type') == "HamQTH") { + // Load the HamQTH library + $this->load->library('hamqth'); - if (empty($callsign['callsign']['callsign'])) { - $qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password); - $this->session->set_userdata('qrz_session_key', $qrz_session_key); - $callsign['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname')); - } - if (isset($callsign['callsign']['dxcc'])) { - $this->load->model('logbook_model'); - $entity = $this->logbook_model->get_entity($callsign['callsign']['dxcc']); - $callsign['callsign']['dxcc_name'] = $entity['name']; - } - } elseif ($this->session->userdata('callbook_type') == "HamQTH") { - // Load the HamQTH library - $this->load->library('hamqth'); + // Load the encryption library + $this->load->library('encryption'); - // Load the encryption library - $this->load->library('encryption'); + // Decrypt the password + $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); - // Decrypt the password - $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); - - if(!$this->session->userdata('hamqth_session_key')) { - $hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password); - $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); - } - - $callsign['callsign'] = $this->hamqth->search($id, $this->session->userdata('hamqth_session_key')); - - // If HamQTH session has expired, start a new session and retry the search. - if($callsign['callsign']['error'] == "Session does not exist or expired") { - $hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password); - $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); - $callsign['callsign'] = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key')); - } - if (isset($data['callsign']['gridsquare'])) { - $this->load->model('logbook_model'); - $callsign['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($data['callsign']['gridsquare'],0,4)), 0, $this->session->userdata('user_default_band')); - } - if (isset($callsign['callsign']['dxcc'])) { - $this->load->model('logbook_model'); - $entity = $this->logbook_model->get_entity($callsign['callsign']['dxcc']); - $callsign['callsign']['dxcc_name'] = $entity['name']; - } - if (isset($callsign['callsign']['error'])) { - $callsign['error'] = $callsign['callsign']['error']; - } - } else { - $callsign['error'] = 'Lookup not configured. Please review configuration.'; + if (!$this->session->userdata('hamqth_session_key')) { + $hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password); + $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); } + $callsign['callsign'] = $this->hamqth->search($id, $this->session->userdata('hamqth_session_key')); - if (isset($callsign['callsign']['gridsquare'])) { + // If HamQTH session has expired, start a new session and retry the search. + if ($callsign['callsign']['error'] == "Session does not exist or expired") { + $hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password); + $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); + $callsign['callsign'] = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key')); + } + if (isset($data['callsign']['gridsquare'])) { $this->load->model('logbook_model'); - $callsign['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($callsign['callsign']['gridsquare'],0,4)), 0, $this->session->userdata('user_default_band')); + $callsign['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($data['callsign']['gridsquare'], 0, 4)), 0, $this->session->userdata('user_default_band')); + } + if (isset($callsign['callsign']['dxcc'])) { + $this->load->model('logbook_model'); + $entity = $this->logbook_model->get_entity($callsign['callsign']['dxcc']); + $callsign['callsign']['dxcc_name'] = $entity['name']; } if (isset($callsign['callsign']['error'])) { $callsign['error'] = $callsign['callsign']['error']; } + } else { + // No callbook type set, return error message + $callsign['error'] = 'Online callbook not configured. Go to Account Settings and select either QRZ or HamQTH in the "Callbook" section.'; + } - $callsign['id'] = strtoupper($id); - return $this->load->view('search/result', $callsign, true); + if (isset($callsign['callsign']['gridsquare'])) { + $this->load->model('logbook_model'); + $callsign['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($callsign['callsign']['gridsquare'], 0, 4)), 0, $this->session->userdata('user_default_band')); + } + if (isset($callsign['callsign']['error'])) { + $callsign['error'] = $callsign['callsign']['error']; + } + + $callsign['id'] = strtoupper($id); + return $this->load->view('search/result', $callsign, true); } } - function search_result($id="", $id2="") { + function search_result($id = "", $id2 = "") + { $this->load->model('user_model'); - - if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } + + if (!$this->user_model->authorize($this->config->item('auth_mode'))) { + return; + } $fixedid = $id; if ($id2 != "") { - if (strlen($id2)>3) { // Last Element longer than 3 chars? Take that as call + if (strlen($id2) > 3) { // Last Element longer than 3 chars? Take that as call $fixedid = $id2; } else { // Last Element up to 3 Chars? Take first element as Call $fixedid = $id; @@ -924,14 +933,12 @@ class Logbook extends CI_Controller { if ($query->num_rows() > 0) { $data['results'] = $query; $this->load->view('view_log/partial/log_ajax.php', $data); - } - else { + } else { $this->load->model('search'); $iota_search = $this->search->callsign_iota($id); - if ($iota_search->num_rows() > 0) - { + if ($iota_search->num_rows() > 0) { $data['results'] = $iota_search; $this->load->view('view_log/partial/log_ajax.php', $data); @@ -947,7 +954,7 @@ class Logbook extends CI_Controller { // Decrypt the password $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); - if(!$this->session->userdata('qrz_session_key')) { + if (!$this->session->userdata('qrz_session_key')) { $qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password); $this->session->set_userdata('qrz_session_key', $qrz_session_key); } @@ -965,7 +972,7 @@ class Logbook extends CI_Controller { } if (isset($data['callsign']['gridsquare'])) { $this->load->model('logbook_model'); - $data['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($data['callsign']['gridsquare'],0,4)), 0, $this->session->userdata('user_default_band')); + $data['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($data['callsign']['gridsquare'], 0, 4)), 0, $this->session->userdata('user_default_band')); } } elseif ($this->session->userdata('callbook_type') == "HamQTH") { // Load the HamQTH library @@ -976,9 +983,9 @@ class Logbook extends CI_Controller { // Decrypt the password $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); - - if(!$this->session->userdata('hamqth_session_key')) { + + if (!$this->session->userdata('hamqth_session_key')) { $hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password); $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); } @@ -986,14 +993,14 @@ class Logbook extends CI_Controller { $data['callsign'] = $this->hamqth->search($fixedid, $this->session->userdata('hamqth_session_key')); // If HamQTH session has expired, start a new session and retry the search. - if($data['callsign']['error'] == "Session does not exist or expired") { + if ($data['callsign']['error'] == "Session does not exist or expired") { $hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password); $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); $data['callsign'] = $this->hamqth->search($fixedid, $this->session->userdata('hamqth_session_key')); } if (isset($data['callsign']['gridsquare'])) { $this->load->model('logbook_model'); - $data['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($data['callsign']['gridsquare'],0,4)), 0, $this->session->userdata('user_default_band')); + $data['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($data['callsign']['gridsquare'], 0, 4)), 0, $this->session->userdata('user_default_band')); } if (isset($data['callsign']['dxcc'])) { $this->load->model('logbook_model'); @@ -1007,39 +1014,43 @@ class Logbook extends CI_Controller { $data['error'] = 'Lookup not configured. Please review configuration.'; } - $data['id'] = strtoupper($id); + $data['id'] = strtoupper($id); $this->load->view('search/result', $data); } } } else { $data['results'] = $query; - + $this->load->view('view_log/partial/log_ajax.php', $data); } } - function querydb($id) { + function querydb($id) + { $this->db->from($this->config->item('table_name')); - $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); - $this->db->join('dxcc_entities', 'dxcc_entities.adif = '.$this->config->item('table_name').'.COL_DXCC', 'left outer'); - $this->db->join('lotw_users', 'lotw_users.callsign = '.$this->config->item('table_name').'.col_call', 'left outer'); + $this->db->join('station_profile', 'station_profile.station_id = ' . $this->config->item('table_name') . '.station_id'); + $this->db->join('dxcc_entities', 'dxcc_entities.adif = ' . $this->config->item('table_name') . '.COL_DXCC', 'left outer'); + $this->db->join('lotw_users', 'lotw_users.callsign = ' . $this->config->item('table_name') . '.col_call', 'left outer'); $this->db->group_start(); - $this->db->like(''.$this->config->item('table_name').'.COL_CALL', $id); - $this->db->or_like(''.$this->config->item('table_name').'.COL_GRIDSQUARE', $id); - $this->db->or_like(''.$this->config->item('table_name').'.COL_VUCC_GRIDS', $id); + $this->db->like('' . $this->config->item('table_name') . '.COL_CALL', $id); + $this->db->or_like('' . $this->config->item('table_name') . '.COL_GRIDSQUARE', $id); + $this->db->or_like('' . $this->config->item('table_name') . '.COL_VUCC_GRIDS', $id); $this->db->group_end(); $this->db->where('station_profile.user_id', $this->session->userdata('user_id')); - $this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', 'desc'); + $this->db->order_by('' . $this->config->item('table_name') . '.COL_TIME_ON', 'desc'); return $this->db->get(); - } + } - function search_duplicates($station_id) { + function search_duplicates($station_id) + { $station_id = $this->security->xss_clean($station_id); $this->load->model('user_model'); - if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } + if (!$this->user_model->authorize($this->config->item('auth_mode'))) { + return; + } $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -1048,10 +1059,10 @@ class Logbook extends CI_Controller { return null; } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $location_list = "'" . implode("','", $logbooks_locations_array) . "'"; $sql = 'select count(*) as occurence, COL_CALL, COL_MODE, COL_SUBMODE, station_callsign, COL_SAT_NAME, COL_BAND, min(col_time_on) Mintime, max(col_time_on) Maxtime from ' . $this->config->item('table_name') . - ' join station_profile on ' . $this->config->item('table_name') . '.station_id = station_profile.station_id where ' . $this->config->item('table_name') .'.station_id in ('. $location_list . ')'; + ' join station_profile on ' . $this->config->item('table_name') . '.station_id = station_profile.station_id where ' . $this->config->item('table_name') . '.station_id in (' . $location_list . ')'; if ($station_id != 'All') { $sql .= ' and station_profile.station_id = ' . $station_id; @@ -1064,15 +1075,17 @@ class Logbook extends CI_Controller { $data['qsos'] = $query; $this->load->view('search/duplicates_result.php', $data); - } - function search_lotw_unconfirmed($station_id) { + function search_lotw_unconfirmed($station_id) + { $station_id = $this->security->xss_clean($station_id); $this->load->model('user_model'); - if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } + if (!$this->user_model->authorize($this->config->item('auth_mode'))) { + return; + } $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -1081,12 +1094,12 @@ class Logbook extends CI_Controller { return null; } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $location_list = "'" . implode("','", $logbooks_locations_array) . "'"; $sql = 'select COL_CALL, COL_MODE, COL_SUBMODE, station_callsign, COL_SAT_NAME, COL_BAND, COL_TIME_ON, lotw_users.lastupload from ' . $this->config->item('table_name') . - ' join station_profile on ' . $this->config->item('table_name') . '.station_id = station_profile.station_id + ' join station_profile on ' . $this->config->item('table_name') . '.station_id = station_profile.station_id join lotw_users on ' . $this->config->item('table_name') . '.col_call = lotw_users.callsign - where ' . $this->config->item('table_name') .'.station_id in ('. $location_list . ')'; + where ' . $this->config->item('table_name') . '.station_id in (' . $location_list . ')'; if ($station_id != 'All') { $sql .= ' and station_profile.station_id = ' . $station_id; @@ -1099,15 +1112,17 @@ class Logbook extends CI_Controller { $data['qsos'] = $query; $this->load->view('search/lotw_unconfirmed_result.php', $data); - } - function search_incorrect_cq_zones($station_id) { + function search_incorrect_cq_zones($station_id) + { $station_id = $this->security->xss_clean($station_id); $this->load->model('user_model'); - if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } + if (!$this->user_model->authorize($this->config->item('auth_mode'))) { + return; + } $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -1116,10 +1131,10 @@ class Logbook extends CI_Controller { return null; } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $location_list = "'" . implode("','", $logbooks_locations_array) . "'"; $sql = 'select *, (select group_concat(distinct cqzone order by cqzone) from dxcc_master where countrycode = thcv.col_dxcc and cqzone <> \'\' order by cqzone asc) as correctcqzone from ' . $this->config->item('table_name') . - ' thcv join station_profile on thcv.station_id = station_profile.station_id where thcv.station_id in ('. $location_list . ') + ' thcv join station_profile on thcv.station_id = station_profile.station_id where thcv.station_id in (' . $location_list . ') and not exists (select 1 from dxcc_master where countrycode = thcv.col_dxcc and cqzone = col_cqz) and col_dxcc > 0 '; @@ -1137,238 +1152,341 @@ class Logbook extends CI_Controller { /* * Provide a dxcc search, returning results json encoded */ - function local_find_dxcc($call = "", $date = "") { + function local_find_dxcc($call = "", $date = "") + { $this->load->model("logbook_model"); - if ($date == ''){ + if ($date == '') { $date = date("Y-m-d"); } $ans = $this->logbook_model->check_dxcc_stored_proc($call, $date); print json_encode($ans); } - function dxcheck($call = "", $date = "") { + function dxcheck($call = "", $date = "") + { $this->load->model("logbook_model"); - if ($date == ''){ + if ($date == '') { $date = date("Y-m-d"); } $ans = $this->logbook_model->dxcc_lookup($call, $date); return $ans; } - function getentity($adif) { - $this->load->model("logbook_model"); + function getentity($adif) + { + $this->load->model("logbook_model"); - $entity = $this->logbook_model->get_entity($adif); - return $entity; - } + $entity = $this->logbook_model->get_entity($adif); + return $entity; + } /* return station bearing */ - function searchbearing() { - $locator = xss_clean($this->input->post('grid')); - $station_id = xss_clean($this->input->post('stationProfile')); - $this->load->library('Qra'); + function searchbearing() + { + $locator = xss_clean($this->input->post('grid')); + $station_id = xss_clean($this->input->post('stationProfile')); + $this->load->library('Qra'); - if($locator != null) { - if (isset($station_id)) { - // be sure that station belongs to user - $this->load->model('Stations'); - if (!$this->Stations->check_station_is_accessible($station_id)) { - return ""; - } - - // get station profile - $station_profile = $this->Stations->profile_clean($station_id); - - // get locator - $mylocator = $station_profile->station_gridsquare; - } else if($this->session->userdata('user_locator') != null){ - $mylocator = $this->session->userdata('user_locator'); - } else { - $mylocator = $this->config->item('locator'); + if ($locator != null) { + if (isset($station_id)) { + // be sure that station belongs to user + $this->load->model('Stations'); + if (!$this->Stations->check_station_is_accessible($station_id)) { + return ""; } - if ($this->session->userdata('user_measurement_base') == NULL) { - $measurement_base = $this->config->item('measurement_base'); - } - else { - $measurement_base = $this->session->userdata('user_measurement_base'); - } + // get station profile + $station_profile = $this->Stations->profile_clean($station_id); - $bearing = $this->qra->bearing($mylocator, $locator, $measurement_base); - - echo $bearing; + // get locator + $mylocator = $station_profile->station_gridsquare; + } else if ($this->session->userdata('user_locator') != null) { + $mylocator = $this->session->userdata('user_locator'); + } else { + $mylocator = $this->config->item('locator'); } - return ""; + + if ($this->session->userdata('user_measurement_base') == NULL) { + $measurement_base = $this->config->item('measurement_base'); + } else { + $measurement_base = $this->session->userdata('user_measurement_base'); + } + + $bearing = $this->qra->bearing($mylocator, $locator, $measurement_base); + + echo $bearing; + } + return ""; } /* return distance */ - function searchdistance() { - $locator = xss_clean($this->input->post('grid')); - $station_id = xss_clean($this->input->post('stationProfile')); - $this->load->library('Qra'); + function searchdistance() + { + $locator = xss_clean($this->input->post('grid')); + $station_id = xss_clean($this->input->post('stationProfile')); + $this->load->library('Qra'); - if($locator != null) { - if (isset($station_id)) { - // be sure that station belongs to user - $this->load->model('Stations'); - if (!$this->Stations->check_station_is_accessible($station_id)) { - return 0; - } - - // get station profile - $station_profile = $this->Stations->profile_clean($station_id); - - // get locator - $mylocator = $station_profile->station_gridsquare; - } else if($this->session->userdata('user_locator') != null){ - $mylocator = $this->session->userdata('user_locator'); - } else { - $mylocator = $this->config->item('locator'); + if ($locator != null) { + if (isset($station_id)) { + // be sure that station belongs to user + $this->load->model('Stations'); + if (!$this->Stations->check_station_is_accessible($station_id)) { + return 0; } - $distance = $this->qra->distance($mylocator, $locator, 'K'); + // get station profile + $station_profile = $this->Stations->profile_clean($station_id); - echo $distance; + // get locator + $mylocator = $station_profile->station_gridsquare; + } else if ($this->session->userdata('user_locator') != null) { + $mylocator = $this->session->userdata('user_locator'); + } else { + $mylocator = $this->config->item('locator'); } - return 0; + + $distance = $this->qra->distance($mylocator, $locator, 'K'); + + echo $distance; + } + return 0; } /* return station bearing */ - function bearing($locator, $unit = 'M', $station_id = null) { - $this->load->library('Qra'); + function bearing($locator, $unit = 'M', $station_id = null) + { + $this->load->library('Qra'); - if($locator != null) { - if (isset($station_id)) { - // be sure that station belongs to user - $this->load->model('Stations'); - if (!$this->Stations->check_station_is_accessible($station_id)) { - return ""; - } - - // get station profile - $station_profile = $this->Stations->profile_clean($station_id); - - // get locator - $mylocator = $station_profile->station_gridsquare; - } else if($this->session->userdata('user_locator') != null){ - $mylocator = $this->session->userdata('user_locator'); - } else { - $mylocator = $this->config->item('locator'); + if ($locator != null) { + if (isset($station_id)) { + // be sure that station belongs to user + $this->load->model('Stations'); + if (!$this->Stations->check_station_is_accessible($station_id)) { + return ""; } - $bearing = $this->qra->bearing($mylocator, $locator, $unit); + // get station profile + $station_profile = $this->Stations->profile_clean($station_id); - return $bearing; + // get locator + $mylocator = $station_profile->station_gridsquare; + } else if ($this->session->userdata('user_locator') != null) { + $mylocator = $this->session->userdata('user_locator'); + } else { + $mylocator = $this->config->item('locator'); } - return ""; + + $bearing = $this->qra->bearing($mylocator, $locator, $unit); + + return $bearing; + } + return ""; } /* return distance */ - function distance($locator, $station_id = null) { - $distance = 0; - $this->load->library('Qra'); + function distance($locator, $station_id = null) + { + $distance = 0; + $this->load->library('Qra'); - if($locator != null) { - if (isset($station_id)) { - // be sure that station belongs to user - $this->load->model('Stations'); - if (!$this->Stations->check_station_is_accessible($station_id)) { - return 0; - } - - // get station profile - $station_profile = $this->Stations->profile_clean($station_id); - - // get locator - $mylocator = $station_profile->station_gridsquare; - } else if($this->session->userdata('user_locator') != null){ - $mylocator = $this->session->userdata('user_locator'); - } else { - $mylocator = $this->config->item('locator'); + if ($locator != null) { + if (isset($station_id)) { + // be sure that station belongs to user + $this->load->model('Stations'); + if (!$this->Stations->check_station_is_accessible($station_id)) { + return 0; } - $distance = $this->qra->distance($mylocator, $locator, 'K'); + // get station profile + $station_profile = $this->Stations->profile_clean($station_id); + // get locator + $mylocator = $station_profile->station_gridsquare; + } else if ($this->session->userdata('user_locator') != null) { + $mylocator = $this->session->userdata('user_locator'); + } else { + $mylocator = $this->config->item('locator'); } - return $distance; + + $distance = $this->qra->distance($mylocator, $locator, 'K'); + } + return $distance; } - function qralatlng($qra) { + function qralatlng($qra) + { $this->load->library('Qra'); $latlng = $this->qra->qra2latlong($qra); return $latlng; } - function qralatlngjson() { + function qralatlngjson() + { $qra = xss_clean($this->input->post('qra')); $this->load->library('Qra'); $latlng = $this->qra->qra2latlong($qra); print json_encode($latlng); } - function get_qsos($num, $offset) { - $this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*'); - $this->db->from($this->config->item('table_name')); + function get_qsos($num, $offset) + { + $this->db->select('' . $this->config->item('table_name') . '.COL_CALL, ' . $this->config->item('table_name') . '.COL_BAND, ' . $this->config->item('table_name') . '.COL_TIME_ON, ' . $this->config->item('table_name') . '.COL_RST_RCVD, ' . $this->config->item('table_name') . '.COL_RST_SENT, ' . $this->config->item('table_name') . '.COL_MODE, ' . $this->config->item('table_name') . '.COL_SUBMODE, ' . $this->config->item('table_name') . '.COL_NAME, ' . $this->config->item('table_name') . '.COL_COUNTRY, ' . $this->config->item('table_name') . '.COL_PRIMARY_KEY, ' . $this->config->item('table_name') . '.COL_SAT_NAME, ' . $this->config->item('table_name') . '.COL_GRIDSQUARE, ' . $this->config->item('table_name') . '.COL_QSL_RCVD, ' . $this->config->item('table_name') . '.COL_EQSL_QSL_RCVD, ' . $this->config->item('table_name') . '.COL_EQSL_QSL_SENT, ' . $this->config->item('table_name') . '.COL_QSL_SENT, ' . $this->config->item('table_name') . '.COL_STX, ' . $this->config->item('table_name') . '.COL_STX_STRING, ' . $this->config->item('table_name') . '.COL_SRX, ' . $this->config->item('table_name') . '.COL_SRX_STRING, ' . $this->config->item('table_name') . '.COL_LOTW_QSL_SENT, ' . $this->config->item('table_name') . '.COL_LOTW_QSL_RCVD, ' . $this->config->item('table_name') . '.COL_VUCC_GRIDS, 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'); - $this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', "desc"); + $this->db->join('station_profile', 'station_profile.station_id = ' . $this->config->item('table_name') . '.station_id'); + $this->db->order_by('' . $this->config->item('table_name') . '.COL_TIME_ON', "desc"); - $this->db->limit($num); - $this->db->offset($offset); + $this->db->limit($num); + $this->db->offset($offset); - return $this->db->get(); - } + return $this->db->get(); + } - function part_table_header_col($ctx, $name) { - $ret=''; - switch($name) { - case 'Mode': $ret.= ''.$ctx->lang->line('gen_hamradio_mode').''; break; - case 'RSTS': $ret.= ''.$ctx->lang->line('gen_hamradio_rsts').''; break; - case 'RSTR': $ret.= ''.$ctx->lang->line('gen_hamradio_rstr').''; break; - case 'Country': $ret.= ''.$ctx->lang->line('general_word_country').''; break; - case 'IOTA': $ret.= ''.$ctx->lang->line('gen_hamradio_iota').''; break; - case 'SOTA': $ret.= ''.$ctx->lang->line('gen_hamradio_sota').''; break; - case 'WWFF': $ret.= ''.$ctx->lang->line('gen_hamradio_wwff').''; break; - case 'POTA': $ret.= ''.$ctx->lang->line('gen_hamradio_pota').''; break; - case 'State': $ret.= ''.$ctx->lang->line('gen_hamradio_state').''; break; - case 'Grid': $ret.= ''.$ctx->lang->line('gen_hamradio_gridsquare').''; break; - case 'Distance': $ret.= ''.$ctx->lang->line('gen_hamradio_distance').''; break; - case 'Band': $ret.= ''.$ctx->lang->line('gen_hamradio_band').''; break; - case 'Frequency': $ret.= ''.$ctx->lang->line('gen_hamradio_frequency').''; break; - case 'Operator': $ret.= ''.$ctx->lang->line('gen_hamradio_operator').''; break; + function part_table_header_col($ctx, $name) + { + $ret = ''; + switch ($name) { + case 'Mode': + $ret .= '' . $ctx->lang->line('gen_hamradio_mode') . ''; + break; + case 'RSTS': + $ret .= '' . $ctx->lang->line('gen_hamradio_rsts') . ''; + break; + case 'RSTR': + $ret .= '' . $ctx->lang->line('gen_hamradio_rstr') . ''; + break; + case 'Country': + $ret .= '' . $ctx->lang->line('general_word_country') . ''; + break; + case 'IOTA': + $ret .= '' . $ctx->lang->line('gen_hamradio_iota') . ''; + break; + case 'SOTA': + $ret .= '' . $ctx->lang->line('gen_hamradio_sota') . ''; + break; + case 'WWFF': + $ret .= '' . $ctx->lang->line('gen_hamradio_wwff') . ''; + break; + case 'POTA': + $ret .= '' . $ctx->lang->line('gen_hamradio_pota') . ''; + break; + case 'State': + $ret .= '' . $ctx->lang->line('gen_hamradio_state') . ''; + break; + case 'Grid': + $ret .= '' . $ctx->lang->line('gen_hamradio_gridsquare') . ''; + break; + case 'Distance': + $ret .= '' . $ctx->lang->line('gen_hamradio_distance') . ''; + break; + case 'Band': + $ret .= '' . $ctx->lang->line('gen_hamradio_band') . ''; + break; + case 'Frequency': + $ret .= '' . $ctx->lang->line('gen_hamradio_frequency') . ''; + break; + case 'Operator': + $ret .= '' . $ctx->lang->line('gen_hamradio_operator') . ''; + break; } return $ret; } - function part_QrbCalcLink($mygrid, $grid, $vucc) { - $ret=''; + function part_QrbCalcLink($mygrid, $grid, $vucc) + { + $ret = ''; if (!empty($grid)) { - $ret.= $grid . ' '; + $ret .= $grid . ' '; } else if (!empty($vucc)) { - $ret.= $vucc .' '; + $ret .= $vucc . ' '; } return $ret; } - function part_table_col($row, $name) { - $ret=''; - $ci =& get_instance(); - switch($name) { - case 'Mode': $ret.= ''; $ret.= $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE . ''; break; - case 'RSTS': $ret.= '' . $row->COL_RST_SENT; if ($row->COL_STX) { $ret.= ' COL_CONTEST_ID:"n/a").'" class="badge text-bg-light">'; $ret.=sprintf("%03d", $row->COL_STX); $ret.= '';} if ($row->COL_STX_STRING) { $ret.= ' COL_CONTEST_ID:"n/a").'" class="badge text-bg-light">' . $row->COL_STX_STRING . '';} $ret.= ''; break; - case 'RSTR': $ret.= '' . $row->COL_RST_RCVD; if ($row->COL_SRX) { $ret.= ' COL_CONTEST_ID:"n/a").'" class="badge text-bg-light">'; $ret.=sprintf("%03d", $row->COL_SRX); $ret.= '';} if ($row->COL_SRX_STRING) { $ret.= ' COL_CONTEST_ID:"n/a").'" class="badge text-bg-light">' . $row->COL_SRX_STRING . '';} $ret.= ''; break; - case 'Country': $ret.= '' . ucwords(strtolower(($row->COL_COUNTRY))); if ($row->end != NULL) $ret.= ' '.$ci->lang->line('gen_hamradio_deleted_dxcc').'' . ''; break; - case 'IOTA': $ret.= '' . ($row->COL_IOTA) . ''; break; - case 'SOTA': $ret.= '' . ($row->COL_SOTA_REF) . ''; break; - case 'WWFF': $ret.= '' . ($row->COL_WWFF_REF) . ''; break; - case 'POTA': $ret.= '' . ($row->COL_POTA_REF) . ''; break; - case 'Grid': $ret.= '' . $this->part_QrbCalcLink($row->COL_MY_GRIDSQUARE, $row->COL_VUCC_GRIDS, $row->COL_GRIDSQUARE) . ''; break; - case 'Distance': $ret .= '' . (property_exists($row, 'COL_DISTANCE') && $row->COL_DISTANCE ? $row->COL_DISTANCE . ' km' : '') . ''; break; - case 'Band': $ret.= ''; if($row->COL_SAT_NAME != null) { $ret.= ''.$row->COL_SAT_NAME.''; } else { $ret.= strtolower($row->COL_BAND); } $ret.= ''; break; - case 'Frequency': $ret.= ''; if($row->COL_SAT_NAME != null) { $ret.= ''.$row->COL_SAT_NAME.''; } else { if($row->COL_FREQ != null) { $ret.= $ci->frequency->hz_to_mhz($row->COL_FREQ); } else { $ret.= strtolower($row->COL_BAND); } } $ret.= ''; break; - case 'State': $ret.= '' . ($row->COL_STATE) . ''; break; - case 'Operator': $ret.= '' . ($row->COL_OPERATOR) . ''; break; + function part_table_col($row, $name) + { + $ret = ''; + $ci = &get_instance(); + switch ($name) { + case 'Mode': + $ret .= ''; + $ret .= $row->COL_SUBMODE == null ? $row->COL_MODE : $row->COL_SUBMODE . ''; + break; + case 'RSTS': + $ret .= '' . $row->COL_RST_SENT; + if ($row->COL_STX) { + $ret .= ' COL_CONTEST_ID : "n/a") . '" class="badge text-bg-light">'; + $ret .= sprintf("%03d", $row->COL_STX); + $ret .= ''; + } + if ($row->COL_STX_STRING) { + $ret .= ' COL_CONTEST_ID : "n/a") . '" class="badge text-bg-light">' . $row->COL_STX_STRING . ''; + } + $ret .= ''; + break; + case 'RSTR': + $ret .= '' . $row->COL_RST_RCVD; + if ($row->COL_SRX) { + $ret .= ' COL_CONTEST_ID : "n/a") . '" class="badge text-bg-light">'; + $ret .= sprintf("%03d", $row->COL_SRX); + $ret .= ''; + } + if ($row->COL_SRX_STRING) { + $ret .= ' COL_CONTEST_ID : "n/a") . '" class="badge text-bg-light">' . $row->COL_SRX_STRING . ''; + } + $ret .= ''; + break; + case 'Country': + $ret .= '' . ucwords(strtolower(($row->COL_COUNTRY))); + if ($row->end != NULL) $ret .= ' ' . $ci->lang->line('gen_hamradio_deleted_dxcc') . '' . ''; + break; + case 'IOTA': + $ret .= '' . ($row->COL_IOTA) . ''; + break; + case 'SOTA': + $ret .= '' . ($row->COL_SOTA_REF) . ''; + break; + case 'WWFF': + $ret .= '' . ($row->COL_WWFF_REF) . ''; + break; + case 'POTA': + $ret .= '' . ($row->COL_POTA_REF) . ''; + break; + case 'Grid': + $ret .= '' . $this->part_QrbCalcLink($row->COL_MY_GRIDSQUARE, $row->COL_VUCC_GRIDS, $row->COL_GRIDSQUARE) . ''; + break; + case 'Distance': + $ret .= '' . (property_exists($row, 'COL_DISTANCE') && $row->COL_DISTANCE ? $row->COL_DISTANCE . ' km' : '') . ''; + break; + case 'Band': + $ret .= ''; + if ($row->COL_SAT_NAME != null) { + $ret .= '' . $row->COL_SAT_NAME . ''; + } else { + $ret .= strtolower($row->COL_BAND); + } + $ret .= ''; + break; + case 'Frequency': + $ret .= ''; + if ($row->COL_SAT_NAME != null) { + $ret .= '' . $row->COL_SAT_NAME . ''; + } else { + if ($row->COL_FREQ != null) { + $ret .= $ci->frequency->hz_to_mhz($row->COL_FREQ); + } else { + $ret .= strtolower($row->COL_BAND); + } + } + $ret .= ''; + break; + case 'State': + $ret .= '' . ($row->COL_STATE) . ''; + break; + case 'Operator': + $ret .= '' . ($row->COL_OPERATOR) . ''; + break; } return $ret; }