<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$session = CRM_Core_Session::singleton();
$this->addRule('from_email_address', ts('From Email Address is required'), 'required');
}
- $this->addWysiwyg('email_comment', ts('If you would like to add personal message to email please add it here. (If sending to more then one receipient the same message will be sent to each contact.)'), array(
+ $this->add('wysiwyg', 'email_comment', ts('If you would like to add personal message to email please add it here. (If sending to more then one receipient the same message will be sent to each contact.)'), array(
'rows' => 2,
'cols' => 40,
));
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
}
/**
- * Process the PDf and email with activity and attachment.
- * on click of Print Invoices
+ * Process the PDf and email with activity and attachment on click of Print Invoices.
*
* @param array $contribIDs
* Contribution Id.
// get organization address
$domain = CRM_Core_BAO_Domain::getDomain();
- $locParams = array('contact_id' => $domain->id);
+ $locParams = array('contact_id' => $domain->contact_id);
$locationDefaults = CRM_Core_BAO_Location::getValues($locParams);
if (isset($locationDefaults['address'][1]['state_province_id'])) {
$stateProvinceAbbreviationDomain = CRM_Core_PseudoConstant::stateProvinceAbbreviation($locationDefaults['address'][1]['state_province_id']);
$tplParams['creditnote_id'] = $creditNoteId;
}
+ $pdfFileName = "{$invoiceId}.pdf";
$sendTemplateParams = array(
'groupName' => 'msg_tpl_workflow_contribution',
'valueName' => 'contribution_invoice_receipt',
'contactId' => $contribution->contact_id,
'tplParams' => $tplParams,
- 'PDFFilename' => 'Invoice.pdf',
+ 'PDFFilename' => $pdfFileName,
);
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
// functions call for adding activity with attachment
- $fileName = self::putFile($html);
+ $pdfFileName = "{$invoiceId}.pdf";
+ $fileName = self::putFile($html, $pdfFileName);
self::addActivities($subject, $contribution->contact_id, $fileName, $params);
}
elseif ($contribution->_component == 'event') {
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
// functions call for adding activity with attachment
- $fileName = self::putFile($html);
+ $pdfFileName = "{$invoiceId}.pdf";
+ $fileName = self::putFile($html, $pdfFileName);
self::addActivities($subject, $contribution->contact_id, $fileName, $params);
}
return $html;
}
else {
- CRM_Utils_PDF_Utils::html2pdf($messageInvoice, 'Invoice.pdf', FALSE, array(
+ $pdfFileName = "{$invoiceId}.pdf";
+ CRM_Utils_PDF_Utils::html2pdf($messageInvoice, $pdfFileName, FALSE, array(
'margin_top' => 10,
'margin_left' => 65,
'metric' => 'px',
));
// functions call for adding activity with attachment
- $fileName = self::putFile($html);
+ $fileName = self::putFile($html, $pdfFileName);
self::addActivities($subject, $contactIds, $fileName, $params);
CRM_Utils_System::civiExit();
* @return string
* Name of file which is in pdf format
*/
- static public function putFile($html) {
+ static public function putFile($html, $name = 'Invoice.pdf') {
require_once "vendor/dompdf/dompdf/dompdf_config.inc.php";
$doc = new DOMPDF();
$doc->load_html($html);
$doc->render();
$html = $doc->output();
$config = CRM_Core_Config::singleton();
- $fileName = $config->uploadDir . 'Invoice.pdf';
+ $fileName = $config->uploadDir . $name;
file_put_contents($fileName, $html);
return $fileName;
}