- global $user;
- $user_id = $user->getActiveUser();
-
- $result = array();
- $mdb2 = getConnection();
-
- $sql = "select distinct c.id, c.name, c.projects from tt_user_project_binds upb
- inner join tt_client_project_binds cpb on (cpb.project_id = upb.project_id)
- inner join tt_clients c on (c.id = cpb.client_id and c.status = 1)
- where upb.user_id = $user_id and upb.status = 1 order by c.name";
-
- $res = $mdb2->query($sql);
- if (!is_a($res, 'PEAR_Error')) {
- while ($val = $res->fetchRow()) {
- // if ($withProjects) {
- // $projects = ttClientHelper::getAssignedProjectsForUser($val['id']);
- //$project_ids = array();
- //foreach ($projects as $project_item)
- //$project_ids[] = $project_item[id];
- //$val['projects'] = implode(',', $project_ids);
- //}
- $result[] = $val;
- }
- }
- return $result;
- }
-
- // getAssignedProjectsForUser - returns an array of projects assigned to a user and associatied with a client.
- static function getAssignedProjectsForUser($client_id)
- {
- global $user;
- $user_id = $user->getActiveUser();
-
- $result = array();