From f43392d109df8f4b04d623bd933f7a98089fb210 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 6 Aug 2018 13:49:19 +0000 Subject: [PATCH] Resuming refactoring report related functions. --- WEB-INF/lib/ttReportHelper.class.php | 11 ++++++----- WEB-INF/templates/footer.tpl | 2 +- cron.php | 6 +++--- report_send.php | 4 +++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index 4d510bbb..46ce3f85 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -657,7 +657,7 @@ class ttReportHelper { } // prepareReportBody - prepares an email body for report. - static function prepareReportBody($bean, $comment) + static function prepareReportBody($bean, $options, $comment) { global $user; global $i18n; @@ -665,10 +665,9 @@ class ttReportHelper { // 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); @@ -700,6 +699,8 @@ class ttReportHelper { // Output comment. if ($comment) $body .= '

'.htmlspecialchars($comment).'

'; +// TODO: refactoring ongoing down from here... + if ($bean->getAttribute('chtotalsonly')) { // Totals only report. Output subtotals. @@ -973,7 +974,7 @@ class ttReportHelper { } // prepareFavReportBody - prepares an email body for a favorite report. - static function prepareFavReportBody($options) + static function prepareFavReportBody($options, $comment = null) { global $user; global $i18n; @@ -1013,7 +1014,7 @@ class ttReportHelper { $body .= '

'.$i18n->get('form.mail.report_subject').': '.$totals['start_date'].' - '.$totals['end_date'].'

'; // Output comment. - // if ($comment) $body .= '

'.htmlspecialchars($comment).'

'; // No comment for fav. reports. + if ($comment) $body .= '

'.htmlspecialchars($comment).'

'; if ($options['show_totals_only']) { // Totals only report. Output subtotals. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 85633338..c8a4919c 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.98.4316 | Copyright © Anuko | +  Anuko Time Tracker 1.17.98.4317 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/cron.php b/cron.php index 1b586cf0..7d766992 100644 --- a/cron.php +++ b/cron.php @@ -66,9 +66,9 @@ while ($val = $res->fetchRow()) { $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. diff --git a/report_send.php b/report_send.php index d7c031fd..ea6c555b 100644 --- a/report_send.php +++ b/report_send.php @@ -72,8 +72,10 @@ if ($request->isPost()) { // 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(); -- 2.20.1