diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php index d9fa9052a..a32553769 100644 --- a/application/controllers/Logbookadvanced.php +++ b/application/controllers/Logbookadvanced.php @@ -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); + } } diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index 7ece14b11..928e4e21a 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -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; } } diff --git a/application/views/logbookadvanced/dbtoolsdialog.php b/application/views/logbookadvanced/dbtoolsdialog.php index 5f1245a8c..3de1e644f 100644 --- a/application/views/logbookadvanced/dbtoolsdialog.php +++ b/application/views/logbookadvanced/dbtoolsdialog.php @@ -86,7 +86,7 @@

-
diff --git a/assets/js/sections/logbookadvanced.js b/assets/js/sections/logbookadvanced.js index 95528e5f9..89632ee81 100644 --- a/assets/js/sections/logbookadvanced.js +++ b/assets/js/sections/logbookadvanced.js @@ -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'); + } + }); + }