Favorite Report Name in Emailed Reports

Discussion forum about Anuko Time Tracker
Post Reply
grovesdm
Posts: 6
Joined: Sun May 03, 2015 5:06 am

Favorite Report Name in Emailed Reports

Post by grovesdm » Wed Jan 20, 2016 2:39 am

Hello,

Is there a way to include the favourite report name when scheduling reports.

I am scheduling employee summaries by project for each employee but they dont have any title to indicate which employee it is for.

I have found a prevoious post that shows how to include the current user (viewtopic.php?p=4149) but that doesnt help as I am the one scheduling all of the reports.

Can I use something else in here:
$body .= '<p style="'.$style_title.'">'.$user->name.'</p>';
to include the employee name or the favorite report title?

Greatly appreciate any help!

Cheers,
Daniel

wrc
Posts: 285
Joined: Tue May 25, 2010 8:30 pm

Re: Favorite Report Name in Emailed Reports

Post by wrc » Wed Jan 20, 2016 2:57 pm

Will email subject work for you?

If, so you can add a fav report name to it in the ttReportHelper::sendFavReport() function (/WEB-INF/lib/ttReportHelper.class.php).

You are looking to modify the $mailer->send() call, so that instead of

Code: Select all

    if (!$mailer->send($i18n->getKey('form.mail.report_subject'), $body))
      return false;
you have:

Code: Select all

    if (!$mailer->send($i18n->getKey('form.mail.report_subject').' '.$report['name'], $body))
      return false;
The entire function will look like this:

Code: Select all

  // 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;
    
    // Prepare report body.
    $body = ttReportHelper::prepareFavReportBody($report);
			
    import('mail.Mailer');
    $mailer = new Mailer();
    $mailer->setCharSet(CHARSET);
    $mailer->setContentType('text/html');
    $mailer->setSender(SENDER);
    $mailer->setReceiver($email);
    $mailer->setSendType(MAIL_MODE);
    if (!$mailer->send($i18n->getKey('form.mail.report_subject').' '.$report['name'], $body))
      return false;
      
    return true;
  }
Basically, we have added a favorite report name to email subject after a space.

I hope it helps.
Last edited by wrc on Thu Jan 21, 2016 1:53 am, edited 1 time in total.

Nik
Posts: 484
Joined: Wed May 26, 2010 5:55 pm

Re: Favorite Report Name in Emailed Reports

Post by Nik » Wed Jan 20, 2016 6:40 pm

I have put the change in Time Tracker 1.9.12.3384 (without form.mail.report_subject).

Hope it helps.

grovesdm
Posts: 6
Joined: Sun May 03, 2015 5:06 am

Re: Favorite Report Name in Emailed Reports

Post by grovesdm » Thu Jan 21, 2016 12:59 am

Hello,

Thats great!!

I tried the code you suggested but got a 500 error so I downloaded the latest and had a look. I inserted the code as follows:

Code: Select all

if (!$mailer->send($report['name'], $body))
and that works perfectly.

It would be nice to see the report name on the report page too. Maybe that would be a nice feature :D

Anyway thanks allot!!

Cheers,
Daniel

dell810
Posts: 42
Joined: Sat Oct 01, 2016 1:09 pm

Re: Favorite Report Name in Emailed Reports

Post by dell810 » Wed Jan 04, 2017 10:45 pm

Hi,
I'd like to see the report name on the report page too.
Thanks

Post Reply