]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttGroupHelper.class.php
Some more refactoring for subgroups.
[timetracker.git] / WEB-INF / lib / ttGroupHelper.class.php
index 8b02c85e18bf39eba3a25442f59f65336ee63ef6..9f9f4a2f9b04840e0ec571b05ab0d3601f229f6b 100644 (file)
@@ -274,4 +274,92 @@ class ttGroupHelper {
     }
     return $roles;
   }
+
+  // The getActiveClients returns an array of active clients for a group.
+  static function getActiveClients($all_fields = false)
+  {
+    global $user;
+    $mdb2 = getConnection();
+
+    $group_id = $user->getGroup();
+    $org_id = $user->org_id;
+    if ($all_fields)
+      $sql = "select * from tt_clients where group_id = $group_id and org_id = $org_id and status = 1 order by upper(name)";
+    else
+      $sql = "select id, name from tt_clients where group_id = $group_id and org_id = $org_id and status = 1 order by upper(name)";
+
+    $res = $mdb2->query($sql);
+    $result = array();
+    if (!is_a($res, 'PEAR_Error')) {
+      while ($val = $res->fetchRow()) {
+        $result[] = $val;
+      }
+    }
+    return $result;
+  }
+
+  // The getInactiveClients returns an array of inactive clients for a group.
+  static function getInactiveClients($all_fields = false)
+  {
+    global $user;
+    $mdb2 = getConnection();
+
+    $group_id = $user->getGroup();
+    $org_id = $user->org_id;
+    if ($all_fields)
+      $sql = "select * from tt_clients where group_id = $group_id and org_id = $org_id and status = 0 order by upper(name)";
+    else
+      $sql = "select id, name from tt_clients where group_id = $group_id and org_id = $org_id and status = 0 order by upper(name)";
+
+    $res = $mdb2->query($sql);
+    $result = array();
+    if (!is_a($res, 'PEAR_Error')) {
+      while ($val = $res->fetchRow()) {
+        $result[] = $val;
+      }
+    }
+    return $result;
+  }
+
+  // getActiveProjects - returns an array of active projects for a group.
+  static function getActiveProjects()
+  {
+    global $user;
+    $mdb2 = getConnection();
+
+    $group_id = $user->getGroup();
+    $org_id = $user->org_id;
+
+    $sql = "select id, name, description, tasks from tt_projects".
+      " where group_id = $group_id and org_id = $org_id and status = 1 order by upper(name)";
+    $res = $mdb2->query($sql);
+    $result = array();
+    if (!is_a($res, 'PEAR_Error')) {
+      while ($val = $res->fetchRow()) {
+        $result[] = $val;
+      }
+    }
+    return $result;
+  }
+
+  // getInactiveProjects - returns an array of inactive projects for a group.
+  static function getInactiveProjects()
+  {
+    global $user;
+    $mdb2 = getConnection();
+
+    $group_id = $user->getGroup();
+    $org_id = $user->org_id;
+
+    $sql = "select id, name, description, tasks from tt_projects".
+      "  where group_id = $group_id and org_id = $org_id and status = 0 order by upper(name)";
+    $res = $mdb2->query($sql);
+    $result = array();
+    if (!is_a($res, 'PEAR_Error')) {
+      while ($val = $res->fetchRow()) {
+        $result[] = $val;
+      }
+    }
+    return $result;
+  }
 }