From cad0163767fc6e70458077278b7354864236fbb1 Mon Sep 17 00:00:00 2001
From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com>
Date: Sat, 21 Feb 2026 22:29:08 +0100
Subject: [PATCH] [Advanced Logbook] Added duration as a column
---
application/controllers/Logbookadvanced.php | 1 +
application/views/logbookadvanced/index.php | 8 ++++++++
application/views/logbookadvanced/useroptions.php | 6 ++++++
assets/js/sections/logbookadvanced.js | 7 +++++++
src/QSLManager/QSO.php | 13 +++++++++++++
5 files changed, 35 insertions(+)
diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php
index 62e561667..716362f39 100644
--- a/application/controllers/Logbookadvanced.php
+++ b/application/controllers/Logbookadvanced.php
@@ -622,6 +622,7 @@ class Logbookadvanced extends CI_Controller {
$json_string['frequency']['show'] = $this->def_boolean($this->input->post('frequency'));
$json_string['dcl']['show'] = $this->def_boolean($this->input->post('dcl'));
$json_string['last_modification']['show'] = $this->def_boolean($this->input->post('last_modification'));
+ $json_string['duration']['show'] = $this->def_boolean($this->input->post('duration'));
$obj['column_settings']= json_encode($json_string);
diff --git a/application/views/logbookadvanced/index.php b/application/views/logbookadvanced/index.php
index 6e0521ed7..e9f8b8ada 100644
--- a/application/views/logbookadvanced/index.php
+++ b/application/views/logbookadvanced/index.php
@@ -128,6 +128,7 @@
\"frequency\":{\"show\":\"true\"},
\"dcl\":{\"show\":\"true\"},
\"last_modification\":{\"show\":\"false\"},
+ \"duration\":{\"show\":\"false\"},
}";
}
$current_opts = json_decode($options);
@@ -240,6 +241,10 @@
echo "\nvar o_template = { last_modification: {show: 'false'}};";
echo "\nuser_options={...user_options, ...o_template};";
}
+ if (!isset($current_opts->duration)) {
+ echo "\nvar o_template = { duration: {show: 'false'}};";
+ echo "\nuser_options={...user_options, ...o_template};";
+ }
foreach ($mapoptions as $mo) {
if ($mo != null) {
@@ -892,6 +897,9 @@ $options = json_decode($options);
datetime->show ?? "true") == "true") {
echo '
' . __("Date/Time") . ' | ';
+ } ?>
+ duration->show ?? "false") == "true") {
+ echo '' . __("Duration") . ' | ';
} ?>
last_modification->show ?? "false") == "true") {
echo '' . __("Last modified") . ' | ';
diff --git a/application/views/logbookadvanced/useroptions.php b/application/views/logbookadvanced/useroptions.php
index 43ddf06cc..6c1618856 100644
--- a/application/views/logbookadvanced/useroptions.php
+++ b/application/views/logbookadvanced/useroptions.php
@@ -22,6 +22,12 @@
+
+
+ duration->show ?? "false") == "true") { echo 'checked'; } ?>>
+
+
+
de->show ?? "true") == "true") { echo 'checked'; } ?>>
diff --git a/assets/js/sections/logbookadvanced.js b/assets/js/sections/logbookadvanced.js
index 49f9d65d0..0816b20a2 100644
--- a/assets/js/sections/logbookadvanced.js
+++ b/assets/js/sections/logbookadvanced.js
@@ -63,6 +63,9 @@ function updateRow(qso) {
if ((user_options.datetime.show ?? 'true') == "true"){
cells.eq(c++).text(qso.qsoDateTime);
}
+ if ((user_options.duration.show ?? 'true') == "true"){
+ cells.eq(c++).text(qso.duration);
+ }
if ((user_options.last_modification.show ?? 'true') == "true"){
cells.eq(c++).text(qso.last_modified);
}
@@ -283,6 +286,9 @@ function loadQSOTable(rows) {
data.push(qso.qsoDateTime);
}
}
+ if ((user_options.duration.show ?? 'true') == "true"){
+ data.push(qso.duration);
+ }
if ((user_options.last_modification.show ?? 'true') == "true"){
data.push(qso.last_modified);
}
@@ -1816,6 +1822,7 @@ function saveOptions() {
type: 'post',
data: {
datetime: $('input[name="datetime"]').is(':checked') ? true : false,
+ duration: $('input[name="duration"]').is(':checked') ? true : false,
last_modification: $('input[name="last_modification"]').is(':checked') ? true : false,
de: $('input[name="de"]').is(':checked') ? true : false,
dx: $('input[name="dx"]').is(':checked') ? true : false,
diff --git a/src/QSLManager/QSO.php b/src/QSLManager/QSO.php
index c4b87d9ab..b5cdc8aba 100644
--- a/src/QSLManager/QSO.php
+++ b/src/QSLManager/QSO.php
@@ -11,6 +11,7 @@ class QSO
{
private string $qsoID;
private string $qsoDateTime;
+ private string $duration;
private string $de;
private string $profilename;
private string $dx;
@@ -303,8 +304,19 @@ class QSO
$this->measurement_base = $measurement_base;
+ $this->duration = $this->calculateDuration($data['COL_TIME_ON'], $data['COL_TIME_OFF']);
+
}
+ function calculateDuration($start, $end) {
+ if ($start == null || $end == null) {
+ return '';
+ }
+ $start = new DateTime($start);
+ $end = new DateTime($end);
+ $interval = $end->diff($start);
+ return $interval->format('%H:%I:%S');
+ }
/**
* @return string
*/
@@ -1310,6 +1322,7 @@ class QSO
'qth' => $this->qth,
'frequency' => $this->getFormattedFrequency(),
'last_modified' => $this->last_modified,
+ 'duration' => $this->duration
];
}