From: Nik Okuntseff Date: Thu, 20 Dec 2018 19:13:18 +0000 (+0000) Subject: Started using quota percent for users if defined. X-Git-Tag: timetracker_1.19-1~394 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0f6454bb20d223018d0f969ab5e1d46f4ce14b96;p=timetracker.git Started using quota percent for users if defined. --- diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 4145f603..7d6ee6de 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -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. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 7d3abc65..a0c889c8 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.34.4671 | Copyright © Anuko | +  Anuko Time Tracker 1.18.34.4672 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/plugins/MonthlyQuota.class.php b/plugins/MonthlyQuota.class.php index 29d8cfb7..a1c1b5d0 100644 --- a/plugins/MonthlyQuota.class.php +++ b/plugins/MonthlyQuota.class.php @@ -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". diff --git a/time.php b/time.php index 013f15ca..ac6b69b5 100644 --- 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); diff --git a/week.php b/week.php index 1dd6e56a..f18817d7 100644 --- 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);