当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_Payment_Form::buildPaymentForm方法代码示例

本文整理汇总了PHP中CRM_Core_Payment_Form::buildPaymentForm方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Payment_Form::buildPaymentForm方法的具体用法?PHP CRM_Core_Payment_Form::buildPaymentForm怎么用?PHP CRM_Core_Payment_Form::buildPaymentForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_Payment_Form的用法示例。


在下文中一共展示了CRM_Core_Payment_Form::buildPaymentForm方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     if ($this->_mode) {
         $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE, array('onChange' => "buildAutoRenew( null, this.value, '{$this->_mode}');"));
         CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE);
     }
     // Build the form for auto renew. This is displayed when in credit card mode or update mode.
     // The reason for showing it in update mode is not that clear.
     if ($this->_mode || $this->_action & CRM_Core_Action::UPDATE) {
         if (!empty($this->_recurPaymentProcessors)) {
             $this->assign('allowAutoRenew', TRUE);
         }
         $autoRenewElement = $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'), NULL, array('onclick' => "showHideByValue('auto_renew','','send-receipt','table-row','radio',true); showHideNotice( );"));
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $autoRenewElement->freeze();
         }
         $this->assign('recurProcessor', json_encode($this->_recurPaymentProcessors));
         $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'));
         $this->assignPaymentRelatedVariables();
     }
     $this->assign('autoRenewOptions', json_encode($this->membershipTypeRenewalStatus));
     if ($this->_action & CRM_Core_Action::RENEW) {
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Renew'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } elseif ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } else {
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
 }
开发者ID:sarehag,项目名称:civicrm-core,代码行数:32,代码来源:Form.php

示例2: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     // FIXME: This probably needs to be done in preprocess
     if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && $this->_action & CRM_Core_Action::UPDATE && CRM_Utils_Array::value('financial_type_id', $this->_values)) {
         $financialTypeID = CRM_Contribute_PseudoConstant::financialType($this->_values['financial_type_id']);
         CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($this->_id, 'edit');
         if (!CRM_Core_Permission::check('edit contributions of type ' . $financialTypeID)) {
             CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
         }
     }
     $allPanes = array();
     $recurJs = NULL;
     //tax rate from financialType
     $this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
     $this->assign('currencies', json_encode(CRM_Core_OptionGroup::values('currencies_enabled')));
     // build price set form.
     $buildPriceSet = FALSE;
     $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
     $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
     $this->assign('invoicing', $invoicing);
     // display tax amount on edit contribution page
     if ($invoicing && $this->_action & CRM_Core_Action::UPDATE && isset($this->_values['tax_amount'])) {
         $this->assign('totalTaxAmount', $this->_values['tax_amount']);
     }
     if (empty($this->_lineItems) && ($this->_priceSetId || !empty($_POST['price_set_id']))) {
         $buildPriceSet = TRUE;
         $getOnlyPriceSetElements = TRUE;
         if (!$this->_priceSetId) {
             $this->_priceSetId = $_POST['price_set_id'];
             $getOnlyPriceSetElements = FALSE;
         }
         $this->set('priceSetId', $this->_priceSetId);
         CRM_Price_BAO_PriceSet::buildPriceSet($this);
         // get only price set form elements.
         if ($getOnlyPriceSetElements) {
             return;
         }
     }
     // use to build form during form rule.
     $this->assign('buildPriceSet', $buildPriceSet);
     $defaults = $this->_values;
     $additionalDetailFields = array('note', 'thankyou_date', 'invoice_id', 'non_deductible_amount', 'fee_amount', 'net_amount');
     foreach ($additionalDetailFields as $key) {
         if (!empty($defaults[$key])) {
             $defaults['hidden_AdditionalDetail'] = 1;
             break;
         }
     }
     if ($this->_productDAO) {
         if ($this->_productDAO->product_id) {
             $defaults['hidden_Premium'] = 1;
         }
     }
     if ($this->_noteID && isset($this->_values['note'])) {
         $defaults['hidden_AdditionalDetail'] = 1;
     }
     $paneNames = array(ts('Additional Details') => 'AdditionalDetail');
     //Add Premium pane only if Premium is exists.
     $dao = new CRM_Contribute_DAO_Product();
     $dao->is_active = 1;
     if ($dao->find(TRUE)) {
         $paneNames[ts('Premium Information')] = 'Premium';
     }
     if ($this->_mode) {
         if (CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE) == TRUE) {
             if (!empty($this->_recurPaymentProcessors)) {
                 $buildRecurBlock = TRUE;
                 if ($this->_ppID) {
                     // ppID denotes a pledge payment.
                     foreach ($this->_paymentProcessors as $processor) {
                         if (!empty($processor['is_recur']) && !empty($processor['object']) && $processor['object']->supports('recurContributionsForPledges')) {
                             $buildRecurBlock = TRUE;
                             break;
                         }
                         $buildRecurBlock = FALSE;
                     }
                 }
                 if ($buildRecurBlock) {
                     CRM_Contribute_Form_Contribution_Main::buildRecur($this);
                     $this->setDefaults(array('is_recur' => 0));
                     $this->assign('buildRecurBlock', TRUE);
                     $recurJs = array('onChange' => "buildRecurBlock( this.value ); return false;");
                 }
             }
         }
     }
     foreach ($paneNames as $name => $type) {
         $allPanes[$name] = $this->generatePane($type, $defaults);
     }
     $qfKey = $this->controller->_key;
     $this->assign('qfKey', $qfKey);
     $this->assign('allPanes', $allPanes);
     $this->addFormRule(array('CRM_Contribute_Form_Contribution', 'formRule'), $this);
     if ($this->_formType) {
         $this->assign('formType', $this->_formType);
         return;
     }
//.........这里部分代码省略.........
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php

示例3: buildQuickForm

 /**
  * Build the form object.
  *
  * @param CRM_Core_Form $form
  *
  * @return void
  */
 public static function buildQuickForm(&$form)
 {
     if ($form->_eventId) {
         $form->_isPaidEvent = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'is_monetary');
         if ($form->_isPaidEvent) {
             $form->addElement('hidden', 'hidden_feeblock', 1);
         }
         // make sure this is for backoffice registration.
         if ($form->getName() == 'Participant') {
             $eventfullMsg = CRM_Event_BAO_Participant::eventFullMessage($form->_eventId, $form->_pId);
             $form->addElement('hidden', 'hidden_eventFullMsg', $eventfullMsg, array('id' => 'hidden_eventFullMsg'));
         }
     }
     if ($form->_pId) {
         if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $form->_pId, 'contribution_id', 'participant_id')) {
             $form->_online = TRUE;
         }
     }
     if ($form->_isPaidEvent) {
         $params = array('id' => $form->_eventId);
         CRM_Event_BAO_Event::retrieve($params, $event);
         //retrieve custom information
         $form->_values = array();
         CRM_Event_Form_Registration::initEventFee($form, $event['id']);
         CRM_Event_Form_Registration_Register::buildAmount($form, TRUE, $form->_discountId);
         $lineItem = array();
         $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
         $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
         $totalTaxAmount = 0;
         if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $form->_values))) {
             $lineItem[] = $form->_values['line_items'];
             foreach ($form->_values['line_items'] as $key => $value) {
                 $totalTaxAmount = $value['tax_amount'] + $totalTaxAmount;
             }
         }
         if ($invoicing) {
             $form->assign('totalTaxAmount', $totalTaxAmount);
         }
         $form->assign('lineItem', empty($lineItem) ? FALSE : $lineItem);
         $discounts = array();
         if (!empty($form->_values['discount'])) {
             foreach ($form->_values['discount'] as $key => $value) {
                 $value = current($value);
                 $discounts[$key] = $value['name'];
             }
             $element = $form->add('select', 'discount_id', ts('Discount Set'), array(0 => ts('- select -')) + $discounts, FALSE, array('class' => "crm-select2"));
             if ($form->_online) {
                 $element->freeze();
             }
         }
         if ($form->_mode) {
             CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, FALSE);
         } elseif (!$form->_mode) {
             $form->addElement('checkbox', 'record_contribution', ts('Record Payment?'), NULL, array('onclick' => "return showHideByValue('record_contribution','','payment_information','table-row','radio',false);"));
             $form->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType());
             $form->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDate'));
             $form->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"));
             // don't show transaction id in batch update mode
             $path = CRM_Utils_System::currentPath();
             $form->assign('showTransactionId', FALSE);
             if ($path != 'civicrm/contact/search/basic') {
                 $form->add('text', 'trxn_id', ts('Transaction ID'));
                 $form->addRule('trxn_id', ts('Transaction ID already exists in Database.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $form->_eventId, 'trxn_id'));
                 $form->assign('showTransactionId', TRUE);
             }
             $status = CRM_Contribute_PseudoConstant::contributionStatus();
             // CRM-14417 suppressing contribution statuses that are NOT relevant to new participant registrations
             $statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
             foreach (array('Cancelled', 'Failed', 'In Progress', 'Overdue', 'Refunded', 'Pending refund') as $suppress) {
                 unset($status[CRM_Utils_Array::key($suppress, $statusName)]);
             }
             $form->add('select', 'contribution_status_id', ts('Payment Status'), $status);
             $form->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number'));
             $form->add('text', 'total_amount', ts('Amount'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'total_amount'));
         }
     } else {
         $form->add('text', 'amount', ts('Event Fee(s)'));
     }
     $form->assign('onlinePendingContributionId', $form->get('onlinePendingContributionId'));
     $form->assign('paid', $form->_isPaidEvent);
     $form->addElement('checkbox', 'send_receipt', ts('Send Confirmation?'), NULL, array('onclick' => "showHideByValue('send_receipt','','notice','table-row','radio',false); showHideByValue('send_receipt','','from-email','table-row','radio',false);"));
     $form->add('select', 'from_email_address', ts('Receipt From'), $form->_fromEmails['from_email_id']);
     $form->add('textarea', 'receipt_text', ts('Confirmation Message'));
     // Retrieve the name and email of the contact - form will be the TO for receipt email ( only if context is not standalone)
     if ($form->_context != 'standalone') {
         if ($form->_contactId) {
             list($form->_contributorDisplayName, $form->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($form->_contactId);
             $form->assign('email', $form->_contributorEmail);
         } else {
             //show email block for batch update for event
             $form->assign('batchEmail', TRUE);
         }
     }
//.........这里部分代码省略.........
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:101,代码来源:EventFees.php

示例4: buildQuickForm

 public function buildQuickForm()
 {
     if ($this->_view == 'transaction' && $this->_action & CRM_Core_Action::BROWSE) {
         $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'spacing' => '         ', 'isDefault' => TRUE)));
         return;
     }
     $ccPane = NULL;
     if ($this->_mode) {
         if (CRM_Utils_Array::value('payment_type', $this->_processors) & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
             $ccPane = array(ts('Direct Debit Information') => 'DirectDebit');
         } else {
             $ccPane = array(ts('Credit Card Information') => 'CreditCard');
         }
         $defaults = $this->_values;
         $showAdditionalInfo = FALSE;
         foreach ($ccPane as $name => $type) {
             if ($this->_formType == $type || !empty($_POST["hidden_{$type}"]) || CRM_Utils_Array::value("hidden_{$type}", $defaults)) {
                 $showAdditionalInfo = TRUE;
                 $allPanes[$name]['open'] = 'true';
             }
             $urlParams = "snippet=4&formType={$type}";
             if ($this->_mode) {
                 $urlParams .= "&mode={$this->_mode}";
             }
             $open = 'false';
             if ($type == 'CreditCard' || $type == 'DirectDebit') {
                 $open = 'true';
             }
             $allPanes[$name] = array('url' => CRM_Utils_System::url('civicrm/payment/add', $urlParams), 'open' => $open, 'id' => $type);
             CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE);
             $qfKey = $this->controller->_key;
             $this->assign('qfKey', $qfKey);
             $this->assign('allPanes', $allPanes);
             $this->assign('showAdditionalInfo', $showAdditionalInfo);
             if ($this->_formType) {
                 $this->assign('formType', $this->_formType);
                 return;
             }
         }
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialTrxn');
     $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, NULL);
     $label = $this->_refund ? ts('Refund Amount') : ts('Payment Amount');
     $this->addMoney('total_amount', $label, FALSE, $attributes['total_amount'], TRUE, 'currency', NULL);
     $this->add('select', 'payment_instrument_id', ts('Payment Method'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"));
     $this->add('text', 'check_number', ts('Check Number'), $attributes['financial_trxn_check_number']);
     $this->add('text', 'trxn_id', ts('Transaction ID'), array('class' => 'twelve') + $attributes['trxn_id']);
     //add receipt for offline contribution
     $this->addElement('checkbox', 'is_email_receipt', ts('Send Receipt?'));
     $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails['from_email_id']);
     $this->add('textarea', 'receipt_text', ts('Confirmation Message'));
     // add various dates
     $dateLabel = $this->_refund ? ts('Refund Date') : ts('Date Received');
     $this->addDateTime('trxn_date', $dateLabel, FALSE, array('formatType' => 'activityDateTime'));
     if ($this->_contactId && $this->_id) {
         if ($this->_component == 'event') {
             $eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
             $event = CRM_Event_BAO_Event::getEvents(0, $eventId);
             $this->assign('eventName', $event[$eventId]);
         }
     }
     $this->assign('displayName', $this->_contributorDisplayName);
     $this->assign('component', $this->_component);
     $this->assign('email', $this->_contributorEmail);
     $this->add('text', 'fee_amount', ts('Fee Amount'), $attributes['fee_amount']);
     $this->addRule('fee_amount', ts('Please enter a valid monetary value for Fee Amount.'), 'money');
     $this->add('text', 'net_amount', ts('Net Amount'), $attributes['net_amount']);
     $this->addRule('net_amount', ts('Please enter a valid monetary value for Net Amount.'), 'money');
     $js = NULL;
     if (!$this->_mode) {
         $js = array('onclick' => "return verify( );");
     }
     $buttonName = $this->_refund ? 'Record Refund' : 'Record Payment';
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('%1', array(1 => $buttonName)), 'js' => $js, 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $mailingInfo = Civi::settings()->get('mailing_backend');
     $this->assign('outBound_option', $mailingInfo['outBound_option']);
     $this->addFormRule(array('CRM_Contribute_Form_AdditionalPayment', 'formRule'), $this);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:78,代码来源:AdditionalPayment.php

示例5: buildQuickForm

 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     if ($this->_mode) {
         $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE, array('onChange' => "buildAutoRenew( null, this.value );"));
         CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE);
     }
     if ($this->_action & CRM_Core_Action::RENEW) {
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Renew'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } elseif ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } else {
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
 }
开发者ID:kidaa30,项目名称:yes,代码行数:19,代码来源:Form.php

示例6: buildPaymentFields

 public function buildPaymentFields()
 {
     $payment_processor_id = NULL;
     $can_pay_later = TRUE;
     $pay_later_text = "";
     $this->pay_later_receipt = "";
     foreach ($this->cart->get_main_events_in_carts() as $event_in_cart) {
         if ($payment_processor_id == NULL && $event_in_cart->event->payment_processor != NULL) {
             $payment_processor_id = $event_in_cart->event->payment_processor;
             $this->financial_type_id = $event_in_cart->event->financial_type_id;
         } else {
             if ($event_in_cart->event->payment_processor != NULL && $event_in_cart->event->payment_processor != $payment_processor_id) {
                 CRM_Core_Error::statusBounce(ts('When registering for multiple events all events must use the same payment processor. '));
             }
         }
         if (!$event_in_cart->event->is_pay_later) {
             $can_pay_later = FALSE;
         } else {
             //XXX
             $pay_later_text = $event_in_cart->event->pay_later_text;
             $this->pay_later_receipt = $event_in_cart->event->pay_later_receipt;
         }
     }
     if ($payment_processor_id == NULL) {
         CRM_Core_Error::statusBounce(ts('A payment processor must be selected for this event registration page, or the event must be configured to give users the option to pay later (contact the site administrator for assistance).'));
     }
     $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($payment_processor_id, $this->_mode);
     $this->assign('paymentProcessor', $this->_paymentProcessor);
     CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, FALSE);
     if ($can_pay_later || self::is_administrator()) {
         $this->addElement('checkbox', 'is_pay_later', $pay_later_text);
         $this->addElement('checkbox', 'payment_completed', ts('Payment Completed'));
         $this->assign('pay_later_instructions', $this->pay_later_receipt);
     }
 }
开发者ID:agloa,项目名称:tournament,代码行数:35,代码来源:Payment.php

示例7: buildQuickform

 /**
  * Build the payment processor form.
  *
  * @param CRM_Core_Form $form
  */
 public static function buildQuickform(&$form)
 {
     //@todo document why this addHidden is here
     //CRM-15743 - we should not set/create hidden element for pay later
     // because payment processor is not selected
     $processorId = $form->getVar('_paymentProcessorID');
     $billing_profile_id = CRM_Utils_Request::retrieve('billing_profile_id', 'String');
     if (!empty($form->_values) && !empty($form->_values['is_billing_required'])) {
         $billing_profile_id = 'billing';
     }
     if (!empty($processorId)) {
         $form->addElement('hidden', 'hidden_processor', 1);
     }
     CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, $billing_profile_id, FALSE);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:20,代码来源:ProcessorForm.php

示例8: buildQuickForm

 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $type = 'next';
     if ($this->_selfService) {
         $type = 'submit';
     }
     $this->addButtons(array(array('type' => $type, 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, TRUE, TRUE);
     $this->addFormRule(array('CRM_Contribute_Form_UpdateBilling', 'formRule'), $this);
 }
开发者ID:indydas,项目名称:civi-demo,代码行数:15,代码来源:UpdateBilling.php

示例9: buildQuickform

 /**
  * @param $form
  */
 public static function buildQuickform(&$form)
 {
     //@todo document why this addHidden is here
     //CRM-15743 - we should not set/create hidden element for pay later
     // because payment processor is not selected
     if (!empty($form->_paymentProcessorID)) {
         $form->addElement('hidden', 'hidden_processor', 1);
     }
     CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, empty($form->_isBillingAddressRequiredForPayLater), FALSE);
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:13,代码来源:ProcessorForm.php

示例10: buildQuickForm

    /**
     * Build the form object.
     */
    public function buildQuickForm()
    {
        if ($this->_mode) {
            $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE, array('onChange' => "buildAutoRenew( null, this.value );"));
            CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE);
        }
        // Build the form for auto renew. This is displayed when in credit card mode or update mode.
        // The reason for showing it in update mode is not that clear.
        $autoRenew = array();
        $recurProcessor = array();
        if ($this->_mode || $this->_action & CRM_Core_Action::UPDATE) {
            if (!empty($recurProcessor)) {
                $autoRenew = array();
                if (!empty($membershipType)) {
                    $sql = '
SELECT  id,
        auto_renew,
        duration_unit,
        duration_interval
 FROM   civicrm_membership_type
WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
                    $recurMembershipTypes = CRM_Core_DAO::executeQuery($sql);
                    while ($recurMembershipTypes->fetch()) {
                        $autoRenew[$recurMembershipTypes->id] = $recurMembershipTypes->auto_renew;
                        foreach (array('id', 'auto_renew', 'duration_unit', 'duration_interval') as $fld) {
                            $this->_recurMembershipTypes[$recurMembershipTypes->id][$fld] = $recurMembershipTypes->{$fld};
                        }
                    }
                }
                if ($this->_mode) {
                    if (!empty($this->_recurPaymentProcessors)) {
                        $this->assign('allowAutoRenew', TRUE);
                    }
                }
                $this->assign('autoRenew', json_encode($autoRenew));
                $autoRenewElement = $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'), NULL, array('onclick' => "showHideByValue('auto_renew','','send-receipt','table-row','radio',true); showHideNotice( );"));
                if ($this->_action & CRM_Core_Action::UPDATE) {
                    $autoRenewElement->freeze();
                }
            }
        }
        $this->assign('recurProcessor', json_encode($recurProcessor));
        if ($this->_mode || $this->_action & CRM_Core_Action::UPDATE) {
            $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'), NULL, array('onclick' => "buildReceiptANDNotice( );"));
            $this->assignPaymentRelatedVariables();
        }
        $this->assign('autoRenewOptions', json_encode($autoRenew));
        if ($this->_action & CRM_Core_Action::RENEW) {
            $this->addButtons(array(array('type' => 'upload', 'name' => ts('Renew'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
        } elseif ($this->_action & CRM_Core_Action::DELETE) {
            $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
        } else {
            $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
        }
    }
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:58,代码来源:Form.php


注:本文中的CRM_Core_Payment_Form::buildPaymentForm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。