/**
  * View details of a recurring contribution.
  */
 public function view()
 {
     $recur = new CRM_Contribute_DAO_ContributionRecur();
     $recur->id = $this->_id;
     if ($recur->find(TRUE)) {
         $values = array();
         CRM_Core_DAO::storeValues($recur, $values);
         // if there is a payment processor ID, get the name of the payment processor
         if (!empty($values['payment_processor_id'])) {
             $values['payment_processor'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor', $values['payment_processor_id'], 'name');
         }
         $idFields = array('contribution_status_id', 'campaign_id');
         if (CRM_Contribute_BAO_ContributionRecur::supportsFinancialTypeChange($values['id'])) {
             $idFields[] = 'financial_type_id';
         }
         foreach ($idFields as $idField) {
             if (!empty($values[$idField])) {
                 $values[substr($idField, 0, -3)] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_ContributionRecur', $idField, $values[$idField]);
             }
         }
         // Get financial type name
         if (!empty($values['financial_type_id'])) {
             $values['financial_type_name'] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_Contribution', 'financial_type_id', $values['financial_type_id']);
         }
         // Get Paid By label
         if (!empty($values['payment_instrument_id'])) {
             $values['payment_instrument'] = CRM_Core_OptionGroup::getLabel('payment_instrument', $values['payment_instrument_id']);
         }
         $this->assign('recur', $values);
         $this->assign('customDataType', 'ContributionRecur');
         $groupTree = CRM_Core_BAO_CustomGroup::getTree('ContributionRecur', $this, $this->_id);
         CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     }
 }
コード例 #2
0
 /**
  * View details of a recurring contribution.
  */
 public function view()
 {
     $recur = new CRM_Contribute_DAO_ContributionRecur();
     $recur->id = $this->_id;
     if ($recur->find(TRUE)) {
         $values = array();
         CRM_Core_DAO::storeValues($recur, $values);
         // if there is a payment processor ID, get the name of the payment processor
         if (!empty($values['payment_processor_id'])) {
             $values['payment_processor'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor', $values['payment_processor_id'], 'name');
         }
         $idFields = array('contribution_status_id', 'campaign_id');
         if (CRM_Contribute_BAO_ContributionRecur::supportsFinancialTypeChange($values['id'])) {
             $idFields[] = 'financial_type_id';
         }
         foreach ($idFields as $idField) {
             if (!empty($values[$idField])) {
                 $values[substr($idField, 0, -3)] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_ContributionRecur', $idField, $values[$idField]);
             }
         }
         $this->assign('recur', $values);
     }
 }
コード例 #3
0
 /**
  * Actually build the components of the form.
  */
 public function buildQuickForm()
 {
     // CRM-16398: If current recurring contribution got > 1 lineitems then make amount field readonly
     $amtAttr = array('size' => 20);
     $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($this->_coid);
     if (count($lineItems) > 1) {
         $amtAttr += array('readonly' => TRUE);
     }
     $this->addMoney('amount', ts('Recurring Contribution Amount'), TRUE, $amtAttr, TRUE, 'currency', $this->_subscriptionDetails->currency, TRUE);
     $this->add('text', 'installments', ts('Number of Installments'), array('size' => 20), FALSE);
     if ($this->_donorEmail) {
         $this->add('checkbox', 'is_notify', ts('Notify Contributor?'));
     }
     if (CRM_Core_Permission::check('edit contributions')) {
         CRM_Campaign_BAO_Campaign::addCampaign($this, $this->_subscriptionDetails->campaign_id);
     }
     if (CRM_Contribute_BAO_ContributionRecur::supportsFinancialTypeChange($this->contributionRecurID)) {
         $this->addEntityRef('financial_type_id', ts('Financial Type'), array('entity' => 'FinancialType'), TRUE);
     }
     $type = 'next';
     if ($this->_selfService) {
         $type = 'submit';
     }
     // define the buttons
     $this->addButtons(array(array('type' => $type, 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
コード例 #4
0
 /**
  * Test checking if contribution recurr object can allow for changes to financial types.
  *
  */
 public function testSupportFinancialTypeChange()
 {
     $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', $this->_params);
     $contribution = $this->callAPISuccess('contribution', 'create', array('contribution_recur_id' => $contributionRecur['id'], 'total_amount' => '3.00', 'financial_type_id' => 1, 'payment_instrument_id' => 1, 'currency' => 'USD', 'contact_id' => $this->individualCreate(), 'contribution_status_id' => 1, 'recieve_date' => 'yesterday'));
     $this->assertTrue(CRM_Contribute_BAO_ContributionRecur::supportsFinancialTypeChange($contributionRecur['id']));
 }