Resolves issue when no previous contest qsos have been set and table was empty
Should resolve #2919 #2139
这个提交包含在:
父节点
e2d7edcf81
当前提交
4128425f2d
共有 3 个文件被更改,包括 203 次插入 和 97 次删除
|
|
@ -50,6 +50,15 @@ class Contesting extends CI_Controller {
|
||||||
echo json_encode($this->Contesting_model->getSessionQsos($qso));
|
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() {
|
public function getSession() {
|
||||||
$this->load->model('Contesting_model');
|
$this->load->model('Contesting_model');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,34 @@ class Contesting_model extends CI_Model {
|
||||||
return $data->result();
|
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() {
|
function getSession() {
|
||||||
$CI =& get_instance();
|
$CI =& get_instance();
|
||||||
$CI->load->model('Stations');
|
$CI->load->model('Stations');
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
// Callsign always has focus on load
|
// Callsign always has focus on load
|
||||||
$("#callsign").focus();
|
$("#callsign").focus();
|
||||||
|
|
||||||
var sessiondata={};
|
var sessiondata = {};
|
||||||
$(document).ready(async function () {
|
$(document).ready(async function () {
|
||||||
sessiondata=await getSession(); // save sessiondata global (we need it later, when adding qso)
|
sessiondata = await getSession(); // save sessiondata global (we need it later, when adding qso)
|
||||||
await restoreContestSession(sessiondata); // wait for restoring until finished
|
await restoreContestSession(sessiondata); // wait for restoring until finished
|
||||||
setRst($("#mode").val());
|
setRst($("#mode").val());
|
||||||
});
|
});
|
||||||
|
|
@ -66,13 +66,13 @@ function setSession(formdata) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// realtime clock
|
// realtime clock
|
||||||
if ( ! manual ) {
|
if (!manual) {
|
||||||
$(function ($) {
|
$(function ($) {
|
||||||
handleStart = setInterval(function() { getUTCTimeStamp($('.input_time')); }, 500);
|
handleStart = setInterval(function () { getUTCTimeStamp($('.input_time')); }, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(function ($) {
|
$(function ($) {
|
||||||
handleDate = setInterval(function() { getUTCDateStamp($('.input_date')); }, 1000);
|
handleDate = setInterval(function () { getUTCDateStamp($('.input_date')); }, 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,22 +181,22 @@ document.onkeyup = function (e) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* time input shortcut */
|
/* time input shortcut */
|
||||||
$('#start_time').change(function() {
|
$('#start_time').change(function () {
|
||||||
var raw_time = $(this).val();
|
var raw_time = $(this).val();
|
||||||
if(raw_time.match(/^\d\[0-6]d$/)) {
|
if (raw_time.match(/^\d\[0-6]d$/)) {
|
||||||
raw_time = "0"+raw_time;
|
raw_time = "0" + raw_time;
|
||||||
}
|
}
|
||||||
if(raw_time.match(/^[012]\d[0-5]\d$/)) {
|
if (raw_time.match(/^[012]\d[0-5]\d$/)) {
|
||||||
raw_time = raw_time.substring(0,2)+":"+raw_time.substring(2,4);
|
raw_time = raw_time.substring(0, 2) + ":" + raw_time.substring(2, 4);
|
||||||
$('#start_time').val(raw_time);
|
$('#start_time').val(raw_time);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* date input shortcut */
|
/* date input shortcut */
|
||||||
$('#start_date').change(function() {
|
$('#start_date').change(function () {
|
||||||
raw_date = $(this).val();
|
raw_date = $(this).val();
|
||||||
if(raw_date.match(/^[12]\d{3}[01]\d[0123]\d$/)) {
|
if (raw_date.match(/^[12]\d{3}[01]\d[0123]\d$/)) {
|
||||||
raw_date = raw_date.substring(0,4)+"-"+raw_date.substring(4,6)+"-"+raw_date.substring(6,8);
|
raw_date = raw_date.substring(0, 4) + "-" + raw_date.substring(4, 6) + "-" + raw_date.substring(6, 8);
|
||||||
$('#start_date').val(raw_date);
|
$('#start_date').val(raw_date);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -212,7 +212,7 @@ $("#callsign").keyup(function () {
|
||||||
data: {
|
data: {
|
||||||
callsign: $(this).val().toUpperCase()
|
callsign: $(this).val().toUpperCase()
|
||||||
},
|
},
|
||||||
success: function(result) {
|
success: function (result) {
|
||||||
$('.callsign-suggestions').text(result);
|
$('.callsign-suggestions').text(result);
|
||||||
highlight(call.toUpperCase());
|
highlight(call.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
@ -241,7 +241,7 @@ function checkIfWorkedBefore() {
|
||||||
'contest': $("#contestname").val()
|
'contest': $("#contestname").val()
|
||||||
},
|
},
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
if (result.message.substr(0,6) == 'Worked') {
|
if (result.message.substr(0, 6) == 'Worked') {
|
||||||
$('#callsign_info').text(result.message);
|
$('#callsign_info').text(result.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -455,6 +455,8 @@ function logQso() {
|
||||||
$("#callsign").focus();
|
$("#callsign").focus();
|
||||||
setSession(formdata);
|
setSession(formdata);
|
||||||
|
|
||||||
|
// try setting session data
|
||||||
|
console.log(sessiondata);
|
||||||
await refresh_qso_table(sessiondata);
|
await refresh_qso_table(sessiondata);
|
||||||
var qTable = $('.qsotable').DataTable();
|
var qTable = $('.qsotable').DataTable();
|
||||||
qTable.search('').order([0, 'desc']).draw();
|
qTable.search('').order([0, 'desc']).draw();
|
||||||
|
|
@ -500,6 +502,7 @@ async function restoreContestSession(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refresh_qso_table(data) {
|
async function refresh_qso_table(data) {
|
||||||
|
if (data && data.qso) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: base_url + 'index.php/contesting/getSessionQsos',
|
url: base_url + 'index.php/contesting/getSessionQsos',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
|
|
@ -545,25 +548,91 @@ async function refresh_qso_table(data) {
|
||||||
order: [0, 'desc'],
|
order: [0, 'desc'],
|
||||||
"columnDefs": [
|
"columnDefs": [
|
||||||
{
|
{
|
||||||
"render": function ( data, type, row ) {
|
"render": function (data, type, row) {
|
||||||
return pad(row[8],3);
|
return pad(row[8], 3);
|
||||||
},
|
},
|
||||||
"targets" : 8
|
"targets": 8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"render": function ( data, type, row ) {
|
"render": function (data, type, row) {
|
||||||
return pad(row[9],3);
|
return pad(row[9], 3);
|
||||||
},
|
},
|
||||||
"targets" : 9
|
"targets": 9
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} 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) {
|
function pad(str, max) {
|
||||||
str = str.toString();
|
str = str.toString();
|
||||||
return str.length < max ? pad("0" + str, max) : str;
|
return str.length < max ? pad("0" + str, max) : str;
|
||||||
}
|
}
|
||||||
|
|
@ -572,12 +641,12 @@ function getUTCTimeStamp(el) {
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
var localTime = now.getTime();
|
var localTime = now.getTime();
|
||||||
var utc = localTime + (now.getTimezoneOffset() * 60000);
|
var utc = localTime + (now.getTimezoneOffset() * 60000);
|
||||||
$(el).attr('value', ("0" + now.getUTCHours()).slice(-2)+':'+("0" + now.getUTCMinutes()).slice(-2)+':'+("0" + now.getUTCSeconds()).slice(-2));
|
$(el).attr('value', ("0" + now.getUTCHours()).slice(-2) + ':' + ("0" + now.getUTCMinutes()).slice(-2) + ':' + ("0" + now.getUTCSeconds()).slice(-2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUTCDateStamp(el) {
|
function getUTCDateStamp(el) {
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
var localTime = now.getTime();
|
var localTime = now.getTime();
|
||||||
var utc = localTime + (now.getTimezoneOffset() * 60000);
|
var utc = localTime + (now.getTimezoneOffset() * 60000);
|
||||||
$(el).attr('value', ("0" + now.getUTCDate()).slice(-2)+'-'+("0" + (now.getUTCMonth()+1)).slice(-2)+'-'+now.getUTCFullYear());
|
$(el).attr('value', ("0" + now.getUTCDate()).slice(-2) + '-' + ("0" + (now.getUTCMonth() + 1)).slice(-2) + '-' + now.getUTCFullYear());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用