// The assignToInvoice assigns a set of records to a specific invoice.
static function assignToInvoice($invoice_id, $time_log_ids, $expense_item_ids)
{
// The assignToInvoice assigns a set of records to a specific invoice.
static function assignToInvoice($invoice_id, $time_log_ids, $expense_item_ids)
{
$sql = "update tt_log set invoice_id = ".$mdb2->quote($invoice_id).
" where id in(".join(', ', $time_log_ids).")";
$affected = $mdb2->exec($sql);
$sql = "update tt_log set invoice_id = ".$mdb2->quote($invoice_id).
" where id in(".join(', ', $time_log_ids).")";
$affected = $mdb2->exec($sql);
if ($expense_item_ids) {
$sql = "update tt_expense_items set invoice_id = ".$mdb2->quote($invoice_id).
" where id in(".join(', ', $expense_item_ids).")";
$affected = $mdb2->exec($sql);
if ($expense_item_ids) {
$sql = "update tt_expense_items set invoice_id = ".$mdb2->quote($invoice_id).
" where id in(".join(', ', $expense_item_ids).")";
$affected = $mdb2->exec($sql);
if ($group_by && 'no_grouping' != $group_by)
$subtotals = ttReportHelper::getSubtotals($bean);
$totals = ttReportHelper::getTotals($bean);
if ($group_by && 'no_grouping' != $group_by)
$subtotals = ttReportHelper::getSubtotals($bean);
$totals = ttReportHelper::getTotals($bean);
// Use custom fields plugin if it is enabled.
if (in_array('cf', explode(',', $user->plugins)))
$custom_fields = new CustomFields($user->team_id);
// Use custom fields plugin if it is enabled.
if (in_array('cf', explode(',', $user->plugins)))
$custom_fields = new CustomFields($user->team_id);
$cellRightAligned = 'text-align: right; vertical-align: top;';
$cellLeftAlignedSubtotal = 'font-weight: bold; text-align: left; vertical-align: top;';
$cellRightAlignedSubtotal = 'font-weight: bold; text-align: right; vertical-align: top;';
$cellRightAligned = 'text-align: right; vertical-align: top;';
$cellLeftAlignedSubtotal = 'font-weight: bold; text-align: left; vertical-align: top;';
$cellRightAlignedSubtotal = 'font-weight: bold; text-align: right; vertical-align: top;';
// Start creating email body.
$body = '<html>';
$body .= '<head><meta http-equiv="content-type" content="text/html; charset='.CHARSET.'"></head>';
$body .= '<body>';
// Start creating email body.
$body = '<html>';
$body .= '<head><meta http-equiv="content-type" content="text/html; charset='.CHARSET.'"></head>';
$body .= '<body>';
// Output comment.
if ($comment) $body .= '<p>'.htmlspecialchars($comment).'</p>';
if ($bean->getAttribute('chtotalsonly')) {
// Totals only report. Output subtotals.
// Output comment.
if ($comment) $body .= '<p>'.htmlspecialchars($comment).'</p>';
if ($bean->getAttribute('chtotalsonly')) {
// Totals only report. Output subtotals.
// Determine group_by header.
if ('cf_1' == $group_by)
$group_by_header = htmlspecialchars($custom_fields->fields[0]['label']);
// Determine group_by header.
if ('cf_1' == $group_by)
$group_by_header = htmlspecialchars($custom_fields->fields[0]['label']);
$body .= '<table border="0" cellpadding="4" cellspacing="0" width="100%">';
$body .= '<tr>';
$body .= '<td style="'.$tableHeader.'">'.$group_by_header.'</td>';
$body .= '<table border="0" cellpadding="4" cellspacing="0" width="100%">';
$body .= '<tr>';
$body .= '<td style="'.$tableHeader.'">'.$group_by_header.'</td>';
// Print totals.
$body .= '<tr><td> </td></tr>';
$body .= '<tr style="'.$rowSubtotal.'">';
$body .= '<td style="'.$cellLeftAlignedSubtotal.'">'.$i18n->getKey('label.total').'</td>';
if ($bean->getAttribute('chduration')) {
// Print totals.
$body .= '<tr><td> </td></tr>';
$body .= '<tr style="'.$rowSubtotal.'">';
$body .= '<td style="'.$cellLeftAlignedSubtotal.'">'.$i18n->getKey('label.total').'</td>';
if ($bean->getAttribute('chduration')) {
- $body .= '<td style="'.$cellRightAlignedSubtotal.'">';
- if ($totals['time'] <> '0:00') $body .= $totals['time'];
- $body .= '</td>';
+ $body .= '<td style="'.$cellRightAlignedSubtotal.'">';
+ if ($totals['time'] <> '0:00') $body .= $totals['time'];
+ $body .= '</td>';
if ($bean->getAttribute('chinvoice'))
$body .= '<td style="'.$tableHeader.'">'.$i18n->getKey('label.invoice').'</td>';
$body .= '</tr>';
if ($bean->getAttribute('chinvoice'))
$body .= '<td style="'.$tableHeader.'">'.$i18n->getKey('label.invoice').'</td>';
$body .= '</tr>';
if ($bean->getAttribute('chduration')) $body .= '<td style="'.$cellRightAlignedSubtotal.'">'.$subtotals[$prev_grouped_by]['time'].'</td>';
if ($bean->getAttribute('chnote')) $body .= '<td></td>';
if ($bean->getAttribute('chcost')) {
if ($bean->getAttribute('chduration')) $body .= '<td style="'.$cellRightAlignedSubtotal.'">'.$subtotals[$prev_grouped_by]['time'].'</td>';
if ($bean->getAttribute('chnote')) $body .= '<td></td>';
if ($bean->getAttribute('chcost')) {
- $body .= '<td style="'.$cellRightAlignedSubtotal.'">';
- $body .= ($user->canManageTeam() || $user->isClient()) ? $subtotals[$prev_grouped_by]['cost'] : $subtotals[$prev_grouped_by]['expenses'];
- $body .= '</td>';
+ $body .= '<td style="'.$cellRightAlignedSubtotal.'">';
+ $body .= ($user->canManageTeam() || $user->isClient()) ? $subtotals[$prev_grouped_by]['cost'] : $subtotals[$prev_grouped_by]['expenses'];
+ $body .= '</td>';
if ($bean->getAttribute('chinvoice'))
$body .= '<td style="'.$cellRightAligned.'">'.htmlspecialchars($record['invoice']).'</td>';
$body .= '</tr>';
if ($bean->getAttribute('chinvoice'))
$body .= '<td style="'.$cellRightAligned.'">'.htmlspecialchars($record['invoice']).'</td>';
$body .= '</tr>';
if ($bean->getAttribute('chduration')) $body .= '<td style="'.$cellRightAlignedSubtotal.'">'.$totals['time'].'</td>';
if ($bean->getAttribute('chnote')) $body .= '<td></td>';
if ($bean->getAttribute('chcost')) {
if ($bean->getAttribute('chduration')) $body .= '<td style="'.$cellRightAlignedSubtotal.'">'.$totals['time'].'</td>';
if ($bean->getAttribute('chnote')) $body .= '<td></td>';
if ($bean->getAttribute('chcost')) {
- $body .= '<td nowrap style="'.$cellRightAlignedSubtotal.'">'.htmlspecialchars($user->currency).' ';
- $body .= ($user->canManageTeam() || $user->isClient()) ? $totals['cost'] : $totals['expenses'];
- $body .= '</td>';
+ $body .= '<td nowrap style="'.$cellRightAlignedSubtotal.'">'.htmlspecialchars($user->currency).' ';
+ $body .= ($user->canManageTeam() || $user->isClient()) ? $totals['cost'] : $totals['expenses'];
+ $body .= '</td>';
// Output footer.
if (!defined('REPORT_FOOTER') || !(REPORT_FOOTER == false))
$body .= '<p style="text-align: center;">'.$i18n->getKey('form.mail.footer').'</p>';
// Output footer.
if (!defined('REPORT_FOOTER') || !(REPORT_FOOTER == false))
$body .= '<p style="text-align: center;">'.$i18n->getKey('form.mail.footer').'</p>';
- if ($group_by && 'no_grouping' != $group_by)
- $subtotals = ttReportHelper::getFavSubtotals($report);
- $totals = ttReportHelper::getFavTotals($report);
-
+ if ($group_by && 'no_grouping' != $group_by)
+ $subtotals = ttReportHelper::getFavSubtotals($report);
+ $totals = ttReportHelper::getFavTotals($report);
+
// Use custom fields plugin if it is enabled.
if (in_array('cf', explode(',', $user->plugins)))
$custom_fields = new CustomFields($user->team_id);
// Use custom fields plugin if it is enabled.
if (in_array('cf', explode(',', $user->plugins)))
$custom_fields = new CustomFields($user->team_id);
$cellRightAligned = 'text-align: right; vertical-align: top;';
$cellLeftAlignedSubtotal = 'font-weight: bold; text-align: left; vertical-align: top;';
$cellRightAlignedSubtotal = 'font-weight: bold; text-align: right; vertical-align: top;';
$cellRightAligned = 'text-align: right; vertical-align: top;';
$cellLeftAlignedSubtotal = 'font-weight: bold; text-align: left; vertical-align: top;';
$cellRightAlignedSubtotal = 'font-weight: bold; text-align: right; vertical-align: top;';
// Start creating email body.
$body = '<html>';
$body .= '<head><meta http-equiv="content-type" content="text/html; charset='.CHARSET.'"></head>';
$body .= '<body>';
// Start creating email body.
$body = '<html>';
$body .= '<head><meta http-equiv="content-type" content="text/html; charset='.CHARSET.'"></head>';
$body .= '<body>';
// Determine group_by header.
if ('cf_1' == $group_by)
$group_by_header = htmlspecialchars($custom_fields->fields[0]['label']);
// Determine group_by header.
if ('cf_1' == $group_by)
$group_by_header = htmlspecialchars($custom_fields->fields[0]['label']);
$body .= '<table border="0" cellpadding="4" cellspacing="0" width="100%">';
$body .= '<tr>';
$body .= '<td style="'.$tableHeader.'">'.$group_by_header.'</td>';
$body .= '<table border="0" cellpadding="4" cellspacing="0" width="100%">';
$body .= '<tr>';
$body .= '<td style="'.$tableHeader.'">'.$group_by_header.'</td>';
// Print totals.
$body .= '<tr><td> </td></tr>';
$body .= '<tr style="'.$rowSubtotal.'">';
$body .= '<td style="'.$cellLeftAlignedSubtotal.'">'.$i18n->getKey('label.total').'</td>';
if ($report['show_duration']) {
// Print totals.
$body .= '<tr><td> </td></tr>';
$body .= '<tr style="'.$rowSubtotal.'">';
$body .= '<td style="'.$cellLeftAlignedSubtotal.'">'.$i18n->getKey('label.total').'</td>';
if ($report['show_duration']) {
- $body .= '<td style="'.$cellRightAlignedSubtotal.'">';
- if ($totals['time'] <> '0:00') $body .= $totals['time'];
- $body .= '</td>';
+ $body .= '<td style="'.$cellRightAlignedSubtotal.'">';
+ if ($totals['time'] <> '0:00') $body .= $totals['time'];
+ $body .= '</td>';
if ($report['show_invoice'])
$body .= '<td style="'.$tableHeader.'">'.$i18n->getKey('label.invoice').'</td>';
$body .= '</tr>';
if ($report['show_invoice'])
$body .= '<td style="'.$tableHeader.'">'.$i18n->getKey('label.invoice').'</td>';
$body .= '</tr>';
if ($report['show_invoice'])
$body .= '<td style="'.$cellRightAligned.'">'.htmlspecialchars($record['invoice']).'</td>';
$body .= '</tr>';
if ($report['show_invoice'])
$body .= '<td style="'.$cellRightAligned.'">'.htmlspecialchars($record['invoice']).'</td>';
$body .= '</tr>';
if ($report['show_duration']) $body .= '<td style="'.$cellRightAlignedSubtotal.'">'.$totals['time'].'</td>';
if ($report['show_note']) $body .= '<td></td>';
if ($report['show_cost']) {
if ($report['show_duration']) $body .= '<td style="'.$cellRightAlignedSubtotal.'">'.$totals['time'].'</td>';
if ($report['show_note']) $body .= '<td></td>';
if ($report['show_cost']) {
- $body .= '<td nowrap style="'.$cellRightAlignedSubtotal.'">'.htmlspecialchars($user->currency).' ';
- $body .= ($user->canManageTeam() || $user->isClient()) ? $totals['cost'] : $totals['expenses'];
- $body .= '</td>';
+ $body .= '<td nowrap style="'.$cellRightAlignedSubtotal.'">'.htmlspecialchars($user->currency).' ';
+ $body .= ($user->canManageTeam() || $user->isClient()) ? $totals['cost'] : $totals['expenses'];
+ $body .= '</td>';
// Output footer.
if (!defined('REPORT_FOOTER') || !(REPORT_FOOTER == false))
$body .= '<p style="text-align: center;">'.$i18n->getKey('form.mail.footer').'</p>';
// Output footer.
if (!defined('REPORT_FOOTER') || !(REPORT_FOOTER == false))
$body .= '<p style="text-align: center;">'.$i18n->getKey('form.mail.footer').'</p>';
// sendFavReport - sends a favorite report to a specified email, called from cron.php
static function sendFavReport($report, $email) {
// We are called from cron.php, we have no $bean in session.
// cron.php set global $user and $i18n objects to match our favorite report user.
global $user;
global $i18n;
// sendFavReport - sends a favorite report to a specified email, called from cron.php
static function sendFavReport($report, $email) {
// We are called from cron.php, we have no $bean in session.
// cron.php set global $user and $i18n objects to match our favorite report user.
global $user;
global $i18n;
$mailer->setSendType(MAIL_MODE);
if (!$mailer->send($report['name'], $body))
return false;
$mailer->setSendType(MAIL_MODE);
if (!$mailer->send($report['name'], $body))
return false;