From: Nik Okuntseff Date: Thu, 13 Dec 2018 17:37:51 +0000 (+0000) Subject: More refactoring for subgroups. X-Git-Tag: timetracker_1.19-1~417 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=54bb71ed8e6b7f79e3b26bc1c8a70a95793950c8;p=timetracker.git More refactoring for subgroups. --- diff --git a/WEB-INF/lib/ttTimeHelper.class.php b/WEB-INF/lib/ttTimeHelper.class.php index 70844eeb..4e10f4ed 100644 --- a/WEB-INF/lib/ttTimeHelper.class.php +++ b/WEB-INF/lib/ttTimeHelper.class.php @@ -571,12 +571,19 @@ class ttTimeHelper { } // getTimeForMonth - gets total time for a user for a given month. - static function getTimeForMonth($user_id, $date){ + static function getTimeForMonth($date) { + global $user; import('Period'); $mdb2 = getConnection(); + $user_id = $user->getUser(); + $group_id = $user->getGroup(); + $org_id = $user->org_id; + $period = new Period(INTERVAL_THIS_MONTH, $date); - $sql = "select sum(time_to_sec(duration)) as sm from tt_log where user_id = $user_id and date >= '".$period->getStartDate(DB_DATEFORMAT)."' and date <= '".$period->getEndDate(DB_DATEFORMAT)."' and status = 1"; + $sql = "select sum(time_to_sec(duration)) as sm from tt_log". + " where user_id = $user_id and group_id = $group_id and org_id = $org_id". + " and date >= '".$period->getStartDate(DB_DATEFORMAT)."' and date <= '".$period->getEndDate(DB_DATEFORMAT)."' and status = 1"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 5e51061b..a7e4b134 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.30.4646 | Copyright © Anuko | +  Anuko Time Tracker 1.18.30.4647 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/time.php b/time.php index 462389af..7e4e8adc 100644 --- a/time.php +++ b/time.php @@ -96,7 +96,7 @@ 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_total = ttTimeHelper::getTimeForMonth($user_id, $selected_date); + $month_total = ttTimeHelper::getTimeForMonth($selected_date); $minutes_left = $month_quota_minutes - ttTimeHelper::toMinutes($month_total); $smarty->assign('month_total', $month_total); diff --git a/week.php b/week.php index bf237853..c1c76f9d 100644 --- a/week.php +++ b/week.php @@ -92,7 +92,7 @@ if ($user->isPluginEnabled('mq')){ require_once('plugins/MonthlyQuota.class.php'); $quota = new MonthlyQuota(); $month_quota = $quota->get($selected_date->mYear, $selected_date->mMonth); - $month_total = ttTimeHelper::getTimeForMonth($user->getUser(), $selected_date); + $month_total = ttTimeHelper::getTimeForMonth($selected_date); $minutes_left = round(60*$month_quota) - ttTimeHelper::toMinutes($month_total); $smarty->assign('month_total', $month_total);