From 9e790340d7544dbb03e1ab1ccf0ef53b8f39f2ea Mon Sep 17 00:00:00 2001 From: Andreas Date: Mon, 28 Dec 2020 19:55:51 +0100 Subject: [PATCH] [Contesting] Restoring QSO table. --- application/controllers/Contesting.php | 12 ++ application/models/Contesting_model.php | 26 +++++ application/views/contesting/index.php | 5 +- application/views/interface_assets/footer.php | 104 ++++++++++++++++-- assets/js/sections/contesting.js | 25 +---- 5 files changed, 141 insertions(+), 31 deletions(-) diff --git a/application/controllers/Contesting.php b/application/controllers/Contesting.php index d49fc8a9..02b26590 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 22ced12a..5a0b022a 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 ad1057b9..902c1994 100644 --- a/application/views/contesting/index.php +++ b/application/views/contesting/index.php @@ -378,7 +378,8 @@ - + + @@ -398,7 +399,7 @@
Contest Logbook (Only for this session)
- +
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index f44fbf6f..9d3056c3 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('' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - ''); + + 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('' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + ''); + }); + + $('.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 42975b83..bb796592 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
Date/Time
'+$("#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()+'
'+ this.col_time_on + ''+ this.col_call + ''+ this.col_band + ''+ mode + ''+ this.col_rst_sent + ''+ this.col_rst_rcvd + ''+ sentexchange + ''+ receivedexchange + '