kopia lustrzana https://github.com/magicbug/Cloudlog
[Contesting] Restoring QSO table.
rodzic
bccfa6762b
commit
9e790340d7
|
@ -51,4 +51,16 @@ class Contesting extends CI_Controller {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public function getSessionQsos() {
|
||||
//load model
|
||||
$this->load->model('Contesting_model');
|
||||
|
||||
$qso = $this->input->post('qso');
|
||||
|
||||
// get QSOs to fill the table
|
||||
$data = $this->Contesting_model->getSessionQsos($qso);
|
||||
|
||||
return json_encode($data);
|
||||
}
|
||||
}
|
|
@ -6,4 +6,30 @@ class Contesting_model extends CI_Model {
|
|||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* This function gets the QSOs to fill the "Contest Logbook" under the contesting form.
|
||||
*/
|
||||
function getSessionQsos($qso) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
|
||||
$qsoarray = explode(',', $qso);
|
||||
|
||||
$contestid = $qsoarray[2];
|
||||
$date = DateTime::createFromFormat('d-m-Y H:i:s', $qsoarray[0]);
|
||||
$date = $date->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, col_srx, col_srx_string, col_stx, col_stx_string 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);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data->result());
|
||||
}
|
||||
}
|
|
@ -378,7 +378,8 @@
|
|||
<input type="text" class="form-control form-control-sm" name="comment" id="comment" value="">
|
||||
</div>
|
||||
</div>
|
||||
<button type="reset" class="btn btn-sm btn-warning" onclick="reset_log_fields()">Reset</button>
|
||||
<button type="reset" class="btn btn-sm btn-warning" onclick="reset_log_fields()">Reset Form</button>
|
||||
<button type="button" class="btn btn-sm btn-warning" onclick="reset_contest_session()">Reset Contest Session</button>
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="logQso();"><i class="fas fa-save"></i> Save QSO</button>
|
||||
</div>
|
||||
|
||||
|
@ -398,7 +399,7 @@
|
|||
<div class="card log">
|
||||
<div class="card-header"><h5 class="card-title">Contest Logbook (Only for this session)</h5></div>
|
||||
|
||||
<table class="table-sm table qsotable table-bordered table-hover table-striped table-condensed text-center">
|
||||
<table style="width:100%" class="table-sm table qsotable table-bordered table-hover table-striped table-condensed text-center">
|
||||
<thead>
|
||||
<tr class="log_title titles">
|
||||
<th>Date/Time</th>
|
||||
|
|
|
@ -2545,16 +2545,19 @@ function deleteQsl(id) {
|
|||
if ($("#callsign").val().length > 0) {
|
||||
|
||||
$('.callsign-suggestions').text("");
|
||||
$(".qsotable tbody").prepend('<tr>' +
|
||||
'<td>'+$("#start_date").val()+ ' ' + $("#start_time").val() + '</td>' +
|
||||
'<td>'+$("#callsign").val().toUpperCase()+'</td>' +
|
||||
'<td>'+$("#band").val()+'</td>' +
|
||||
'<td>'+$("#mode").val()+'</td>' +
|
||||
'<td>'+$("#rst_sent").val()+'</td>' +
|
||||
'<td>'+$("#rst_recv").val()+'</td>' +
|
||||
'<td>'+$("#exch_sent").val()+'</td>' +
|
||||
'<td>'+$("#exch_recv").val()+'</td>' +
|
||||
'</tr>');
|
||||
|
||||
var table = $('.qsotable').DataTable();
|
||||
|
||||
var data = [[$("#start_date").val()+ ' ' + $("#start_time").val(),
|
||||
$("#callsign").val().toUpperCase(),
|
||||
$("#band").val(),
|
||||
$("#mode").val(),
|
||||
$("#rst_sent").val(),
|
||||
$("#rst_recv").val(),
|
||||
$("#exch_sent").val(),
|
||||
$("#exch_recv").val()]];
|
||||
|
||||
table.rows.add(data).draw();
|
||||
|
||||
var baseURL= "<?php echo base_url();?>";
|
||||
var formdata = new FormData(document.getElementById("qso_input"));
|
||||
|
@ -2566,6 +2569,10 @@ function deleteQsl(id) {
|
|||
contentType: false,
|
||||
enctype: 'multipart/form-data',
|
||||
success: function (html) {
|
||||
if (localStorage.getItem("qso") == null) {
|
||||
localStorage.setItem("qso", $("#start_date").val()+ ' ' + $("#start_time").val() + ',' + $("#callsign").val().toUpperCase() + ',' + $("#contestname").val());
|
||||
}
|
||||
|
||||
$('#name').val("");
|
||||
|
||||
$('#callsign').val("");
|
||||
|
@ -2584,6 +2591,83 @@ function deleteQsl(id) {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
// We are restoring the settings in the contest logging form here
|
||||
function restoreContestSession() {
|
||||
var contestname = localStorage.getItem("contestid");
|
||||
|
||||
if (contestname != null) {
|
||||
$("#contestname").val(contestname);
|
||||
}
|
||||
|
||||
var exchangetype = localStorage.getItem("exchangetype");
|
||||
|
||||
if (exchangetype == "other") {
|
||||
$("[name=exchangeradio]").val(["other"]);
|
||||
}
|
||||
|
||||
var exchangesent = localStorage.getItem("exchangesent");
|
||||
|
||||
if (exchangesent != null) {
|
||||
$("#exch_sent").val(exchangesent);
|
||||
}
|
||||
|
||||
if (localStorage.getItem("qso") != null) {
|
||||
var baseURL= "<?php echo base_url();?>";
|
||||
//alert(localStorage.getItem("qso"));
|
||||
var qsodata = localStorage.getItem("qso");
|
||||
$.ajax({
|
||||
url: baseURL + 'index.php/contesting/getSessionQsos',
|
||||
type: 'post',
|
||||
data: {'qso': qsodata,},
|
||||
success: function (html) {
|
||||
var mode = '';
|
||||
var sentexchange = '';
|
||||
var receivedexchange = '';
|
||||
$.each(html, function(){
|
||||
if (this.col_submode == null || this.col_submode == '') {
|
||||
mode = this.col_mode;
|
||||
} else {
|
||||
mode = this.col_submode;
|
||||
}
|
||||
|
||||
if (this.col_srx == null || this.col_srx == '') {
|
||||
receivedexchange = this.col_srx_string;
|
||||
} else {
|
||||
receivedexchange = this.col_srx;
|
||||
}
|
||||
|
||||
if (this.col_stx == null || this.col_stx == '') {
|
||||
sentexchange = this.col_stx_string;
|
||||
} else {
|
||||
sentexchange = this.col_stx;
|
||||
}
|
||||
|
||||
$(".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>'+ sentexchange + '</td>' +
|
||||
'<td>'+ receivedexchange + '</td>' +
|
||||
'</tr>');
|
||||
});
|
||||
|
||||
$('.qsotable').DataTable({
|
||||
"pageLength": 25,
|
||||
responsive: false,
|
||||
"scrollY": "400px",
|
||||
"scrollCollapse": true,
|
||||
"paging": false,
|
||||
"scrollX": true,
|
||||
"order": [[ 0, "desc" ]]
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php } ?>
|
||||
|
|
|
@ -8,25 +8,12 @@ $( document ).ready(function() {
|
|||
restoreContestSession();
|
||||
});
|
||||
|
||||
// We are restoring the settings in the contest logging form here
|
||||
function restoreContestSession() {
|
||||
var contestname = localStorage.getItem("contestid");
|
||||
|
||||
if (contestname != null) {
|
||||
$("#contestname").val(contestname);
|
||||
}
|
||||
|
||||
var exchangetype = localStorage.getItem("exchangetype");
|
||||
|
||||
if (exchangetype == "other") {
|
||||
$("[name=exchangeradio]").val(["other"]);
|
||||
}
|
||||
|
||||
var exchangesent = localStorage.getItem("exchangesent");
|
||||
|
||||
if (exchangesent != null) {
|
||||
$("#exch_sent").val(exchangesent);
|
||||
}
|
||||
// This erases the contest logging session which is stored in localStorage
|
||||
function reset_contest_session() {
|
||||
localStorage.removeItem("contestid");
|
||||
localStorage.removeItem("exchangetype");
|
||||
localStorage.removeItem("exchangesent");
|
||||
localStorage.removeItem("qso");
|
||||
}
|
||||
|
||||
// Storing the contestid in contest session
|
||||
|
|
Ładowanie…
Reference in New Issue