Trying to fix reduce call problem

This commit is contained in:
Andreas Kristiansen
2024-11-25 18:42:41 +01:00
parent 888f9c9743
commit a4100a4149
3 changed files with 38 additions and 48 deletions

View File

@@ -127,12 +127,12 @@ class Logbook extends CI_Controller {
$return['dxcc'] = $this->dxcheck($callsign,$date);
$lookupcall=$this->logbook_model->get_plaincall($callsign);
$return['partial'] = $this->partial($lookupcall, $band);
$lookupcall = $this->logbook_model->get_plaincall($callsign);
$callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('use_fullname'));
$return['partial'] = $this->partial($lookupcall, $callbook, $callsign, $band);
if ($this->session->userdata('user_measurement_base') == NULL) {
$measurement_base = $this->config->item('measurement_base');
} else {
@@ -614,7 +614,7 @@ class Logbook extends CI_Controller {
$this->load->view('interface_assets/footer');
}
function partial($id, $band = null) {
function partial($lookupcall, $callbook, $callsign, $band = null) {
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
@@ -631,10 +631,10 @@ class Logbook extends CI_Controller {
$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', $lookupcall);
$this->db->or_like($this->config->item('table_name').'.COL_CALL', '/'.$lookupcall,'before');
$this->db->or_like($this->config->item('table_name').'.COL_CALL', $lookupcall.'/','after');
$this->db->or_like($this->config->item('table_name').'.COL_CALL', '/'.$lookupcall.'/');
$this->db->group_end();
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "desc");
@@ -825,33 +825,29 @@ class Logbook extends CI_Controller {
$html .= "</div>";
return $html;
} else {
$callsigninfo['callsign'] = $callbook;
if (!$this->load->is_loaded('callbook')) {
$this->load->library('callbook');
}
$callsign['callsign'] = $this->callbook->getCallbookData($id);
if (isset($callsign['callsign']['dxcc'])) {
if (isset($callsigninfo['callsign']['dxcc'])) {
$this->load->model('logbook_model');
$entity = $this->logbook_model->get_entity($callsign['callsign']['dxcc']);
$callsign['callsign']['dxcc_name'] = $entity['name'];
$callsign['dxcc_worked'] = $this->logbook_model->check_if_dxcc_worked_in_logbook($callsign['callsign']['dxcc'], null, $this->session->userdata('user_default_band'));
$callsign['dxcc_confirmed'] = $this->logbook_model->check_if_dxcc_cnfmd_in_logbook($callsign['callsign']['dxcc'], null, $this->session->userdata('user_default_band'));
$entity = $this->logbook_model->get_entity($callsigninfo['callsign']['dxcc']);
$callsigninfo['callsign']['dxcc_name'] = $entity['name'];
$callsigninfo['dxcc_worked'] = $this->logbook_model->check_if_dxcc_worked_in_logbook($callsigninfo['callsign']['dxcc'], null, $this->session->userdata('user_default_band'));
$callsigninfo['dxcc_confirmed'] = $this->logbook_model->check_if_dxcc_cnfmd_in_logbook($callsigninfo['callsign']['dxcc'], null, $this->session->userdata('user_default_band'));
}
if (isset($callsign['callsign']['gridsquare'])) {
if (isset($callsigninfo['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)), null, $band)->num_rows();
$callsigninfo['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($callsigninfo['callsign']['gridsquare'],0,4)), null, $band)->num_rows();
}
if (isset($callsign['callsign']['error'])) {
$callsign['error'] = $callsign['callsign']['error'];
if (isset($callsigninfo['callsign']['error'])) {
$callsigninfo['error'] = $callsigninfo['callsign']['error'];
}
$callsign['id'] = strtoupper($id);
$callsign['lotw_lastupload'] = $this->logbook_model->check_last_lotw($id);
return $this->load->view('search/result', $callsign, true);
$callsigninfo['lookupcall'] = strtoupper($lookupcall);
$callsigninfo['realcall'] = strtoupper($callsign);
$callsigninfo['lotw_lastupload'] = $this->logbook_model->check_last_lotw($callsign);
return $this->load->view('search/result', $callsigninfo, true);
}
}

View File

@@ -18,33 +18,27 @@ class Callbook {
// Implement the following:
// - Implement callsign reduced logic
public function getCallbookData($callsign) {
$reduced = false;
if (strpos($callsign, "/") !== false) {
$reduced = true;
}
switch ($this->ci->config->item('callbook')) {
case 'qrz':
if ($this->ci->config->item('qrz_username') == null || $this->ci->config->item('qrz_password') == null) {
$callbook['error'] = 'Lookup not configured. Please review configuration.';
return $callbook;
}
return $this->qrz($this->ci->config->item('qrz_username'), $this->ci->config->item('qrz_password'), $callsign, $this->ci->config->item('use_fullname'), $reduced);
return $this->qrz($this->ci->config->item('qrz_username'), $this->ci->config->item('qrz_password'), $callsign, $this->ci->config->item('use_fullname'));
break;
case 'qrzcq':
if ($this->ci->config->item('qrzcq_username') == null || $this->ci->config->item('qrzcq_password') == null) {
$callbook['error'] = 'Lookup not configured. Please review configuration.';
return $callbook;
}
return $this->qrzcq($this->ci->config->item('qrzcq_username'), $this->ci->config->item('qrzcq_password'), $callsign, $reduced);
return $this->qrzcq($this->ci->config->item('qrzcq_username'), $this->ci->config->item('qrzcq_password'), $callsign);
break;
case 'hamqth':
if ($this->ci->config->item('hamqth_username') == null || $this->ci->config->item('hamqth_password') == null) {
$callbook['error'] = 'Lookup not configured. Please review configuration.';
return $callbook;
}
return $this->hamqth($this->ci->config->item('hamqth_username'), $this->ci->config->item('hamqth_password'), $callsign, $reduced);
return $this->hamqth($this->ci->config->item('hamqth_username'), $this->ci->config->item('hamqth_password'), $callsign);
break;
default:
$callbook['error'] = 'No callbook defined. Please review configuration.';
@@ -52,7 +46,7 @@ class Callbook {
}
}
function qrz($username, $password, $callsign, $fullname, $reduced) {
function qrz($username, $password, $callsign, $fullname) {
if (!$this->ci->load->is_loaded('qrz')) {
$this->ci->load->library('qrz');
}
@@ -62,12 +56,12 @@ class Callbook {
$this->ci->session->set_userdata('qrz_session_key', $qrz_session_key);
}
$callbook = $this->ci->qrz->search($callsign, $this->ci->session->userdata('qrz_session_key'), $fullname, $reduced);
$callbook = $this->ci->qrz->search($callsign, $this->ci->session->userdata('qrz_session_key'), $fullname);
if ($callbook['error'] ?? '' == 'Invalid session key') {
$qrz_session_key = $this->ci->qrz->session($username, $password);
$this->ci->session->set_userdata('qrz_session_key', $qrz_session_key);
$callbook = $this->ci->qrz->search($callsign, $this->ci->session->userdata('qrz_session_key'), $fullname, $reduced);
$callbook = $this->ci->qrz->search($callsign, $this->ci->session->userdata('qrz_session_key'), $fullname);
}
if (strpos($callbook['error'] ?? '', 'Not found') !== false && strpos($callsign, "/") !== false) {
@@ -79,7 +73,7 @@ class Callbook {
return $callbook;
}
function qrzcq($username, $password, $callsign, $reduced) {
function qrzcq($username, $password, $callsign) {
if (!$this->ci->load->is_loaded('qrzcq')) {
$this->ci->load->library('qrzcq');
}
@@ -94,12 +88,12 @@ class Callbook {
}
}
$callbook = $this->ci->qrzcq->search($callsign, $this->ci->session->userdata('qrzcq_session_key'), $reduced);
$callbook = $this->ci->qrzcq->search($callsign, $this->ci->session->userdata('qrzcq_session_key'));
if ($callbook['error'] ?? '' == 'Invalid session key') {
$qrzcq_session_key = $this->ci->qrzcq->session($username, $password);
$this->ci->session->set_userdata('qrzcq_session_key', $qrzcq_session_key);
$callbook = $this->ci->qrzcq->search($callsign, $this->ci->session->userdata('qrzcq_session_key'), $reduced);
$callbook = $this->ci->qrzcq->search($callsign, $this->ci->session->userdata('qrzcq_session_key'));
}
if (strpos($callbook['error'] ?? '', 'Not found') !== false && strpos($callsign, "/") !== false) {
@@ -111,7 +105,7 @@ class Callbook {
return $callbook;
}
function hamqth($username, $password, $callsign, $reduced) {
function hamqth($username, $password, $callsign) {
// Load the HamQTH library
if (!$this->ci->load->is_loaded('hamqth')) {
$this->ci->load->library('hamqth');
@@ -122,13 +116,13 @@ class Callbook {
$this->ci->session->set_userdata('hamqth_session_key', $hamqth_session_key);
}
$callbook = $this->ci->hamqth->search($callsign, $this->ci->session->userdata('hamqth_session_key'), $reduced);
$callbook = $this->ci->hamqth->search($callsign, $this->ci->session->userdata('hamqth_session_key'));
// If HamQTH session has expired, start a new session and retry the search.
if ($callbook['error'] == "Session does not exist or expired") {
$hamqth_session_key = $this->ci->hamqth->session($username, $password);
$this->ci->session->set_userdata('hamqth_session_key', $hamqth_session_key);
$callbook = $this->ci->hamqth->search($callsign, $this->ci->session->userdata('hamqth_session_key'), $reduced);
$callbook = $this->ci->hamqth->search($callsign, $this->ci->session->userdata('hamqth_session_key'));
}
if (strpos($callbook['error'] ?? '', 'Not found') !== false && strpos($callsign, "/") !== false) {

View File

@@ -1,9 +1,9 @@
<div class="card-body">
<h2><?= sprintf(__("Results for %s"), str_replace('0', 'Ø', $id)); ?></h2>
<h2><?= sprintf(__("Results for %s"), str_replace('0', 'Ø', $lookupcall)); ?></h2>
<p><?= sprintf(__("Sorry, but we didn't find any past QSOs with %s"), str_replace('0', 'Ø', $id)); ?></p>
<p><?= sprintf(__("Sorry, but we didn't find any past QSOs with %s"), str_replace('0', 'Ø', $lookupcall)); ?></p>
<h3><?= sprintf(__("Callbook Search for %s"), str_replace('0', 'Ø', $id)); ?></h3>
<h3><?= sprintf(__("Callbook Search for %s"), str_replace('0', 'Ø', $realcall)); ?></h3>
<?php if(isset($callsign['callsign'])) { ?>
<table>
@@ -26,7 +26,7 @@
<tr>
<td style="padding: 0 0.3em 0 0;" align="left"><?= __("DXCC"); ?></td>
<td style="padding: 0.3em 0 0.3em 0.5em;" align="left">
<?php
<?php
if ($dxcc_worked != 0) {
if ($dxcc_confirmed != 0) {
$title_text = __("Confirmed");