Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
e70a7fc0 | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | class CRM_Contribute_Form_AdditionalInfo { | |
36 | ||
37 | /** | |
c490a46a | 38 | * Build the form object for Premium Information. |
6a488035 | 39 | * |
6a488035 | 40 | * |
c490a46a | 41 | * @param CRM_Core_Form $form |
dd244018 | 42 | * |
6a488035 TO |
43 | * @return void |
44 | */ | |
00be9182 | 45 | public static function buildPremium(&$form) { |
6a488035 TO |
46 | //premium section |
47 | $form->add('hidden', 'hidden_Premium', 1); | |
48 | $sel1 = $sel2 = array(); | |
49 | ||
50 | $dao = new CRM_Contribute_DAO_Product(); | |
51 | $dao->is_active = 1; | |
52 | $dao->find(); | |
53 | $min_amount = array(); | |
54 | $sel1[0] = '-select product-'; | |
55 | while ($dao->fetch()) { | |
56 | $sel1[$dao->id] = $dao->name . " ( " . $dao->sku . " )"; | |
57 | $min_amount[$dao->id] = $dao->min_contribution; | |
58 | $options = explode(',', $dao->options); | |
59 | foreach ($options as $k => $v) { | |
60 | $options[$k] = trim($v); | |
61 | } | |
62 | if ($options[0] != '') { | |
63 | $sel2[$dao->id] = $options; | |
64 | } | |
65 | $form->assign('premiums', TRUE); | |
66 | } | |
67 | $form->_options = $sel2; | |
68 | $form->assign('mincontribution', $min_amount); | |
353ffa53 | 69 | $sel = &$form->addElement('hierselect', "product_name", ts('Premium'), 'onclick="showMinContrib();"'); |
6a488035 TO |
70 | $js = "<script type='text/javascript'>\n"; |
71 | $formName = 'document.forms.' . $form->getName(); | |
72 | ||
73 | for ($k = 1; $k < 2; $k++) { | |
74 | if (!isset($defaults['product_name'][$k]) || (!$defaults['product_name'][$k])) { | |
75 | $js .= "{$formName}['product_name[$k]'].style.display = 'none';\n"; | |
76 | } | |
77 | } | |
78 | ||
79 | $sel->setOptions(array($sel1, $sel2)); | |
80 | $js .= "</script>\n"; | |
81 | $form->assign('initHideBoxes', $js); | |
82 | ||
83 | $form->addDate('fulfilled_date', ts('Fulfilled'), FALSE, array('formatType' => 'activityDate')); | |
84 | $form->addElement('text', 'min_amount', ts('Minimum Contribution Amount')); | |
85 | } | |
86 | ||
87 | /** | |
c490a46a | 88 | * Build the form object for Additional Details. |
6a488035 | 89 | * |
6a488035 | 90 | * |
c490a46a | 91 | * @param CRM_Core_Form $form |
6c8f6e67 | 92 | * |
6a488035 TO |
93 | * @return void |
94 | */ | |
00be9182 | 95 | public static function buildAdditionalDetail(&$form) { |
6a488035 TO |
96 | //Additional information section |
97 | $form->add('hidden', 'hidden_AdditionalDetail', 1); | |
98 | ||
99 | $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution'); | |
100 | ||
101 | $form->addDateTime('thankyou_date', ts('Thank-you Sent'), FALSE, array('formatType' => 'activityDateTime')); | |
102 | ||
103 | // add various amounts | |
353ffa53 TO |
104 | $nonDeductAmount = &$form->add('text', 'non_deductible_amount', ts('Non-deductible Amount'), |
105 | $attributes['non_deductible_amount'] | |
6a488035 TO |
106 | ); |
107 | $form->addRule('non_deductible_amount', ts('Please enter a valid monetary value for Non-deductible Amount.'), 'money'); | |
108 | ||
109 | if ($form->_online) { | |
110 | $nonDeductAmount->freeze(); | |
111 | } | |
353ffa53 TO |
112 | $feeAmount = &$form->add('text', 'fee_amount', ts('Fee Amount'), |
113 | $attributes['fee_amount'] | |
6a488035 TO |
114 | ); |
115 | $form->addRule('fee_amount', ts('Please enter a valid monetary value for Fee Amount.'), 'money'); | |
116 | if ($form->_online) { | |
117 | $feeAmount->freeze(); | |
118 | } | |
0e6e8724 | 119 | |
353ffa53 TO |
120 | $netAmount = &$form->add('text', 'net_amount', ts('Net Amount'), |
121 | $attributes['net_amount'] | |
6a488035 TO |
122 | ); |
123 | $form->addRule('net_amount', ts('Please enter a valid monetary value for Net Amount.'), 'money'); | |
124 | if ($form->_online) { | |
125 | $netAmount->freeze(); | |
126 | } | |
353ffa53 TO |
127 | $element = &$form->add('text', 'invoice_id', ts('Invoice ID'), |
128 | $attributes['invoice_id'] | |
6a488035 TO |
129 | ); |
130 | if ($form->_online) { | |
131 | $element->freeze(); | |
132 | } | |
133 | else { | |
134 | $form->addRule('invoice_id', | |
135 | ts('This Invoice ID already exists in the database.'), | |
136 | 'objectExists', | |
137 | array('CRM_Contribute_DAO_Contribution', $form->_id, 'invoice_id') | |
138 | ); | |
139 | } | |
933c5f44 | 140 | $element = $form->add('text', 'creditnote_id', ts('Credit Note ID'), |
141 | $attributes['creditnote_id'] | |
142 | ); | |
143 | if ($form->_online) { | |
144 | $element->freeze(); | |
145 | } | |
146 | else { | |
147 | $form->addRule('creditnote_id', | |
148 | ts('This Credit Note ID already exists in the database.'), | |
149 | 'objectExists', | |
150 | array('CRM_Contribute_DAO_Contribution', $form->_id, 'creditnote_id') | |
151 | ); | |
152 | } | |
6a488035 TO |
153 | |
154 | $form->add('select', 'contribution_page_id', | |
155 | ts('Online Contribution Page'), | |
156 | array( | |
21dfd5f5 | 157 | '' => ts('- select -'), |
6a488035 TO |
158 | ) + |
159 | CRM_Contribute_PseudoConstant::contributionPage() | |
160 | ); | |
161 | ||
162 | $form->add('textarea', 'note', ts('Notes'), array("rows" => 4, "cols" => 60)); | |
0e6e8724 | 163 | |
6a488035 TO |
164 | $statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); |
165 | if ($form->_id && $form->_values['contribution_status_id'] == array_search('Cancelled', $statusName)) { | |
166 | $netAmount->freeze(); | |
167 | $feeAmount->freeze(); | |
168 | } | |
0e6e8724 | 169 | |
6a488035 TO |
170 | } |
171 | ||
6a488035 | 172 | /** |
dc195289 | 173 | * used by CRM/Pledge/Form/Pledge.php |
6a488035 | 174 | * |
c490a46a | 175 | * Build the form object for PaymentReminders Information. |
6a488035 | 176 | * |
6a488035 | 177 | * |
c490a46a | 178 | * @param CRM_Core_Form $form |
6a488035 | 179 | * |
da6b46f4 | 180 | * @return void |
6a488035 | 181 | */ |
00be9182 | 182 | public static function buildPaymentReminders(&$form) { |
6a488035 TO |
183 | //PaymentReminders section |
184 | $form->add('hidden', 'hidden_PaymentReminders', 1); | |
185 | $form->add('text', 'initial_reminder_day', ts('Send Initial Reminder'), array('size' => 3)); | |
3f4b742c | 186 | $form->addRule('initial_reminder_day', ts('Please enter a valid reminder day.'), 'positiveInteger'); |
6a488035 | 187 | $form->add('text', 'max_reminders', ts('Send up to'), array('size' => 3)); |
3f4b742c | 188 | $form->addRule('max_reminders', ts('Please enter a valid No. of reminders.'), 'positiveInteger'); |
6a488035 | 189 | $form->add('text', 'additional_reminder_day', ts('Send additional reminders'), array('size' => 3)); |
3f4b742c | 190 | $form->addRule('additional_reminder_day', ts('Please enter a valid additional reminder day.'), 'positiveInteger'); |
6a488035 TO |
191 | } |
192 | ||
193 | /** | |
100fef9d | 194 | * Process the Premium Information |
6a488035 | 195 | * |
6a488035 | 196 | * |
c490a46a | 197 | * @param array $params |
100fef9d CW |
198 | * @param int $contributionID |
199 | * @param int $premiumID | |
e60f24eb | 200 | * @param NULL $options |
355ba699 | 201 | * @return void |
6a488035 | 202 | */ |
00be9182 | 203 | public static function processPremium(&$params, $contributionID, $premiumID = NULL, &$options = NULL) { |
6a488035 TO |
204 | $dao = new CRM_Contribute_DAO_ContributionProduct(); |
205 | $dao->contribution_id = $contributionID; | |
206 | $dao->product_id = $params['product_name'][0]; | |
207 | $dao->fulfilled_date = CRM_Utils_Date::processDate($params['fulfilled_date'], NULL, TRUE); | |
353ffa53 | 208 | $isDeleted = FALSE; |
6a488035 TO |
209 | //CRM-11106 |
210 | $premiumParams = array( | |
211 | 'id' => $params['product_name'][0], | |
212 | ); | |
213 | $productDetails = array(); | |
214 | CRM_Contribute_BAO_ManagePremiums::retrieve($premiumParams, $productDetails); | |
215 | $dao->financial_type_id = CRM_Utils_Array::value('financial_type_id', $productDetails); | |
a7488080 | 216 | if (!empty($options[$params['product_name'][0]])) { |
6a488035 TO |
217 | $dao->product_option = $options[$params['product_name'][0]][$params['product_name'][1]]; |
218 | } | |
219 | if ($premiumID) { | |
220 | $premoumDAO = new CRM_Contribute_DAO_ContributionProduct(); | |
221 | $premoumDAO->id = $premiumID; | |
222 | $premoumDAO->find(TRUE); | |
223 | if ($premoumDAO->product_id == $params['product_name'][0]) { | |
224 | $dao->id = $premiumID; | |
225 | $premium = $dao->save(); | |
226 | } | |
227 | else { | |
228 | $premoumDAO->delete(); | |
229 | $isDeleted = TRUE; | |
230 | $premium = $dao->save(); | |
231 | } | |
232 | } | |
233 | else { | |
234 | $premium = $dao->save(); | |
235 | } | |
236 | //CRM-11106 | |
237 | if ($premiumID == NULL || $isDeleted) { | |
238 | $params = array( | |
239 | 'cost' => CRM_Utils_Array::value('cost', $productDetails), | |
240 | 'currency' => CRM_Utils_Array::value('currency', $productDetails), | |
241 | 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $productDetails), | |
21dfd5f5 | 242 | 'contributionId' => $contributionID, |
6a488035 TO |
243 | ); |
244 | if ($isDeleted) { | |
245 | $params['oldPremium']['product_id'] = $premoumDAO->product_id; | |
246 | $params['oldPremium']['contribution_id'] = $premoumDAO->contribution_id; | |
247 | } | |
248 | CRM_Core_BAO_FinancialTrxn::createPremiumTrxn($params); | |
249 | } | |
250 | } | |
251 | ||
252 | /** | |
100fef9d | 253 | * Process the Note |
6a488035 | 254 | * |
6a488035 | 255 | * |
c490a46a | 256 | * @param array $params |
100fef9d CW |
257 | * @param int $contactID |
258 | * @param int $contributionID | |
259 | * @param int $contributionNoteID | |
fd31fa4c | 260 | * |
355ba699 | 261 | * @return void |
6a488035 | 262 | */ |
00be9182 | 263 | public static function processNote(&$params, $contactID, $contributionID, $contributionNoteID = NULL) { |
6a488035 TO |
264 | //process note |
265 | $noteParams = array( | |
266 | 'entity_table' => 'civicrm_contribution', | |
267 | 'note' => $params['note'], | |
268 | 'entity_id' => $contributionID, | |
269 | 'contact_id' => $contactID, | |
270 | ); | |
271 | $noteID = array(); | |
272 | if ($contributionNoteID) { | |
273 | $noteID = array("id" => $contributionNoteID); | |
274 | $noteParams['note'] = $noteParams['note'] ? $noteParams['note'] : "null"; | |
275 | } | |
276 | CRM_Core_BAO_Note::add($noteParams, $noteID); | |
277 | } | |
278 | ||
279 | /** | |
100fef9d | 280 | * Process the Common data |
6a488035 | 281 | * |
6a488035 | 282 | * |
c490a46a | 283 | * @param array $params |
da6b46f4 | 284 | * @param $formatted |
c490a46a | 285 | * @param CRM_Core_Form $form |
355ba699 | 286 | * @return void |
6a488035 | 287 | */ |
00be9182 | 288 | public static function postProcessCommon(&$params, &$formatted, &$form) { |
6a488035 TO |
289 | $fields = array( |
290 | 'non_deductible_amount', | |
291 | 'total_amount', | |
292 | 'fee_amount', | |
293 | 'net_amount', | |
294 | 'trxn_id', | |
295 | 'invoice_id', | |
933c5f44 | 296 | 'creditnote_id', |
6a488035 | 297 | 'campaign_id', |
6a488035 TO |
298 | 'contribution_page_id', |
299 | ); | |
300 | foreach ($fields as $f) { | |
301 | $formatted[$f] = CRM_Utils_Array::value($f, $params); | |
302 | } | |
303 | ||
a7488080 | 304 | if (!empty($params['thankyou_date']) && !CRM_Utils_System::isNull($params['thankyou_date'])) { |
6a488035 TO |
305 | $formatted['thankyou_date'] = CRM_Utils_Date::processDate($params['thankyou_date'], $params['thankyou_date_time']); |
306 | } | |
307 | else { | |
308 | $formatted['thankyou_date'] = 'null'; | |
309 | } | |
310 | ||
a7488080 | 311 | if (!empty($params['is_email_receipt'])) { |
6a488035 TO |
312 | $params['receipt_date'] = $formatted['receipt_date'] = date('YmdHis'); |
313 | } | |
314 | ||
6a488035 TO |
315 | //special case to handle if all checkboxes are unchecked |
316 | $customFields = CRM_Core_BAO_CustomField::getFields('Contribution', | |
317 | FALSE, | |
318 | FALSE, | |
319 | CRM_Utils_Array::value('financial_type_id', | |
320 | $params | |
321 | ) | |
322 | ); | |
323 | $formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($params, | |
324 | $customFields, | |
325 | CRM_Utils_Array::value('id', $params, NULL), | |
326 | 'Contribution' | |
327 | ); | |
328 | } | |
329 | ||
330 | /** | |
100fef9d | 331 | * Send email receipt. |
6a488035 | 332 | * |
c490a46a | 333 | * @param CRM_Core_Form $form |
76e7a76c | 334 | * instance of Contribution form. |
014c4014 TO |
335 | * @param array $params |
336 | * (reference ) an assoc array of name/value pairs. | |
da6b46f4 | 337 | * @param bool $ccContribution |
76e7a76c | 338 | * is it credit card contribution. |
6a488035 | 339 | * |
d77a0a58 | 340 | * @return array |
6a488035 | 341 | */ |
00be9182 | 342 | public static function emailReceipt(&$form, &$params, $ccContribution = FALSE) { |
3f4b742c | 343 | $form->assign('receiptType', 'contribution'); |
6a488035 TO |
344 | // Retrieve Financial Type Name from financial_type_id |
345 | $params['contributionType_name'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', | |
346 | $params['financial_type_id']); | |
a7488080 | 347 | if (!empty($params['payment_instrument_id'])) { |
6a488035 TO |
348 | $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument(); |
349 | $params['paidBy'] = $paymentInstrument[$params['payment_instrument_id']]; | |
350 | } | |
351 | ||
352 | // retrieve individual prefix value for honoree | |
1421174e | 353 | if (isset($params['soft_credit'])) { |
354 | $softCreditTypes = $softCredits = array(); | |
355 | foreach ($params['soft_credit'] as $key => $softCredit) { | |
356 | $softCredits[$key] = array( | |
357 | 'Name' => $softCredit['contact_name'], | |
21dfd5f5 | 358 | 'Amount' => CRM_Utils_Money::format($softCredit['amount'], $softCredit['currency']), |
1421174e | 359 | ); |
360 | $softCreditTypes[$key] = $softCredit['soft_credit_type_label']; | |
361 | } | |
362 | $form->assign('softCreditTypes', $softCreditTypes); | |
363 | $form->assign('softCredits', $softCredits); | |
6a488035 TO |
364 | } |
365 | ||
366 | // retrieve premium product name and assigned fulfilled | |
367 | // date to template | |
a7488080 | 368 | if (!empty($params['hidden_Premium'])) { |
6a488035 TO |
369 | if (isset($params['product_name']) && |
370 | is_array($params['product_name']) && | |
371 | !empty($params['product_name']) | |
372 | ) { | |
373 | $productDAO = new CRM_Contribute_DAO_Product(); | |
374 | $productDAO->id = $params['product_name'][0]; | |
375 | $productDAO->find(TRUE); | |
376 | $params['product_name'] = $productDAO->name; | |
377 | $params['product_sku'] = $productDAO->sku; | |
378 | ||
33421d01 | 379 | if (empty($params['product_option']) && !empty($form->_options[$params['product_name'][0]])) { |
6a488035 TO |
380 | $params['product_option'] = $form->_options[$params['product_name'][0]][$params['product_name'][1]]; |
381 | } | |
382 | } | |
383 | ||
a7488080 | 384 | if (!empty($params['fulfilled_date'])) { |
3f4b742c | 385 | $form->assign('fulfilled_date', CRM_Utils_Date::processDate($params['fulfilled_date'])); |
6a488035 TO |
386 | } |
387 | } | |
388 | ||
3f4b742c | 389 | $form->assign('ccContribution', $ccContribution); |
6a488035 TO |
390 | if ($ccContribution) { |
391 | //build the name. | |
392 | $name = CRM_Utils_Array::value('billing_first_name', $params); | |
a7488080 | 393 | if (!empty($params['billing_middle_name'])) { |
6a488035 TO |
394 | $name .= " {$params['billing_middle_name']}"; |
395 | } | |
396 | $name .= ' ' . CRM_Utils_Array::value('billing_last_name', $params); | |
397 | $name = trim($name); | |
3f4b742c | 398 | $form->assign('billingName', $name); |
6a488035 TO |
399 | |
400 | //assign the address formatted up for display | |
401 | $addressParts = array( | |
402 | "street_address" => "billing_street_address-{$form->_bltID}", | |
403 | "city" => "billing_city-{$form->_bltID}", | |
404 | "postal_code" => "billing_postal_code-{$form->_bltID}", | |
405 | "state_province" => "state_province-{$form->_bltID}", | |
406 | "country" => "country-{$form->_bltID}", | |
407 | ); | |
408 | ||
409 | $addressFields = array(); | |
410 | foreach ($addressParts as $name => $field) { | |
411 | $addressFields[$name] = CRM_Utils_Array::value($field, $params); | |
412 | } | |
3f4b742c | 413 | $form->assign('address', CRM_Utils_Address::format($addressFields)); |
6a488035 TO |
414 | |
415 | $date = CRM_Utils_Date::format($params['credit_card_exp_date']); | |
416 | $date = CRM_Utils_Date::mysqlToIso($date); | |
3f4b742c KJ |
417 | $form->assign('credit_card_type', CRM_Utils_Array::value('credit_card_type', $params)); |
418 | $form->assign('credit_card_exp_date', $date); | |
419 | $form->assign('credit_card_number', | |
6a488035 TO |
420 | CRM_Utils_System::mungeCreditCard($params['credit_card_number']) |
421 | ); | |
422 | } | |
423 | else { | |
424 | //offline contribution | |
425 | // assigned various dates to the templates | |
426 | $form->assign('receipt_date', CRM_Utils_Date::processDate($params['receipt_date'])); | |
427 | ||
a7488080 | 428 | if (!empty($params['cancel_date'])) { |
6a488035 TO |
429 | $form->assign('cancel_date', CRM_Utils_Date::processDate($params['cancel_date'])); |
430 | } | |
a7488080 | 431 | if (!empty($params['thankyou_date'])) { |
6a488035 TO |
432 | $form->assign('thankyou_date', CRM_Utils_Date::processDate($params['thankyou_date'])); |
433 | } | |
434 | if ($form->_action & CRM_Core_Action::UPDATE) { | |
435 | $form->assign('lineItem', empty($form->_lineItems) ? FALSE : $form->_lineItems); | |
436 | } | |
437 | } | |
438 | ||
439 | //handle custom data | |
a7488080 | 440 | if (!empty($params['hidden_custom'])) { |
6a488035 TO |
441 | $contribParams = array(array('contribution_id', '=', $params['contribution_id'], 0, 0)); |
442 | if ($form->_mode == 'test') { | |
443 | $contribParams[] = array('contribution_test', '=', 1, 0, 0); | |
444 | } | |
445 | ||
446 | //retrieve custom data | |
447 | $customGroup = array(); | |
448 | ||
449 | foreach ($form->_groupTree as $groupID => $group) { | |
450 | $customFields = $customValues = array(); | |
451 | if ($groupID == 'info') { | |
452 | continue; | |
453 | } | |
454 | foreach ($group['fields'] as $k => $field) { | |
455 | $field['title'] = $field['label']; | |
456 | $customFields["custom_{$k}"] = $field; | |
457 | } | |
458 | ||
459 | //build the array of customgroup contain customfields. | |
460 | CRM_Core_BAO_UFGroup::getValues($params['contact_id'], $customFields, $customValues, FALSE, $contribParams); | |
461 | $customGroup[$group['title']] = $customValues; | |
462 | } | |
463 | //assign all custom group and corresponding fields to template. | |
464 | $form->assign('customGroup', $customGroup); | |
465 | } | |
466 | ||
467 | $form->assign_by_ref('formValues', $params); | |
468 | list($contributorDisplayName, | |
469 | $contributorEmail | |
470 | ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($params['contact_id']); | |
3f4b742c KJ |
471 | $form->assign('contactID', $params['contact_id']); |
472 | $form->assign('contributionID', $params['contribution_id']); | |
6a488035 | 473 | |
a7488080 | 474 | if (!empty($params['currency'])) { |
3f4b742c | 475 | $form->assign('currency', $params['currency']); |
6a488035 TO |
476 | } |
477 | ||
a7488080 | 478 | if (!empty($params['receive_date'])) { |
3f4b742c | 479 | $form->assign('receive_date', CRM_Utils_Date::processDate($params['receive_date'])); |
6a488035 TO |
480 | } |
481 | ||
353ffa53 TO |
482 | $template = CRM_Core_Smarty::singleton(); |
483 | $taxAmt = $template->get_template_vars('dataArray'); | |
484 | $eventTaxAmt = $template->get_template_vars('totalTaxAmount'); | |
485 | $prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings'); | |
486 | $invoicing = CRM_Utils_Array::value('invoicing', $prefixValue); | |
487 | if ((!empty($taxAmt) || isset($eventTaxAmt)) && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) { | |
488 | $isEmailPdf = TRUE; | |
489 | } | |
490 | else { | |
491 | $isEmailPdf = FALSE; | |
492 | } | |
d75f2f47 | 493 | |
c6327d7d | 494 | list($sendReceipt, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate( |
6a488035 TO |
495 | array( |
496 | 'groupName' => 'msg_tpl_workflow_contribution', | |
497 | 'valueName' => 'contribution_offline_receipt', | |
498 | 'contactId' => $params['contact_id'], | |
499 | 'contributionId' => $params['contribution_id'], | |
500 | 'from' => $params['from_email_address'], | |
501 | 'toName' => $contributorDisplayName, | |
502 | 'toEmail' => $contributorEmail, | |
503 | 'isTest' => $form->_mode == 'test', | |
92fcb95f | 504 | 'PDFFilename' => ts('receipt') . '.pdf', |
9161952c | 505 | 'isEmailPdf' => $isEmailPdf, |
6a488035 TO |
506 | ) |
507 | ); | |
508 | ||
509 | return $sendReceipt; | |
510 | } | |
511 | ||
512 | } |