From 2ddf698af7c4c45e06fe6a446f7f346180f76011 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Sun, 7 Dec 2025 15:55:52 +0100 Subject: [PATCH] Added state check --- application/controllers/Logbookadvanced.php | 14 +++- application/models/Logbookadvanced_model.php | 22 ++++++ .../views/logbookadvanced/checkresult.php | 38 ++++++++++ assets/js/sections/logbookadvanced.js | 73 ++++++++++++++++++- 4 files changed, 142 insertions(+), 5 deletions(-) create mode 100644 application/views/logbookadvanced/checkresult.php diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php index 301bf6139..1ca6422da 100644 --- a/application/controllers/Logbookadvanced.php +++ b/application/controllers/Logbookadvanced.php @@ -893,10 +893,16 @@ class Logbookadvanced extends CI_Controller { 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); + + if ($type == 'checkstate') { + $data['result'] = $this->logbookadvanced_model->runCheckDb($type); + $this->load->view('logbookadvanced/checkresult', $data); + } else { + $result = $this->logbookadvanced_model->runCheckDb($type); + header("Content-Type: application/json"); + echo json_encode($result); + } + } } diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index fbeb85691..0124843fa 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -1455,6 +1455,8 @@ class Logbookadvanced_model extends CI_Model { return $this->check_qsos_missing_continent(); case 'checkdxcc': return $this->check_missing_dxcc(); + case 'checkstate': + return $this->check_missing_state(); return null; } } @@ -1504,4 +1506,24 @@ class Logbookadvanced_model extends CI_Model { $query = $this->db->query($sql, $bindings); return $query->result(); } + + public function check_missing_state() { + $this->load->library('Geojson'); + $supported_dxcc_list = $this->geojson->getSupportedDxccs(); + $supported_dxcc_array = array_keys($supported_dxcc_list); + + $sql = "select count(*) as count, col_dxcc, dxcc_entities.name as dxcc_name, dxcc_entities.prefix from " . $this->config->item('table_name') . " + join station_profile on " . $this->config->item('table_name') . ".station_id = station_profile.station_id + join dxcc_entities on " . $this->config->item('table_name') . ".col_dxcc = dxcc_entities.adif + where user_id = ? and coalesce(col_state, '') = '' + and col_dxcc in (" . implode(',', array_map('intval', $supported_dxcc_array)) . ") + and length(col_gridsquare) >= 6 + group by col_dxcc, dxcc_entities.name, dxcc_entities.prefix + order by dxcc_entities.prefix"; + + $bindings[] = [$this->session->userdata('user_id')]; + + $query = $this->db->query($sql, $bindings); + return $query->result(); + } } diff --git a/application/views/logbookadvanced/checkresult.php b/application/views/logbookadvanced/checkresult.php new file mode 100644 index 000000000..e1a86a04d --- /dev/null +++ b/application/views/logbookadvanced/checkresult.php @@ -0,0 +1,38 @@ + 0): ?> +
+
State Check Results
+

QSOs with missing state and gridsquares with 6 or more characters found for the following DXCC's:

+ +
+ + + + + + + + + + $item): ?> + dxcc_name) ? $item->dxcc_name : ''; + $formattedName = ucwords(strtolower($rawName), "- (/"); + $name = htmlspecialchars($formattedName, ENT_QUOTES, 'UTF-8'); + $qsos = isset($item->count) ? intval($item->count) : 0; + ?> + + + + + + + +
PrefixDXCCQSOs
prefix; ?>
+
+
+ +
+
State Check Results
+

No issues found. All QSOs have proper state information.

+
+ diff --git a/assets/js/sections/logbookadvanced.js b/assets/js/sections/logbookadvanced.js index 759c993cc..2b9f2d161 100644 --- a/assets/js/sections/logbookadvanced.js +++ b/assets/js/sections/logbookadvanced.js @@ -2119,7 +2119,7 @@ function saveOptions() { $('#closeButton').prop("disabled", false); // Create a nice display for the results let resultHtml = '
Continent Check Results
'; - resultHtml += '

QSOs without missing or invalid continent information found: ' + (response[0].count) + '

'; + resultHtml += '

QSOs with missing or invalid continent information found: ' + (response[0].count) + '

'; $('.result').html(resultHtml); }, @@ -2140,3 +2140,74 @@ function saveOptions() { } }); } + + function checkFixState() { + $('#checkFixStateBtn').prop("disabled", true).addClass("running"); + $('#closeButton').prop("disabled", true); + + $.ajax({ + url: base_url + 'index.php/logbookadvanced/checkDb', + data: { + type: 'checkstate' + }, + type: 'POST', + success: function(response) { + $('#checkFixStateBtn').prop("disabled", false).removeClass("running"); + $('#closeButton').prop("disabled", false); + + $('.result').html(response); + }, + error: function(xhr, status, error) { + $('#checkFixStateBtn').prop('disabled', false).text(''); + $('#closeButton').prop('disabled', false); + + let errorMsg = ''; + if (xhr.responseJSON && xhr.responseJSON.message) { + errorMsg += ': ' + xhr.responseJSON.message; + } + + BootstrapDialog.alert({ + title: '', + message: errorMsg, + type: BootstrapDialog.TYPE_DANGER + }); + } + }); + } + + function checkFixState2() { + $('#checkFixStateBtn').prop("disabled", true).addClass("running"); + $('#closeButton').prop("disabled", true); + + $.ajax({ + url: base_url + 'index.php/logbookadvanced/checkDb', + data: { + type: 'checkstate' + }, + type: 'POST', + success: function(response) { + $('#checkFixStateBtn').prop("disabled", false).removeClass("running"); + $('#closeButton').prop("disabled", false); + // Create a nice display for the results + let resultHtml = '
State Check Results
'; + resultHtml += '

QSOs with missing state and gridsquares with 6 or more characters found: ' + (response[0].count) + '

'; + + $('.result').html(resultHtml); + }, + error: function(xhr, status, error) { + $('#checkFixStateBtn').prop('disabled', false).text(''); + $('#closeButton').prop('disabled', false); + + let errorMsg = ''; + if (xhr.responseJSON && xhr.responseJSON.message) { + errorMsg += ': ' + xhr.responseJSON.message; + } + + BootstrapDialog.alert({ + title: '', + message: errorMsg, + type: BootstrapDialog.TYPE_DANGER + }); + } + }); + }