Resolves issue when no previous contest qsos have been set and table was empty

Should resolve #2919 #2139
这个提交包含在:
Peter Goodhall 2024-01-14 18:04:35 +00:00
父节点 e2d7edcf81
当前提交 4128425f2d
共有 3 个文件被更改,包括 203 次插入97 次删除

查看文件

@ -50,6 +50,15 @@ class Contesting extends CI_Controller {
echo json_encode($this->Contesting_model->getSessionQsos($qso));
}
public function getSessionFreshQsos() {
$this->load->model('Contesting_model');
$contest_id = $this->input->post('contest_id');
header('Content-Type: application/json');
echo json_encode($this->Contesting_model->getSessionFreshQsos($contest_id));
}
public function getSession() {
$this->load->model('Contesting_model');

查看文件

@ -29,6 +29,34 @@ class Contesting_model extends CI_Model {
return $data->result();
}
function getSessionFreshQsos($contest_id) {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
$contestid = $contest_id;
// save contestid to debug
// Get current date and time
$now = new DateTime();
$now->modify('-1 minute');
$date = $now->format('Y-m-d H:i:s');
$sql = "SELECT date_format(col_time_on, '%d-%m-%Y %H:%i:%s') as col_time_on, col_call, col_band, col_mode,
col_submode, col_rst_sent, col_rst_rcvd, coalesce(col_srx, '') col_srx, coalesce(col_srx_string, '') col_srx_string,
coalesce(col_stx, '') col_stx, coalesce(col_stx_string, '') col_stx_string, coalesce(col_gridsquare, '') col_gridsquare,
coalesce(col_vucc_grids, '') col_vucc_grids FROM " .
$this->config->item('table_name') .
" WHERE station_id = " . $station_id .
" AND COL_TIME_ON >= '" . $date . "'" .
" AND COL_CONTEST_ID = '" . $contestid . "'" .
" ORDER BY COL_PRIMARY_KEY ASC";
$data = $this->db->query($sql);
return $data->result();
}
function getSession() {
$CI =& get_instance();
$CI->load->model('Stations');

查看文件

@ -455,6 +455,8 @@ function logQso() {
$("#callsign").focus();
setSession(formdata);
// try setting session data
console.log(sessiondata);
await refresh_qso_table(sessiondata);
var qTable = $('.qsotable').DataTable();
qTable.search('').order([0, 'desc']).draw();
@ -500,6 +502,7 @@ async function restoreContestSession(data) {
}
async function refresh_qso_table(data) {
if (data && data.qso) {
$.ajax({
url: base_url + 'index.php/contesting/getSessionQsos',
type: 'post',
@ -561,6 +564,72 @@ async function refresh_qso_table(data) {
}
}
});
} else {
// Runs when no session is set usually when its a clean contest
var selectElement = document.getElementById('contestname');
var selected_contest_id = selectElement.options[selectElement.selectedIndex].value;
$.ajax({
url: base_url + 'index.php/contesting/getSessionFreshQsos',
type: 'post',
data: { 'contest_id': selected_contest_id },
success: function (html) {
var mode = '';
$(".contest_qso_table_contents").empty();
$.each(html, function () {
if (this.col_submode == null || this.col_submode == '') {
mode = this.col_mode;
} else {
mode = this.col_submode;
}
$(".qsotable tbody").prepend('<tr>' +
'<td>' + this.col_time_on + '</td>' +
'<td>' + this.col_call + '</td>' +
'<td>' + this.col_band + '</td>' +
'<td>' + mode + '</td>' +
'<td>' + this.col_rst_sent + '</td>' +
'<td>' + this.col_rst_rcvd + '</td>' +
'<td>' + this.col_stx_string + '</td>' +
'<td>' + this.col_srx_string + '</td>' +
'<td>' + this.col_stx + '</td>' +
'<td>' + this.col_srx + '</td>' +
'<td>' + this.col_gridsquare + '</td>' +
'<td>' + this.col_vucc_grids + '</td>' +
'</tr>');
});
if (!$.fn.DataTable.isDataTable('.qsotable')) {
$.fn.dataTable.moment('DD-MM-YYYY HH:mm:ss');
$('.qsotable').DataTable({
"stateSave": true,
"pageLength": 25,
responsive: false,
"scrollY": "400px",
"scrollCollapse": true,
"paging": false,
"scrollX": true,
"language": {
url: getDataTablesLanguageUrl(),
},
order: [0, 'desc'],
"columnDefs": [
{
"render": function (data, type, row) {
return pad(row[8], 3);
},
"targets": 8
},
{
"render": function (data, type, row) {
return pad(row[9], 3);
},
"targets": 9
}
]
});
}
}
});
}
}
function pad(str, max) {