diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php index 301bf6139..1ca6422da 100644 --- a/application/controllers/Logbookadvanced.php +++ b/application/controllers/Logbookadvanced.php @@ -893,10 +893,16 @@ class Logbookadvanced extends CI_Controller { if(!clubaccess_check(9)) return; $type = $this->input->post('type', true); - $this->load->model('logbookadvanced_model'); - $result = $this->logbookadvanced_model->runCheckDb($type); - header("Content-Type: application/json"); - print json_encode($result); + + if ($type == 'checkstate') { + $data['result'] = $this->logbookadvanced_model->runCheckDb($type); + $this->load->view('logbookadvanced/checkresult', $data); + } else { + $result = $this->logbookadvanced_model->runCheckDb($type); + header("Content-Type: application/json"); + echo json_encode($result); + } + } } diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index fbeb85691..0124843fa 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -1455,6 +1455,8 @@ class Logbookadvanced_model extends CI_Model { return $this->check_qsos_missing_continent(); case 'checkdxcc': return $this->check_missing_dxcc(); + case 'checkstate': + return $this->check_missing_state(); return null; } } @@ -1504,4 +1506,24 @@ class Logbookadvanced_model extends CI_Model { $query = $this->db->query($sql, $bindings); return $query->result(); } + + public function check_missing_state() { + $this->load->library('Geojson'); + $supported_dxcc_list = $this->geojson->getSupportedDxccs(); + $supported_dxcc_array = array_keys($supported_dxcc_list); + + $sql = "select count(*) as count, col_dxcc, dxcc_entities.name as dxcc_name, dxcc_entities.prefix from " . $this->config->item('table_name') . " + join station_profile on " . $this->config->item('table_name') . ".station_id = station_profile.station_id + join dxcc_entities on " . $this->config->item('table_name') . ".col_dxcc = dxcc_entities.adif + where user_id = ? and coalesce(col_state, '') = '' + and col_dxcc in (" . implode(',', array_map('intval', $supported_dxcc_array)) . ") + and length(col_gridsquare) >= 6 + group by col_dxcc, dxcc_entities.name, dxcc_entities.prefix + order by dxcc_entities.prefix"; + + $bindings[] = [$this->session->userdata('user_id')]; + + $query = $this->db->query($sql, $bindings); + return $query->result(); + } } diff --git a/application/views/logbookadvanced/checkresult.php b/application/views/logbookadvanced/checkresult.php new file mode 100644 index 000000000..e1a86a04d --- /dev/null +++ b/application/views/logbookadvanced/checkresult.php @@ -0,0 +1,38 @@ + 0): ?> +
QSOs with missing state and gridsquares with 6 or more characters found for the following DXCC's:
+ +| Prefix | +DXCC | +QSOs | +
|---|---|---|
| prefix; ?> | ++ | + |
No issues found. All QSOs have proper state information.
+QSOs without missing or invalid continent information found: ' + (response[0].count) + '
'; + resultHtml += 'QSOs with missing or invalid continent information found: ' + (response[0].count) + '
'; $('.result').html(resultHtml); }, @@ -2140,3 +2140,74 @@ function saveOptions() { } }); } + + function checkFixState() { + $('#checkFixStateBtn').prop("disabled", true).addClass("running"); + $('#closeButton').prop("disabled", true); + + $.ajax({ + url: base_url + 'index.php/logbookadvanced/checkDb', + data: { + type: 'checkstate' + }, + type: 'POST', + success: function(response) { + $('#checkFixStateBtn').prop("disabled", false).removeClass("running"); + $('#closeButton').prop("disabled", false); + + $('.result').html(response); + }, + error: function(xhr, status, error) { + $('#checkFixStateBtn').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 checkFixState2() { + $('#checkFixStateBtn').prop("disabled", true).addClass("running"); + $('#closeButton').prop("disabled", true); + + $.ajax({ + url: base_url + 'index.php/logbookadvanced/checkDb', + data: { + type: 'checkstate' + }, + type: 'POST', + success: function(response) { + $('#checkFixStateBtn').prop("disabled", false).removeClass("running"); + $('#closeButton').prop("disabled", false); + // Create a nice display for the results + let resultHtml = 'QSOs with missing state and gridsquares with 6 or more characters found: ' + (response[0].count) + '
'; + + $('.result').html(resultHtml); + }, + error: function(xhr, status, error) { + $('#checkFixStateBtn').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 + }); + } + }); + }