X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/887a005ea99f044d266f489632b0a94a4acc99b2..c7d73ed8f6e2deade801bedaeb3af934ba69bf88:/WEB-INF/lib/ttTimesheetHelper.class.php diff --git a/WEB-INF/lib/ttTimesheetHelper.class.php b/WEB-INF/lib/ttTimesheetHelper.class.php index 07f02f86..0d4556bc 100644 --- a/WEB-INF/lib/ttTimesheetHelper.class.php +++ b/WEB-INF/lib/ttTimesheetHelper.class.php @@ -321,4 +321,29 @@ class ttTimesheetHelper { } return $options; } + + // getApprovers obtains a list of users who can approve a timesheet for a given user + // and also have an email to receive a notification about it. + static function getApprovers($user_id) { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $approvers = array(); + $rank = ttUserHelper::getUserRank($user_id); + $sql = "select u.id, u.name, u.email". + " from tt_users u". + " left join tt_roles r on (r.id = u.role_id)". + " where u.status = 1 and u.email is not null". + " and (r.rights like '%approve_all_timesheets%' or (r.rank > $rank and r.rights like '%approve_timesheets%'))"; + $res = $mdb2->query($sql); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $approvers[] = $val; + } + } + return $approvers; + } }