From: Nik Okuntseff Date: Thu, 13 Dec 2018 17:19:52 +0000 (+0000) Subject: A bit more refactoring for subgroups. X-Git-Tag: timetracker_1.19-1~419 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=1ca0df080b44b700872bec9216d8405b1f90bc11;p=timetracker.git A bit more refactoring for subgroups. --- diff --git a/WEB-INF/lib/ttTimeHelper.class.php b/WEB-INF/lib/ttTimeHelper.class.php index 5eeed1f0..a8bde987 100644 --- a/WEB-INF/lib/ttTimeHelper.class.php +++ b/WEB-INF/lib/ttTimeHelper.class.php @@ -549,12 +549,19 @@ class ttTimeHelper { } // getTimeForWeek - gets total time for a user for a given week. - static function getTimeForWeek($user_id, $date) { + static function getTimeForWeek($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_WEEK, $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 861431d9..2b6eb791 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.30.4644 | Copyright © Anuko | +  Anuko Time Tracker 1.18.30.4645 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/mobile/timer.php b/mobile/timer.php index 682634c8..c754740a 100644 --- a/mobile/timer.php +++ b/mobile/timer.php @@ -283,7 +283,7 @@ if ($request->isPost()) { } } // isPost -$week_total = ttTimeHelper::getTimeForWeek($user->getUser(), $cl_date); +$week_total = ttTimeHelper::getTimeForWeek($cl_date); $smarty->assign('week_total', $week_total); $smarty->assign('uncompleted', $uncompleted); diff --git a/time.php b/time.php index b85cad0e..462389af 100644 --- a/time.php +++ b/time.php @@ -394,7 +394,7 @@ if ($request->isPost()) { } } // isPost -$week_total = ttTimeHelper::getTimeForWeek($user_id, $selected_date); +$week_total = ttTimeHelper::getTimeForWeek($selected_date); $smarty->assign('selected_date', $selected_date); $smarty->assign('week_total', $week_total); diff --git a/week.php b/week.php index edba8996..bf237853 100644 --- a/week.php +++ b/week.php @@ -494,7 +494,7 @@ if ($request->isPost()) { } } // isPost -$week_total = ttTimeHelper::getTimeForWeek($user->getUser(), $selected_date); +$week_total = ttTimeHelper::getTimeForWeek($selected_date); $smarty->assign('selected_date', $selected_date); $smarty->assign('week_total', $week_total);