From 969b079ae7848d26bc4f4d96c3bdef06b4db71a9 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 2 Dec 2025 07:59:17 +0100 Subject: [PATCH] [Advanced Logbook] Started on dbtools --- application/controllers/Logbookadvanced.php | 15 +++ application/models/Logbookadvanced_model.php | 15 +++ .../views/logbookadvanced/dbtoolsdialog.php | 117 ++++++++++++++++++ application/views/logbookadvanced/index.php | 1 + assets/js/sections/logbookadvanced.js | 65 ++++++++++ 5 files changed, 213 insertions(+) create mode 100644 application/views/logbookadvanced/dbtoolsdialog.php diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php index 8b963fefa..301bf6139 100644 --- a/application/controllers/Logbookadvanced.php +++ b/application/controllers/Logbookadvanced.php @@ -884,4 +884,19 @@ class Logbookadvanced extends CI_Controller { public function callbookDialog() { $this->load->view('logbookadvanced/callbookdialog'); } + + public function dbtoolsDialog() { + $this->load->view('logbookadvanced/dbtoolsdialog'); + } + + public function checkDb() { + if(!clubaccess_check(9)) return; + + $type = $this->input->post('type', true); + + $this->load->model('logbookadvanced_model'); + $result = $this->logbookadvanced_model->runCheckDb($type); + header("Content-Type: application/json"); + print json_encode($result); + } } diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index f283af058..924af2f26 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -1446,4 +1446,19 @@ class Logbookadvanced_model extends CI_Model { return $recordcount; } + + public function runCheckDb($type) { + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + $sql = "select count(*) as count 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 (" . implode(',', array_map('intval', $logbooks_locations_array)) . ") + and user_id = ? and coalesce(col_distance, '') = ''"; + + $bindings[] = [$this->session->userdata('user_id')]; + + $query = $this->db->query($sql, $bindings); + return $query->result(); + } } diff --git a/application/views/logbookadvanced/dbtoolsdialog.php b/application/views/logbookadvanced/dbtoolsdialog.php new file mode 100644 index 000000000..e1ae53af0 --- /dev/null +++ b/application/views/logbookadvanced/dbtoolsdialog.php @@ -0,0 +1,117 @@ +
= __("Update missing or incorrect CQ zone information") ?>
+= __("Update missing or incorrect ITU zone information") ?>
+= __("Update missing or incorrect continent information") ?>
+= __("Update missing or incorrect state/province information") ?>
+= __("Calculate and update distance information for QSOs") ?>
+= __("Identify QSOs that are missing DXCC information") ?>
+= __("Use Wavelog to determine DXCC for all QSOs. This will overwrite existing DXCC information.") ?>
+QSO to update found: ' + (response[0].count) + '
'; + + $('.result').html(resultHtml); + }, + error: function(xhr, status, error) { + $('#checkUpdateDistancesBtn').prop('disabled', false).text('= __("Check") ?>'); + $('#closeButton').prop('disabled', false); + + let errorMsg = '= __("Error checking distance information") ?>'; + if (xhr.responseJSON && xhr.responseJSON.message) { + errorMsg += ': ' + xhr.responseJSON.message; + } + + BootstrapDialog.alert({ + title: '= __("Error") ?>', + message: errorMsg, + type: BootstrapDialog.TYPE_DANGER + }); + } + }); + + + }