Added call_cnf, call_cnf_band and call_cnf_band_mode as result

This commit is contained in:
int2001
2024-10-01 05:38:41 +00:00
parent 035e95356f
commit 5f7ff9ab2f
2 changed files with 37 additions and 24 deletions

View File

@@ -745,10 +745,11 @@ class API extends CI_Controller {
/*
*
* Pool any local data we have for a callsign
* Pool stations local data we have for a callsign
*
*/
$call_lookup_results = $this->logbook_model->call_lookup_result($lookup_callsign, $station_ids);
$userdata=$this->user_model->get_by_id($user_id);
$call_lookup_results = $this->logbook_model->call_lookup_result($lookup_callsign, $station_ids,$userdata->row()->user_default_confirmation,$band,$mode);
if($call_lookup_results != null) {
$return['name'] = $call_lookup_results->COL_NAME;
@@ -761,6 +762,9 @@ class API extends CI_Controller {
$return['dxcc_id'] = $call_lookup_results->COL_DXCC;
$return['cont'] = $call_lookup_results->COL_CONT;
$return['workedBefore'] = true;
$return['call_confirmed'] = ($call_lookup_results->CALL_CNF==1) ? true : false;
$return['call_confirmed_band'] = ($call_lookup_results->CALL_CNF_BAND==1) ? true : false;
$return['call_confirmed_band_mode'] = ($call_lookup_results->CALL_CNF_BAND_MODE==1) ? true : false;
if ($return['gridsquare'] != "") {
$return['latlng'] = $this->qralatlng($return['gridsquare']);
@@ -784,7 +788,6 @@ class API extends CI_Controller {
* Output Returned data
*
*/
$userdata=$this->user_model->get_by_id($user_id);
if ($return['dxcc_id'] ?? '' != '') { // DXCC derivated before?
$return['dxcc_confirmed']=($this->logbook_model->check_if_dxcc_cnfmd_in_logbook_api($userdata->row()->user_default_confirmation,$return['dxcc_id'], $station_ids, null, null)>0) ? true : false;
@@ -922,7 +925,7 @@ class API extends CI_Controller {
* Pool any local data we have for a callsign
*
*/
$call_lookup_results = $this->logbook_model->call_lookup_result($lookup_callsign, $station_ids);
$call_lookup_results = $this->logbook_model->call_lookup_result($lookup_callsign, $station_ids,'','NO BAND','NO MODE');
if($call_lookup_results != null)
{

View File

@@ -1449,26 +1449,33 @@ class Logbook_model extends CI_Model {
*
* Function: call_lookup_result
*
* Usage: Callsign lookup data for the QSO panel and API/callsign_lookup
* Usage: Callsign lookup data for API/callsign_lookup
*
*/
function call_lookup_result($callsign, $station_ids) {
$this->db->select('COL_CALL, COL_NAME, COL_QSL_VIA, COL_GRIDSQUARE, COL_QTH, COL_IOTA, COL_TIME_ON, COL_STATE, COL_CNTY, COL_DXCC, COL_CONT');
$this->db->where('station_id in (' . $station_ids . ')');
$this->db->where('COL_CALL', $callsign);
$where = "COL_NAME != \"\"";
function call_lookup_result($callsign, $station_ids, $user_default_confirmation, $band, $mode) {
$binding=[];
$qsl_where = $this->qsl_default_where($user_default_confirmation);
$band_addon='COL_BAND=?';
if ($band == 'SAT') {
$band_addon="COL_PROP_MODE=?";
}
$this->db->where($where);
$sql="SELECT COL_CALL, COL_NAME, COL_QSL_VIA, COL_GRIDSQUARE, COL_QTH, COL_IOTA, COL_TIME_ON, COL_STATE, COL_CNTY, COL_DXCC, COL_CONT,
CASE WHEN ( (".$qsl_where.") ) THEN 1 ELSE 0 END AS CALL_CNF,
CASE WHEN ( (".$qsl_where.") AND ".$band_addon.") THEN 1 ELSE 0 END AS CALL_CNF_BAND,
CASE WHEN ( (".$qsl_where.") AND ".$band_addon." AND COL_MODE=?) THEN 1 ELSE 0 END AS CALL_CNF_BAND_MODE
FROM ".$this->config->item('table_name')." WHERE ";
$sql.="station_id IN (".$station_ids.") AND COL_CALL = ? ORDER BY call_cnf desc, call_cnf_band desc, call_cnf_band_mode desc limit 1";
$binding[]=$band;
$binding[]=$band;
$binding[]=$mode;
$binding[]=$callsign;
$this->db->order_by("COL_TIME_ON", "desc");
$this->db->limit(1);
$query = $this->db->get($this->config->item('table_name'));
$name = "";
$query = $this->db->query($sql, $binding);
$data = [];
if ($query->num_rows() > 0) {
$data = $query->row();
}
return $data;
}
@@ -2198,13 +2205,8 @@ class Logbook_model extends CI_Model {
return $query->num_rows();
}
function check_if_dxcc_cnfmd_in_logbook_api($user_default_confirmation,$dxcc, $station_ids = null, $band = null, $mode = null) {
$binding=[];
if ($station_ids == null) {
return [];
}
$extrawhere = '';
private function qsl_default_where($user_default_confirmation) {
$extrawhere='';
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) {
$extrawhere = "COL_QSL_RCVD='Y'";
}
@@ -2227,11 +2229,19 @@ class Logbook_model extends CI_Model {
}
$extrawhere .= " COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'";
}
if ($extrawhere == '') {
$extrawhere='1=0'; // No default_confirmations set? in that case everything is false
}
return $extrawhere;
}
function check_if_dxcc_cnfmd_in_logbook_api($user_default_confirmation,$dxcc, $station_ids = null, $band = null, $mode = null) {
$binding=[];
if ($station_ids == null) {
return [];
}
$extrawhere = $this->qsl_default_where($user_default_confirmation);
$sql="SELECT count(1) as CNT from ".$this->config->item('table_name')." where station_id in (".$station_ids.") and (".$extrawhere.") and COL_DXCC=?";
$binding[]=$dxcc;