bulk comment fix
[civicrm-core.git] / CRM / Pledge / Form / Pledge.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
06b69b18 4 | CiviCRM version 4.5 |
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 +--------------------------------------------------------------------+
26*/
27
28/**
29 *
30 * @package CRM
06b69b18 31 * @copyright CiviCRM LLC (c) 2004-2014
6a488035
TO
32 * $Id$
33 *
34 */
35
36/**
37 * This class generates form components for processing a pledge
38 *
39 */
40class CRM_Pledge_Form_Pledge extends CRM_Core_Form {
41 public $_action;
42
43 /**
44 * the id of the pledge that we are proceessing
45 *
46 * @var int
47 * @public
48 */
49 public $_id;
50
51 /**
52 * the id of the contact associated with this pledge
53 *
54 * @var int
55 * @public
56 */
57 public $_contactID;
58
59 /**
60 * The Pledge values if an existing pledge
61 * @public
62 */
63 public $_values;
64
6a488035
TO
65 /**
66 * The Pledge frequency Units
67 * @public
68 */
69 public $_freqUnits;
70
71 /**
72 * is current pledge pending.
73 * @public
74 */
75 public $_isPending = FALSE;
76
77 /**
78 * Function to set variables up before form is built
79 *
80 * @return void
81 * @access public
82 */
83 public function preProcess() {
84 $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
85 $this->_action = CRM_Utils_Request::retrieve('action', 'String',
86 $this, FALSE, 'add'
87 );
88 $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
89 $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
90
91 // check for action permissions.
92 if (!CRM_Core_Permission::checkActionPermission('CiviPledge', $this->_action)) {
93 CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
94 }
95
96 $this->assign('action', $this->_action);
97 $this->assign('context', $this->_context);
98 if ($this->_action & CRM_Core_Action::DELETE) {
99 return;
100 }
101
102 $this->userDisplayName = $this->userEmail = NULL;
103 if ($this->_contactID) {
104 list($this->userDisplayName,
105 $this->userEmail
106 ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
107 $this->assign('displayName', $this->userDisplayName);
108
109 // set title to "Pledge - "+Contact Name
110 $displayName = $this->userDisplayName;
111 $pageTitle = ts('Pledge by'). ' ' . $displayName;
112 $this->assign('pageTitle', $pageTitle);
113 CRM_Utils_System::setTitle($pageTitle);
114 }
115
116 //build custom data
117 CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Pledge', $this->_id);
118
119 $this->_values = array();
120 // current pledge id
121 if ($this->_id) {
122 //get the contribution id
123 $this->_contributionID = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment',
124 $this->_id, 'contribution_id', 'pledge_id'
125 );
126 $params = array('id' => $this->_id);
127 CRM_Pledge_BAO_Pledge::getValues($params, $this->_values);
128
6a488035
TO
129 $paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
130
131 //check for pending pledge.
132 if (CRM_Utils_Array::value('status_id', $this->_values) ==
133 array_search('Pending', $paymentStatusTypes)
134 ) {
135 $this->_isPending = TRUE;
136 }
137 elseif (CRM_Utils_Array::value('status_id', $this->_values) ==
138 array_search('Overdue', $paymentStatusTypes)
139 ) {
140
141 $allPledgePayments = array();
142 CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment',
143 'pledge_id',
144 $this->_id,
145 $allPledgePayments,
146 array('status_id')
147 );
148
149 foreach ($allPledgePayments as $key => $value) {
150 $allStatus[$value['id']] = $paymentStatusTypes[$value['status_id']];
151 }
152
153 if (count(array_count_values($allStatus)) <= 2) {
154 if (CRM_Utils_Array::value('Pending', array_count_values($allStatus))) {
155 $this->_isPending = TRUE;
156 }
157 }
158 }
159 }
160
161 //get the pledge frequency units.
162 $this->_freqUnits = CRM_Core_OptionGroup::values('recur_frequency_units');
163
164 $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
165 }
166
167 /**
168 * This function sets the default values for the form.
169 * the default values are retrieved from the database
170 *
171 * @access public
172 *
355ba699 173 * @return void
6a488035
TO
174 */
175 function setDefaultValues() {
176 $defaults = $this->_values;
177
178 $fields = array();
179 if ($this->_action & CRM_Core_Action::DELETE) {
180 return $defaults;
181 }
182
a7488080 183 if (!empty($defaults['is_test'])) {
6a488035
TO
184 $this->assign('is_test', TRUE);
185 }
186
187 if ($this->_id) {
188 $startDate = CRM_Utils_Array::value('start_date', $this->_values);
189 $createDate = CRM_Utils_Array::value('create_date', $this->_values);
190 list($defaults['start_date']) = CRM_Utils_Date::setDateDefaults($startDate);
191 list($defaults['create_date']) = CRM_Utils_Date::setDateDefaults($createDate);
192
193 if ($ackDate = CRM_Utils_Array::value('acknowledge_date', $this->_values)) {
194 list($defaults['acknowledge_date']) = CRM_Utils_Date::setDateDefaults($ackDate);
195 }
196
197 //check is this pledge pending
198 // fix the display of the monetary value, CRM-4038
199 if ($this->_isPending) {
200 $defaults['eachPaymentAmount'] = $this->_values['amount'] / $this->_values['installments'];
201 $defaults['eachPaymentAmount'] = CRM_Utils_Money::format($defaults['eachPaymentAmount'], NULL, '%a');
202 }
203 else {
204 $this->assign('start_date', $startDate);
205 $this->assign('create_date', $createDate);
206 }
207 // fix the display of the monetary value, CRM-4038
208 if (isset($this->_values['amount'])) {
209 $defaults['amount'] = CRM_Utils_Money::format($this->_values['amount'], NULL, '%a');
210 }
211 $this->assign('amount', $this->_values['amount']);
212 $this->assign('installments', $defaults['installments']);
213 }
214 else {
215 //default values.
216 list($now) = CRM_Utils_Date::setDateDefaults();
217 $defaults['create_date'] = $now;
218 $defaults['start_date'] = $now;
219 $defaults['installments'] = 12;
220 $defaults['frequency_interval'] = 1;
221 $defaults['frequency_day'] = 1;
222 $defaults['initial_reminder_day'] = 5;
223 $defaults['max_reminders'] = 1;
224 $defaults['additional_reminder_day'] = 5;
225 $defaults['frequency_unit'] = array_search('month', $this->_freqUnits);
226 $defaults['financial_type_id'] = array_search( 'Donation', CRM_Contribute_PseudoConstant::financialType() );
227 }
228
229 $pledgeStatus = CRM_Contribute_PseudoConstant::contributionStatus();
230 $pledgeStatusNames = CRM_Core_OptionGroup::values('contribution_status',
231 FALSE, FALSE, FALSE, NULL, 'name', TRUE
232 );
233 // get default status label (pending)
234 $defaultPledgeStatus = CRM_Utils_Array::value(array_search('Pending', $pledgeStatusNames),
235 $pledgeStatus
236 );
237
238 //assign status.
239 $this->assign('status', CRM_Utils_Array::value(CRM_Utils_Array::value('status_id', $this->_values),
240 $pledgeStatus,
241 $defaultPledgeStatus
242 ));
243
6a488035
TO
244 if (isset($this->userEmail)) {
245 $this->assign('email', $this->userEmail);
246 }
247
248 // custom data set defaults
249 $defaults += CRM_Custom_Form_CustomData::setDefaultValues($this);
250
251 return $defaults;
252 }
253
254 /**
255 * Function to build the form
256 *
355ba699 257 * @return void
6a488035
TO
258 * @access public
259 */
260 public function buildQuickForm() {
261 if ($this->_action & CRM_Core_Action::DELETE) {
262 $this->addButtons(array(
263 array(
264 'type' => 'next',
265 'name' => ts('Delete'),
266 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
267 'isDefault' => TRUE,
268 ),
269 array(
270 'type' => 'cancel',
271 'name' => ts('Cancel'),
272 ),
273 )
274 );
275 return;
276 }
277
278 if ($this->_context == 'standalone') {
b9aa8f56 279 $this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE), TRUE);
6a488035
TO
280 }
281
282 $showAdditionalInfo = FALSE;
283 $this->_formType = CRM_Utils_Array::value('formType', $_GET);
284
6a488035 285 $defaults = array();
6a488035
TO
286
287 $paneNames = array(
6a488035
TO
288 'Payment Reminders' => 'PaymentReminders',
289 );
290 foreach ($paneNames as $name => $type) {
291 $urlParams = "snippet=4&formType={$type}";
292 $allPanes[$name] = array('url' => CRM_Utils_System::url('civicrm/contact/view/pledge', $urlParams),
293 'open' => 'false',
294 'id' => $type,
295 );
296 //see if we need to include this paneName in the current form
8cc574cf 297 if ($this->_formType == $type || !empty($_POST["hidden_{$type}"]) ||
6a488035
TO
298 CRM_Utils_Array::value("hidden_{$type}", $defaults)
299 ) {
300 $showAdditionalInfo = TRUE;
301 $allPanes[$name]['open'] = 'true';
302 }
0e6e8724
DL
303 $fnName = "build{$type}";
304 CRM_Contribute_Form_AdditionalInfo::$fnName($this);
6a488035
TO
305 }
306
307 $this->assign('allPanes', $allPanes);
308 $this->assign('showAdditionalInfo', $showAdditionalInfo);
309
310 if ($this->_formType) {
311 $this->assign('formType', $this->_formType);
312 return;
313 }
314
315 $this->applyFilter('__ALL__', 'trim');
316
317 //pledge fields.
318 $attributes = CRM_Core_DAO::getAttribute('CRM_Pledge_DAO_Pledge');
319
320 $this->assign('isPending', $this->_isPending);
321
322 $js = array(
323 'onblur' => "calculatedPaymentAmount( );",
324 'onkeyup' => "calculatedPaymentAmount( );",
325 );
326
327 $currencyFreeze = FALSE;
328 if ($this->_id &&
329 !$this->_isPending
330 ) {
331 $currencyFreeze = TRUE;
332 }
333
334 $element = $this->addMoney('amount', ts('Total Pledge Amount'), TRUE,
335 array_merge($attributes['pledge_amount'], $js), TRUE,
336 'currency', NULL, $currencyFreeze
337 );
338
339 if ($this->_id &&
340 !$this->_isPending
341 ) {
342 $element->freeze();
343 }
344
345 $element = &$this->add('text', 'installments', ts('To be paid in'),
346 array_merge($attributes['installments'], $js), TRUE
347 );
348 $this->addRule('installments', ts('Please enter a valid number of installments.'), 'positiveInteger');
349 if ($this->_id &&
350 !$this->_isPending
351 ) {
352 $element->freeze();
353 }
354
355 $element = &$this->add('text', 'frequency_interval', ts('every'),
356 $attributes['pledge_frequency_interval'], TRUE
357 );
358 $this->addRule('frequency_interval', ts('Please enter a number for frequency (e.g. every "3" months).'), 'positiveInteger');
359 if ($this->_id &&
360 !$this->_isPending
361 ) {
362 $element->freeze();
363 }
364
365 // Fix frequency unit display for use with frequency_interval
366 $freqUnitsDisplay = array();
367 foreach ($this->_freqUnits as $val => $label) {
368 $freqUnitsDisplay[$val] = ts('%1(s)', array(1 => $label));
369 }
370 $element = &$this->add('select', 'frequency_unit',
371 ts('Frequency'),
372 array(
373 '' => ts('- select -')) + $freqUnitsDisplay,
374 TRUE
375 );
376
377 if ($this->_id &&
378 !$this->_isPending
379 ) {
380 $element->freeze();
381 }
382
383 $element = &$this->add('text', 'frequency_day', ts('Payments are due on the'), $attributes['frequency_day'], TRUE);
384 $this->addRule('frequency_day', ts('Please enter a valid payment due day.'), 'positiveInteger');
385 if ($this->_id &&
386 !$this->_isPending
387 ) {
388 $element->freeze();
389 }
390
391 $this->add('text', 'eachPaymentAmount', ts('each'), array('size' => 10, 'style' => "background-color:#EBECE4", 'READONLY'));
392
393 //add various dates
394 if (!$this->_id || $this->_isPending) {
395 $this->addDate('create_date', ts('Pledge Made'), TRUE);
396 $this->addDate('start_date', ts('Payments Start'), TRUE);
397 }
398
399 if ($this->_id &&
400 !$this->_isPending
401 ) {
402 $eachPaymentAmount = $this->_values['original_installment_amount'];
403 $this->assign('currency', $this->_values['currency']);
404 $this->assign('eachPaymentAmount', $eachPaymentAmount);
405 $this->assign('hideCalender', TRUE);
406 }
407
408 if (CRM_Utils_Array::value('status_id', $this->_values) !=
409 array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'))
410 ) {
411
412 $this->addElement('checkbox', 'is_acknowledge', ts('Send Acknowledgment?'), NULL,
413 array('onclick' => "showHideByValue( 'is_acknowledge', '', 'acknowledgeDate', 'table-row', 'radio', true); showHideByValue( 'is_acknowledge', '', 'fromEmail', 'table-row', 'radio', false );")
414 );
415
416 $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails);
417 }
418
419 $this->addDate('acknowledge_date', ts('Acknowledgment Date'));
420
366fe2a3 421 $this->add('select', 'financial_type_id',
422 ts( 'Financial Type' ),
6a488035
TO
423 array(''=>ts( '- select -' )) + CRM_Contribute_PseudoConstant::financialType( ),
424 TRUE
425 );
426
427 //CRM-7362 --add campaigns.
428 CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
429
430 $pageIds = array();
431 CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgeBlock', 'entity_table',
432 'civicrm_contribution_page', $pageIds, array('entity_id')
433 );
434 $pages = CRM_Contribute_PseudoConstant::contributionPage();
435 $pledgePages = array();
436 foreach ($pageIds as $key => $value) {
437 $pledgePages[$value['entity_id']] = $pages[$value['entity_id']];
438 }
439 $ele = $this->add('select', 'contribution_page_id', ts('Self-service Payments Page'),
440 array(
441 '' => ts('- select -')) + $pledgePages
442 );
443
444 $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
445 'mailing_backend'
446 );
447 $this->assign('outBound_option', $mailingInfo['outBound_option']);
448
449 //build custom data
450 CRM_Custom_Form_CustomData::buildQuickForm($this);
451
452 // make this form an upload since we dont know if the custom data injected dynamically
453 // is of type file etc $uploadNames = $this->get( 'uploadNames' );
454 $this->addButtons(array(
455 array(
456 'type' => 'upload',
457 'name' => ts('Save'),
458 'js' => array('onclick' => "return verify( );"),
459 'isDefault' => TRUE,
460 ),
461 array(
462 'type' => 'upload',
463 'name' => ts('Save and New'),
464 'js' => array('onclick' => "return verify( );"),
465 'subName' => 'new',
466 ),
467 array(
468 'type' => 'cancel',
469 'name' => ts('Cancel'),
470 ),
471 )
472 );
473
474 $this->addFormRule(array('CRM_Pledge_Form_Pledge', 'formRule'), $this);
475
476 if ($this->_action & CRM_Core_Action::VIEW) {
477 $this->freeze();
478 }
479 }
480
481 /**
482 * global form rule
483 *
484 * @param array $fields the input form values
485 * @param array $files the uploaded files if any
486 * @param array $options additional user data
487 *
488 * @return true if no errors, else array of errors
489 * @access public
490 * @static
491 */
492 static function formRule($fields, $files, $self) {
493 $errors = array();
494
6a488035
TO
495 if ($fields['amount'] <= 0) {
496 $errors['amount'] = ts('Total Pledge Amount should be greater than zero.');
497 }
498 if ($fields['installments'] <= 0) {
499 $errors['installments'] = ts('Installments should be greater than zero.');
500 }
501
502 if ($fields['frequency_unit'] != 'week') {
503 if ($fields['frequency_day'] > 31 || $fields['frequency_day'] == 0) {
504 $errors['frequency_day'] = ts('Please enter a valid frequency day ie. 1 through 31.');
505 }
506 }
507 elseif ($fields['frequency_unit'] == 'week') {
508 if ($fields['frequency_day'] > 7 || $fields['frequency_day'] == 0) {
509 $errors['frequency_day'] = ts('Please enter a valid frequency day ie. 1 through 7.');
510 }
511 }
512 return $errors;
513 }
514
515 /**
516 * Function to process the form
517 *
518 * @access public
519 *
355ba699 520 * @return void
6a488035
TO
521 */
522 public function postProcess() {
523 if ($this->_action & CRM_Core_Action::DELETE) {
524 CRM_Pledge_BAO_Pledge::deletePledge($this->_id);
525 return;
526 }
527
528 //get the submitted form values.
529 $formValues = $this->controller->exportValues($this->_name);
530
531 // set the contact, when contact is selected
b9aa8f56
CW
532 if (!empty($formValues['contact_id'])) {
533 $this->_contactID = $formValues['contact_id'];
6a488035
TO
534 }
535
6a488035
TO
536 $session = CRM_Core_Session::singleton();
537
538 //get All Payments status types.
539 $paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
540
541 $fields = array(
542 'frequency_unit',
543 'frequency_interval',
544 'frequency_day',
545 'installments',
b9aa8f56 546 'financial_type_id',
6a488035
TO
547 'initial_reminder_day',
548 'max_reminders',
549 'additional_reminder_day',
6a488035
TO
550 'contribution_page_id',
551 'campaign_id',
552 );
553 foreach ($fields as $f) {
554 $params[$f] = CRM_Utils_Array::value($f, $formValues);
555 }
556
557 //defaults status is "Pending".
558 //if update get status.
559 if ($this->_id) {
560 $params['pledge_status_id'] = $params['status_id'] = $this->_values['status_id'];
561 }
562 else {
563 $params['pledge_status_id'] = $params['status_id'] = array_search('Pending', $paymentStatusTypes);
564 }
565 //format amount
566 $params['amount'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('amount', $formValues));
567 $params['currency'] = CRM_Utils_Array::value('currency', $formValues);
568 $params['original_installment_amount'] = ($params['amount'] / $params['installments']);
569
570 $dates = array('create_date', 'start_date', 'acknowledge_date', 'cancel_date');
571 foreach ($dates as $d) {
8cc574cf 572 if ($this->_id && (!$this->_isPending) && !empty($this->_values[$d])) {
6a488035
TO
573 if ($d == 'start_date') {
574 $params['scheduled_date'] = CRM_Utils_Date::processDate($this->_values[$d]);
575 }
576 $params[$d] = CRM_Utils_Date::processDate($this->_values[$d]);
577 }
a7488080 578 elseif (!empty($formValues[$d]) && !CRM_Utils_System::isNull($formValues[$d])) {
6a488035
TO
579 if ($d == 'start_date') {
580 $params['scheduled_date'] = CRM_Utils_Date::processDate($formValues[$d]);
581 }
582 $params[$d] = CRM_Utils_Date::processDate($formValues[$d]);
583 }
584 else {
585 $params[$d] = 'null';
586 }
587 }
588
a7488080 589 if (!empty($formValues['is_acknowledge'])) {
6a488035
TO
590 $params['acknowledge_date'] = date('Y-m-d');
591 }
592
593 // assign id only in update mode
594 if ($this->_action & CRM_Core_Action::UPDATE) {
595 $params['id'] = $this->_id;
596 }
597
598 $params['contact_id'] = $this->_contactID;
599
6a488035 600 //format custom data
a7488080 601 if (!empty($formValues['hidden_custom'])) {
6a488035
TO
602 $params['hidden_custom'] = 1;
603
604 $customFields = CRM_Core_BAO_CustomField::getFields('Pledge');
605 $params['custom'] = CRM_Core_BAO_CustomField::postProcess($formValues,
606 $customFields,
607 $this->_id,
608 'Pledge'
609 );
610 }
611
612 //handle pending pledge.
613 $params['is_pledge_pending'] = $this->_isPending;
614
615 //create pledge record.
616 $pledge = CRM_Pledge_BAO_Pledge::create($params);
617
618 $statusMsg = NULL;
619
620 if ($pledge->id) {
621 //set the status msg.
622 if ($this->_action & CRM_Core_Action::ADD) {
623 $statusMsg = ts('Pledge has been recorded and the payment schedule has been created.<br />');
624 }
625 elseif ($this->_action & CRM_Core_Action::UPDATE) {
626 $statusMsg = ts('Pledge has been updated.<br />');
627 }
628 }
629
630 //handle Acknowledgment.
a7488080 631 if (!empty($formValues['is_acknowledge']) && $pledge->id) {
6a488035
TO
632
633 //calculate scheduled amount.
634 $params['scheduled_amount'] = round($params['amount'] / $params['installments']);
635 $params['total_pledge_amount'] = $params['amount'];
636 //get some required pledge values in params.
637 $params['id'] = $pledge->id;
638 $params['acknowledge_date'] = $pledge->acknowledge_date;
639 $params['is_test'] = $pledge->is_test;
640 $params['currency'] = $pledge->currency;
641 // retrieve 'from email id' for acknowledgement
642 $params['from_email_id'] = $formValues['from_email_address'];
643
644 $this->paymentId = NULL;
645 //send Acknowledgment mail.
646 CRM_Pledge_BAO_Pledge::sendAcknowledgment($this, $params);
647
648 if (!isset($this->userEmail)) {
649 list($this->userDisplayName,
650 $this->userEmail
651 ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
652 }
653
654 $statusMsg .= ' ' . ts("An acknowledgment email has been sent to %1.<br />", array(1 => $this->userEmail));
655
656 //build the payment urls.
657 if ($this->paymentId) {
658 $urlParams = "reset=1&action=add&cid={$this->_contactID}&ppid={$this->paymentId}&context=pledge";
659 $contribURL = CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams);
660 $urlParams .= "&mode=live";
661 $creditURL = CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams);
662
663 //check if we can process credit card payment.
664 $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE,
665 "billing_mode IN ( 1, 3 )"
666 );
667 if (count($processors) > 0) {
668 $statusMsg .= ' ' . ts("If a payment is due now, you can record <a href='%1'>a check, EFT, or cash payment for this pledge</a> OR <a href='%2'>submit a credit card payment</a>.", array(1 => $contribURL, 2 => $creditURL));
669 }
670 else {
671 $statusMsg .= ' ' . ts("If a payment is due now, you can record <a href='%1'>a check, EFT, or cash payment for this pledge</a>.", array(1 => $contribURL));
672 }
673 }
674 }
675 CRM_Core_Session::setStatus($statusMsg, ts('Payment Due'), 'info');
676
677 $buttonName = $this->controller->getButtonName();
678 if ($this->_context == 'standalone') {
679 if ($buttonName == $this->getButtonName('upload', 'new')) {
680 $session->replaceUserContext(CRM_Utils_System::url('civicrm/pledge/add',
681 'reset=1&action=add&context=standalone'
682 ));
683 }
684 else {
685 $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view',
686 "reset=1&cid={$this->_contactID}&selectedChild=pledge"
687 ));
688 }
689 }
690 elseif ($buttonName == $this->getButtonName('upload', 'new')) {
691 $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/pledge',
692 "reset=1&action=add&context=pledge&cid={$this->_contactID}"
693 ));
694 }
695 }
696}
697