diff --git a/application/controllers/Calltester.php b/application/controllers/Calltester.php index 8da8f79bd..3d3064907 100644 --- a/application/controllers/Calltester.php +++ b/application/controllers/Calltester.php @@ -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
"; - echo $i . " calls tested.
"; - $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; } diff --git a/application/views/calltester/index.php b/application/views/calltester/index.php new file mode 100644 index 000000000..043e76862 --- /dev/null +++ b/application/views/calltester/index.php @@ -0,0 +1,19 @@ +
+
+
+
+ + + +
+
+
+
\ No newline at end of file diff --git a/application/views/calltester/result.php b/application/views/calltester/result.php new file mode 100644 index 000000000..5717709cc --- /dev/null +++ b/application/views/calltester/result.php @@ -0,0 +1,22 @@ + + + + + + + $value) { + echo ""; + } + + // Table body + echo ''; + foreach ($result as $value) { + echo ""; + foreach ($value as $val) { + echo ""; + } + echo ""; + } + echo ''; + echo "
".$key."
".$val."
"; ?> \ No newline at end of file diff --git a/assets/js/sections/calltester.js b/assets/js/sections/calltester.js new file mode 100644 index 000000000..dfc50283e --- /dev/null +++ b/assets/js/sections/calltester.js @@ -0,0 +1,15 @@ + $('#startDxccCheck').on('click', function() { + let de = $('#de').val(); + $('.result').html('
Loading...
'); + $.ajax({ + url: site_url + '/calltester/doDxccCheck', + type: "POST", + data: {de: de}, + success: function(response) { + $('.result').html(response); + }, + error: function(xhr, status, error) { + $('.result').html(''); + } + }); + }); \ No newline at end of file