diff --git a/application/controllers/Lookup.php b/application/controllers/Lookup.php index 20df0fa88..9e2b4d8d9 100644 --- a/application/controllers/Lookup.php +++ b/application/controllers/Lookup.php @@ -74,6 +74,18 @@ class Lookup extends CI_Controller { } + public function sat() { + $this->load->model('lookup_model'); + $this->load->model('bands'); + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $data['location_list'] = "'".implode("','",$logbooks_locations_array)."'"; + $data['callsign'] = xss_clean($this->input->post('callsign')); + $data['sats'] = $this->bands->get_worked_sats(); + $data['result'] = $this->lookup_model->getSatResult($data); + $this->load->view('lookup/satresult', $data); + } + public function scp() { session_write_close(); $uppercase_callsign = strtoupper($this->input->post('callsign', TRUE) ?? ''); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 77e41d339..bd0cda7c0 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -583,6 +583,11 @@ class Logbook_model extends CI_Model { } } break; + case 'SAT': + $this->db->where('COL_CALL', $searchphrase); + $this->db->where('COL_PROP_MODE', 'SAT'); + $this->db->where('COL_SAT_NAME', $sat); + break; case 'CQZone': $this->db->where('COL_CQZ', $searchphrase); break; diff --git a/application/models/Lookup_model.php b/application/models/Lookup_model.php index eb1088d60..194f2ebf8 100644 --- a/application/models/Lookup_model.php +++ b/application/models/Lookup_model.php @@ -2,6 +2,25 @@ class Lookup_model extends CI_Model{ + function getSatResult($queryinfo){ + foreach ($queryinfo['sats'] as $sat) { + $resultArray[$sat] = '-'; + } + $sql = "SELECT DISTINCT(COL_SAT_NAME) FROM ".$this->config->item('table_name')." WHERE COL_PROP_MODE = 'SAT' AND COL_CALL = ?;"; + $binds[] = $queryinfo['callsign']; + $query = $this->db->query($sql,$binds); + foreach ($query->result() as $workedsat) { + $resultArray[$workedsat->COL_SAT_NAME] = 'W'; + } + $sql = "SELECT DISTINCT(COL_SAT_NAME) FROM ".$this->config->item('table_name')." WHERE COL_PROP_MODE = 'SAT' AND COL_CALL = ?"; + $sql .= $this->buildConfirmationString('confirmed'); + $query = $this->db->query($sql,$binds); + foreach ($query->result() as $confirmedsat) { + $resultArray[$confirmedsat->COL_SAT_NAME] = 'C'; + } + return $resultArray; + } + function getSearchResult($queryinfo){ $modes = $this->get_worked_modes($queryinfo['location_list']); @@ -107,41 +126,8 @@ class Lookup_model extends CI_Model{ $binds = []; $sqlquerytypestring = ''; + $sqlqueryconfirmationstring = $this->buildConfirmationString($confirmedtype); - if ($confirmedtype == 'confirmed') { - $user_default_confirmation = $this->session->userdata('user_default_confirmation'); - $extrawhere=''; - if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) { - $extrawhere="COL_QSL_RCVD='Y'"; - } - if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'L') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; - } - $extrawhere.=" COL_LOTW_QSL_RCVD='Y'"; - } - if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'E') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; - } - $extrawhere.=" COL_EQSL_QSL_RCVD='Y'"; - } - - if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Z') !== false) { - if ($extrawhere!='') { - $extrawhere.=" OR"; - } - $extrawhere.=" COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'"; - } - - if (($confirmedtype == 'confirmed') && ($extrawhere != '')){ - $sqlqueryconfirmationstring = " and (".$extrawhere.")"; - } else { - $sqlqueryconfirmationstring = ' and (1=0)'; - } - } else { - $sqlqueryconfirmationstring = ''; - } // Fetching info for all modes and bands except satellite $sql = "SELECT distinct col_band, lower(col_mode) as col_mode FROM " . $this->config->item('table_name') . " thcv"; @@ -199,6 +185,44 @@ class Lookup_model extends CI_Model{ return $query->result(); } + function buildConfirmationString ($confirmedtype) { + if ($confirmedtype == 'confirmed') { + $user_default_confirmation = $this->session->userdata('user_default_confirmation'); + $extrawhere=''; + if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) { + $extrawhere="COL_QSL_RCVD='Y'"; + } + if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'L') !== false) { + if ($extrawhere!='') { + $extrawhere.=" OR"; + } + $extrawhere.=" COL_LOTW_QSL_RCVD='Y'"; + } + if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'E') !== false) { + if ($extrawhere!='') { + $extrawhere.=" OR"; + } + $extrawhere.=" COL_EQSL_QSL_RCVD='Y'"; + } + + if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Z') !== false) { + if ($extrawhere!='') { + $extrawhere.=" OR"; + } + $extrawhere.=" COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'"; + } + + if (($confirmedtype == 'confirmed') && ($extrawhere != '')){ + $sqlqueryconfirmationstring = " and (".$extrawhere.")"; + } else { + $sqlqueryconfirmationstring = ' and (1=0)'; + } + } else { + $sqlqueryconfirmationstring = ''; + } + return $sqlqueryconfirmationstring; + } + /* * Get's the worked modes from the log */ diff --git a/application/views/qso/award_tabs.php b/application/views/qso/award_tabs.php index 3f4d31ef8..33753b1eb 100644 --- a/application/views/qso/award_tabs.php +++ b/application/views/qso/award_tabs.php @@ -1,20 +1,22 @@