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