More refactoring for subgroups.
authorNik Okuntseff <support@anuko.com>
Thu, 13 Dec 2018 17:37:51 +0000 (17:37 +0000)
committerNik Okuntseff <support@anuko.com>
Thu, 13 Dec 2018 17:37:51 +0000 (17:37 +0000)
WEB-INF/lib/ttTimeHelper.class.php
WEB-INF/templates/footer.tpl
time.php
week.php

index 70844ee..4e10f4e 100644 (file)
@@ -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();
index 5e51061..a7e4b13 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.4646 | 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.4647 | 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 462389a..7e4e8ad 100644 (file)
--- 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);
index bf23785..c1c76f9 100644 (file)
--- 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);