/** * Flush processors from static cache. * * This is particularly used for tests. */ public function flushProcessors() { $this->cache = array(); \CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('all', TRUE); \CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('live', TRUE); \CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('test', TRUE); }
/** * Build the form object. */ public function buildQuickForm() { // do u want to allow a free form text field for amount $this->addElement('checkbox', 'is_allow_other_amount', ts('Allow other amounts'), NULL, array('onclick' => "minMax(this);showHideAmountBlock( this, 'is_allow_other_amount' );")); $this->add('text', 'min_amount', ts('Minimum Amount'), array('size' => 8, 'maxlength' => 8)); $this->addRule('min_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money'); $this->add('text', 'max_amount', ts('Maximum Amount'), array('size' => 8, 'maxlength' => 8)); $this->addRule('max_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); //CRM-12055 $this->add('text', 'amount_label', ts('Contribution Amounts Label')); $default = array($this->createElement('radio', NULL, NULL, NULL, 0)); $this->add('hidden', "price_field_id", '', array('id' => "price_field_id")); $this->add('hidden', "price_field_other", '', array('id' => "price_field_option")); for ($i = 1; $i <= self::NUM_OPTION; $i++) { // label $this->add('text', "label[{$i}]", ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label')); $this->add('hidden', "price_field_value[{$i}]", '', array('id' => "price_field_value[{$i}]")); // value $this->add('text', "value[{$i}]", ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value')); $this->addRule("value[{$i}]", ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); // default $default[] = $this->createElement('radio', NULL, NULL, NULL, $i); } $this->addGroup($default, 'default'); $this->addElement('checkbox', 'amount_block_is_active', ts('Contribution Amounts section enabled'), NULL, array('onclick' => "showHideAmountBlock( this, 'amount_block_is_active' );")); $this->addElement('checkbox', 'is_monetary', ts('Execute real-time monetary transactions')); $paymentProcessors = CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('live'); $recurringPaymentProcessor = $futurePaymentProcessor = $paymentProcessor = array(); if (!empty($paymentProcessors)) { foreach ($paymentProcessors as $id => $processor) { if ($id != 0) { $paymentProcessor[$id] = $processor['name']; } if (CRM_Utils_Array::value('is_recur', $processor)) { $recurringPaymentProcessor[] = $id; } if (CRM_Utils_Array::value('object', $processor) && $processor['object']->supports('FutureRecurStartDate')) { $futurePaymentProcessor[] = $id; } } } if (count($recurringPaymentProcessor)) { $this->assign('recurringPaymentProcessor', $recurringPaymentProcessor); } if (count($futurePaymentProcessor)) { $this->assign('futurePaymentProcessor', $futurePaymentProcessor); } if (count($paymentProcessor)) { $this->assign('paymentProcessor', $paymentProcessor); } $this->addCheckBox('payment_processor', ts('Payment Processor'), array_flip($paymentProcessor), NULL, NULL, NULL, NULL, array(' ', ' ', ' ', '<br/>')); //check if selected payment processor supports recurring payment if (!empty($recurringPaymentProcessor)) { $this->addElement('checkbox', 'is_recur', ts('Recurring Contributions'), NULL, array('onclick' => "showHideByValue('is_recur',true,'recurFields','table-row','radio',false);")); $this->addCheckBox('recur_frequency_unit', ts('Supported recurring units'), CRM_Core_OptionGroup::values('recur_frequency_units', FALSE, FALSE, TRUE), NULL, NULL, NULL, NULL, array(' ', ' ', ' ', '<br/>'), TRUE); $this->addElement('checkbox', 'is_recur_interval', ts('Support recurring intervals')); $this->addElement('checkbox', 'is_recur_installments', ts('Offer installments')); } // add pay later options $this->addElement('checkbox', 'is_pay_later', ts('Pay later option'), NULL); $this->addElement('textarea', 'pay_later_text', ts('Pay later label'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'pay_later_text'), FALSE); $this->add('wysiwyg', 'pay_later_receipt', ts('Pay Later Instructions'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'pay_later_receipt')); $this->addElement('checkbox', 'is_billing_required', ts('Billing address required')); //add partial payment options // add price set fields $price = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviContribute'); if (CRM_Utils_System::isNull($price)) { $this->assign('price', FALSE); } else { $this->assign('price', TRUE); } $this->add('select', 'price_set_id', ts('Price Set'), array('' => ts('- none -')) + $price, NULL, array('onchange' => "showHideAmountBlock( this.value, 'price_set_id' );")); //CiviPledge fields. $config = CRM_Core_Config::singleton(); if (in_array('CiviPledge', $config->enableComponents)) { $this->assign('civiPledge', TRUE); $this->addElement('checkbox', 'is_pledge_active', ts('Pledges'), NULL, array('onclick' => "showHideAmountBlock( this, 'is_pledge_active' ); return showHideByValue('is_pledge_active',true,'pledgeFields','table-row','radio',false);")); $this->addCheckBox('pledge_frequency_unit', ts('Supported pledge frequencies'), CRM_Core_OptionGroup::values('recur_frequency_units', FALSE, FALSE, TRUE), NULL, NULL, NULL, NULL, array(' ', ' ', ' ', '<br/>'), TRUE); $this->addElement('checkbox', 'is_pledge_interval', ts('Allow frequency intervals')); $this->addElement('text', 'initial_reminder_day', ts('Send payment reminder'), array('size' => 3)); $this->addElement('text', 'max_reminders', ts('Send up to'), array('size' => 3)); $this->addElement('text', 'additional_reminder_day', ts('Send additional reminders'), array('size' => 3)); if (!empty($futurePaymentProcessor)) { // CRM-18854 $this->addElement('checkbox', 'adjust_recur_start_date', ts('Adjust Recurring Start Date'), NULL, array('onclick' => "showHideByValue('adjust_recur_start_date',true,'recurDefaults','table-row','radio',false);")); $this->addDate('pledge_calendar_date', ts('Specific Calendar Date')); $month = CRM_Utils_Date::getCalendarDayOfMonth(); $this->add('select', 'pledge_calendar_month', ts('Specific day of Month'), $month); $pledgeDefaults = array('contribution_date' => ts('Day of Contribution'), 'calendar_date' => ts('Specific Calendar Date'), 'calendar_month' => ts('Specific day of Month')); $this->addRadio('pledge_default_toggle', ts('Recurring Contribution Start Date Default'), $pledgeDefaults, array('allowClear' => FALSE), '<br/><br/>'); $this->addElement('checkbox', 'is_pledge_start_date_visible', ts('Show Recurring Donation Start Date?'), NULL); $this->addElement('checkbox', 'is_pledge_start_date_editable', ts('Allow Edits to Recurring Donation Start date?'), NULL); } } //add currency element. $this->addCurrency('currency', ts('Currency')); $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Amount', 'formRule'), $this); parent::buildQuickForm(); }