From 6d98bfada4d44ad9f8e1fbfad7f1932333322e7f Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Tue, 26 Jul 2016 14:28:27 +1000 Subject: [PATCH] CRM-19129 Allow Users to Select the From Address used for when sending Email Receipts --- CRM/Contribute/Form/Task/PDF.php | 20 ++++++++++++++++++-- templates/CRM/Contribute/Form/Task/PDF.tpl | 3 +++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/Task/PDF.php b/CRM/Contribute/Form/Task/PDF.php index 0dd94859e6..6c064d0cb3 100644 --- a/CRM/Contribute/Form/Task/PDF.php +++ b/CRM/Contribute/Form/Task/PDF.php @@ -93,7 +93,7 @@ AND {$this->_componentClause}"; 'title' => ts('Search Results'), ), ); - + CRM_Contact_Form_Task_EmailCommon ::preProcessFromAddress($this); CRM_Utils_System::appendBreadCrumb($breadCrumb); CRM_Utils_System::setTitle(ts('Print Contribution Receipts')); } @@ -104,7 +104,9 @@ AND {$this->_componentClause}"; public function buildQuickForm() { $this->addElement('radio', 'output', NULL, ts('Email Receipts'), 'email_receipt', - array('onClick' => "document.getElementById('selectPdfFormat').style.display = 'none';") + array( + 'onClick' => "document.getElementById('selectPdfFormat').style.display = 'none'; + document.getElementById('selectEmailFrom').style.display = 'block';") ); $this->addElement('radio', 'output', NULL, ts('PDF Receipts'), 'pdf_receipt', array('onClick' => "document.getElementById('selectPdfFormat').style.display = 'block';") @@ -117,6 +119,8 @@ AND {$this->_componentClause}"; $this->add('checkbox', 'receipt_update', ts('Update receipt dates for these contributions'), FALSE); $this->add('checkbox', 'override_privacy', ts('Override privacy setting? (Do not email / Do not mail)'), FALSE); + $this->add('select', 'fromEmailAddress', ts('From Email'), $this->_fromEmails, FALSE, array('class' => 'crm-select2 huge')); + $this->addButtons(array( array( 'type' => 'next', @@ -150,6 +154,10 @@ AND {$this->_componentClause}"; $params = $this->controller->exportValues($this->_name); $elements = self::getElements($this->_contributionIds, $params, $this->_contactIds); + $fromEmail = $params['fromEmailAddress']; + $from = CRM_Utils_Array::value($fromEmail, $this->_emails); + $fromDetails = explode(' <', $from); + foreach ($elements['details'] as $contribID => $detail) { $input = $ids = $objects = array(); @@ -192,6 +200,14 @@ AND {$this->_componentClause}"; $objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date); $values = array(); + if (isset($params['fromEmailAddress']) && !$elements['createPdf']) { + $fromEmail = $params['fromEmailAddress']; + $from = CRM_Utils_Array::value($fromEmail, $this->_emails); + $fromDetails = explode(' <', $from); + $input['receipt_from_email'] = substr(trim($fromDetails[1]), 0, -1); + $input['receipt_from_name'] = str_replace('"', '', $fromDetails[0]); + } + $mail = CRM_Contribute_BAO_Contribution::sendMail($input, $ids, $objects['contribution']->id, $values, FALSE, $elements['createPdf']); diff --git a/templates/CRM/Contribute/Form/Task/PDF.tpl b/templates/CRM/Contribute/Form/Task/PDF.tpl index 7895f208fe..f3e96fc34f 100644 --- a/templates/CRM/Contribute/Form/Task/PDF.tpl +++ b/templates/CRM/Contribute/Form/Task/PDF.tpl @@ -35,6 +35,9 @@ {$form.output.email_receipt.html} + + {$form.fromEmailAddress.label}: {$form.fromEmailAddress.html} + {$form.output.pdf_receipt.html} -- 2.25.1