}
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;
+ }
}
return false;
// So far, so good. Check user now.
- $options = array('group_id'=>$group_id,'status'=>ACTIVE,'max_rank'=>MAX_RANK);
+ $options = array('status'=>ACTIVE,'max_rank'=>MAX_RANK);
$users = $this->getUsers($options);
foreach($users as $one_user) {
if ($one_user['id'] == $this->behalf_id)
return false;
}
+
+ // getUserRank - obtains a rank for a given user.
+ static function getUserRank($user_id) {
+ global $user;
+ $mdb2 = getConnection();
+
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
+ $sql = "select r.rank from tt_users u".
+ " left join tt_roles r on (u.role_id = r.id)".
+ " where u.id = $user_id and u.group_id = $group_id and u.org_id = $org_id";
+ $res = $mdb2->query($sql);
+ if (is_a($res, 'PEAR_Error')) return 0;
+ $val = $res->fetchRow();
+ return $val['rank'];
+ }
}
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.37.4751 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.37.4752 | Copyright © <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>
$totals = ttReportHelper::getTotals($options);
$notClient = !$user->isClient();
+// Determine managers we can submit this timesheet for approval to.
+$approvers = ttTimesheetHelper::getApprovers($timesheet['user_id']);
+
$smarty->assign('not_client', $notClient);
$smarty->assign('group_by_header', ttReportHelper::makeGroupByHeader($options));
$smarty->assign('timesheet', $timesheet);