From 77314edd31be56469d1355b95287e580e8414d8b Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 27 Oct 2023 10:08:49 +0200 Subject: [PATCH] Basics for QSO end time logging --- .../language/english/general_words_lang.php | 2 + application/models/Logbook_model.php | 3 +- application/views/interface_assets/footer.php | 41 +++- application/views/qso/index.php | 14 +- application/views/view_log/qso.php | 4 +- assets/js/jquery.jclock.js | 222 ------------------ assets/js/sections/qso.js | 10 + 7 files changed, 56 insertions(+), 240 deletions(-) delete mode 100644 assets/js/jquery.jclock.js diff --git a/application/language/english/general_words_lang.php b/application/language/english/general_words_lang.php index 19f6155d..fb707e5d 100644 --- a/application/language/english/general_words_lang.php +++ b/application/language/english/general_words_lang.php @@ -21,6 +21,8 @@ $lang['general_word_import'] = "Import"; $lang['general_word_date'] = 'Date'; $lang['general_word_time'] = 'Time'; +$lang['general_word_time_on'] = 'Time on'; +$lang['general_word_time_off'] = 'Time off'; $lang['general_word_datetime'] = 'Date/Time'; $lang['general_word_none'] = 'None'; $lang['general_word_name'] = 'Name'; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 90bdad19..c62ddf56 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -8,6 +8,7 @@ class Logbook_model extends CI_Model { $callsign = str_replace('Ø', '0', $this->input->post('callsign')); // Join date+time $datetime = date("Y-m-d",strtotime($this->input->post('start_date')))." ". $this->input->post('start_time'); + $datetime_off = date("Y-m-d",strtotime($this->input->post('start_date')))." ". $this->input->post('end_time'); if ($this->input->post('prop_mode') != null) { $prop_mode = $this->input->post('prop_mode'); } else { @@ -174,7 +175,7 @@ class Logbook_model extends CI_Model { // Create array with QSO Data $data = array( 'COL_TIME_ON' => $datetime, - 'COL_TIME_OFF' => $datetime, + 'COL_TIME_OFF' => $datetime_off, 'COL_CALL' => strtoupper(trim($callsign)), 'COL_BAND' => $this->input->post('band'), 'COL_BAND_RX' => $this->input->post('band_rx'), diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 51aff59d..ebba5f18 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -28,7 +28,6 @@ - @@ -1106,24 +1105,22 @@ $(document).on('keypress',function(e) { if ( ! manual ) { $(function($) { - var options = { - utc: true, - format: '%H:%M:%S' - } - $('.input_time').jclock(options); + handleStart = setInterval(function() { getUTCTimeStamp($('.input_start_time')); }, 500); + handleEnd = setInterval(function() { getUTCTimeStamp($('.input_end_time')); }, 500); }); $(function($) { - var options = { - utc: true, - format: '%d-%m-%Y' - } - $('.input_date').jclock(options); + handleDate = setInterval(function() { getUTCDateStamp($('.input_date')); }, 1000); }); } }); - + $('#callsign').focusout(function() { + if (! manual && $('#callsign').val() != '') { + clearInterval(handleStart); + clearInterval(handleDate); + } + }); jQuery(function($) { var input = $('#callsign'); @@ -1142,6 +1139,11 @@ $(document).on('keypress',function(e) { } if (e.key === "Escape") { // escape key maps to keycode `27` reset_fields(); + if ( ! manual ) { + handleStart = setInterval(function() { getUTCTimeStamp($('.input_start_time')); }, 500); + handleEnd = setInterval(function() { getUTCTimeStamp($('.input_end_time')); }, 500); + handleDate = setInterval(function() { getUTCDateStamp($('.input_date')); }, 1000); + } $('#callsign').val(""); $("#callsign").focus(); } @@ -1316,6 +1318,21 @@ $(document).on('keypress',function(e) { $('#rst_rcvd').val('59'); } } + + function getUTCTimeStamp(el) { + var now = new Date(); + var localTime = now.getTime(); + var utc = localTime + (now.getTimezoneOffset() * 60000); + $(el).attr('value', ("0" + now.getUTCHours()).slice(-2)+':'+("0" + now.getUTCMinutes()).slice(-2)+':'+("0" + now.getUTCSeconds()).slice(-2)); + } + + function getUTCDateStamp(el) { + var now = new Date(); + var localTime = now.getTime(); + var utc = localTime + (now.getTimezoneOffset() * 60000); + $(el).attr('value', ("0" + now.getUTCDate()).slice(-2)+'-'+("0" + (now.getUTCMonth()+1)).slice(-2)+'-'+now.getUTCFullYear()); + } +