Started using quota percent for users if defined.
authorNik Okuntseff <support@anuko.com>
Thu, 20 Dec 2018 19:13:18 +0000 (19:13 +0000)
committerNik Okuntseff <support@anuko.com>
Thu, 20 Dec 2018 19:13:18 +0000 (19:13 +0000)
WEB-INF/lib/ttUser.class.php
WEB-INF/templates/footer.tpl
plugins/MonthlyQuota.class.php
time.php
week.php

index 4145f60..7d6ee6d 100644 (file)
@@ -162,9 +162,14 @@ class ttUser {
     }
   }
 
-  // The getUser returns user id on behalf of whom the current user is operating.
+  // getUser returns user id on behalf of whom the current user is operating.
   function getUser() {
-    return ($this->behalf_id ? $this->behalf_id : $this->id);
+    return ($this->behalfUser ? $this->behalfUser->id : $this->id);
+  }
+
+  // getQuotaPercent returns quota percent for active user.
+  function getQuotaPercent() {
+    return ($this->behalfUser ? $this->behalfUser->quota_percent : $this->quota_percent);
   }
 
   // The getGroup returns group id on behalf of which the current user is operating.
index 7d3abc6..a0c889c 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.18.34.4671 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.18.34.4672 | 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 29d8cfb..a1c1b5d 100644 (file)
@@ -84,6 +84,16 @@ class MonthlyQuota {
     return $numWorkdays * $user->getWorkdayMinutes();
   }
 
+  // getUserQuota - obtains a quota for user for a single month.
+  // This quota is adjusted by quota_percent value for user.
+  public function getUserQuota($year, $month) {
+    global $user;
+
+    $minutes = $this->getSingle($year, $month);
+    $userMinutes = (int) $minutes * $user->getQuotaPercent() / 100;
+    return $userMinutes;
+  }
+
   // getMany - returns an array of quotas for a given year for group.
   private function getMany($year){
     $sql = "select month, minutes from tt_monthly_quotas".
index 013f15c..ac6b69b 100644 (file)
--- a/time.php
+++ b/time.php
@@ -85,7 +85,7 @@ if ($user->isPluginEnabled('cf')) {
 if ($user->isPluginEnabled('mq')){
   require_once('plugins/MonthlyQuota.class.php');
   $quota = new MonthlyQuota();
-  $month_quota_minutes = $quota->get($selected_date->mYear, $selected_date->mMonth);
+  $month_quota_minutes = $quota->getUserQuota($selected_date->mYear, $selected_date->mMonth);
   $month_total = ttTimeHelper::getTimeForMonth($selected_date);
   $minutes_left = $month_quota_minutes - ttTimeHelper::toMinutes($month_total);
   
index 1dd6e56..f18817d 100644 (file)
--- a/week.php
+++ b/week.php
@@ -91,7 +91,7 @@ if ($user->isPluginEnabled('cf')) {
 if ($user->isPluginEnabled('mq')){
   require_once('plugins/MonthlyQuota.class.php');
   $quota = new MonthlyQuota();
-  $month_quota_minutes = $quota->get($selected_date->mYear, $selected_date->mMonth);
+  $month_quota_minutes = $quota->getUserQuota($selected_date->mYear, $selected_date->mMonth);
   $month_total = ttTimeHelper::getTimeForMonth($selected_date);
   $minutes_left = $month_quota_minutes - ttTimeHelper::toMinutes($month_total);