From e83e7340f53e3f9955acce390910024e05a0afe7 Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 8 Nov 2020 10:46:08 +0100 Subject: [PATCH 1/4] [Contest logging] Started work on the logging form. --- application/controllers/Contesting.php | 44 ++++- application/models/Contesting_model.php | 9 + application/views/contesting/index.php | 163 ++++++++++++++++++ application/views/interface_assets/header.php | 2 + 4 files changed, 215 insertions(+), 3 deletions(-) create mode 100644 application/models/Contesting_model.php create mode 100644 application/views/contesting/index.php diff --git a/application/controllers/Contesting.php b/application/controllers/Contesting.php index 62227406..f6dbeca1 100644 --- a/application/controllers/Contesting.php +++ b/application/controllers/Contesting.php @@ -9,8 +9,46 @@ if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Contesting extends CI_Controller { - public function index() + public function index() { - echo 'Functions to come'; - } + + $this->load->model('cat'); + $this->load->model('stations'); + $this->load->model('logbook_model'); + $this->load->model('user_model'); + $this->load->model('modes'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + + $data['active_station_profile'] = $this->stations->find_active(); + $data['notice'] = false; + $data['stations'] = $this->stations->all(); + $data['radios'] = $this->cat->radios(); + $data['dxcc'] = $this->logbook_model->fetchDxcc(); + $data['modes'] = $this->modes->active(); + + + $this->load->library('form_validation'); + + $this->form_validation->set_rules('start_date', 'Date', 'required'); + $this->form_validation->set_rules('start_time', 'Time', 'required'); + $this->form_validation->set_rules('callsign', 'Callsign', 'required'); + + $data['page_title'] = "Contest logging"; + + $this->load->view('interface_assets/header', $data); + $this->load->view('contesting/index'); + $this->load->view('interface_assets/footer'); + + + //setcookie("radio", $qso_data['radio'], time()+3600*24*99); + //setcookie("station_profile_id", $qso_data['station_profile_id'], time()+3600*24*99); + + //$this->session->set_userdata($qso_data); + + // If SAT name is set make it session set to sat + if($this->input->post('sat_name')) { + $this->session->set_userdata('prop_mode', 'SAT'); + } + + } } \ No newline at end of file diff --git a/application/models/Contesting_model.php b/application/models/Contesting_model.php new file mode 100644 index 00000000..22ced12a --- /dev/null +++ b/application/models/Contesting_model.php @@ -0,0 +1,9 @@ + +

+
+ +
+
+ +
+ + +
+
+ + +
+ +
+ + +
+ +
+ +
+ +
+ + + +
+ +
+ + +
+ +
+ + + +
+ +
+ + +
+ +
+ + +
+
+ + +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ + + +
+ +
+ +
+
+ + +
+ +
+ +
+
+

Callsign Suggestions

+ +
+
+ +
+

Logbook (for this session)

+ +
+ +
+ +
+ + + + + + + + + + + + +
Date/TimeCallModeRST sRST rExch SExch RBand
+
+
+
+ + + + + + diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index ec4156b1..b09b7920 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -68,6 +68,8 @@ Post QSO + Contest logging + View QSL From e557d92c4705b9f796272925811b1f0d5fc0d3d8 Mon Sep 17 00:00:00 2001 From: Andreas Date: Mon, 16 Nov 2020 19:20:45 +0100 Subject: [PATCH 2/4] Tweaking of logging form. Added some logic in javascript, and started on a function for saving the qso in the controller. --- application/controllers/Qso.php | 42 ++++++ application/views/contesting/index.php | 127 ++++++++++------- application/views/interface_assets/footer.php | 134 ++++++++++++++++++ 3 files changed, 250 insertions(+), 53 deletions(-) diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 03702344..c8a38a8e 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -98,6 +98,48 @@ class QSO extends CI_Controller { $this->load->view('interface_assets/footer'); } } + + /* + * This is used for contest-logging and the ajax-call + */ + public function saveqso() { + $this->load->model('logbook_model'); + // Add QSO + // $this->logbook_model->add(); + //change to create_qso function as add and create_qso duplicate functionality + $this->logbook_model->create_qso(); + + // Store Basic QSO Info for reuse + // Put data in an array first, then call set_userdata once. + // This solves the problem of CI dumping out the session + // cookie each time set_userdata is called. + // For more info, see http://bizhole.com/codeigniter-nginx-error-502-bad-gateway/ + $qso_data = array( + 'start_date' => $this->input->post('start_date'), + 'start_time' => $this->input->post('start_time'), + 'time_stamp' => time(), + 'band' => $this->input->post('band'), + 'freq' => $this->input->post('freq_display'), + 'freq_rx' => $this->input->post('freq_display_rx'), + 'mode' => $this->input->post('mode'), + 'sat_name' => $this->input->post('sat_name'), + 'sat_mode' => $this->input->post('sat_mode'), + 'prop_mode' => $this->input->post('prop_mode'), + 'radio' => $this->input->post('radio'), + 'station_profile_id' => $this->input->post('station_profile'), + 'transmit_power' => $this->input->post('transmit_power') + ); + + setcookie("radio", $qso_data['radio'], time()+3600*24*99); + setcookie("station_profile_id", $qso_data['station_profile_id'], time()+3600*24*99); + + $this->session->set_userdata($qso_data); + + // If SAT name is set make it session set to sat + if($this->input->post('sat_name')) { + $this->session->set_userdata('prop_mode', 'SAT'); + } + } function edit() { diff --git a/application/views/contesting/index.php b/application/views/contesting/index.php index a311584f..3c40c78b 100644 --- a/application/views/contesting/index.php +++ b/application/views/contesting/index.php @@ -4,31 +4,40 @@
+
Logging form
+
+
- +
+ + +
+
+ + +
+
+ + +
+
+
-
-
+
-
+
-
- -
- -
- - - -
-
-
+
+ +
+ +
+ + + +
+ +
-
+
+ + +
+ +
-
- +
+ + +
+ +
- -
-
- -
+
+
-
-
- -
+
+
-
- - - +
+ +
-
-
-
- - -
- + +
+
-
+
-

Callsign Suggestions

+
Callsign Suggestions
-
-

Logbook (for this session)

- -
+
+
Logbook (for this logging session)
- +
+ - - - - - - - - + + + + + + + + + + +
Date/TimeCallModeRST sRST rExch SExch RBandDate/TimeCallBandModeRST (S)RST (R)Exch SExch R
@@ -158,6 +178,7 @@
+
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 299d936c..739b5080 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2436,5 +2436,139 @@ function deleteQsl(id) { }); } +uri->segment(1) == "contesting") { ?> + + From 2229a1579b5c25ba0c68b0bbf43a7b828d5f948e Mon Sep 17 00:00:00 2001 From: Andreas Date: Tue, 17 Nov 2020 09:47:57 +0100 Subject: [PATCH 3/4] Logging is working. Contest exchange is being logged. Basic contest logging is now working. --- application/controllers/Qso.php | 34 ------------ application/models/Logbook_model.php | 28 ++++++++-- application/views/contesting/index.php | 6 --- application/views/interface_assets/footer.php | 52 +++++++++++++------ 4 files changed, 60 insertions(+), 60 deletions(-) diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index c8a38a8e..7d24e842 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -104,41 +104,7 @@ class QSO extends CI_Controller { */ public function saveqso() { $this->load->model('logbook_model'); - // Add QSO - // $this->logbook_model->add(); - //change to create_qso function as add and create_qso duplicate functionality $this->logbook_model->create_qso(); - - // Store Basic QSO Info for reuse - // Put data in an array first, then call set_userdata once. - // This solves the problem of CI dumping out the session - // cookie each time set_userdata is called. - // For more info, see http://bizhole.com/codeigniter-nginx-error-502-bad-gateway/ - $qso_data = array( - 'start_date' => $this->input->post('start_date'), - 'start_time' => $this->input->post('start_time'), - 'time_stamp' => time(), - 'band' => $this->input->post('band'), - 'freq' => $this->input->post('freq_display'), - 'freq_rx' => $this->input->post('freq_display_rx'), - 'mode' => $this->input->post('mode'), - 'sat_name' => $this->input->post('sat_name'), - 'sat_mode' => $this->input->post('sat_mode'), - 'prop_mode' => $this->input->post('prop_mode'), - 'radio' => $this->input->post('radio'), - 'station_profile_id' => $this->input->post('station_profile'), - 'transmit_power' => $this->input->post('transmit_power') - ); - - setcookie("radio", $qso_data['radio'], time()+3600*24*99); - setcookie("station_profile_id", $qso_data['station_profile_id'], time()+3600*24*99); - - $this->session->set_userdata($qso_data); - - // If SAT name is set make it session set to sat - if($this->input->post('sat_name')) { - $this->session->set_userdata('prop_mode', 'SAT'); - } } function edit() { diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index b5bd539b..4ce04b5a 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -20,7 +20,27 @@ class Logbook_model extends CI_Model { if($this->input->post('sat_name')) { $prop_mode = "SAT"; - } + } + + // Contest exchange, need to separate between serial and other type of exchange + if($this->input->post('exchangeradio')) { + if($this->input->post('exchangeradio') == "serial") { + $srx = $this->input->post('exch_recv'); + $stx = $this->input->post('exch_sent'); + $srx_string = null; + $stx_string = null; + } else { + $srx = null; + $stx = null; + $srx_string = $this->input->post('exch_recv'); + $stx_string = $this->input->post('exch_sent'); + } + } else { + $srx_string = null; + $stx_string = null; + $srx = null; + $stx = null; + } if($this->session->userdata('user_locator')){ $locator = $this->session->userdata('user_locator'); @@ -108,8 +128,10 @@ class Logbook_model extends CI_Model { 'COL_AGE' => null, 'COL_TEN_TEN' => null, 'COL_TX_PWR' => $tx_power, - 'COL_STX' => null, - 'COL_SRX' => null, + 'COL_STX' => $stx, + 'COL_SRX' => $srx, + 'COL_STX_STRING' => $stx_string, + 'COL_SRX_STRING' => $srx_string, 'COL_NR_BURSTS' => null, 'COL_NR_PINGS' => null, 'COL_MAX_BURSTS' => null, diff --git a/application/views/contesting/index.php b/application/views/contesting/index.php index 3c40c78b..0cbb5622 100644 --- a/application/views/contesting/index.php +++ b/application/views/contesting/index.php @@ -97,7 +97,6 @@
-
@@ -152,9 +151,6 @@
Logbook (for this logging session)
-
- -
@@ -172,8 +168,6 @@
-
-
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 739b5080..9f4e0ece 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2439,6 +2439,29 @@ function deleteQsl(id) { uri->segment(1) == "contesting") { ?> + + +uri->segment(1) == "qso" && $_GET['manual'] == 0) || $this->uri->segment(1) == "contesting") { ?> + + +uri->segment(1) == "qso" && $_GET['manual'] == 0) || $this->uri->segment(1) == "contesting") { ?> + @@ -2437,156 +2442,48 @@ function deleteQsl(id) { } uri->segment(1) == "contesting") { ?> + + diff --git a/assets/js/sections/contesting.js b/assets/js/sections/contesting.js new file mode 100644 index 00000000..05c23680 --- /dev/null +++ b/assets/js/sections/contesting.js @@ -0,0 +1,131 @@ +// Callsign always has focus on load +$("#callsign").focus(); + +// Init serial sent as 1 when loading page +$("#exch_sent").val(1); + +// realtime clock +$(function($) { + var options = { + utc: true, + format: '%H:%M:%S' + } + $('.input_time').jclock(options); +}); + +$(function($) { + var options = { + utc: true, + format: '%d-%m-%Y' + } + $('.input_date').jclock(options); +}); + +// We don't want spaces to be written in callsign +$(function() { + $('#callsign').on('keypress', function(e) { + if (e.which == 32){ + return false; + } + }); +}); + +// We don't want spaces to be written in exchange +$(function() { + $('#exch_recv').on('keypress', function(e) { + if (e.which == 32){ + return false; + } + }); +}); + +// Here we capture keystrokes fo execute functions +document.onkeyup = function(e) { + // ALT-W wipe + if (e.altKey && e.which == 87) { + reset_log_fields(); + } else if ((e.keyCode == 10 || e.keyCode == 13) && (e.ctrlKey || e.metaKey)) { + logQso(); + } else if (e.which == 27) { + reset_log_fields(); + // Space to jump to either callsign or sent exchange + } else if (e.which == 32) { + if ($(document.activeElement).attr("id") == "callsign") { + $("#exch_recv").focus(); + return false; + } else if ($(document.activeElement).attr("id") == "exch_recv") { + $("#callsign").focus(); + return false; + } + } + +}; + +// On Key up check and suggest callsigns +$("#callsign").keyup(function() { + var call = $(this).val(); + if (call.length >= 3) { + $.get('lookup/scp/' + call.toUpperCase(), function(result) { + $('.callsign-suggestions').text(result); + highlight(call.toUpperCase()); + }); + } + else if (call.length <= 2) { + $('.callsign-suggestions').text(""); + } +}); + +function reset_log_fields() { + $('#name').val(""); + $('.callsign-suggestions').text(""); + $('#callsign').val(""); + $('#comment').val(""); + $('#exch_recv').val(""); + $("#callsign").focus(); +} + +RegExp.escape = function(text) { + return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); +} + +function highlight(term, base) { + if (!term) return; + base = base || document.body; + var re = new RegExp("(" + RegExp.escape(term) + ")", "gi"); + var replacement = "" + term + ""; + $(".callsign-suggestions", base).contents().each( function(i, el) { + if (el.nodeType === 3) { + var data = el.data; + if (data = data.replace(re, replacement)) { + var wrapper = $("").html(data); + $(el).before(wrapper.contents()).remove(); + } + } + }); +} + +// Only set the frequency when not set by userdata/PHP. +if ($('#frequency').val() == "") +{ + $.get('qso/band_to_freq/' + $('#band').val() + '/' + $('.mode').val(), function(result) { + $('#frequency').val(result); + $('#frequency_rx').val(""); + }); +} + +/* on mode change */ +$('.mode').change(function() { + $.get('qso/band_to_freq/' + $('#band').val() + '/' + $('.mode').val(), function(result) { + $('#frequency').val(result); + $('#frequency_rx').val(""); + }); +}); + +/* Calculate Frequency */ +/* on band change */ +$('#band').change(function() { + $.get('qso/band_to_freq/' + $(this).val() + '/' + $('.mode').val(), function(result) { + $('#frequency').val(result); + $('#frequency_rx').val(""); + }); +}); \ No newline at end of file