Finished refactoring ttInvoiceHelper class for subgroups.
authorNik Okuntseff <support@anuko.com>
Fri, 7 Dec 2018 14:25:55 +0000 (14:25 +0000)
committerNik Okuntseff <support@anuko.com>
Fri, 7 Dec 2018 14:25:55 +0000 (14:25 +0000)
WEB-INF/lib/ttInvoiceHelper.class.php
WEB-INF/templates/footer.tpl

index ff4a9f2..becea87 100644 (file)
@@ -392,6 +392,9 @@ class ttInvoiceHelper {
     global $user;
     global $i18n;
 
+    $currency = $user->getCurrency();
+    $decimalMark = $user->getDecimalMark();
+
     $invoice = ttInvoiceHelper::getInvoice($invoice_id);
     $client = ttClientHelper::getClient($invoice['client_id'], true);
     $invoice_items = ttInvoiceHelper::getInvoiceItems($invoice_id);
@@ -412,13 +415,13 @@ class ttInvoiceHelper {
     }
     $total = $subtotal + $tax;
 
-    $subtotal = htmlspecialchars($user->currency).' '.str_replace('.', $user->decimal_mark, sprintf('%8.2f', round($subtotal, 2)));
-    if ($tax) $tax = htmlspecialchars($user->currency).' '.str_replace('.', $user->decimal_mark, sprintf('%8.2f', round($tax, 2)));
-    $total = htmlspecialchars($user->currency).' '.str_replace('.', $user->decimal_mark, sprintf('%8.2f', round($total, 2)));
+    $subtotal = htmlspecialchars($currency).' '.str_replace('.', $decimalMark, sprintf('%8.2f', round($subtotal, 2)));
+    if ($tax) $tax = htmlspecialchars($currency).' '.str_replace('.', $decimalMark, sprintf('%8.2f', round($tax, 2)));
+    $total = htmlspecialchars($currency).' '.str_replace('.', $decimalMark, sprintf('%8.2f', round($total, 2)));
 
-    if ('.' != $user->decimal_mark) {
+    if ('.' != $decimalMark) {
       foreach ($invoice_items as &$item) {
-        $item['cost'] = str_replace('.', $user->decimal_mark, $item['cost']);
+        $item['cost'] = str_replace('.', $decimalMark, $item['cost']);
       }
       unset($item); // Unset the reference. If we don't, the foreach loop below modifies the array while printing.
                     // See http://stackoverflow.com/questions/8220399/php-foreach-pass-by-reference-last-element-duplicating-bug
index 1168961..db006ef 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.4604 | 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.4605 | 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>