Attach a Report to an Email Notification
You can attach a document generated by a Deepser report to a notification email. This is configured within email events.
Example: Attach Worklog Report to Service Operation Closure Notification
To attach a report to a notification, edit the To field of the email event. In this example, the REQUESTER - Closed Operation event is modified.
Replace the PHP code in the To field with the following:
//set Requester User as recipient
$user = $this->getModel()->getRequesterUser();
if ($user && $user->getId()){
$this->changeLanguage($user->getLocale());
$this->addTo($user->getEmail());
}
$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
$attachment->setContent($reportHistory->getContent());
//define naming template
$attachment->setFileName('Worklog Report_'. $this->getModel()->getId() . '.pdf');
//set filetype
$attachment->setFileType(Zend_Mime::TYPE_OCTETSTREAM);
//add attachment to the message
$mailAttachments = new Varien_Data_Collection();
$mailAttachments->addItem($attachment);
$this->getMailbox()->setForcedAttachments($mailAttachments);
note
Replace the report ID (14 in the example) with the actual ID of your report. You can find the report ID in the report grid within the Deepser Backend.