function loadStationInfo() {
$(".stationinfo").empty();
$(".searchinfo").empty();
$.ajax({
url: base_url+'index.php/oqrs/get_station_info',
type: 'post',
data: {'station_id': $("#station").val()},
success: function (data) {
if (data.count > 0) {
$(".stationinfo").append(' ' + data.count + ' Qsos logged between ' + data.mindate + ' and ' + data.maxdate + '. ');
$(".stationinfo").append('
');
// Get the input field
var input = document.getElementById("oqrssearch");
// Execute a function when the user presses a key on the keyboard
input.addEventListener("keypress", function(event) {
// If the user presses the "Enter" key on the keyboard
if (event.key === "Enter") {
// Cancel the default action, if needed
event.preventDefault();
// Trigger the button element with a click
document.getElementById("stationbuttonsubmit").click();
}
});
} else {
$(".stationinfo").append("No QSOs for this callsign was found!");
}
}
});
}
function searchOqrs() {
$(".searchinfo").empty();
$.ajax({
url: base_url+'index.php/oqrs/get_qsos',
type: 'post',
data: {'station_id': $("#station").val(), 'callsign': $("#oqrssearch").val()},
success: function (data) {
$(".searchinfo").append(data);
}
});
}
function notInLog() {
$.ajax({
url: base_url + 'index.php/oqrs/not_in_log',
type: 'post',
data: {'station_id': $("#station").val(), 'callsign': $("#oqrssearch").val()},
success: function(html) {
$(".searchinfo").html(html);
}
});
}
function saveNotInLogRequest() {
$(".alertinfo").remove();
if ($("#emailInput").val() == '') {
$(".searchinfo").prepend('× You need to fill out an email address!
');
} else {
const qsos = [];
$(".notinlog-table tbody tr").each(function(i) {
var data = [];
var datecell = $("#date", this).val();
var timecell = $("#time", this).val();
var bandcell = $("#band", this).val();
var modecell = $("#mode", this).val();
if (datecell != "" && timecell != "" && bandcell != "" && modecell != "") {
data.push(datecell);
data.push(timecell);
data.push(bandcell);
data.push(modecell);
qsos.push(data);
}
});
if (qsos.length === 0) {
$(".searchinfo").prepend('× You need to fill the QSO information before submitting a request!
');
} else {
$.ajax({
url: base_url+'index.php/oqrs/save_not_in_log',
type: 'post',
data: { 'station_id': $("#station").val(),
'callsign': $("#oqrssearch").val(),
'email': $("#emailInput").val(),
'message': $("#messageInput").val(),
'qsos': qsos
},
success: function (data) {
$(".stationinfo").empty();
$(".searchinfo").empty();
$(".stationinfo").append('× Your not in log query has been saved!
');
}
});
}
}
}
function oqrsAddLine() {
var rowCount = $('.notinlog-table tr').length;
var $myTable = $('.notinlog-table');
var $row = $(' ');
var $iterator = $(' ').html(rowCount);
var $date = $(' ').html(' ');
var $time = $(' ').html(' ');
var $band = $(' ').html(' ');
var $mode = $(' ').html(' ');
$row.append($iterator, $date, $time, $band, $mode);
$myTable.append($row);
}
function requestOqrs() {
$.ajax({
url: base_url + 'index.php/oqrs/request_form',
type: 'post',
data: {'station_id': $("#station").val(), 'callsign': $("#oqrssearch").val()},
success: function(html) {
$(".searchinfo").html(html);
$('.result-table').DataTable({
"pageLength": 25,
responsive: false,
ordering: false,
"scrollY": "410px",
"scrollCollapse": true,
"paging": false,
"scrollX": true,
});
}
});
}
function submitOqrsRequest() {
$(".alertinfo").remove();
if ($("#emailInput").val() == '') {
$(".searchinfo").prepend('× You need to fill out an email address!
');
} else {
const qsos = [];
$(".result-table tbody tr").each(function(i) {
var data = [];
var datecell = $("#date", this).val();
var timecell = $("#time", this).val();
var bandcell = $("#band", this).text();
var modecell = $("#mode", this).text();
if (datecell != "" && timecell != "") {
data.push(datecell);
data.push(timecell);
data.push(bandcell);
data.push(modecell);
qsos.push(data);
}
});
if (qsos.length === 0) {
$(".searchinfo").prepend('× You need to fill the QSO information before submitting a request!
');
} else {
$.ajax({
url: base_url+'index.php/oqrs/save_oqrs_request',
type: 'post',
data: { 'station_id': $("#station").val(),
'callsign': $("#oqrssearch").val(),
'email': $("#emailInput").val(),
'message': $("#messageInput").val(),
'qsos': qsos,
'qslroute': $('input[name="qslroute"]:checked').val()
},
success: function (data) {
$(".stationinfo").empty();
$(".searchinfo").empty();
$(".stationinfo").append('× Your QSL request has been saved!
');
}
});
}
}
}
function deleteOqrsLine(id) {
BootstrapDialog.confirm({
title: 'DANGER',
message: 'Warning! Are you sure you want to delete this OQRS request?',
type: BootstrapDialog.TYPE_DANGER,
closable: true,
draggable: true,
btnOKClass: 'btn-danger',
callback: function (result) {
$.ajax({
url: base_url+'index.php/oqrs/delete_oqrs_line',
type: 'post',
data: { 'id': id,
},
success: function (data) {
$(".oqrsid_"+id).remove();
}
});
}
});
}
function searchLog(callsign) {
$.ajax({
url: base_url + 'index.php/oqrs/search_log',
type: 'post',
data: {'callsign': callsign,
},
success: function(html) {
BootstrapDialog.show({
title: 'QSO List',
size: BootstrapDialog.SIZE_WIDE,
cssClass: 'qso-dialog',
nl2br: false,
message: html,
onshown: function(dialog) {
$('[data-toggle="tooltip"]').tooltip();
},
buttons: [{
label: 'Close',
action: function (dialogItself) {
dialogItself.close();
}
}]
});
}
});
}
function searchLogTimeDate(id) {
$.ajax({
url: base_url + 'index.php/oqrs/search_log_time_date',
type: 'post',
data: {'time': $('.oqrsid_'+id+ ' td:nth-child(2)').text(),
'date': $('.oqrsid_'+id+ ' td:nth-child(1)').text(),
'band': $('.oqrsid_'+id+ ' td:nth-child(3)').text(),
'mode': $('.oqrsid_'+id+ ' td:nth-child(4)').text()
},
success: function(html) {
BootstrapDialog.show({
title: 'QSO List',
size: BootstrapDialog.SIZE_WIDE,
cssClass: 'qso-dialog',
nl2br: false,
message: html,
onshown: function(dialog) {
$('[data-toggle="tooltip"]').tooltip();
},
buttons: [{
label: 'Close',
action: function (dialogItself) {
dialogItself.close();
}
}]
});
}
});
}
function markOqrsLineAsDone(id) {
$.ajax({
url: base_url+'index.php/oqrs/mark_oqrs_line_as_done',
type: 'post',
data: { 'id': id,
},
success: function (data) {
$(".oqrsid_"+id).remove();
}
});
}