From 05a4c08e87003837421b3759a6c462d1ce6910ed Mon Sep 17 00:00:00 2001
From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com>
Date: Tue, 23 Dec 2025 18:15:59 +0100
Subject: [PATCH 1/3] [Advanced Logbook] Rewrote DXCC checker
---
application/models/Logbookadvanced_model.php | 66 ++++++++++++++++++-
.../views/logbookadvanced/checkresult.php | 51 +++++++++++++-
.../views/logbookadvanced/dbtoolsdialog.php | 10 +--
assets/js/sections/logbookadvanced.js | 37 ++++++++++-
4 files changed, 155 insertions(+), 9 deletions(-)
diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php
index 6415c3324..aacc09b23 100644
--- a/application/models/Logbookadvanced_model.php
+++ b/application/models/Logbookadvanced_model.php
@@ -1,5 +1,6 @@
check_missing_distance();
case 'checkcontinent':
return $this->check_qsos_missing_continent();
- case 'checkdxcc':
+ case 'checkmissingdxcc':
return $this->check_missing_dxcc();
+ case 'checkdxcc':
+ return $this->check_dxcc();
case 'checkstate':
return $this->check_missing_state();
case 'checkcqzones':
@@ -1887,4 +1890,65 @@ class Logbookadvanced_model extends CI_Model {
return $query->result();
}
+
+ public function check_dxcc() {
+
+ $i = 0;
+ $result = array();
+
+ $callarray = $this->getQsos();
+
+ // Starting clock time in seconds
+ $start_time = microtime(true);
+ $dxccobj = new Dxcc(null);
+
+ foreach ($callarray->result() as $call) {
+
+ $i++;
+ //$dxcc = $this->logbook_model->dxcc_lookup($call->col_call, $call->date);
+ $dxcc = $dxccobj->dxcc_lookup($call->col_call, $call->date);
+
+ $dxcc['adif'] = (isset($dxcc['adif'])) ? $dxcc['adif'] : 0;
+ $dxcc['entity'] = (isset($dxcc['entity'])) ? $dxcc['entity'] : 'None';
+
+ if ($call->col_dxcc != $dxcc['adif']) {
+ $result[] = array(
+ 'callsign' => $call->col_call,
+ 'qso_date' => $call->date,
+ 'station_profile' => $call->station_profile_name,
+ 'existing_dxcc' => $call->col_country,
+ 'existing_adif' => $call->col_dxcc,
+ 'result_country' => ucwords(strtolower($dxcc['entity']), "- (/"),
+ 'result_adif' => $dxcc['adif'],
+ 'id' => $call->col_primary_key,
+ );
+ }
+ }
+
+ // End clock time in seconds
+ $end_time = microtime(true);
+
+ // Calculate script execution time
+ $execution_time = ($end_time - $start_time);
+
+ $data['execution_time'] = $execution_time;
+ $data['calls_tested'] = $i;
+ $data['result'] = $result;
+
+ return $data;
+ }
+
+ function getQsos() {
+ $sql = 'select distinct col_country, col_call, col_dxcc, date(col_time_on) date, station_profile.station_profile_name, col_primary_key
+ from ' . $this->config->item('table_name') . '
+ join station_profile on ' . $this->config->item('table_name') . '.station_id = station_profile.station_id
+ where station_profile.user_id = ?';
+ $params[] = array($this->session->userdata('user_id'));
+
+ $sql .= ' order by station_profile.station_profile_name asc, date desc';
+
+ $query = $this->db->query($sql, $params);
+
+ return $query;
+ }
}
diff --git a/application/views/logbookadvanced/checkresult.php b/application/views/logbookadvanced/checkresult.php
index 8353786a7..8cfca38a4 100644
--- a/application/views/logbookadvanced/checkresult.php
+++ b/application/views/logbookadvanced/checkresult.php
@@ -1,4 +1,14 @@
session->userdata('user_date_format')) {
+ // If Logged in and session exists
+ $custom_date_format = $this->session->userdata('user_date_format');
+} else {
+ // Get Default date format from /config/wavelog.php
+ $custom_date_format = $this->config->item('qso_date_format');
+}
+
+
switch ($type) {
case 'checkdistance':
check_missing_distance($result);
@@ -6,7 +16,7 @@ switch ($type) {
case 'checkcontinent':
check_qsos_missing_continent($result);
break;
- case 'checkdxcc':
+ case 'checkmissingdxcc':
check_missing_dxcc($result);
break;
case 'checkcqzones':
@@ -18,6 +28,9 @@ switch ($type) {
case 'checkgrids':
check_missing_grids($result);
break;
+ case 'checkdxcc':
+ check_dxcc($result, $custom_date_format);
+ break;
default:
// Invalid type
break;
@@ -97,3 +110,39 @@ function check_missing_grids($result) { ?>
= __("Update now") ?>
+ = __("DXCC Check Results") ?>
+ " . __("Callsigns tested: ") . $result['calls_tested'] . "";
+ echo "" . __("Execution time: ") . round($result['execution_time'], 2) . "s
";
+ echo "" . __("Number of potential QSOs with wrong DXCC: ") . count($result['result']) . "
";
+
+ if ($result) { ?>
+
+
+
+
+ | = __("Callsign"); ?> |
+ = __("QSO Date"); ?> |
+ = __("Station Profile"); ?> |
+ = __("Existing DXCC"); ?> |
+ = __("Result DXCC"); ?> |
+
+
+
+
+
+ | ' . htmlspecialchars($qso['callsign']) . ''; ?> |
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
-
+
= __("Data Repair Tools") ?>
= __("Wiki Help") ?>
@@ -85,8 +85,8 @@
= __("This will overwrite ALL existing DXCC information!") ?>
-
@@ -107,7 +107,7 @@
-
+
diff --git a/assets/js/sections/logbookadvanced.js b/assets/js/sections/logbookadvanced.js
index 4d4ac7834..bf4d3ee8b 100644
--- a/assets/js/sections/logbookadvanced.js
+++ b/assets/js/sections/logbookadvanced.js
@@ -1319,7 +1319,7 @@ $(document).ready(function () {
success: function (html) {
BootstrapDialog.show({
title: 'Database tools',
- size: BootstrapDialog.SIZE_WIDE,
+ size: BootstrapDialog.SIZE_EXTRAWIDE,
cssClass: 'options',
nl2br: false,
message: html,
@@ -2059,7 +2059,7 @@ function saveOptions() {
$.ajax({
url: base_url + 'index.php/logbookadvanced/checkDb',
data: {
- type: 'checkdxcc'
+ type: 'checkmissingdxcc'
},
type: 'POST',
success: function(response) {
@@ -2514,3 +2514,36 @@ function saveOptions() {
}
});
}
+
+ function checkDxcc() {
+ $('#checkDxccBtn').prop("disabled", true).addClass("running");
+ $('#closeButton').prop("disabled", true);
+
+ $.ajax({
+ url: base_url + 'index.php/logbookadvanced/checkDb',
+ data: {
+ type: 'checkdxcc'
+ },
+ type: 'POST',
+ success: function(response) {
+ $('#checkDxccBtn').prop("disabled", false).removeClass("running");
+ $('#closeButton').prop("disabled", false);
+ $('.result').html(response);
+ },
+ error: function(xhr, status, error) {
+ $('#checkDxccBtn').prop('disabled', false).text('= __("Check") ?>');
+ $('#closeButton').prop('disabled', false);
+
+ let errorMsg = 'Error checking DXCC information';
+ if (xhr.responseJSON && xhr.responseJSON.message) {
+ errorMsg += ': ' + xhr.responseJSON.message;
+ }
+
+ BootstrapDialog.alert({
+ title: 'Error',
+ message: errorMsg,
+ type: BootstrapDialog.TYPE_DANGER
+ });
+ }
+ });
+ }
From 42e63e1a1680ab0723a99423088859ec80461cf5 Mon Sep 17 00:00:00 2001
From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com>
Date: Thu, 25 Dec 2025 18:20:05 +0100
Subject: [PATCH 2/3] Update works
---
application/controllers/Logbookadvanced.php | 13 ++++
application/models/Logbookadvanced_model.php | 31 +++++++-
.../views/logbookadvanced/checkresult.php | 58 ++++++++-------
.../views/logbookadvanced/dbtoolsdialog.php | 3 +-
assets/js/sections/logbookadvanced.js | 72 +++++++++++++++++++
5 files changed, 149 insertions(+), 28 deletions(-)
diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php
index e19768668..0cd00b110 100644
--- a/application/controllers/Logbookadvanced.php
+++ b/application/controllers/Logbookadvanced.php
@@ -992,4 +992,17 @@ class Logbookadvanced extends CI_Controller {
$this->load->view('logbookadvanced/dupesearchdialog');
}
+ function fixDxccSelected() {
+ if(!clubaccess_check(9)) return;
+
+ $ids = xss_clean($this->input->post('ids'));
+
+ $this->load->model('logbookadvanced_model');
+ $result = $this->logbookadvanced_model->fixDxccSelected($ids);
+ $result['message'] = '' . sprintf(__("DXCC updated for %d QSO(s)."), $result['count']) . '
';
+
+ header("Content-Type: application/json");
+ print json_encode($result);
+ }
+
}
diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php
index aacc09b23..a2a05b5d5 100644
--- a/application/models/Logbookadvanced_model.php
+++ b/application/models/Logbookadvanced_model.php
@@ -1905,7 +1905,6 @@ class Logbookadvanced_model extends CI_Model {
foreach ($callarray->result() as $call) {
$i++;
- //$dxcc = $this->logbook_model->dxcc_lookup($call->col_call, $call->date);
$dxcc = $dxccobj->dxcc_lookup($call->col_call, $call->date);
$dxcc['adif'] = (isset($dxcc['adif'])) ? $dxcc['adif'] : 0;
@@ -1951,4 +1950,34 @@ class Logbookadvanced_model extends CI_Model {
return $query;
}
+
+ function fixDxccSelected($ids) {
+ $sql = "select COL_PRIMARY_KEY, COL_CALL, COL_TIME_ON, COL_TIME_OFF, station_profile.station_profile_name from " . $this->config->item('table_name') .
+ " join station_profile on " . $this->config->item('table_name') . ".station_id = station_profile.station_id
+ where station_profile.user_id = ? and " . $this->config->item('table_name') . ".col_primary_key in ?";
+
+ $r = $this->db->query($sql, array($this->session->userdata('user_id'), json_decode($ids, true)));
+
+ $count = 0;
+ $dxccobj = new Dxcc(null);
+
+ if ($r->num_rows() > 0) { //query dxcc_prefixes
+ $sql = "update " . $this->config->item('table_name') . " set COL_COUNTRY = ?, COL_DXCC = ? where COL_PRIMARY_KEY = ?";
+ $q = $this->db->conn_id->prepare($sql);
+ foreach ($r->result_array() as $row) {
+ $qso_date = $row['COL_TIME_OFF'] == '' ? $row['COL_TIME_ON'] : $row['COL_TIME_OFF'];
+ $qso_date = date("Y-m-d", strtotime($qso_date));
+ $dxcc = $dxccobj->dxcc_lookup($row['COL_CALL'], $qso_date);
+ $dxcc['adif'] = (isset($dxcc['adif'])) ? $dxcc['adif'] : 0;
+ $dxcc['entity'] = (isset($dxcc['entity'])) ? $dxcc['entity'] : 'None';
+ if ($dxcc['adif'] != 'Not Found') {
+ $q->execute(array(addslashes(ucwords(strtolower($dxcc['entity']), "- (/")), $dxcc['adif'], $row['COL_PRIMARY_KEY']));
+ $count++;
+ }
+ }
+ }
+
+ $result['count'] = $count;
+ return $result;
+ }
}
diff --git a/application/views/logbookadvanced/checkresult.php b/application/views/logbookadvanced/checkresult.php
index 8cfca38a4..a7ce37d6b 100644
--- a/application/views/logbookadvanced/checkresult.php
+++ b/application/views/logbookadvanced/checkresult.php
@@ -114,35 +114,43 @@ function check_missing_grids($result) { ?>
function check_dxcc($result, $custom_date_format) { ?>
= __("DXCC Check Results") ?>
" . __("Callsigns tested: ") . $result['calls_tested'] . "";
- echo "" . __("Execution time: ") . round($result['execution_time'], 2) . "s
";
- echo "" . __("Number of potential QSOs with wrong DXCC: ") . count($result['result']) . "
";
+ echo __("Callsigns tested: ") . $result['calls_tested'] . ".
";
+ echo __("Execution time: ") . round($result['execution_time'], 2) . "s.
";
+ echo __("Number of potential QSOs with wrong DXCC: ") . count($result['result']);
if ($result) { ?>
-
-
-
-
- | = __("Callsign"); ?> |
- = __("QSO Date"); ?> |
- = __("Station Profile"); ?> |
- = __("Existing DXCC"); ?> |
- = __("Result DXCC"); ?> |
-
-
-
-
+
+
+ = __("Update selected") ?>
+
+
+
+
+
+
+
+
+ |
+ ' . htmlspecialchars($qso['callsign']) . ''; ?> |
+ |
+ |
+ |
+ |
+
+
+
+
+
-
= __("Re-check DXCC for all QSOs in the logbook") ?>
+
= __("Check all QSOs in the logbook for incorrect DXCC") ?>
= __("Use Wavelog to determine DXCC for all QSOs.") ?>
-
= __("This will overwrite ALL existing DXCC information!") ?>
diff --git a/assets/js/sections/logbookadvanced.js b/assets/js/sections/logbookadvanced.js
index bf4d3ee8b..01fee69f6 100644
--- a/assets/js/sections/logbookadvanced.js
+++ b/assets/js/sections/logbookadvanced.js
@@ -2529,6 +2529,7 @@ function saveOptions() {
$('#checkDxccBtn').prop("disabled", false).removeClass("running");
$('#closeButton').prop("disabled", false);
$('.result').html(response);
+ rebind_checkbox_trigger_dxcc();
},
error: function(xhr, status, error) {
$('#checkDxccBtn').prop('disabled', false).text('= __("Check") ?>');
@@ -2547,3 +2548,74 @@ function saveOptions() {
}
});
}
+
+ function rebind_checkbox_trigger_dxcc() {
+ $('#checkBoxAllDxcc').change(function (event) {
+ if (this.checked) {
+ $('#dxccCheckTable tbody tr').each(function (i) {
+ selectQsoIDDxcc($(this).first().closest('tr').attr('id')?.replace(/\D/g, ''));
+ });
+ } else {
+ $('#dxccCheckTable tbody tr').each(function (i) {
+ unselectQsoIDDxcc($(this).first().closest('tr').attr('id')?.replace(/\D/g, ''));
+ });
+ }
+ });
+ }
+
+ function selectQsoIDDxcc(qsoID) {
+ var element = $("#qsoID-" + qsoID);
+ element.find("input[type=checkbox]").prop("checked", true);
+ element.addClass('activeRow');
+ }
+
+ function unselectQsoIDDxcc(qsoID) {
+ var element = $("#qsoID-" + qsoID);
+ element.find("input[type=checkbox]").prop("checked", false);
+ element.removeClass('activeRow');
+ $('#checkBoxAllDxcc').prop("checked", false);
+ }
+
+ function fixDxccSelected() {
+ let id_list = [];
+ $('#dxccCheckTable tbody input:checked').each(function () {
+ let id = $(this).closest('tr').attr('id')?.replace(/\D/g, '');
+ id_list.push(id);
+ });
+
+ if (id_list.length === 0) {
+ BootstrapDialog.alert({
+ title: lang_gen_advanced_logbook_info,
+ message: lang_gen_advanced_logbook_select_at_least_one_row,
+ type: BootstrapDialog.TYPE_INFO,
+ closable: false,
+ draggable: false,
+ callback: function (result) {
+ }
+ });
+ return;
+ }
+
+ $('#fixSelectedDxccBtn').prop("disabled", true).addClass("running");
+ $('#closeButton').prop("disabled", true);
+
+ $.ajax({
+ url: base_url + 'index.php/logbookadvanced/fixDxccSelected',
+ type: 'post',
+ data: {'ids': JSON.stringify(id_list, null, 2)},
+ success: function(data) {
+ $('#fixSelectedDxccBtn').prop("disabled", false).removeClass("running");
+ $('#closeButton').prop("disabled", false);
+ id_list.forEach(function(id) {
+ let row = $("#dxccCheckTable tbody tr#qsoID-" + id);
+ row.remove();
+ });
+ $('.dxcctablediv').html(data.message);
+ },
+ error: function(xhr, status, error) {
+ $('#fixSelectedDxccBtn').prop("disabled", false).removeClass("running");
+ $('#closeButton').prop("disabled", false);
+ $('.result').html(error);
+ }
+ });
+ }
From 8e1be2710e258ba840edd42d390b9527308a9a65 Mon Sep 17 00:00:00 2001
From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com>
Date: Thu, 25 Dec 2025 22:52:44 +0100
Subject: [PATCH 3/3] Only show grid update if callbook is defined
---
application/views/logbookadvanced/dbtoolsdialog.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/views/logbookadvanced/dbtoolsdialog.php b/application/views/logbookadvanced/dbtoolsdialog.php
index 6ce0a6695..149a43cda 100644
--- a/application/views/logbookadvanced/dbtoolsdialog.php
+++ b/application/views/logbookadvanced/dbtoolsdialog.php
@@ -89,7 +89,7 @@
- config->item('callbook_batch_lookup') ?? true): ?>
+ config->item('callbook_batch_lookup') ?? true) && $this->config->item('callbook')): ?>
= __("Lookup QSOs with missing grid in callbook") ?>