More verbose message on dxcc and state fixer

This commit is contained in:
Andreas Kristiansen
2025-12-15 16:51:11 +01:00
parent 9d29f7e076
commit 90daf3ae0d
4 changed files with 132 additions and 29 deletions

View File

@@ -911,17 +911,16 @@ class Logbookadvanced extends CI_Controller {
$this->load->model('logbookadvanced_model');
$dxcc = $this->input->post('dxcc', true);
$country = $this->input->post('country', true);
$data['country'] = $this->input->post('country', true);
// Process for batch QSO state fix
$result = $this->logbookadvanced_model->fixStateBatch($dxcc);
$data['result'] = count($result);
$data['result'] = $result;
$data['message'] = __("The number of QSOs updated for state/province in") . ' ' . $country . ' : ' . count($result);
$data['type'] = 'state';
header("Content-Type: application/json");
echo json_encode($data);
$this->load->view('logbookadvanced/showUpdateResult', $data);
}
public function openStateList() {
@@ -945,14 +944,10 @@ class Logbookadvanced extends CI_Controller {
$result = $this->logbookadvanced_model->check_missing_dxcc_id($all);
$data['result'] = $result;
$data['all'] = $all;
$data['type'] = 'dxcc';
if ($all == 'false') {
$data['message'] = __("The number of QSOs updated for missing DXCC IDs was") .' ' . $result;
} else {
$data['message'] = __("The number of QSOs re-checked for DXCC was") .' ' . $result;
}
header("Content-Type: application/json");
echo json_encode($data);
$this->load->view('logbookadvanced/showUpdateResult', $data);
}
public function openMissingDxccList() {

View File

@@ -1598,13 +1598,19 @@ class Logbookadvanced_model extends CI_Model {
$results = [];
$count = 0;
foreach ($query->result() as $qso) {
$result = $this->fixStateSingle($qso->COL_PRIMARY_KEY);
if ($result['success']) {
$count++;
} else {
$results []= $result;
}
}
$results['count'] = $count;
return $results;
}
@@ -1652,14 +1658,23 @@ class Logbookadvanced_model extends CI_Model {
$qso_date = $row['COL_TIME_OFF'] == '' ? $row['COL_TIME_ON'] : $row['COL_TIME_OFF'];
$qso_date = date("Y-m-d", strtotime($qso_date));
$d = $this->logbook_model->check_dxcc_table($row['COL_CALL'], $qso_date);
if ($d[0] != 'Not Found') {
if ($d[0] == 'Not Found') {
$result[] = [
'callsign' => $row['COL_CALL'],
'reason' => 'DXCC Not Found',
'location' => '',
'id' => $row['COL_PRIMARY_KEY']
];
} else {
$q->execute(array(addslashes(ucwords(strtolower($d[1]), "- (/")), $d[0], $row['COL_PRIMARY_KEY']));
$count++;
}
}
}
$this->db->trans_complete();
return $count;
$result['count'] = $count;
return $result;
}
function getMissingDxccQsos() {

View File

@@ -0,0 +1,105 @@
<?php
switch ($type) {
case 'dxcc':
showDxccUpdateResult($result, $all);
break;
case 'state':
showStateUpdateResult($result, $country);
break;
default:
// Invalid type
break;
}
function showDxccUpdateResult($result, $all) {
if ($result['count'] == 0) {
if ($all == 'false') {
echo '<div class="alert alert-danger" role="alert">' . __("The number of QSOs updated for missing DXCC IDs was") .' ' . $result['count'] . '</div>';
} else {
echo '<div class="alert alert-danger" role="alert">' . __("The number of QSOs re-checked for DXCC was") .' ' . $result['count'] . '</div>';
}
} else {
if ($all == 'false') {
echo '<div class="alert alert-success" role="alert">' . __("The number of QSOs updated for missing DXCC IDs was") .' ' . $result['count'] . '</div>';
} else {
echo '<div class="alert alert-success" role="alert">' . __("The number of QSOs re-checked for DXCC was") .' ' . $result['count'] . '</div>';
}
}
if ($result) {
echo __("These QSOs could not be updated:");
$details = [];
foreach ($result as $r) {
if (is_array($r)) {
$details[] = $r;
}
}
if (!empty($details)) {
echo '<div class="table-responsive mt-3">';
echo '<table class="table table-striped table-hover">';
echo '<thead class="table-dark">';
echo '<tr>';
echo '<th>Callsign</th>';
echo '<th>Reason</th>';
echo '<th>Station location</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
foreach ($details as $r) {
echo '<tr>';
echo '<td>' . htmlspecialchars($r['callsign']) . '</td>';
echo '<td>' . htmlspecialchars($r['reason']) . '</td>';
echo '<td>' . htmlspecialchars($r['location']) . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
echo '</div>';
}
}
}
function showStateUpdateResult($result, $country) {
if ($result['count'] == 0) {
echo '<div class="alert alert-danger" role="alert">' . __("The number of QSOs updated for state/province in") . ' ' . $country . ' : ' . $result['count'] . '</div>';
} else {
echo '<div class="alert alert-success" role="alert">' . __("The number of QSOs updated for state/province in") . ' ' . $country . ' : ' . $result['count'] . '</div>';
}
if ($result) {
echo __("These QSOs could not be updated:");
$details = [];
foreach ($result as $r) {
if (is_array($r)) {
$details[] = $r;
}
}
if (!empty($details)) {
echo '<div class="table-responsive mt-3">';
echo '<table class="table table-striped table-hover">';
echo '<thead class="table-dark">';
echo '<tr>';
echo '<th>Callsign</th>';
echo '<th>Reason</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
foreach ($details as $r) {
echo '<tr>';
echo '<td>' . htmlspecialchars($r['callsign']) . '</td>';
echo '<td>' . htmlspecialchars($r['reason']) . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
echo '</div>';
}
}
}

View File

@@ -2188,11 +2188,7 @@ function saveOptions() {
},
success: function (response) {
$('#fixStateBtn_' + dxcc).prop("disabled", false).removeClass("running");
if (response.result == 0) {
$('.result').html('<div class="alert alert-danger" role="alert">' + response.message + '</div>');
return;
}
$('.result').html('<div class="alert alert-success" role="alert">' + response.message + '</div>');
$('.result').html(response);
},
error: function () {
$('#fixStateBtn_' + dxcc).prop("disabled", false).removeClass("running");
@@ -2259,11 +2255,7 @@ function saveOptions() {
success: function(data) {
$('#updateDxccBtn').prop("disabled", false).removeClass("running");
$('#closeButton').prop("disabled", false);
if (data.result == 0) {
$('.result').html('<div class="alert alert-danger" role="alert">' + data.message + '</div>');
return;
}
$('.result').html('<div class="alert alert-success" role="alert">' + data.message + '</div>');
$('.result').html(data);
},
error: function(xhr, status, error) {
$('#updateDxccBtn').prop("disabled", false).removeClass("running");
@@ -2289,11 +2281,7 @@ function saveOptions() {
success: function(data) {
$('#fixMissingDxccBtn').prop("disabled", false).removeClass("running");
$('#closeButton').prop("disabled", false);
if (data.result == 0) {
$('.result').html('<div class="alert alert-danger" role="alert">' + data.message + '</div>');
return;
}
$('.result').html('<div class="alert alert-success" role="alert">' + data.message + '</div>');
$('.result').html(data);
},
error: function(xhr, status, error) {
$('#fixMissingDxccBtn').prop("disabled", false).removeClass("running");