From f1670d5b607135ac146139adc2cd45fc04c452c8 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Mon, 2 Feb 2015 11:46:03 +0100 Subject: [PATCH 1/5] altered managetimetracker to respect start AND enddate --- managetimetracker.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/managetimetracker.php b/managetimetracker.php index a9ee34d0..7fdb0026 100644 --- a/managetimetracker.php +++ b/managetimetracker.php @@ -22,7 +22,7 @@ $ended = getArrayVal($_POST, "ended"); $tproject = getArrayVal($_POST, "project"); $task = getArrayVal($_POST, "ttask"); -$startdate = getArrayVal($_POST, "ttday"); +$startdate = getArrayVal($_POST, "ttstartday"); $enddate = getArrayVal($_POST, "ttendday"); $comment = getArrayVal($_POST, "comment"); $redir = getArrayVal($_GET, "redir"); @@ -84,7 +84,7 @@ $lodate = date("d.m.Y"); $started = date("H:i:s", $started); $ended = date("H:i:s", $ended); - $repeat = 0; + $repeat = 0; $comment = ""; } @@ -95,11 +95,13 @@ for ($i = 0; $i <= $repeat; $i++) { // more than one day will be tracked if ($i > 0) { - $tempend = strtotime($startdate); - $tempend += 86400; // magic number: add 1 day to start date - $startdate = date("d.m.Y", $tempend); + $tempstart = strtotime($startdate); + $tempend = strtotime($enddate); + $tempstart += 86400; // magic number: add 1 day to start date + $tempend += 86400; + $startdate = date("d.m.Y", $tempstart); + $enddate = date('d.m.Y', $tempend); } - $enddate = $startdate; $trackerstate = $tracker->add($userid, $tproject, $task, $comment, $started, $ended, $startdate, $enddate); } From fd66dd8768ed3c4b729883fb410ec3738f3df386 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Mon, 2 Feb 2015 11:48:49 +0100 Subject: [PATCH 2/5] adjusted timetracker script so it does not drop minutes when adding hours --- include/js/timetracker_widget.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/include/js/timetracker_widget.js b/include/js/timetracker_widget.js index 4b7b61e5..0013194e 100644 --- a/include/js/timetracker_widget.js +++ b/include/js/timetracker_widget.js @@ -10,13 +10,23 @@ function zeroFill( number, width ) function populateEndtime() { - var startVal = parseInt($('started').value,10); - var hrsVal = parseInt($('workhours').value,10); + var startTime=$('started').value; + var parts=startTime.split(':'); + var startHour=parseInt(parts[0]); + var startMin=parseInt(parts[1]); - var finVal = startVal + hrsVal; + // get the start time seconds + var startVal = 60*startHour+startMin; - finVal = zeroFill(finVal,2); - $('ended').value = finVal + ":00"; + // calculate the 'workminutes' from the work hours + var minDiff = 60*parseInt($('workhours').value,10); + + // calculate the end time + var endVal = startVal + minDiff; + var endMin = zeroFill(endVal % 60,2); + var endHour = zeroFill((endVal-endMin) / 60,2); + + $('ended').value = endHour + ":" + endMin; } function populateHours() { @@ -29,4 +39,4 @@ function populateHours() { $('workhours').value = finVal; } -} \ No newline at end of file +} From 6b1c9203a3465f034028eb8f62cde65ca59c7ea6 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Mon, 2 Feb 2015 11:49:49 +0100 Subject: [PATCH 3/5] refactored timetracker form to allow selection of end day --- templates/standard/addtimetracker.tpl | 187 +++++++++++++------------- 1 file changed, 90 insertions(+), 97 deletions(-) diff --git a/templates/standard/addtimetracker.tpl b/templates/standard/addtimetracker.tpl index 6793d00a..8cb2e741 100644 --- a/templates/standard/addtimetracker.tpl +++ b/templates/standard/addtimetracker.tpl @@ -1,102 +1,95 @@
-
-
- - - -
- - -
- -
- -
- - - -
- - - - - - - - - - - - - -
- - - -
- - -
- -
- -
- - -
- -
- - -
- -
-
+
+
+ + + +
+ + + + + +
+ +
+ + +
+ + + + + + +
+ + + + + + + +
+
+ + + + + + +
+ + +
+ + +
+ +
+ +
+ + +
+ +
+ + +
+ +
+
{*block_in_wrapper end*} From 000d60d188a6d02c265520bee2f4eebeba98775c Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Mon, 2 Feb 2015 11:50:34 +0100 Subject: [PATCH 4/5] adjusted css to improve layot of added field --- .../standard/theme/standard/css/style_main.css | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/templates/standard/theme/standard/css/style_main.css b/templates/standard/theme/standard/css/style_main.css index 3438f73c..2d62fc0e 100644 --- a/templates/standard/theme/standard/css/style_main.css +++ b/templates/standard/theme/standard/css/style_main.css @@ -1022,6 +1022,10 @@ td.message ul { background: url(../images/color-c-cyan.png) repeat 0 0; } +.datepick #datepicker_addendtt{ + left: 440px; +} + /* ## BIG CALENDAR ###################################### */ .block .bigcal table.thecal { @@ -1227,6 +1231,17 @@ td.message ul { background-image: url(../images/back-side-neutral.png); } +.starttimebtn{ + width: 60px; +} + +#workhours{ + width: 60px; + margin-right: 109px; +} + + + /* ## ONLINELISTE ######################################## */ #onlinelist ul { @@ -2905,4 +2920,4 @@ span.info { -/* ## Footer ## end ## */ \ No newline at end of file +/* ## Footer ## end ## */ From f442940bd499a82c40447f307e524f48c7027330 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Mon, 2 Feb 2015 11:51:57 +0100 Subject: [PATCH 5/5] adjusted timetracker script to allow cross-midnight tracking. unfortunately, the javascript Date function seems to be broken, so it returns 29.2.2015 as day after 28.2.2015. But this is an upstream error in Firefox --- include/js/timetracker_widget.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/js/timetracker_widget.js b/include/js/timetracker_widget.js index 0013194e..26d30724 100644 --- a/include/js/timetracker_widget.js +++ b/include/js/timetracker_widget.js @@ -15,6 +15,11 @@ function populateEndtime() var startHour=parseInt(parts[0]); var startMin=parseInt(parts[1]); + // get the start date. used to calculate the end date later + var startDateString=$('ttstartday').value; + var startDateParts=startDateString.split('.'); + var startDate=new Date(startDateParts[2],startDateParts[1],startDateParts[0]); + // get the start time seconds var startVal = 60*startHour+startMin; @@ -26,6 +31,26 @@ function populateEndtime() var endMin = zeroFill(endVal % 60,2); var endHour = zeroFill((endVal-endMin) / 60,2); + // initialize the end date + var endDateStamp=Date.parse(startDate); + + // if our timesheet exceeds the 11:59pm barrier, add a day + if (endHour>23){ + var oneday=24*60*60*1000; + while (endHour > 23){ + endHour-=24; + endDateStamp+=oneday; + } + } + + // create the end date + var endDate=new Date(endDateStamp); + var endDay = zeroFill(endDate.getDate(),2); + var endMonth= zeroFill(endDate.getMonth(),2); + var endYear = endDate.getFullYear(); + + // set end date and end time + $('ttendday').value = endDay + "." + endMonth+"."+endYear; $('ended').value = endHour + ":" + endMin; } function populateHours()