A bit more refactoring for subgroups.
authorNik Okuntseff <support@anuko.com>
Thu, 13 Dec 2018 17:19:52 +0000 (17:19 +0000)
committerNik Okuntseff <support@anuko.com>
Thu, 13 Dec 2018 17:19:52 +0000 (17:19 +0000)
WEB-INF/lib/ttTimeHelper.class.php
WEB-INF/templates/footer.tpl
mobile/timer.php
time.php
week.php

index 5eeed1f..a8bde98 100644 (file)
@@ -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();
index 861431d..2b6eb79 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.30.4644 | 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.30.4645 | 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 682634c..c754740 100644 (file)
@@ -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);
index b85cad0..462389a 100644 (file)
--- 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);
index edba899..bf23785 100644 (file)
--- 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);