75 lines
1.9 KiB
PHP
75 lines
1.9 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
class EcmEmailsDataCreator {
|
||
|
|
|
||
|
|
var $data;
|
||
|
|
|
||
|
|
function EcmEmailsDataCreator() {
|
||
|
|
$this->data = array();
|
||
|
|
}
|
||
|
|
|
||
|
|
function setAssignedUser($id, $name) {
|
||
|
|
$this->data['assigned_user']['id'] = $id;
|
||
|
|
$this->data['assigned_user']['name'] = $name;
|
||
|
|
}
|
||
|
|
|
||
|
|
function addToModule($module, $id) {
|
||
|
|
$this->data['to'][] = array($module, $id);
|
||
|
|
}
|
||
|
|
|
||
|
|
function addTo($name, $email) {
|
||
|
|
if(strlen($name) > 0)
|
||
|
|
$to = $name.' <'.$email.'>; ';
|
||
|
|
else
|
||
|
|
$to = '<'.$email.'>; ';
|
||
|
|
$this->data['to'][] = $to;
|
||
|
|
}
|
||
|
|
|
||
|
|
function setFromModule($module, $id) {
|
||
|
|
$this->data['from'][0] = array($module, $id);
|
||
|
|
}
|
||
|
|
|
||
|
|
function setFrom($name, $email) {
|
||
|
|
$this->data['from'][0] = $name.' <'.$email.'>; ';
|
||
|
|
}
|
||
|
|
|
||
|
|
function addAttachmentByLink($name, $link, $mime_type = 'application/pdf') {
|
||
|
|
$this->data['attachments']['links'][] = array($name, $link, $mime_type);
|
||
|
|
}
|
||
|
|
|
||
|
|
function addAttachmentBySugar($name, $module, $action, $getData, $previewData, $mime_type = 'application/pdf') {
|
||
|
|
$this->data['attachments']['sugar'][] = array($name, $module, $action, $getData, $previewData, $mime_type);
|
||
|
|
}
|
||
|
|
|
||
|
|
function addAssigned($module, $id) {
|
||
|
|
$this->data['assigned_ids'][$module] = $id;
|
||
|
|
}
|
||
|
|
|
||
|
|
function getLinkData() {
|
||
|
|
return base64_encode(serialize($this->data));
|
||
|
|
}
|
||
|
|
|
||
|
|
function createJavaScriptAction($link = 'index.php?module=EcmEmails&action=EditView&to_pdf=1') {
|
||
|
|
return "EcmPreviewPDF('".$link.'&data='.$this->getLinkData()."');";
|
||
|
|
}
|
||
|
|
|
||
|
|
function setEmailTemplateId($id) {
|
||
|
|
$this->data['template_id'] = $id;
|
||
|
|
}
|
||
|
|
|
||
|
|
function getBean($module, $id) {
|
||
|
|
global $beanList, $beanFiles;
|
||
|
|
$file = $beanFiles[$beanList[$module]];
|
||
|
|
if(file_exists($file)) {
|
||
|
|
require_once($file);
|
||
|
|
$focus = new $beanList[$module]();
|
||
|
|
$focus->retrieve($id);
|
||
|
|
$focus->format_all_fields();
|
||
|
|
return $focus;
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
?>
|