Refactored getRecentInvoices and moved to another class.
authorNik Okuntseff <support@anuko.com>
Wed, 12 Dec 2018 19:35:53 +0000 (19:35 +0000)
committerNik Okuntseff <support@anuko.com>
Wed, 12 Dec 2018 19:35:53 +0000 (19:35 +0000)
WEB-INF/lib/ttGroupHelper.class.php
WEB-INF/lib/ttTeamHelper.class.php
WEB-INF/templates/footer.tpl
report.php

index fb895c4..762fffb 100644 (file)
@@ -598,4 +598,27 @@ class ttGroupHelper {
     }
     return $user_list;
   }
+
+  // The getRecentInvoices returns an array of recent invoices (max 3) for a client.
+  static function getRecentInvoices($client_id) {
+    global $user;
+    $mdb2 = getConnection();
+
+    $group_id = $user->getGroup();
+    $org_id = $user->org_id;
+
+    $sql = "select i.id, i.name from tt_invoices i".
+      " left join tt_clients c on (c.id = i.client_id)".
+      " where i.group_id = $group_id and i.org_id = $org_id and i.status = 1 and c.id = $client_id".
+      " order by i.id desc limit 3";
+    $res = $mdb2->query($sql);
+    $result = array();
+    if (!is_a($res, 'PEAR_Error')) {
+      $dt = new DateAndTime(DB_DATEFORMAT);
+      while ($val = $res->fetchRow()) {
+        $result[] = $val;
+      }
+    }
+    return $result;
+  }
 }
index 7207087..6c058c5 100644 (file)
@@ -255,29 +255,6 @@ class ttTeamHelper {
     return $result;
   }
 
-  // The getRecentInvoices returns an array of recent invoices (max 3) for a client.
-  static function getRecentInvoices($group_id, $client_id)
-  {
-    global $user;
-
-    $result = array();
-    $mdb2 = getConnection();
-
-    $sql = "select i.id, i.name from tt_invoices i
-      left join tt_clients c on (c.id = i.client_id)
-      where i.group_id = $group_id and i.status = 1 and c.id = $client_id
-      order by i.id desc limit 3";
-    $res = $mdb2->query($sql);
-    $result = array();
-    if (!is_a($res, 'PEAR_Error')) {
-      $dt = new DateAndTime(DB_DATEFORMAT);
-      while ($val = $res->fetchRow()) {
-        $result[] = $val;
-      }
-    }
-    return $result;
-  }
-
   // getUserToProjectBinds - obtains all user to project binds for a group.
   static function getUserToProjectBinds($group_id) {
     $mdb2 = getConnection();
index 51675b0..2a14a1f 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.4638 | 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.4639 | 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 1a8ce63..924c780 100644 (file)
@@ -30,7 +30,7 @@ require_once('initialize.php');
 import('form.Form');
 import('form.ActionForm');
 import('ttReportHelper');
-import('ttTeamHelper');
+import('ttGroupHelper');
 
 // Access check.
 if (!(ttAccessAllowed('view_own_reports') || ttAccessAllowed('view_reports') || ttAccessAllowed('view_all_reports'))) {
@@ -94,7 +94,7 @@ if ($user->can('manage_invoices') && $bean->getAttribute('chpaid')) {
 if ($user->can('manage_invoices') &&
   ($client_id && $bean->getAttribute('chinvoice') && ('no_grouping' == $bean->getAttribute('group_by1')) && !$user->isClient())) {
   // Client is selected and we are displaying the invoice column.
-  $recent_invoices = ttTeamHelper::getRecentInvoices($user->group_id, $client_id);
+  $recent_invoices = ttGroupHelper::getRecentInvoices($client_id);
   if ($recent_invoices) {
     $assign_invoice_select_options = array('1'=>$i18n->get('dropdown.all'),'2'=>$i18n->get('dropdown.select'));
     $form->addInput(array('type'=>'combobox',