From 2c115ac8743f86f05bca6b01ffe215248e195464 Mon Sep 17 00:00:00 2001 From: Brad Brighton Date: Sun, 3 May 2020 09:13:59 -0700 Subject: [PATCH 1/9] Support for extensible group date formats by configuration file. --- WEB-INF/config.php.dist | 13 +++++++++++++ group_edit.php | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/WEB-INF/config.php.dist b/WEB-INF/config.php.dist index 6ffdff08e..aed7345c8 100644 --- a/WEB-INF/config.php.dist +++ b/WEB-INF/config.php.dist @@ -181,3 +181,16 @@ define('AUTH_MODULE', 'db'); // A comma-separated list of default plugins for new group registrations. // Example below enables charts and attachments. // define('DEFAULT_PLUGINS', 'ch,at'); + +// Panegyris Config Edits - bbrighton@panegyris.com + + +// GROUP_DATE_FORMAT_LIST_SEPARATOR - separator to explode this array on (see group_edit.php) +// +// GROUP_DATE_FORMAT_LIST - allow group date formats to be modified/extended without having to modify code +// This will be exploded into an array at processing time so it's "key","value" (double quotes due to single quote in define) +// "format","human format" + + +define ("GROUP_DATE_FORMAT_LIST_SEPARATOR", '^^'); +define('GROUP_DATE_FORMAT_LIST','"%Y-%m-%d","Y-m-d"^^"%m/%d/%Y","m/d/Y"^^"%d-%m-%Y","d-m-Y"^^"%d.%m.%Y","d.m.Y"^^"%d.%m.%Y %a","d.m.Y a"^^"%m/%d/%y (%a)","m/d/y (day)"'); \ No newline at end of file diff --git a/group_edit.php b/group_edit.php index c4fdc2174..62c15ae83 100644 --- a/group_edit.php +++ b/group_edit.php @@ -154,6 +154,21 @@ array('id'=>'%d-%m-%Y','name'=>'d-m-Y'), array('id'=>'%d.%m.%Y','name'=>'d.m.Y'), array('id'=>'%d.%m.%Y %a','name'=>'d.m.Y a')); + +// Panegyris ++++ +if (defined('GROUP_DATE_FORMAT_LIST_SEPARATOR') && defined('GROUP_DATE_FORMAT_LIST')) { + $DATE_FORMAT_OPTIONS = array(); + $DATE_FORMAT_OPTIONS_ARRAY = explode(GROUP_DATE_FORMAT_LIST_SEPARATOR, GROUP_DATE_FORMAT_LIST); + foreach($DATE_FORMAT_OPTIONS_ARRAY as $formatPair) { + $formatArray = explode(',', $formatPair); + $key = str_replace('"', "", $formatArray[0]); + $value = str_replace('"', "", $formatArray[1]); + array_push($DATE_FORMAT_OPTIONS, array('id'=> $key, 'name'=> $value)); + } +} +// Panegyris ++++ + + $form->addInput(array('type'=>'combobox','name'=>'date_format','style'=>'width: 150px;','data'=>$DATE_FORMAT_OPTIONS,'datakeys'=>array('id','name'),'value'=>$cl_date_format, 'onchange'=>'MakeFormatPreview("date_format_preview", this);')); $TIME_FORMAT_OPTIONS = array( From 6c9a0ff3463fb87672aa36257c760f0e66951ec1 Mon Sep 17 00:00:00 2001 From: Brad Brighton Date: Sun, 3 May 2020 09:49:07 -0700 Subject: [PATCH 2/9] Tweaking the smarty date format - two-digit year seems to break reporting at this point. --- WEB-INF/config.php.dist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WEB-INF/config.php.dist b/WEB-INF/config.php.dist index aed7345c8..fd9cbbb90 100644 --- a/WEB-INF/config.php.dist +++ b/WEB-INF/config.php.dist @@ -189,8 +189,8 @@ define('AUTH_MODULE', 'db'); // // GROUP_DATE_FORMAT_LIST - allow group date formats to be modified/extended without having to modify code // This will be exploded into an array at processing time so it's "key","value" (double quotes due to single quote in define) -// "format","human format" +// "smarty date format","human format" define ("GROUP_DATE_FORMAT_LIST_SEPARATOR", '^^'); -define('GROUP_DATE_FORMAT_LIST','"%Y-%m-%d","Y-m-d"^^"%m/%d/%Y","m/d/Y"^^"%d-%m-%Y","d-m-Y"^^"%d.%m.%Y","d.m.Y"^^"%d.%m.%Y %a","d.m.Y a"^^"%m/%d/%y (%a)","m/d/y (day)"'); \ No newline at end of file +define('GROUP_DATE_FORMAT_LIST','"%Y-%m-%d","Y-m-d"^^"%m/%d/%Y","m/d/Y"^^"%d-%m-%Y","d-m-Y"^^"%d.%m.%Y","d.m.Y"^^"%d.%m.%Y %a","d.m.Y a"^^"%m/%d/%Y (%a)","mm/dd/yyyy (day)"'); From dcf229ffd3eac03c050259796790d70ed5fee4ef Mon Sep 17 00:00:00 2001 From: Brad Brighton Date: Sun, 3 May 2020 10:14:45 -0700 Subject: [PATCH 3/9] Selectively removing visible Anuko branding/messaging to avoid user confusion (no license or copyright statement removal). --- WEB-INF/resources/en.lang.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index 0c1b8e0a9..b4511ddff 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -429,8 +429,8 @@ // Resetting Password form. See example at https://timetracker.anuko.com/password_reset.php. 'form.reset_password.message' => 'Password reset request sent by email.', -'form.reset_password.email_subject' => 'Anuko Time Tracker password reset request', -'form.reset_password.email_body' => "Dear User,\n\nSomeone from IP %s requested your Anuko Time Tracker password reset. Please visit this link if you want to reset your password.\n\n%s\n\nAnuko Time Tracker is a simple, easy to use, open source time tracking system. Visit https://www.anuko.com for more information.\n\n", +'form.reset_password.email_subject' => 'Time Tracker password reset request', +'form.reset_password.email_body' => "Dear User,\n\nSomeone from IP %s requested your Time Tracker password reset. Please visit this link if you want to reset your password.", // Changing Password form. See example at https://timetracker.anuko.com/password_change.php?ref=1. 'form.change_password.tip' => 'Type new password and click on Save.', From c6f7a8fcd529b824d401556439b3e30a85673054 Mon Sep 17 00:00:00 2001 From: Brad Brighton Date: Sun, 3 May 2020 15:15:39 -0700 Subject: [PATCH 4/9] Cleanup of Panegyris edits for group date format configs --- WEB-INF/config.php.dist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WEB-INF/config.php.dist b/WEB-INF/config.php.dist index fd9cbbb90..ec9653088 100644 --- a/WEB-INF/config.php.dist +++ b/WEB-INF/config.php.dist @@ -182,7 +182,7 @@ define('AUTH_MODULE', 'db'); // Example below enables charts and attachments. // define('DEFAULT_PLUGINS', 'ch,at'); -// Panegyris Config Edits - bbrighton@panegyris.com +// Panegyris Config Edits - https://panegyris.com // GROUP_DATE_FORMAT_LIST_SEPARATOR - separator to explode this array on (see group_edit.php) @@ -192,5 +192,5 @@ define('AUTH_MODULE', 'db'); // "smarty date format","human format" -define ("GROUP_DATE_FORMAT_LIST_SEPARATOR", '^^'); +define("GROUP_DATE_FORMAT_LIST_SEPARATOR", '^^'); define('GROUP_DATE_FORMAT_LIST','"%Y-%m-%d","Y-m-d"^^"%m/%d/%Y","m/d/Y"^^"%d-%m-%Y","d-m-Y"^^"%d.%m.%Y","d.m.Y"^^"%d.%m.%Y %a","d.m.Y a"^^"%m/%d/%Y (%a)","mm/dd/yyyy (day)"'); From 3a4fe4414a10fd8d690e67dba982f3b7cc59fba0 Mon Sep 17 00:00:00 2001 From: Brad Brighton Date: Sun, 3 May 2020 15:16:44 -0700 Subject: [PATCH 5/9] Added User/Role/Group to mobile page header. --- WEB-INF/templates/mobile/header.tpl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/WEB-INF/templates/mobile/header.tpl b/WEB-INF/templates/mobile/header.tpl index ec0b05926..65a014282 100644 --- a/WEB-INF/templates/mobile/header.tpl +++ b/WEB-INF/templates/mobile/header.tpl @@ -97,6 +97,15 @@ {/if} {/if} + + +{if $title} + + + {* No need to escape as it is done in the class. *} +
{$title}{if $timestring}: {$timestring}{/if}
{$user->getUserPartForHeader()}
+{/if} + {if $err->yes()} From 180fed70675c4658b5a3f1fc02fb8c698d1d2b08 Mon Sep 17 00:00:00 2001 From: Brad Brighton Date: Mon, 4 May 2020 09:33:22 -0700 Subject: [PATCH 6/9] Hack our way into a version of live duration computation during time entry when using start/end times --- WEB-INF/templates/time_script.tpl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/WEB-INF/templates/time_script.tpl b/WEB-INF/templates/time_script.tpl index 3e8a02024..0cce3ee58 100644 --- a/WEB-INF/templates/time_script.tpl +++ b/WEB-INF/templates/time_script.tpl @@ -177,6 +177,32 @@ function formDisable(formField) { x.value = ""; x.disabled = true; x.style.background = "#e9e9e9"; + + + // Panegyris ++++ Dynamic computation of duration -- hackery! + var startDateValue = eval("document.timeRecordForm.start.value"); + var endDateValue = eval("document.timeRecordForm.finish.value"); + + // Only compute a duration after both entries made + if ((startDateValue != "") && (endDateValue != "")) { + startDateValue = startDateValue + ":00"; + endDateValue = endDateValue + ":00"; + + var startDate = Date.parse("01/01/01 "+startDateValue); + var endDate = Date.parse("01/01/01 "+endDateValue); + + var timeDifferenceInMS = endDate - startDate; + var timeDifferenceInS = Math.floor(timeDifferenceInMS/1000); + + var hours = Math.floor(timeDifferenceInS / 3600); + var minutes = Math.floor((timeDifferenceInS - (hours*3600)) / 60); + var leadingZero = (minutes < 10 ? "0" : ""); + + x.value = hours+":"+leadingZero+minutes; + } + + // Panegyris ++++ + } if (((formFieldValue == "") && (formFieldName == "start") && (document.timeRecordForm.finish.value == "")) || ((formFieldValue == "") && (formFieldName == "finish") && (document.timeRecordForm.start.value == ""))) { From b868474b6c798c081d4086b6cb061f2f14390886 Mon Sep 17 00:00:00 2001 From: Brad Brighton Date: Mon, 4 May 2020 09:44:10 -0700 Subject: [PATCH 7/9] Add logout functionality to mobile menubar --- WEB-INF/templates/mobile/header.tpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WEB-INF/templates/mobile/header.tpl b/WEB-INF/templates/mobile/header.tpl index 65a014282..31d8d8077 100644 --- a/WEB-INF/templates/mobile/header.tpl +++ b/WEB-INF/templates/mobile/header.tpl @@ -73,6 +73,9 @@ From 0dd290a3381bbed2bf76644aed72e172fa6c7a5b Mon Sep 17 00:00:00 2001 From: Brad Brighton Date: Mon, 4 May 2020 16:22:39 -0700 Subject: [PATCH 9/9] Tweak the dynamic calculation of duration to support 12hr time entries. --- WEB-INF/templates/time_script.tpl | 33 ++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/WEB-INF/templates/time_script.tpl b/WEB-INF/templates/time_script.tpl index 0cce3ee58..32247a581 100644 --- a/WEB-INF/templates/time_script.tpl +++ b/WEB-INF/templates/time_script.tpl @@ -69,6 +69,13 @@ function fillDropdowns() { fillProjectDropdown(document.timeRecordForm.client.value); fillTaskDropdown(document.timeRecordForm.project.value); + + // Panegyris ++++ + // This doesn't really belong here but the onload() doesn't point to a general onload() handler. + // -- minimize the number of changes right now. + formDisable('start'); + formDisable('finish'); + // Panegyris ---- } // The fillProjectDropdown function populates the project combo box with @@ -166,6 +173,21 @@ function fillTaskDropdown(id) { } } +// Panegyris ++++ +// Adapt entry times to 24hr as needed +function adaptTime(inTime) { + var newDate = new Date(Date.parse("01/01/01 "+inTime)); + var hours = newDate.getHours(); + var minutes = newDate.getMinutes(); + var leadingZero = (minutes < 10 ? "0" : ""); + var newTime = hours+":"+leadingZero+minutes+":00"; + + return newTime; +} +// Panegyris ---- + + + // The formDisable function disables some fields depending on what we have in other fields. function formDisable(formField) { var formFieldValue = eval("document.timeRecordForm." + formField + ".value"); @@ -185,11 +207,12 @@ function formDisable(formField) { // Only compute a duration after both entries made if ((startDateValue != "") && (endDateValue != "")) { - startDateValue = startDateValue + ":00"; - endDateValue = endDateValue + ":00"; - - var startDate = Date.parse("01/01/01 "+startDateValue); - var endDate = Date.parse("01/01/01 "+endDateValue); + + var normalizedStart = adaptTime(startDateValue); + var normalizedEnd = adaptTime(endDateValue); + + var startDate = Date.parse("01/01/01 "+normalizedStart); + var endDate = Date.parse("01/01/01 "+normalizedEnd); var timeDifferenceInMS = endDate - startDate; var timeDifferenceInS = Math.floor(timeDifferenceInMS/1000);