X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/c2b4a52bc12c6ee6204fd03d1d1b2534b7249554..e304b6c8564a6c3f2a3c6e68a0f5e9c7db817a65:/WEB-INF/lib/ttUser.class.php diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 2511ecfb..e3de5b4c 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -236,6 +236,33 @@ class ttUser { return $result; } + // getAssignedClients - returns an array of clients assigned to own projects. + function getAssignedClients() + { + // Start with projects; + $projects = $this->getAssignedProjects(); + if (!$projects) return false; + $assigned_project_ids = array(); + foreach($projects as $project) { + $assigned_project_ids[] = $project['id']; + } + + $mdb2 = getConnection(); + + // Get active clients for group. + $clients = array(); + $sql = "select id, name, address, projects from tt_clients where group_id = $this->group_id and status = 1"; + $res = $mdb2->query($sql); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $client_project_ids = $val['projects'] ? explode(',', $val['projects']) : array(); + if (array_intersect($assigned_project_ids, $client_project_ids)) + $clients[] = $val; // Add client if one of user projects is a client project, too. + } + } + return $clients; + } + // isDateLocked checks whether a specifc date is locked for modifications. function isDateLocked($date) {