if (is_a($affected, 'PEAR_Error')) return false;
- $last_id = 0;
- $sql = "select last_insert_id() as last_insert_id";
- $res = $mdb2->query($sql);
- $val = $res->fetchRow();
- $last_id = $val['last_insert_id'];
-
+ $last_id = $mdb2->lastInsertID('tt_invoices', 'id');
return $last_id;
}
// 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
if (is_a($affected, 'PEAR_Error')) return false;
// Mark associated invoice items with invoice id.
- $last_id = 0;
- $sql = "select last_insert_id() as last_insert_id";
- $res = $mdb2->query($sql);
- $val = $res->fetchRow();
- $last_id = $val['last_insert_id'];
+ $last_id = $mdb2->lastInsertID('tt_invoices', '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) {