}
// prepareReportBody - prepares an email body for report.
- static function prepareReportBody($bean, $comment)
+ static function prepareReportBody($bean, $options, $comment)
{
global $user;
global $i18n;
// Determine these once as they are used in multiple places in this function.
$canViewReports = $user->can('view_reports') || $user->can('view_all_reports');
$isClient = $user->isClient();
- $options = ttReportHelper::getReportOptions($bean);
$items = ttReportHelper::getItems($options);
- $group_by = $bean->getAttribute('group_by');
+ $group_by = $options['group_by'];
if ($group_by && 'no_grouping' != $group_by)
$subtotals = ttReportHelper::getSubtotals($options);
$totals = ttReportHelper::getTotals($options);
// Output comment.
if ($comment) $body .= '<p>'.htmlspecialchars($comment).'</p>';
+// TODO: refactoring ongoing down from here...
+
if ($bean->getAttribute('chtotalsonly')) {
// Totals only report. Output subtotals.
}
// prepareFavReportBody - prepares an email body for a favorite report.
- static function prepareFavReportBody($options)
+ static function prepareFavReportBody($options, $comment = null)
{
global $user;
global $i18n;
$body .= '<p style="'.$style_title.'">'.$i18n->get('form.mail.report_subject').': '.$totals['start_date'].' - '.$totals['end_date'].'</p>';
// Output comment.
- // if ($comment) $body .= '<p>'.htmlspecialchars($comment).'</p>'; // No comment for fav. reports.
+ if ($comment) $body .= '<p>'.htmlspecialchars($comment).'</p>';
if ($options['show_totals_only']) {
// Totals only report. Output subtotals.
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.17.98.4316 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.17.98.4317 | 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>
$user = new ttUser(null, $options['user_id']);
if (!$user->id) continue; // Skip not found user.
- // TODO: write a new function ttFavReportHelper::adjustReportOptions that will use
- // a $user objected recycled above. Put user handling below into it.
- // Also adjust all other options for potentially changed user access rights and group properties.
+ // TODO: write a new function ttFavReportHelper::adjustOptions that will use
+ // a $user objecte recycled above. Put user handling below into it.
+ // Also adjust remaining options for potentially changed user access rights and group properties.
// For example, tracking mode may have changed, but fav report options are still old...
// This needs to be fixed.
// Obtain session bean with report attributes.
$bean = new ActionForm('reportBean', new Form('reportForm'));
+ $options = ttReportHelper::getReportOptions($bean);
+
// Prepare report body.
- $body = ttReportHelper::prepareReportBody($bean, $cl_comment);
+ $body = ttReportHelper::prepareReportBody($bean, $options, $cl_comment);
import('mail.Mailer');
$mailer = new Mailer();