diff --git a/application/controllers/Contesting.php b/application/controllers/Contesting.php
index d49fc8a9a..02b265909 100644
--- a/application/controllers/Contesting.php
+++ b/application/controllers/Contesting.php
@@ -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);
+ }
}
\ No newline at end of file
diff --git a/application/models/Contesting_model.php b/application/models/Contesting_model.php
index 22ced12ad..5a0b022ab 100644
--- a/application/models/Contesting_model.php
+++ b/application/models/Contesting_model.php
@@ -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());
+ }
}
\ No newline at end of file
diff --git a/application/views/contesting/index.php b/application/views/contesting/index.php
index ad1057b97..902c19943 100644
--- a/application/views/contesting/index.php
+++ b/application/views/contesting/index.php
@@ -378,7 +378,8 @@
-
+
+
@@ -398,7 +399,7 @@
-
+
| Date/Time |
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php
index f44fbf6fe..9d3056c32 100644
--- a/application/views/interface_assets/footer.php
+++ b/application/views/interface_assets/footer.php
@@ -2545,16 +2545,19 @@ function deleteQsl(id) {
if ($("#callsign").val().length > 0) {
$('.callsign-suggestions').text("");
- $(".qsotable tbody").prepend('
' +
- '| '+$("#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()+' | ' +
- '
');
+
+ 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= "";
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= "";
+ //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('' +
+ '| '+ this.col_time_on + ' | ' +
+ ''+ this.col_call + ' | ' +
+ ''+ this.col_band + ' | ' +
+ ''+ mode + ' | ' +
+ ''+ this.col_rst_sent + ' | ' +
+ ''+ this.col_rst_rcvd + ' | ' +
+ ''+ sentexchange + ' | ' +
+ ''+ receivedexchange + ' | ' +
+ '
');
+ });
+
+ $('.qsotable').DataTable({
+ "pageLength": 25,
+ responsive: false,
+ "scrollY": "400px",
+ "scrollCollapse": true,
+ "paging": false,
+ "scrollX": true,
+ "order": [[ 0, "desc" ]]
+ });
+ }
+ });
+ }
+ }
diff --git a/assets/js/sections/contesting.js b/assets/js/sections/contesting.js
index 42975b832..bb7965927 100644
--- a/assets/js/sections/contesting.js
+++ b/assets/js/sections/contesting.js
@@ -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