Fixed monthly quotas for negative hours.
authorNik Okuntseff <support@anuko.com>
Sun, 21 Apr 2019 16:09:34 +0000 (16:09 +0000)
committerNik Okuntseff <support@anuko.com>
Sun, 21 Apr 2019 16:09:34 +0000 (16:09 +0000)
WEB-INF/lib/ttTimeHelper.class.php
WEB-INF/templates/footer.tpl
quotas.php

index 8142a26..44d9678 100644 (file)
@@ -188,8 +188,11 @@ class ttTimeHelper {
 
   // toMinutes - converts a time string in format 00:00 to a number of minutes.
   static function toMinutes($value) {
+    $signMultiplier = ttStartsWith($value, '-') ? -1 : 1;
+    if ($signMultiplier == -1) $duration = ltrim($duration, '-');
+
     $time_a = explode(':', $value);
-    return (int)@$time_a[1] + ((int)@$time_a[0]) * 60;
+    return $signMultiplier * ((int)@$time_a[1] + ((int)@$time_a[0]) * 60);
   }
 
   // toAbsDuration - converts a number of minutes to format 0:00
index 9afec79..2524785 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.19.1.4966 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.19.1.4967 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
index 1f37619..b6d63fa 100644 (file)
@@ -74,12 +74,14 @@ $quota = new MonthlyQuota();
 
 if ($request->isPost()){
   // Validate user input.
-  if (false === ttTimeHelper::postedDurationToMinutes($request->getParameter('workdayHours')))
+  $workdayMinutes = ttTimeHelper::postedDurationToMinutes($request->getParameter('workdayHours'));
+  if (false === $workdayMinutes || $workdayMinutes <= 0 )
     $err->add($i18n->get('error.field'), $i18n->get('form.quota.workday_hours'));
 
   for ($i = 0; $i < count($months); $i++){
     $val = $request->getParameter($months[$i]);
-    if (false === ttTimeHelper::postedDurationToMinutes($val, 44640/*24*60*31*/))
+    $monthMinutes = ttTimeHelper::postedDurationToMinutes($val, 44640/*24*60*31*/);
+    if (false === $monthMinutes || $monthMinutes < 0)
       $err->add($i18n->get('error.field'), $months[$i]);
   }
   // Finished validating user input.