A bit more refactoring for subgroups.
authorNik Okuntseff <support@anuko.com>
Tue, 4 Dec 2018 17:33:36 +0000 (17:33 +0000)
committerNik Okuntseff <support@anuko.com>
Tue, 4 Dec 2018 17:33:36 +0000 (17:33 +0000)
WEB-INF/lib/ttExpenseHelper.class.php
WEB-INF/lib/ttGroup.class.php
WEB-INF/lib/ttUser.class.php
WEB-INF/templates/expenses.tpl
WEB-INF/templates/footer.tpl

index 9f5e838..0b202c6 100644 (file)
@@ -110,14 +110,14 @@ class ttExpenseHelper {
     $group_id = $user->getGroup();
     $org_id = $user->org_id;
 
-    $sql = "select sum(cost) as sm from tt_expense_items".
+    $sql = "select sum(cost) as total from tt_expense_items".
       " where user_id = $user_id and group_id = $group_id and org_id = $org_id".
       " and date = ".$mdb2->quote($date)." and status = 1";
     $res = $mdb2->query($sql);
     if (!is_a($res, 'PEAR_Error')) {
       $val = $res->fetchRow();
-      $val['sm'] = str_replace('.', $user->getDecimalMark(), $val['sm']);
-      return $val['sm'];
+      $val['total'] = str_replace('.', $user->getDecimalMark(), $val['total']);
+      return $val['total'];
     }
     return false;
   }
index b7e78f9..b0c50ee 100644 (file)
@@ -94,8 +94,8 @@ class ttGroup {
       $this->allow_ip = $val['allow_ip'];
       $this->password_complexity = $val['password_complexity'];
       $this->group_name = $val['group_name'];
-      $this->currency = $val['currency'];
       */
+      $this->currency = $val['currency'];
       $this->plugins = $val['plugins'];
       /*
       $this->lock_spec = $val['lock_spec'];
index 5e359cd..548d70e 100644 (file)
@@ -179,6 +179,16 @@ class ttUser {
     return ($this->behalfGroup ? $this->behalfGroup->decimal_mark : $this->decimal_mark);
   }
 
+  // getDateFormat returns date format for active group.
+  function getDateFormat() {
+    return ($this->behalfGroup ? $this->behalfGroup->date_format : $this->date_format);
+  }
+
+  // getTimeFormat returns time format for active group.
+  function getTimeFormat() {
+    return ($this->behalfGroup ? $this->behalfGroup->time_format : $this->time_format);
+  }
+
   // getTrackingMode returns tracking mode for active group.
   function getTrackingMode() {
     return ($this->behalfGroup ? $this->behalfGroup->tracking_mode : $this->tracking_mode);
@@ -189,6 +199,11 @@ class ttUser {
     return ($this->behalfGroup ? $this->behalfGroup->record_type : $this->record_type);
   }
 
+  // getCurrency returns currency string for active group.
+  function getCurrency() {
+    return ($this->behalfGroup ? $this->behalfGroup->currency : $this->currency);
+  }
+
   // getPlugins returns plugins string for active group.
   function getPlugins() {
     return ($this->behalfGroup ? $this->behalfGroup->plugins : $this->plugins);
index ed98bb5..8e1ef0a 100644 (file)
@@ -86,7 +86,7 @@ function recalculateCost() {
 
   var comment_control = document.getElementById("item_name");
   var cost_control = document.getElementById("cost");
-  var replaceDecimalMark = ("." != "{$user->decimal_mark}");
+  var replaceDecimalMark = ("." != "{$user->getDecimalMark()}");
 
   // Calculate cost.
   var dropdown = document.getElementById("predefined_expense");
@@ -102,10 +102,10 @@ function recalculateCost() {
     else {
       var expenseCost = defined_expenses[dropdown.selectedIndex - 1][2];
       if (replaceDecimalMark)
-        expenseCost = expenseCost.replace("{$user->decimal_mark}", ".");
+        expenseCost = expenseCost.replace("{$user->getDecimalMark()}", ".");
       var newCost = (quantity_control.value * expenseCost).toFixed(2);
       if (replaceDecimalMark)
-        newCost = newCost.replace(".", "{$user->decimal_mark}");
+        newCost = newCost.replace(".", "{$user->getDecimalMark()}");
       cost_control.value = newCost;
     }
   }
@@ -201,7 +201,7 @@ function recalculateCost() {
     </table>
     <table border="0" cellpadding="3" cellspacing="1" width="100%">
       <tr>
-        <td nowrap align="right">{$i18n.label.day_total}: {$user->currency|escape} {$day_total}</td>
+        <td nowrap align="right">{$i18n.label.day_total}: {$user->getCurrency()|escape} {$day_total}</td>
       </tr>
     </table>
 {/if}
index 747f720..7654f5d 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.29.4583 | 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.29.4584 | 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>