// The getClient looks up a client by id.
static function getClient($client_id, $all_fields = false) {
-
- $mdb2 = getConnection();
global $user;
+ $mdb2 = getConnection();
+
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
$sql = 'select ';
if ($all_fields)
else
$sql .= 'name ';
- $sql .= "from tt_clients where group_id = ".$user->getGroup().
+ $sql .= "from tt_clients where group_id = $group_id and org_id = $org_id".
" and id = $client_id and (status = 1 or status = 0)";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
// It is anticipated to support "totals only" option later on.
// Our query is different depending on tracking mode.
- if (MODE_TIME == $user->tracking_mode) {
+ if (MODE_TIME == $user->getTrackingMode()) {
// In "time only" tracking mode there is a single user rate.
$sql = "select l.date as date, 1 as type, u.name as user_name, p.name as project_name,
t.name as task_name, l.comment as note,
if (isset($fields['project_id'])) $project_id = (int) $fields['project_id'];
// Our query is different depending on tracking mode.
- if (MODE_TIME == $user->tracking_mode) {
+ if (MODE_TIME == $user->getTrackingMode()) {
// In "time only" tracking mode there is a single user rate.
$sql = "select count(*) as num from tt_log l, tt_users u
where l.status = 1 and l.client_id = $client_id and l.invoice_id is NULL
$last_id = $val['last_insert_id'];
// Our update sql is different depending on tracking mode.
- if (MODE_TIME == $user->tracking_mode) {
+ if (MODE_TIME == $user->getTrackingMode()) {
// In "time only" tracking mode there is a single user rate.
$sql = "update tt_log l
left join tt_users u on (u.id = l.user_id)
$style_tableHeader = 'font-weight: bold; background-color: #a6ccf7; text-align: left;';
$style_tableHeaderCentered = 'font-weight: bold; background-color: #a6ccf7; text-align: center;';
+ // Determine tracking mode once for multiple reuse below.
+ $trackingMode = $user->getTrackingMode();
+
// Start creating email body.
$body = '<html>';
$body .= '<head><meta http-equiv="content-type" content="text/html; charset='.CHARSET.'"></head>';
$body .= '<tr>';
$body .= '<td style="'.$style_tableHeader.'">'.$i18n->get('label.date').'</td>';
$body .= '<td style="'.$style_tableHeader.'">'.$i18n->get('form.invoice.person').'</td>';
- if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode)
+ if (MODE_PROJECTS == $trackingMode || MODE_PROJECTS_AND_TASKS == $trackingMode)
$body .= '<td style="'.$style_tableHeader.'">'.$i18n->get('label.project').'</td>';
- if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode)
+ if (MODE_PROJECTS_AND_TASKS == $trackingMode)
$body .= '<td style="'.$style_tableHeader.'">'.$i18n->get('label.task').'</td>';
$body .= '<td style="'.$style_tableHeader.'">'.$i18n->get('label.note').'</td>';
$body .= '<td style="'.$style_tableHeaderCentered.'" width="5%">'.$i18n->get('label.duration').'</td>';
$body .= '<tr>';
$body .= '<td>'.$item['date'].'</td>';
$body .= '<td>'.htmlspecialchars($item['user_name']).'</td>';
- if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode)
+ if (MODE_PROJECTS == $trackingMode || MODE_PROJECTS_AND_TASKS == $trackingMode)
$body .= '<td>'.htmlspecialchars($item['project_name']).'</td>';
- if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode)
+ if (MODE_PROJECTS_AND_TASKS == $trackingMode)
$body .= '<td>'.htmlspecialchars($item['task_name']).'</td>';
$body .= '<td>'.htmlspecialchars($item['note']).'</td>';
$body .= '<td align="right">'.$item['duration'].'</td>';
}
// Output summary.
$colspan = 4;
- if (MODE_PROJECTS == $user->tracking_mode)
+ if (MODE_PROJECTS == $trackingMode)
$colspan++;
- elseif (MODE_PROJECTS_AND_TASKS == $user->tracking_mode)
+ elseif (MODE_PROJECTS_AND_TASKS == $trackingMode)
$colspan += 2;
$body .= '<tr><td> </td></tr>';
if ($tax) {