From f787edd7045299de3885c052d243b446f7324ea0 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 23 Apr 2019 19:10:27 +0000 Subject: [PATCH] Another fix in week view for negative hours. --- WEB-INF/lib/ttWeekViewHelper.class.php | 10 ++++++++-- WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/WEB-INF/lib/ttWeekViewHelper.class.php b/WEB-INF/lib/ttWeekViewHelper.class.php index a790268b..1144cea6 100644 --- a/WEB-INF/lib/ttWeekViewHelper.class.php +++ b/WEB-INF/lib/ttWeekViewHelper.class.php @@ -354,7 +354,7 @@ class ttWeekViewHelper { } // Convert minutes to hh:mm for display. foreach($dayHeaders as $dayHeader) { - $dayTotals[$dayHeader] = ttTimeHelper::minutesToDuration($dayTotals[$dayHeader]); // This breaks for negative hours. + $dayTotals[$dayHeader] = ttTimeHelper::minutesToDuration($dayTotals[$dayHeader]); } return $dayTotals; } @@ -579,8 +579,14 @@ class ttWeekViewHelper { } // We do have start time. - // Quick test if new duration is less then already existing. $newMinutes = ttTimeHelper::toMinutes($new_duration); + if ($newMinutes < 0) { + // Negative durations are not supported when start time is defined. + $err->add($i18n->get('error.field'), $i18n->get('label.duration')); + return false; + } + + // Quick test if new duration is less than already existing. $oldMinutes = ttTimeHelper::toMinutes($oldDuration); if ($newMinutes < $oldMinutes) return true; // Safe to modify. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 5e5dd184..3e0c4c8a 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.19.3.4980 | Copyright © Anuko | +  Anuko Time Tracker 1.19.3.4981 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1