Tweaked layout a bit and implemented checks for continent/dxcc/distance

This commit is contained in:
Andreas Kristiansen
2025-12-07 14:18:20 +01:00
parent 24672dd193
commit cdf942d3bd
3 changed files with 173 additions and 59 deletions

View File

@@ -1448,6 +1448,49 @@ class Logbookadvanced_model extends CI_Model {
}
public function runCheckDb($type) {
switch ($type) {
case 'checkdistance':
return $this->check_missing_distance();
case 'checkcontinent':
return $this->check_qsos_missing_continent();
case 'checkdxcc':
return $this->check_missing_dxcc();
return null;
}
}
public function check_missing_dxcc() {
$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_dxcc, '') = ''";
$bindings[] = [$this->session->userdata('user_id')];
$query = $this->db->query($sql, $bindings);
return $query->result();
}
public function check_qsos_missing_continent() {
$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_cont, '') = '' or col_cont not in ('AF', 'AN', 'AS', 'EU', 'NA', 'OC', 'SA'))";
$bindings[] = [$this->session->userdata('user_id')];
$query = $this->db->query($sql, $bindings);
return $query->result();
}
public function check_missing_distance() {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));

View File

@@ -9,11 +9,11 @@
<p class="mb-1 small text-muted"><?= __("Update missing or incorrect CQ zone information") ?></p>
</div>
<div class="d-flex nowrap">
<button type="button" class="btn btn-sm btn-secondary me-1" id="checkFixCqZonesBtn" onclick="checkFixCqZones()">
<?= __("Check") ?>
<button type="button" class="btn btn-sm btn-secondary me-1 ld-ext-right" id="checkFixCqZonesBtn" onclick="checkFixCqZones()">
<?= __("Check") ?><div class="ld ld-ring ld-spin"></div>
</button>
<button type="button" class="btn btn-sm btn-primary" id="fixCqZonesBtn" onclick="runFixCqZones()">
<?= __("Run") ?>
<button type="button" class="btn btn-sm btn-primary ld-ext-right" id="fixCqZonesBtn" onclick="runFixCqZones()">
<?= __("Run") ?><div class="ld ld-ring ld-spin"></div>
</button>
</div>
</div>
@@ -24,11 +24,11 @@
<p class="mb-1 small text-muted"><?= __("Update missing or incorrect ITU zone information") ?></p>
</div>
<div class="d-flex nowrap">
<button type="button" class="btn btn-sm btn-secondary me-1" id="checkFixItuZonesBtn" onclick="checkFixItuZones()">
<?= __("Check") ?>
<button type="button" class="btn btn-sm btn-secondary me-1 ld-ext-right" id="checkFixItuZonesBtn" onclick="checkFixItuZones()">
<?= __("Check") ?><div class="ld ld-ring ld-spin"></div>
</button>
<button type="button" class="btn btn-sm btn-primary" id="fixItuZonesBtn" onclick="runFixItuZones()">
<?= __("Run") ?>
<button type="button" class="btn btn-sm btn-primary ld-ext-right" id="fixItuZonesBtn" onclick="runFixItuZones()">
<?= __("Run") ?><div class="ld ld-ring ld-spin"></div>
</button>
</div>
</div>
@@ -39,11 +39,11 @@
<p class="mb-1 small text-muted"><?= __("Update missing or incorrect continent information") ?></p>
</div>
<div class="d-flex nowrap">
<button type="button" class="btn btn-sm btn-secondary me-1" id="checkFixContinentBtn" onclick="checkFixContinent()">
<?= __("Check") ?>
<button type="button" class="btn btn-sm btn-secondary me-1 ld-ext-right" id="checkFixContinentBtn" onclick="checkFixContinent()">
<?= __("Check") ?><div class="ld ld-ring ld-spin"></div>
</button>
<button type="button" class="btn btn-sm btn-primary" id="fixContinentBtn" onclick="runFixContinent()">
<?= __("Run") ?>
<button type="button" class="btn btn-sm btn-primary ld-ext-right" id="fixContinentBtn" onclick="runFixContinent()">
<?= __("Run") ?><div class="ld ld-ring ld-spin"></div>
</button>
</div>
</div>
@@ -54,11 +54,11 @@
<p class="mb-1 small text-muted"><?= __("Update missing or incorrect state/province information") ?></p>
</div>
<div class="d-flex nowrap">
<button type="button" class="btn btn-sm btn-secondary me-1" id="checkFixStateBtn" onclick="checkFixState()">
<?= __("Check") ?>
<button type="button" class="btn btn-sm btn-secondary me-1 ld-ext-right" id="checkFixStateBtn" onclick="checkFixState()">
<?= __("Check") ?><div class="ld ld-ring ld-spin"></div>
</button>
<button type="button" class="btn btn-sm btn-primary" id="fixStateBtn" onclick="runFixState()">
<?= __("Run") ?>
<button type="button" class="btn btn-sm btn-primary ld-ext-right" id="fixStateBtn" onclick="runFixState()">
<?= __("Run") ?><div class="ld ld-ring ld-spin"></div>
</button>
</div>
</div>
@@ -69,11 +69,11 @@
<p class="mb-1 small text-muted"><?= __("Calculate and update distance information for QSOs") ?></p>
</div>
<div class="d-flex nowrap">
<button type="button" class="btn btn-sm btn-secondary me-1" id="checkUpdateDistancesBtn" onclick="checkUpdateDistances()">
<?= __("Check") ?>
<button type="button" class="btn btn-sm btn-secondary me-1 ld-ext-right" id="checkUpdateDistancesBtn" onclick="checkUpdateDistances()">
<?= __("Check") ?><div class="ld ld-ring ld-spin"></div>
</button>
<button type="button" class="btn btn-sm btn-primary" id="updateDistancesBtn" onclick="runUpdateDistances()">
<?= __("Run") ?>
<button type="button" class="btn btn-sm btn-primary ld-ext-right" id="updateDistancesBtn" onclick="runUpdateDistances()">
<?= __("Run") ?><div class="ld ld-ring ld-spin"></div>
</button>
</div>
</div>
@@ -84,11 +84,11 @@
<p class="mb-1 small text-muted"><?= __("Identify QSOs that are missing DXCC information") ?></p>
</div>
<div class="d-flex nowrap">
<button type="button" class="btn btn-sm btn-secondary me-1" id="checkUpdateDistancesBtn" onclick="checkUpdateDistances()">
<?= __("Check") ?>
<button type="button" class="btn btn-sm btn-secondary me-1 ld-ext-right" id="checkMissingDxccsBtn" onclick="checkMissingDxcc()">
<?= __("Check") ?><div class="ld ld-ring ld-spin"></div>
</button>
<button type="button" class="btn btn-sm btn-primary" id="updateDistancesBtn" onclick="runUpdateDistances()">
<?= __("Run") ?>
<button type="button" class="btn btn-sm btn-primary ld-ext-right" id="updateDistancesBtn" onclick="runUpdateDistances()">
<?= __("Run") ?><div class="ld ld-ring ld-spin"></div>
</button>
</div>
</div>
@@ -96,14 +96,12 @@
<div class="list-group-item d-flex justify-content-between align-items-center">
<div>
<h6 class="mb-1"><?= __("Re-check DXCC for all QSOs in the logbook") ?></h6>
<p class="mb-1 small text-muted"><?= __("Use Wavelog to determine DXCC for all QSOs. This will overwrite existing DXCC information.") ?></p>
<p class="mb-1 small text-muted"><?= __("Use Wavelog to determine DXCC for all QSOs.") ?></p>
<p class="mb-1 small alert-danger"><?= __("This will overwrite existing DXCC information!") ?></p>
</div>
<div class="d-flex nowrap">
<button type="button" class="btn btn-sm btn-secondary me-1" id="checkUpdateDistancesBtn" onclick="checkUpdateDistances()">
<?= __("Check") ?>
</button>
<button type="button" class="btn btn-sm btn-primary" id="updateDistancesBtn" onclick="runUpdateDistances()">
<?= __("Run") ?>
<button type="button" class="btn btn-sm btn-primary ld-ext-right" id="updateDistancesBtn" onclick="runUpdateDistances()">
<?= __("Run") ?><div class="ld ld-ring ld-spin"></div>
</button>
</div>
</div>

View File

@@ -2034,36 +2034,109 @@ function saveOptions() {
$.ajax({
url: base_url + 'index.php/logbookadvanced/checkDb',
data: {
type: 'distance'
},
type: 'POST',
success: function(response) {
$('#checkUpdateDistancesBtn').prop("disabled", false).removeClass("running");
$('#closeButton').prop("disabled", false);
// Create a nice display for the results
let resultHtml = '<h6>Distance Check Results</h6>';
resultHtml += '<p><strong>QSO to update found:</strong> ' + (response[0].count) + '</p>';
url: base_url + 'index.php/logbookadvanced/checkDb',
data: {
type: 'checkdistance'
},
type: 'POST',
success: function(response) {
$('#checkUpdateDistancesBtn').prop("disabled", false).removeClass("running");
$('#closeButton').prop("disabled", false);
// Create a nice display for the results
let resultHtml = '<h5>Distance Check Results</h5>';
resultHtml += '<p><strong>QSO to update found:</strong> ' + (response[0].count) + '</p>';
$('.result').html(resultHtml);
},
error: function(xhr, status, error) {
$('#checkUpdateDistancesBtn').prop('disabled', false).text('<?= __("Check") ?>');
$('#closeButton').prop('disabled', false);
$('.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;
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
});
}
BootstrapDialog.alert({
title: '<?= __("Error") ?>',
message: errorMsg,
type: BootstrapDialog.TYPE_DANGER
});
}
});
});
}
function checkMissingDxcc() {
$('#checkMissingDxccsBtn').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) {
$('#checkMissingDxccsBtn').prop("disabled", false).removeClass("running");
$('#closeButton').prop("disabled", false);
// Create a nice display for the results
let resultHtml = '<h5>DXCC Check Results</h5>';
resultHtml += '<p><strong>QSOs without DXCC information found:</strong> ' + (response[0].count) + '</p>';
$('.result').html(resultHtml);
},
error: function(xhr, status, error) {
$('#checkMissingDxccsBtn').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
});
}
});
}
function checkFixContinent() {
$('#checkFixContinentBtn').prop("disabled", true).addClass("running");
$('#closeButton').prop("disabled", true);
$.ajax({
url: base_url + 'index.php/logbookadvanced/checkDb',
data: {
type: 'checkcontinent'
},
type: 'POST',
success: function(response) {
$('#checkFixContinentBtn').prop("disabled", false).removeClass("running");
$('#closeButton').prop("disabled", false);
// Create a nice display for the results
let resultHtml = '<h5>Continent Check Results</h5>';
resultHtml += '<p><strong>QSOs without missing or invalid continent information found:</strong> ' + (response[0].count) + '</p>';
$('.result').html(resultHtml);
},
error: function(xhr, status, error) {
$('#checkFixContinentBtn').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
});
}
});
}