From db42a27da73cc0c9913410a2f7ae218666342c26 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Sat, 27 Dec 2025 16:34:37 +0100 Subject: [PATCH] [Advanced Logbook] Added gridsquare/cq/itu checker --- application/models/Logbookadvanced_model.php | 84 +++++++ .../views/logbookadvanced/checkresult.php | 195 ++++++++++++++++ .../views/logbookadvanced/dbtoolsdialog.php | 35 +++ application/views/logbookadvanced/index.php | 4 + assets/js/sections/logbookadvanced.js | 210 ++++++++++++++++-- 5 files changed, 508 insertions(+), 20 deletions(-) diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index a2a05b5d5..ef2e4ef62 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -1549,10 +1549,54 @@ class Logbookadvanced_model extends CI_Model { return $this->check_missing_itu_zones(); case 'checkgrids': return $this->getMissingGridQsos(); + case 'checkincorrectgridsquares': + return $this->getIncorrectGridsquares(); + case 'checkincorrectcqzones': + return $this->getIncorrectCqZones(); + case 'checkincorrectituzones': + return $this->getIncorrectItuZones(); return null; } } + public function getIncorrectGridsquares() { + $sqlcheck = "select count(*) as count from vuccgrids";; + $querycheck = $this->db->query($sqlcheck); + $rowcheck = $querycheck->row(); + if ($rowcheck->count == 0) { + return ['status' => 'error', 'message' => __("VuccGrids table is empty. Please import the VUCC grids data first.")]; + } + + $sql = "select col_primary_key, col_time_on, col_call, col_band, col_gridsquare, col_dxcc, col_country, station_profile_name, + ( + select group_concat(distinct gridsquare order by gridsquare separator ', ') + from vuccgrids + where adif = thcv.col_dxcc + order by gridsquare asc + ) as correctgridsquare + from " . $this->config->item('table_name') . " thcv + join station_profile on thcv.station_id = station_profile.station_id + join dxcc_entities on dxcc_entities.adif = thcv.COL_DXCC + where station_profile.user_id = ? + and thcv.col_dxcc > 0 + and not exists ( + select 1 + from vuccgrids + where adif = thcv.col_dxcc + and gridsquare = substr(thcv.col_gridsquare, 1, 4) + ) + and exists (select 1 from vuccgrids where adif = thcv.col_dxcc) + and thcv.col_dxcc > 0 + and thcv.col_gridsquare is not null + and thcv.col_gridsquare <> '' + order by station_profile_name, col_time_on desc"; + + $bindings[] = [$this->session->userdata('user_id')]; + + $query = $this->db->query($sql, $bindings); + return $query->result(); + } + public function check_missing_dxcc() { $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 @@ -1980,4 +2024,44 @@ class Logbookadvanced_model extends CI_Model { $result['count'] = $count; return $result; } + + function getIncorrectCqZones() { + if(!clubaccess_check(9)) return; + + $sql = "select *, (select group_concat(distinct cqzone order by cqzone separator ', ') from dxcc_master where countrycode = thcv.col_dxcc and cqzone <> '' order by cqzone asc) as correctcqzone + from " . $this->config->item('table_name') . " thcv + join station_profile on thcv.station_id = station_profile.station_id + where station_profile.user_id = ? + and not exists (select 1 from dxcc_master where countrycode = thcv.col_dxcc and cqzone = col_cqz) and col_dxcc > 0 + "; + + $params[] = $this->session->userdata('user_id'); + + $sql .= " order by station_profile.station_profile_name, thcv.col_time_on desc + limit 5000"; + + $query = $this->db->query($sql, $params); + + return $query->result(); + } + + function getIncorrectItuZones() { + if(!clubaccess_check(9)) return; + + $sql = "select *, (select group_concat(distinct ituzone order by ituzone separator ', ') from dxcc_master where countrycode = thcv.col_dxcc and ituzone <> '' order by ituzone asc) as correctituzone + from " . $this->config->item('table_name') . " thcv + join station_profile on thcv.station_id = station_profile.station_id + where station_profile.user_id = ? + and not exists (select 1 from dxcc_master where countrycode = thcv.col_dxcc and ituzone = col_ituz) and col_dxcc > 0 + "; + + $params[] = $this->session->userdata('user_id'); + + $sql .= " order by station_profile.station_profile_name, thcv.col_time_on desc + limit 5000"; + + $query = $this->db->query($sql, $params); + + return $query->result(); + } } diff --git a/application/views/logbookadvanced/checkresult.php b/application/views/logbookadvanced/checkresult.php index a7ce37d6b..5ae33b3d6 100644 --- a/application/views/logbookadvanced/checkresult.php +++ b/application/views/logbookadvanced/checkresult.php @@ -31,6 +31,15 @@ switch ($type) { case 'checkdxcc': check_dxcc($result, $custom_date_format); break; + case 'checkincorrectgridsquares': + check_incorrect_gridsquares($result, $custom_date_format); + break; + case 'checkincorrectcqzones': + check_incorrect_cq_zones($result, $custom_date_format); + break; + case 'checkincorrectituzones': + check_incorrect_itu_zones($result, $custom_date_format); + break; default: // Invalid type break; @@ -154,3 +163,189 @@ function check_dxcc($result, $custom_date_format) { ?> +
| = __("Callsign"); ?> | += __("QSO Date"); ?> | += __("Station Profile"); ?> | += __("DXCC"); ?> | += __("Gridsquare"); ?> | += __("DXCC Gridsquare"); ?> | +
|---|---|---|---|---|---|
| col_primary_key . ')">' . htmlspecialchars($qso->col_call) . ''; ?> | +col_time_on)); ?> | +station_profile_name; ?> | +col_country), "- (/"), ENT_QUOTES, 'UTF-8'); ?> | +col_gridsquare; ?> | ++ correctgridsquare; + $maxChars = 50; + if (strlen($gridsquare) > $maxChars) { + $truncated = substr($gridsquare, 0, $maxChars); + $uniqueId = 'gridsquare-' . $qso->col_primary_key; + echo '' . htmlspecialchars($truncated) . '... '; + echo ' '; + echo '' . __('Show more') . ''; + } else { + echo htmlspecialchars($gridsquare); + } + ?> + | +
| + | + | + | + | + | + |
= __("Check incorrect CQ zone information") ?>
+= __("Check incorrect ITU zone information") ?>
+= __("Check gridsquares that does not match the DXCC") ?>
+