Пример #1
0
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     require_once 'CRM/Utils/Money.php';
     // 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');
     $default = array();
     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'));
         // 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'));
     $paymentProcessor =& CRM_Core_PseudoConstant::paymentProcessor();
     if (count($paymentProcessor)) {
         $this->assign('paymentProcessor', $paymentProcessor);
     }
     $this->add('select', 'payment_processor_id', ts('Payment Processor'), array('' => ts('- select -')) + $paymentProcessor);
     require_once "CRM/Contribute/BAO/ContributionPage.php";
     //check if selected payment processor supports recurring payment
     if (CRM_Contribute_BAO_ContributionPage::checkRecurPaymentProcessor($this->_id)) {
         $this->addElement('checkbox', 'is_recur', ts('Recurring contributions'), null, array('onclick' => "return showHideByValue('is_recur',true,'recurFields','table-row','radio',false);"));
         require_once 'CRM/Core/OptionGroup.php';
         $this->addCheckBox('recur_frequency_unit', ts('Supported recurring units'), CRM_Core_OptionGroup::values('recur_frequency_units', false, false, false, null, 'name'), null, null, null, null, array('&nbsp;&nbsp;', '&nbsp;&nbsp;', '&nbsp;&nbsp;', '<br/>'));
         $this->addElement('checkbox', 'is_recur_interval', ts('Support recurring intervals'));
     }
     // add pay later options
     $this->addElement('checkbox', 'is_pay_later', ts('Pay later option'), null, array('onclick' => "payLater(this);"));
     $this->addElement('textarea', 'pay_later_text', ts('Pay later label'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'pay_later_text'), false);
     $this->addElement('textarea', 'pay_later_receipt', ts('Pay later instructions'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'pay_later_receipt'), false);
     // add price set fields
     require_once 'CRM/Price/BAO/Set.php';
     $this->add('select', 'price_set_id', ts('Price Set'), array('' => ts('- none -')) + CRM_Price_BAO_Set::getAssoc(false, 'Contribution'), 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);
         require_once 'CRM/Core/OptionGroup.php';
         $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, false, null, 'name'), null, null, null, null, array('&nbsp;&nbsp;', '&nbsp;&nbsp;', '&nbsp;&nbsp;', '<br/>'));
         $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));
     }
     $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Amount', 'formRule'), $this);
     parent::buildQuickForm();
 }
Пример #2
0
 /**
  * test checkRecurPaymentProcessor() method
  */
 function testcheckRecurPaymentProcessor()
 {
     $paymentProcessor = PaypalPro::create();
     $params = array('title' => 'Test Cotribution Page', 'contribution_type_id' => $this->_contributionTypeID, 'is_active' => 1, 'payment_processor_id' => $paymentProcessor);
     require_once 'CRM/Contribute/BAO/ContributionPage.php';
     $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params, $ids);
     $id = $contributionpage->id;
     $checkRecurring = CRM_Contribute_BAO_ContributionPage::checkRecurPaymentProcessor($id);
     $this->assertEquals($checkRecurring, false, 'Check for false return.');
 }
 /**
  * test checkRecurPaymentProcessor() method
  */
 function testcheckRecurPaymentProcessor()
 {
     //@todo paypalpro create seems to fail silently without causing this class to fail
     // $this->paymentProcessorCreate may be a better option
     $paymentProcessor = PaypalPro::create();
     $params = array('title' => 'Test Contribution Page', 'financial_type_id' => $this->_financialTypeID, 'is_active' => 1, 'payment_processor_id' => $paymentProcessor);
     $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params);
     $id = $contributionpage->id;
     $checkRecurring = CRM_Contribute_BAO_ContributionPage::checkRecurPaymentProcessor($id);
     $this->assertEquals($checkRecurring, FALSE, 'Check for false return.');
     ContributionPage::delete($contributionpage->id);
 }