Get dxcc fix working in gui

This commit is contained in:
Andreas Kristiansen
2025-12-08 14:59:43 +01:00
parent bde29d6cbf
commit 7e3b962019
4 changed files with 33 additions and 4 deletions

View File

@@ -928,7 +928,6 @@ class Logbookadvanced extends CI_Controller {
public function openStateList() {
if(!clubaccess_check(9)) return;
$this->load->model('logbook_model');
$this->load->model('logbookadvanced_model');
$data['dxcc'] = $this->input->post('dxcc', true);
@@ -938,4 +937,15 @@ class Logbookadvanced extends CI_Controller {
$this->load->view('logbookadvanced/showStateQsos', $data);
}
public function fixMissingDxcc() {
if(!clubaccess_check(9)) return;
$all = $this->input->post('all', true);
$this->load->model('logbookadvanced_model');
$result = $this->logbookadvanced_model->check_missing_dxcc_id($all);
header("Content-Type: application/json");
echo json_encode($result);
}
}

View File

@@ -1598,7 +1598,7 @@ class Logbookadvanced_model extends CI_Model {
We need to ensure that we only update the relevant QSOs, filtered on user.
The function needs a rewrite to add filtering on user/station.
*/
public function check_missing_dxcc_id($all) {
public function check_missing_dxcc_id($all = false) {
ini_set('memory_limit', '-1'); // This consumes a lot of Memory!
$this->db->trans_start(); // Transaction has to be started here, because otherwise we're trying to update rows which are locked by the select
$this->db->select("COL_PRIMARY_KEY, COL_CALL, COL_TIME_ON, COL_TIME_OFF"); // get all records with no COL_DXCC
@@ -1606,7 +1606,10 @@ class Logbookadvanced_model extends CI_Model {
$this->db->where("station_profile.user_id", $this->session->userdata('user_id'));
if (!$all) { // check which to update - records with no dxcc or all records
$this->db->group_start();
$this->db->where("COL_DXCC is NULL");
$this->db->or_where("COL_DXCC = ''");
$this->db->group_end();
}
$r = $this->db->get($this->config->item('table_name'));
@@ -1627,6 +1630,6 @@ class Logbookadvanced_model extends CI_Model {
}
}
$this->db->trans_complete();
print("$count updated\n");
return $count;
}
}

View File

@@ -86,7 +86,7 @@
<p class="mb-1 small alert-danger"><?= __("This will overwrite ALL existing DXCC information!") ?></p>
</div>
<div class="d-flex nowrap">
<button type="button" class="btn btn-sm btn-primary ld-ext-right" id="updateDistancesBtn" onclick="runUpdateDistances()">
<button type="button" class="btn btn-sm btn-primary ld-ext-right" id="updateDistancesBtn" onclick="fixMissingDxcc('All')">
<?= __("Run") ?><div class="ld ld-ring ld-spin"></div>
</button>
</div>

View File

@@ -2316,3 +2316,19 @@ function saveOptions() {
});
}
function fixMissingDxcc() {
$.ajax({
url: base_url + 'index.php/logbookadvanced/fixMissingDxcc',
data: {
all: 'false'
},
type: 'POST',
success: function(response) {
alert('dxcc');
},
error: function(xhr, status, error) {
alert('error');
}
});
}