Attach Report to Email Notification

You can attach a document, generated by a report already defined in Deepser, to a notification email.

This functionality is configured within Email Events.

Example: Attach Worklog Report to operation closure notification.

To generate a report and attach it to an email notification you need to edit ‘To’ field of the email event.

In this example the configuration of the REQUESTER – Closed Operation event will be changed.

Replace the PHP code in the field ‘To‘ with the following one.                       

//set Requester User as recipient
$user = $this->getModel()->getRequesterUser();
if ($user && $user->getId()){

$attachment = Deep::getModel('deep_attachment/attachment');
//load the report instance
$report = Deep::getModel('deep_report/report')->load(14); // id 14 = Worklog Report
//pass to the report the id of the operation
$report->setFormData(['operation_id' => $this->getModel()->getId()]);
//run the report
$reportHistory = $report->run();
//set document as attachment
//define naming template
$attachment->setFileName('Worklog Report_'. $this->getModel()->getId() . '.pdf');
//set filetype
//add attachment to the message
$mailAttachments = new Varien_Data_Collection();