From c8025280ade6c1dd6d6f78380c992d3621311a31 Mon Sep 17 00:00:00 2001 From: Sunil Pawar Date: Sat, 29 Aug 2020 08:22:30 +0530 Subject: [PATCH] user-interface#30 Ability to Send Invoice with modified subject and CC --- CRM/Contribute/Form/Task/Invoice.php | 11 +++++++++++ CRM/Core/BAO/MessageTemplate.php | 5 +++++ templates/CRM/Contribute/Form/Task/Invoice.tpl | 12 ++++++++++++ 3 files changed, 28 insertions(+) diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index b2087a6474..419cf483eb 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -143,6 +143,9 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $this->addRule('from_email_address', ts('From Email Address is required'), 'required'); } + $attributes = ['class' => 'huge']; + $this->add('text', 'cc_id', ts('CC'), $attributes); + $this->add('text', 'subject', ts('Subject'), $attributes + ['placeholder' => ts('Optional')]); $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.)'), [ 'rows' => 2, 'cols' => 40, @@ -413,6 +416,14 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { // from email address $fromEmailAddress = $params['from_email_address'] ?? NULL; + if (!empty($params['cc_id'])) { + $values['cc_receipt'] = $params['cc_id']; + } + + // get subject from UI + if (!empty($params['subject'])) { + $sendTemplateParams['subject'] = $values['subject'] = $params['subject']; + } // condition to check for download PDF Invoice or email Invoice if ($invoiceElements['createPdf']) { diff --git a/CRM/Core/BAO/MessageTemplate.php b/CRM/Core/BAO/MessageTemplate.php index 4dedb8c66e..bc683a8ec0 100644 --- a/CRM/Core/BAO/MessageTemplate.php +++ b/CRM/Core/BAO/MessageTemplate.php @@ -464,6 +464,11 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $mailContent['html'] = preg_replace('/html}", $mailContent['html']); } + // Overwrite subject from form field + if (!empty($params['subject'])) { + $mailContent['subject'] = $params['subject']; + } + // replace tokens in the three elements (in subject as if it was the text body) $domain = CRM_Core_BAO_Domain::getDomain(); $hookTokens = []; diff --git a/templates/CRM/Contribute/Form/Task/Invoice.tpl b/templates/CRM/Contribute/Form/Task/Invoice.tpl index 9f3dde8889..777354f29f 100644 --- a/templates/CRM/Contribute/Form/Task/Invoice.tpl +++ b/templates/CRM/Contribute/Form/Task/Invoice.tpl @@ -28,6 +28,18 @@ {$form.from_email_address.label} {$form.from_email_address.html} {help id="id-from_email" file="CRM/Contact/Form/Task/Email.hlp" isAdmin=$isAdmin} + + {$form.cc_id.label} + + {$form.cc_id.html} + + + + {$form.subject.label} + + {$form.subject.html} + + {$form.email_comment.label} {$form.email_comment.html} -- 2.25.1