/**
* 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();
/**
* 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.
$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;
}