[Calltester] Added gui for calltester, to see potential wrong DXCC

This commit is contained in:
Andreas Kristiansen
2025-12-18 11:03:06 +01:00
parent 89b2accaff
commit 3fc74975cf
4 changed files with 105 additions and 17 deletions

View File

@@ -12,24 +12,39 @@ class Calltester extends CI_Controller {
}
public function db() {
public function index() {
set_time_limit(3600);
// Starting clock time in seconds
$start_time = microtime(true);
$callarray = $this->getQsos(null);
$this->load->model('stations');
$data['station_profile'] = $this->stations->all_of_user();
$footerData = [];
$footerData['scripts'] = [
'assets/js/sections/calltester.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/calltester.js"))
];
$this->load->view('interface_assets/header', $data);
$this->load->view('calltester/index');
$this->load->view('interface_assets/footer', $footerData);
}
function doDxccCheck() {
$this->load->model('logbook_model');
$i = 0;
$result = array();
$sql = 'select distinct col_country, col_call, col_dxcc, date(col_time_on) date from ' . $this->config->item('table_name');
$query = $this->db->query($sql);
$callarray = $this->getQsos($this->input->post('de', true));
$callarray = $query->result();
// Starting clock time in seconds
$start_time = microtime(true);
$result = array();
$i = 0;
foreach ($callarray as $call) {
foreach ($callarray->result() as $call) {
$i++;
$dxcc = $this->logbook_model->dxcc_lookup($call->col_call, $call->date);
@@ -39,8 +54,10 @@ class Calltester extends CI_Controller {
if ($call->col_dxcc != $dxcc['adif']) {
$result[] = array(
'Callsign' => $call->col_call,
'Expected country' => $call->col_country,
'Expected adif' => $call->col_dxcc,
'QSO date' => $call->date,
'Station profile' => $call->station_profile_name,
'Existing DXCC' => $call->col_country,
'Existing adif' => $call->col_dxcc,
'Result country' => ucwords(strtolower($dxcc['entity']), "- (/"),
'Result adif' => $dxcc['adif'],
);
@@ -53,14 +70,29 @@ class Calltester extends CI_Controller {
// Calculate script execution time
$execution_time = ($end_time - $start_time);
echo " Execution time of script = ".$execution_time." sec <br/>";
echo $i . " calls tested. <br/>";
$count = 0;
$data['execution_time'] = $execution_time;
$data['calls_tested'] = $i;
$data['result'] = $result;
if ($result) {
$this->array_to_table($result);
}
$this->load->view('calltester/result', $data);
}
function getQsos($station_id) {
$sql = 'select distinct col_country, col_call, col_dxcc, date(col_time_on) date, station_profile.station_profile_name
from ' . $this->config->item('table_name') . '
join station_profile on ' . $this->config->item('table_name') . '.station_id = station_profile.station_id
where station_profile.user_id = ?';
$params[] = array($this->session->userdata('user_id'));
if ($station_id && is_numeric($station_id)) {
$sql .= ' and ' . $this->config->item('table_name') . '.station_id = ?';
$params[] = $station_id;
}
$sql .= ' order by station_profile.station_profile_name asc, date desc';
$query = $this->db->query($sql, $params);
return $query;
}

View File

@@ -0,0 +1,19 @@
<div class="container">
<br />
<h5><?= __("Callsign DXCC identification"); ?></h5>
<div class="d-flex align-items-center mb-3">
<label class="me-2" for="de"><?= __("Station Location"); ?></label>
<select class="form-select form-select-sm w-auto me-2" id="de" name="de">
<option value="all">All</option>
<?php foreach ($station_profile->result() as $station) { ?>
<option value="<?php echo $station->station_id; ?>">
<?= __("Callsign: ") . " " ?>
<?php echo str_replace("0", "&Oslash;", strtoupper($station->station_callsign)); ?> (<?php echo $station->station_profile_name; ?>)
</option>
<?php } ?>
</select>
<button id="startDxccCheck" class="btn btn-primary btn-sm"><?= __("Start DXCC Check"); ?></button>
</div>
<div class='result'>
</div>
</div>

View File

@@ -0,0 +1,22 @@
<?php $execution_time ?>
<?php $calls_tested ?>
<table class="table table-striped table-bordered table-sm">
<thead>
<tr>
<?php // Table header
foreach ($result[0] as $key=>$value) {
echo "<th>".$key."</th>";
}
// Table body
echo '<tbody>';
foreach ($result as $value) {
echo "<tr>";
foreach ($value as $val) {
echo "<td>".$val."</td>";
}
echo "</tr>";
}
echo '</tbody>';
echo "</table>"; ?>

View File

@@ -0,0 +1,15 @@
$('#startDxccCheck').on('click', function() {
let de = $('#de').val();
$('.result').html('<div class="spinner-border text-primary" role="status"><span class="visually-hidden">Loading...</span></div> <?= __("Processing...") ?>');
$.ajax({
url: site_url + '/calltester/doDxccCheck',
type: "POST",
data: {de: de},
success: function(response) {
$('.result').html(response);
},
error: function(xhr, status, error) {
$('.result').html('<div class="alert alert-danger" role="alert"><?= __("An error occurred while processing the request.") ?></div>');
}
});
});