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


PHP CRM_Member_BAO_Membership::buildMembershipTypeValues方法代码示例

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


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

示例1: preProcess

 public function preProcess()
 {
     // Check for edit permission.
     if (!CRM_Core_Permission::checkActionPermission('CiviMember', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     parent::preProcess();
     $params = array();
     $params['context'] = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'membership');
     $params['id'] = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $params['mode'] = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->setContextVariables($params);
     $this->assign('context', $this->_context);
     $this->assign('membershipMode', $this->_mode);
     $this->allMembershipTypeDetails = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, array(), TRUE);
     foreach ($this->allMembershipTypeDetails as $index => $membershipType) {
         if ($membershipType['auto_renew']) {
             $this->_recurMembershipTypes[$index] = $membershipType;
             $this->membershipTypeRenewalStatus[$index] = $membershipType['auto_renew'];
         }
     }
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:22,代码来源:Form.php

示例2: buildQuickForm

    /**
     * Build the form object.
     *
     * @return void
     */
    public function buildQuickForm()
    {
        if ($this->_cdType) {
            return CRM_Custom_Form_CustomData::buildQuickForm($this);
        }
        $this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
        $config = CRM_Core_Config::singleton();
        $this->assign('currency', $config->defaultCurrencySymbol);
        $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
        $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
        if (isset($invoicing)) {
            $this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings));
        }
        // build price set form.
        $buildPriceSet = FALSE;
        if ($this->_priceSetId || !empty($_POST['price_set_id'])) {
            if (!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);
            $optionsMembershipTypes = array();
            foreach ($this->_priceSet['fields'] as $pField) {
                if (empty($pField['options'])) {
                    continue;
                }
                foreach ($pField['options'] as $opId => $opValues) {
                    $optionsMembershipTypes[$opId] = CRM_Utils_Array::value('membership_type_id', $opValues, 0);
                }
            }
            $this->assign('autoRenewOption', CRM_Price_BAO_PriceSet::checkAutoRenewForPriceSet($this->_priceSetId));
            $this->assign('optionsMembershipTypes', $optionsMembershipTypes);
            $this->assign('contributionType', CRM_Utils_Array::value('financial_type_id', $this->_priceSet));
            // get only price set form elements.
            if ($getOnlyPriceSetElements) {
                return;
            }
        }
        // use to build form during form rule.
        $this->assign('buildPriceSet', $buildPriceSet);
        if ($this->_action & CRM_Core_Action::ADD) {
            $buildPriceSet = FALSE;
            $priceSets = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviMember');
            if (!empty($priceSets)) {
                $buildPriceSet = TRUE;
            }
            if ($buildPriceSet) {
                $this->add('select', 'price_set_id', ts('Choose price set'), array('' => ts('Choose price set')) + $priceSets, NULL, array('onchange' => "buildAmount( this.value );"));
            }
            $this->assign('hasPriceSets', $buildPriceSet);
        }
        //need to assign custom data type and subtype to the template
        $this->assign('customDataType', 'Membership');
        $this->assign('customDataSubType', $this->_memType);
        $this->assign('entityID', $this->_id);
        if ($this->_action & CRM_Core_Action::DELETE) {
            $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => '         ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
            return;
        }
        if ($this->_context == 'standalone') {
            $this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE, 'api' => array('extra' => array('email'))), TRUE);
        }
        $selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -');
        $dao = new CRM_Member_DAO_MembershipType();
        $dao->domain_id = CRM_Core_Config::domainID();
        $dao->find();
        // retrieve all memberships
        $allMemberships = CRM_Member_BAO_Membership::buildMembershipTypeValues($this);
        $allMembershipInfo = $membershipType = array();
        foreach ($allMemberships as $key => $values) {
            if (!empty($values['is_active'])) {
                $membershipType[$key] = CRM_Utils_Array::value('name', $values);
                if ($this->_mode && empty($values['minimum_fee'])) {
                    continue;
                } else {
                    $memberOfContactId = CRM_Utils_Array::value('member_of_contact_id', $values);
                    if (empty($selMemTypeOrg[$memberOfContactId])) {
                        $selMemTypeOrg[$memberOfContactId] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $memberOfContactId, 'display_name', 'id');
                        $selOrgMemType[$memberOfContactId][0] = ts('- select -');
                    }
                    if (empty($selOrgMemType[$memberOfContactId][$key])) {
                        $selOrgMemType[$memberOfContactId][$key] = CRM_Utils_Array::value('name', $values);
                    }
                }
                // build membership info array, which is used when membership type is selected to:
                // - set the payment information block
                // - set the max related block
                $allMembershipInfo[$key] = array('financial_type_id' => CRM_Utils_Array::value('financial_type_id', $values), 'total_amount' => CRM_Utils_Money::format($values['minimum_fee'], NULL, '%a'), 'total_amount_numeric' => CRM_Utils_Array::value('minimum_fee', $values), 'auto_renew' => CRM_Utils_Array::value('auto_renew', $values), 'has_related' => isset($values['relationship_type_id']), 'max_related' => CRM_Utils_Array::value('max_related', $values));
            }
        }
//.........这里部分代码省略.........
开发者ID:indydas,项目名称:civi-demo,代码行数:101,代码来源:Membership.php

示例3: submit

 /**
  * Submit function.
  *
  * This is the guts of the postProcess made also accessible to the test suite.
  *
  * @param array $params
  *   Submitted values.
  */
 public function submit($params)
 {
     //carry campaign from profile.
     if (array_key_exists('contribution_campaign_id', $params)) {
         $params['campaign_id'] = $params['contribution_campaign_id'];
     }
     $params['currencyID'] = CRM_Core_Config::singleton()->defaultCurrency;
     $is_quick_config = 0;
     if (!empty($params['priceSetId'])) {
         $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
         if ($is_quick_config) {
             $priceField = new CRM_Price_DAO_PriceField();
             $priceField->price_set_id = $params['priceSetId'];
             $priceField->orderBy('weight');
             $priceField->find();
             $priceOptions = array();
             while ($priceField->fetch()) {
                 CRM_Price_BAO_PriceFieldValue::getValues($priceField->id, $priceOptions);
                 if (($selectedPriceOptionID = CRM_Utils_Array::value("price_{$priceField->id}", $params)) != FALSE && $selectedPriceOptionID > 0) {
                     switch ($priceField->name) {
                         case 'membership_amount':
                             $this->_params['selectMembership'] = $params['selectMembership'] = CRM_Utils_Array::value('membership_type_id', $priceOptions[$selectedPriceOptionID]);
                             $this->set('selectMembership', $params['selectMembership']);
                         case 'contribution_amount':
                             $params['amount'] = $selectedPriceOptionID;
                             if ($priceField->name == 'contribution_amount' || $priceField->name == 'membership_amount' && CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock) == 0) {
                                 $this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
                             }
                             $this->_values[$selectedPriceOptionID]['value'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
                             $this->_values[$selectedPriceOptionID]['label'] = CRM_Utils_Array::value('label', $priceOptions[$selectedPriceOptionID]);
                             $this->_values[$selectedPriceOptionID]['amount_id'] = CRM_Utils_Array::value('id', $priceOptions[$selectedPriceOptionID]);
                             $this->_values[$selectedPriceOptionID]['weight'] = CRM_Utils_Array::value('weight', $priceOptions[$selectedPriceOptionID]);
                             break;
                         case 'other_amount':
                             $params['amount_other'] = $selectedPriceOptionID;
                             break;
                     }
                 }
             }
         }
     }
     if (!empty($this->_ccid) && !empty($this->_pendingAmount)) {
         $params['amount'] = $this->_pendingAmount;
     } else {
         // from here on down, $params['amount'] holds a monetary value (or null) rather than an option ID
         $params['amount'] = self::computeAmount($params, $this->_values);
     }
     $params['separate_amount'] = $params['amount'];
     $memFee = NULL;
     if (!empty($params['selectMembership'])) {
         if (empty($this->_membershipTypeValues)) {
             $this->_membershipTypeValues = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, (array) $params['selectMembership']);
         }
         $membershipTypeValues = $this->_membershipTypeValues[$params['selectMembership']];
         $memFee = $membershipTypeValues['minimum_fee'];
         if (!$params['amount'] && !$this->_separateMembershipPayment) {
             $params['amount'] = $memFee ? $memFee : 0;
         }
     }
     //If the membership & contribution is used in contribution page & not separate payment
     $fieldId = $memPresent = $membershipLabel = $fieldOption = $is_quick_config = NULL;
     $proceFieldAmount = 0;
     if (property_exists($this, '_separateMembershipPayment') && $this->_separateMembershipPayment == 0) {
         $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
         if ($is_quick_config) {
             foreach ($this->_priceSet['fields'] as $fieldKey => $fieldVal) {
                 if ($fieldVal['name'] == 'membership_amount' && !empty($params['price_' . $fieldKey])) {
                     $fieldId = $fieldVal['id'];
                     $fieldOption = $params['price_' . $fieldId];
                     $proceFieldAmount += $fieldVal['options'][$this->_submitValues['price_' . $fieldId]]['amount'];
                     $memPresent = TRUE;
                 } else {
                     if (!empty($params['price_' . $fieldKey]) && $memPresent && ($fieldVal['name'] == 'other_amount' || $fieldVal['name'] == 'contribution_amount')) {
                         $fieldId = $fieldVal['id'];
                         if ($fieldVal['name'] == 'other_amount') {
                             $proceFieldAmount += $this->_submitValues['price_' . $fieldId];
                         } elseif ($fieldVal['name'] == 'contribution_amount' && $this->_submitValues['price_' . $fieldId] > 0) {
                             $proceFieldAmount += $fieldVal['options'][$this->_submitValues['price_' . $fieldId]]['amount'];
                         }
                         unset($params['price_' . $fieldId]);
                         break;
                     }
                 }
             }
         }
     }
     if (!isset($params['amount_other'])) {
         $this->set('amount_level', CRM_Utils_Array::value('amount_level', $params));
     }
     if (!empty($this->_ccid)) {
         $this->set('lineItem', $this->_lineItem);
     } elseif ($priceSetId = CRM_Utils_Array::value('priceSetId', $params)) {
//.........这里部分代码省略.........
开发者ID:nielosz,项目名称:civicrm-core,代码行数:101,代码来源:Main.php

示例4: processMembership

 /**
  * Process membership.
  *
  * @param array $membershipParams
  * @param int $contactID
  * @param array $customFieldsFormatted
  * @param array $fieldTypes
  * @param array $premiumParams
  * @param array $membershipLineItems
  *   Line items specifically relating to memberships.
  * @param bool $isPayLater
  */
 protected function processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams, $membershipLineItems, $isPayLater)
 {
     $membershipTypeIDs = (array) $membershipParams['selectMembership'];
     $membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $membershipTypeIDs);
     $membershipType = empty($membershipTypes) ? array() : reset($membershipTypes);
     $isPending = $this->getIsPending();
     $this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType));
     $isPaidMembership = FALSE;
     if ($this->_amount >= 0.0 && isset($membershipParams['amount'])) {
         //amount must be greater than zero for
         //adding contribution record  to contribution table.
         //this condition arises when separate membership payment is
         //enabled and contribution amount is not selected. fix for CRM-3010
         $isPaidMembership = TRUE;
     }
     $isProcessSeparateMembershipTransaction = $this->isSeparateMembershipTransaction($this->_id, $this->_values['amount_block_is_active']);
     if ($this->_values['amount_block_is_active']) {
         $financialTypeID = $this->_values['financial_type_id'];
     } else {
         $financialTypeID = CRM_Utils_Array::value('financial_type_id', $membershipType, CRM_Utils_Array::value('financial_type_id', $membershipParams));
     }
     if (CRM_Utils_Array::value('membership_source', $this->_params)) {
         $membershipParams['contribution_source'] = $this->_params['membership_source'];
     }
     $this->postProcessMembership($membershipParams, $contactID, $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipType, $membershipTypeIDs, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $financialTypeID, $membershipLineItems, $isPayLater, $isPending);
     $this->assign('membership_assign', TRUE);
     $this->set('membershipTypeID', $membershipParams['selectMembership']);
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:40,代码来源:Confirm.php

示例5: buildMembershipBlock

 /**
  * Build Membership  Block in Contribution Pages.
  *
  * @param int $cid
  *   Contact checked for having a current membership for a particular membership.
  * @param bool $isContributionMainPage
  *   Is this the main page? If so add form input fields.
  *   (or better yet don't have this functionality in a function shared with forms that don't share it).
  * @param int $selectedMembershipTypeID
  *   Selected membership id.
  * @param bool $thankPage
  *   Thank you page.
  * @param null $isTest
  *
  * @return bool
  *   Is this a separate membership payment
  */
 protected function buildMembershipBlock($cid, $isContributionMainPage = FALSE, $selectedMembershipTypeID = NULL, $thankPage = FALSE, $isTest = NULL)
 {
     $separateMembershipPayment = FALSE;
     if ($this->_membershipBlock) {
         $this->_currentMemberships = array();
         $membershipTypeIds = $membershipTypes = $radio = array();
         $membershipPriceset = !empty($this->_priceSetId) && $this->_useForMember ? TRUE : FALSE;
         $allowAutoRenewMembership = $autoRenewOption = FALSE;
         $autoRenewMembershipTypeOptions = array();
         $separateMembershipPayment = CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock);
         if ($membershipPriceset) {
             foreach ($this->_priceSet['fields'] as $pField) {
                 if (empty($pField['options'])) {
                     continue;
                 }
                 foreach ($pField['options'] as $opId => $opValues) {
                     if (empty($opValues['membership_type_id'])) {
                         continue;
                     }
                     $membershipTypeIds[$opValues['membership_type_id']] = $opValues['membership_type_id'];
                 }
             }
         } elseif (!empty($this->_membershipBlock['membership_types'])) {
             $membershipTypeIds = explode(',', $this->_membershipBlock['membership_types']);
         }
         if (!empty($membershipTypeIds)) {
             //set status message if wrong membershipType is included in membershipBlock
             if (isset($this->_mid) && !$membershipPriceset) {
                 $membershipTypeID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_mid, 'membership_type_id');
                 if (!in_array($membershipTypeID, $membershipTypeIds)) {
                     CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Invalid Membership'), 'error');
                 }
             }
             $membershipTypeValues = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $membershipTypeIds);
             $this->_membershipTypeValues = $membershipTypeValues;
             $endDate = NULL;
             foreach ($membershipTypeIds as $value) {
                 $memType = $membershipTypeValues[$value];
                 if ($selectedMembershipTypeID != NULL) {
                     if ($memType['id'] == $selectedMembershipTypeID) {
                         $this->assign('minimum_fee', CRM_Utils_Array::value('minimum_fee', $memType));
                         $this->assign('membership_name', $memType['name']);
                         if (!$thankPage && $cid) {
                             $membership = new CRM_Member_DAO_Membership();
                             $membership->contact_id = $cid;
                             $membership->membership_type_id = $memType['id'];
                             if ($membership->find(TRUE)) {
                                 $this->assign('renewal_mode', TRUE);
                                 $memType['current_membership'] = $membership->end_date;
                                 $this->_currentMemberships[$membership->membership_type_id] = $membership->membership_type_id;
                             }
                         }
                         $membershipTypes[] = $memType;
                     }
                 } elseif ($memType['is_active']) {
                     $javascriptMethod = NULL;
                     $allowAutoRenewOpt = (int) $memType['auto_renew'];
                     if (is_array($this->_paymentProcessors)) {
                         foreach ($this->_paymentProcessors as $id => $val) {
                             if (!$val['is_recur']) {
                                 $allowAutoRenewOpt = 0;
                                 continue;
                             }
                         }
                     }
                     $javascriptMethod = array('onclick' => "return showHideAutoRenew( this.value );");
                     $autoRenewMembershipTypeOptions["autoRenewMembershipType_{$value}"] = (int) $allowAutoRenewOpt * CRM_Utils_Array::value($value, CRM_Utils_Array::value('auto_renew', $this->_membershipBlock));
                     if ($allowAutoRenewOpt) {
                         $allowAutoRenewMembership = TRUE;
                     }
                     //add membership type.
                     $radio[$memType['id']] = $this->createElement('radio', NULL, NULL, NULL, $memType['id'], $javascriptMethod);
                     if ($cid) {
                         $membership = new CRM_Member_DAO_Membership();
                         $membership->contact_id = $cid;
                         $membership->membership_type_id = $memType['id'];
                         //show current membership, skip pending and cancelled membership records,
                         //because we take first membership record id for renewal
                         $membership->whereAdd('status_id != 5 AND status_id !=6');
                         if (!is_null($isTest)) {
                             $membership->is_test = $isTest;
                         }
                         //CRM-4297
//.........这里部分代码省略.........
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:101,代码来源:ContributionBase.php

示例6: postProcess

 /**
  * Process the form submission.
  */
 public function postProcess()
 {
     $config = CRM_Core_Config::singleton();
     // we first reset the confirm page so it accepts new values
     $this->controller->resetPage('Confirm');
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     //carry campaign from profile.
     if (array_key_exists('contribution_campaign_id', $params)) {
         $params['campaign_id'] = $params['contribution_campaign_id'];
     }
     if (!empty($params['onbehalfof_id'])) {
         $params['organization_id'] = $params['onbehalfof_id'];
     }
     $params['currencyID'] = $config->defaultCurrency;
     if (!empty($params['priceSetId'])) {
         $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
         if ($is_quick_config) {
             $priceField = new CRM_Price_DAO_PriceField();
             $priceField->price_set_id = $params['priceSetId'];
             $priceField->orderBy('weight');
             $priceField->find();
             $priceOptions = array();
             while ($priceField->fetch()) {
                 CRM_Price_BAO_PriceFieldValue::getValues($priceField->id, $priceOptions);
                 if ($selectedPriceOptionID = CRM_Utils_Array::value("price_{$priceField->id}", $params)) {
                     switch ($priceField->name) {
                         case 'membership_amount':
                             $this->_params['selectMembership'] = $params['selectMembership'] = CRM_Utils_Array::value('membership_type_id', $priceOptions[$selectedPriceOptionID]);
                             $this->set('selectMembership', $params['selectMembership']);
                             if (CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock) == 0) {
                                 $this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
                             }
                             break;
                         case 'contribution_amount':
                             $params['amount'] = $selectedPriceOptionID;
                             $this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
                             $this->_values[$selectedPriceOptionID]['value'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
                             $this->_values[$selectedPriceOptionID]['label'] = CRM_Utils_Array::value('label', $priceOptions[$selectedPriceOptionID]);
                             $this->_values[$selectedPriceOptionID]['amount_id'] = CRM_Utils_Array::value('id', $priceOptions[$selectedPriceOptionID]);
                             $this->_values[$selectedPriceOptionID]['weight'] = CRM_Utils_Array::value('weight', $priceOptions[$selectedPriceOptionID]);
                             break;
                         case 'other_amount':
                             $params['amount_other'] = $selectedPriceOptionID;
                             break;
                     }
                 }
             }
         }
     }
     if ($this->_values['is_pay_later'] && empty($this->_paymentProcessor) && !array_key_exists('hidden_processor', $params) || !empty($params['payment_processor_id']) && $params['payment_processor_id'] == 0) {
         $params['is_pay_later'] = 1;
     } else {
         $params['is_pay_later'] = 0;
     }
     $this->set('is_pay_later', $params['is_pay_later']);
     // assign pay later stuff
     $this->_params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, FALSE);
     $this->assign('is_pay_later', $params['is_pay_later']);
     if ($params['is_pay_later']) {
         $this->assign('pay_later_text', $this->_values['pay_later_text']);
         $this->assign('pay_later_receipt', $this->_values['pay_later_receipt']);
     }
     // from here on down, $params['amount'] holds a monetary value (or null) rather than an option ID
     $params['amount'] = self::computeAmount($params, $this->_values);
     $params['separate_amount'] = $params['amount'];
     $memFee = NULL;
     if (!empty($params['selectMembership'])) {
         if (!empty($this->_membershipTypeValues)) {
             $membershipTypeValues = $this->_membershipTypeValues[$params['selectMembership']];
         } else {
             $membershipTypeValues = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $params['selectMembership']);
         }
         $memFee = $membershipTypeValues['minimum_fee'];
         if (!$params['amount'] && !$this->_separateMembershipPayment) {
             $params['amount'] = $memFee ? $memFee : 0;
         }
     }
     //If the membership & contribution is used in contribution page & not separate payment
     $fieldId = $memPresent = $membershipLabel = $fieldOption = $is_quick_config = NULL;
     $proceFieldAmount = 0;
     if (property_exists($this, '_separateMembershipPayment') && $this->_separateMembershipPayment == 0) {
         $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
         if ($is_quick_config) {
             foreach ($this->_priceSet['fields'] as $fieldKey => $fieldVal) {
                 if ($fieldVal['name'] == 'membership_amount' && !empty($params['price_' . $fieldKey])) {
                     $fieldId = $fieldVal['id'];
                     $fieldOption = $params['price_' . $fieldId];
                     $proceFieldAmount += $fieldVal['options'][$this->_submitValues['price_' . $fieldId]]['amount'];
                     $memPresent = TRUE;
                 } else {
                     if (!empty($params['price_' . $fieldKey]) && $memPresent && ($fieldVal['name'] == 'other_amount' || $fieldVal['name'] == 'contribution_amount')) {
                         $fieldId = $fieldVal['id'];
                         if ($fieldVal['name'] == 'other_amount') {
                             $proceFieldAmount += $this->_submitValues['price_' . $fieldId];
                         } elseif ($fieldVal['name'] == 'contribution_amount' && $this->_submitValues['price_' . $fieldId] > 0) {
                             $proceFieldAmount += $fieldVal['options'][$this->_submitValues['price_' . $fieldId]]['amount'];
//.........这里部分代码省略.........
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:101,代码来源:Main.php

示例7: buildQuickForm

    /**
     * Build the form object.
     *
     * @return void
     */
    public function buildQuickForm()
    {
        if ($this->_cdType) {
            return CRM_Custom_Form_CustomData::buildQuickForm($this);
        }
        parent::buildQuickForm();
        $defaults = parent::setDefaultValues();
        $this->_memType = $defaults['membership_type_id'];
        $this->assign('customDataType', 'Membership');
        $this->assign('customDataSubType', $this->_memType);
        $this->assign('entityID', $this->_id);
        $selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -');
        $allMemberships = CRM_Member_BAO_Membership::buildMembershipTypeValues($this);
        $allMembershipInfo = $membershipType = array();
        //CRM-16950
        $taxRates = CRM_Core_PseudoConstant::getTaxRates();
        $taxRate = CRM_Utils_Array::value($allMemberships[$defaults['membership_type_id']]['financial_type_id'], $taxRates);
        $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
        // auto renew options if enabled for the membership
        $options = CRM_Core_SelectValues::memberAutoRenew();
        foreach ($allMemberships as $key => $values) {
            if (!empty($values['is_active'])) {
                $membershipType[$key] = CRM_Utils_Array::value('name', $values);
                if ($this->_mode && empty($values['minimum_fee'])) {
                    continue;
                } else {
                    $memberOfContactId = CRM_Utils_Array::value('member_of_contact_id', $values);
                    if (empty($selMemTypeOrg[$memberOfContactId])) {
                        $selMemTypeOrg[$memberOfContactId] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $memberOfContactId, 'display_name', 'id');
                        $selOrgMemType[$memberOfContactId][0] = ts('- select -');
                    }
                    if (empty($selOrgMemType[$memberOfContactId][$key])) {
                        $selOrgMemType[$memberOfContactId][$key] = CRM_Utils_Array::value('name', $values);
                    }
                }
                //CRM-16950
                $taxAmount = NULL;
                $totalAmount = CRM_Utils_Array::value('minimum_fee', $values);
                if (CRM_Utils_Array::value($values['financial_type_id'], $taxRates)) {
                    $taxAmount = $taxRate / 100 * CRM_Utils_Array::value('minimum_fee', $values);
                    $totalAmount = $totalAmount + $taxAmount;
                }
                // build membership info array, which is used to set the payment information block when
                // membership type is selected.
                $allMembershipInfo[$key] = array('financial_type_id' => CRM_Utils_Array::value('financial_type_id', $values), 'total_amount' => CRM_Utils_Money::format($totalAmount, NULL, '%a'), 'total_amount_numeric' => $totalAmount, 'tax_message' => $taxAmount ? ts("Includes %1 amount of %2", array(1 => CRM_Utils_Array::value('tax_term', $invoiceSettings), 2 => CRM_Utils_Money::format($taxAmount))) : $taxAmount);
                if (!empty($values['auto_renew'])) {
                    $allMembershipInfo[$key]['auto_renew'] = $options[$values['auto_renew']];
                }
            }
        }
        $this->assign('allMembershipInfo', json_encode($allMembershipInfo));
        if ($this->_memType) {
            $this->assign('orgName', $selMemTypeOrg[$allMemberships[$this->_memType]['member_of_contact_id']]);
            $this->assign('memType', $allMemberships[$this->_memType]['name']);
        }
        // force select of organization by default, if only one organization in
        // the list
        if (count($selMemTypeOrg) == 2) {
            unset($selMemTypeOrg[0], $selOrgMemType[0][0]);
        }
        //sort membership organization and type, CRM-6099
        natcasesort($selMemTypeOrg);
        foreach ($selOrgMemType as $index => $orgMembershipType) {
            natcasesort($orgMembershipType);
            $selOrgMemType[$index] = $orgMembershipType;
        }
        $js = array('onChange' => "setPaymentBlock( ); CRM.buildCustomData( 'Membership', this.value );");
        //build the form for auto renew.
        $recurProcessor = array();
        if ($this->_mode || $this->_action & CRM_Core_Action::UPDATE) {
            //get the valid recurring processors.
            $test = strtolower($this->_mode) == 'test' ? TRUE : FALSE;
            $recurring = CRM_Core_PseudoConstant::paymentProcessor(FALSE, $test, 'is_recur = 1');
            $recurProcessor = array_intersect_key($this->_processors, $recurring);
            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};
                        }
                    }
                }
                $js = array('onChange' => "setPaymentBlock(); CRM.buildCustomData( 'Membership', this.value );");
                $this->assign('autoRenew', json_encode($autoRenew));
            }
//.........这里部分代码省略.........
开发者ID:vincent1892,项目名称:contact_report,代码行数:101,代码来源:MembershipRenewal.php

示例8: processMembership

 /**
  * @param array $membershipParams
  * @param integer $contactID
  * @param array $customFieldsFormatted
  * @param array $fieldTypes
  * @param array $premiumParams
  * @param array $membershipLineItems line items specifically relating to memberships
  */
 public function processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams, $membershipLineItems)
 {
     try {
         $membershipTypeIDs = (array) $membershipParams['selectMembership'];
         $membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $membershipTypeIDs);
         $membershipType = empty($membershipTypes) ? array() : reset($membershipTypes);
         $this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType));
         $isPaidMembership = FALSE;
         if ($this->_amount >= 0.0 && isset($membershipParams['amount'])) {
             //amount must be greater than zero for
             //adding contribution record  to contribution table.
             //this condition arises when separate membership payment is
             //enabled and contribution amount is not selected. fix for CRM-3010
             $isPaidMembership = TRUE;
         }
         $isProcessSeparateMembershipTransaction = $this->isSeparateMembershipTransaction($this->_id, $this->_values['amount_block_is_active']);
         if ($this->_values['amount_block_is_active']) {
             $contributionTypeId = $this->_values['financial_type_id'];
         } else {
             $contributionTypeId = CRM_Utils_Array::value('financial_type_id', $membershipType, CRM_Utils_Array::value('financial_type_id', $membershipParams));
         }
         CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID, $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipType, $membershipTypeIDs, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $contributionTypeId, $membershipLineItems);
         $this->assign('membership_assign', TRUE);
         $this->set('membershipTypeID', $membershipParams['selectMembership']);
     } catch (CRM_Core_Exception $e) {
         CRM_Core_Session::singleton()->setStatus($e->getMessage());
         CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$this->_params['qfKey']}"));
     }
 }
开发者ID:ruchirapingale,项目名称:civicrm-core,代码行数:37,代码来源:Confirm.php

示例9: postProcess

 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     $config = CRM_Core_Config::singleton();
     // we first reset the confirm page so it accepts new values
     $this->controller->resetPage('Confirm');
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     if (CRM_Utils_Array::value('priceSetId', $params)) {
         $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_priceSetId, 'is_quick_config');
         $formValue = array();
         if ($is_quick_config) {
             $priceField = new CRM_Price_DAO_Field();
             $priceField->price_set_id = $params['priceSetId'];
             $priceField->orderBy('weight');
             $priceField->find();
             $check = array();
             $otherAmount = FALSE;
             while ($priceField->fetch()) {
                 CRM_Price_BAO_FieldValue::getValues($priceField->id, $values);
                 if ($priceField->name == "membership_amount") {
                     if ($priceFiledID = CRM_Utils_Array::value("price_{$priceField->id}", $params)) {
                         $this->_params['selectMembership'] = $params['selectMembership'] = CRM_Utils_Array::value('membership_type_id', $values[$priceFiledID]);
                         $this->set('selectMembership', CRM_Utils_Array::value('selectMembership', $params));
                         if (CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock) == 0) {
                             $this->_values['amount'] = CRM_Utils_Array::value('amount', $values[$priceFiledID]);
                         }
                     }
                 }
                 if ($priceField->name == 'contribution_amount') {
                     $priceFiledID = CRM_Utils_Array::value("price_{$priceField->id}", $params);
                     if ($priceFiledID > 0 && !empty($priceFiledID)) {
                         $params['amount'] = $priceFiledID;
                         $this->_values['amount'] = CRM_Utils_Array::value('amount', $values[$priceFiledID]);
                         $this->_values[$priceFiledID]['value'] = CRM_Utils_Array::value('amount', $values[$priceFiledID]);
                         $this->_values[$priceFiledID]['label'] = CRM_Utils_Array::value('label', $values[$priceFiledID]);
                         $this->_values[$priceFiledID]['amount_id'] = CRM_Utils_Array::value('id', $values[$priceFiledID]);
                         $this->_values[$priceFiledID]['weight'] = CRM_Utils_Array::value('weight', $values[$priceFiledID]);
                     }
                 }
                 if ($priceField->name == "other_amount" && ($priceFiledID = CRM_Utils_Array::value("price_{$priceField->id}", $params))) {
                     $params['amount_other'] = $priceFiledID;
                 }
             }
         }
     }
     if ($this->_values['is_pay_later'] && empty($this->_paymentProcessor) && !array_key_exists('hidden_processor', $params) || CRM_Utils_Array::value('payment_processor', $params) == 0) {
         $params['is_pay_later'] = 1;
     } else {
         $params['is_pay_later'] = 0;
     }
     $this->set('is_pay_later', $params['is_pay_later']);
     // assign pay later stuff
     $this->_params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, FALSE);
     $this->assign('is_pay_later', $params['is_pay_later']);
     if ($params['is_pay_later']) {
         $this->assign('pay_later_text', $this->_values['pay_later_text']);
         $this->assign('pay_later_receipt', $this->_values['pay_later_receipt']);
     }
     //carry campaign from profile.
     if (array_key_exists('contribution_campaign_id', $params)) {
         $params['campaign_id'] = $params['contribution_campaign_id'];
     }
     if (CRM_Utils_Array::value('onbehalfof_id', $params)) {
         $params['organization_id'] = $params['onbehalfof_id'];
     }
     $params['currencyID'] = $config->defaultCurrency;
     $params['amount'] = self::computeAmount($params, $this);
     $params['separate_amount'] = $params['amount'];
     $memFee = NULL;
     if (CRM_Utils_Array::value('selectMembership', $params)) {
         if (!empty($this->_membershipTypeValues)) {
             $membershipTypeValues = $this->_membershipTypeValues[$params['selectMembership']];
         } else {
             $membershipTypeValues = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $params['selectMembership']);
         }
         $memFee = $membershipTypeValues['minimum_fee'];
         if (!$params['amount'] && !$this->_separateMembershipPayment) {
             $params['amount'] = $memFee ? $memFee : 0;
         }
     }
     //If the membership & contribution is used in contribution page & not seperate payment
     $fieldId = $memPresent = $membershipLabel = $fieldOption = $proceFieldAmount = $is_quick_config = NULL;
     if ($this->_separateMembershipPayment == 0) {
         $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_priceSetId, 'is_quick_config');
         if ($is_quick_config) {
             foreach ($this->_priceSet['fields'] as $fieldKey => $fieldVal) {
                 if ($fieldVal['name'] == 'membership_amount') {
                     $fieldId = $fieldVal['id'];
                     $fieldOption = $params['price_' . $fieldId];
                     $memPresent = TRUE;
                 } else {
                     if (CRM_Utils_Array::value('price_' . $fieldKey, $params) && $memPresent && ($fieldVal['name'] == 'other_amount' || $fieldVal['name'] == 'contribution_amount')) {
                         $fieldId = $fieldVal['id'];
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Main.php

示例10: postProcess

 /**
  * Process the form submission.
  */
 public function postProcess()
 {
     $config = CRM_Core_Config::singleton();
     // we first reset the confirm page so it accepts new values
     $this->controller->resetPage('Confirm');
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     //carry campaign from profile.
     if (array_key_exists('contribution_campaign_id', $params)) {
         $params['campaign_id'] = $params['contribution_campaign_id'];
     }
     if (!empty($params['onbehalfof_id'])) {
         $params['organization_id'] = $params['onbehalfof_id'];
     }
     $params['currencyID'] = $config->defaultCurrency;
     if (!empty($params['priceSetId'])) {
         $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
         if ($is_quick_config) {
             $priceField = new CRM_Price_DAO_PriceField();
             $priceField->price_set_id = $params['priceSetId'];
             $priceField->orderBy('weight');
             $priceField->find();
             $priceOptions = array();
             while ($priceField->fetch()) {
                 CRM_Price_BAO_PriceFieldValue::getValues($priceField->id, $priceOptions);
                 if ($selectedPriceOptionID = CRM_Utils_Array::value("price_{$priceField->id}", $params)) {
                     switch ($priceField->name) {
                         case 'membership_amount':
                             $this->_params['selectMembership'] = $params['selectMembership'] = CRM_Utils_Array::value('membership_type_id', $priceOptions[$selectedPriceOptionID]);
                             $this->set('selectMembership', $params['selectMembership']);
                             if (CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock) == 0) {
                                 $this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
                             }
                             break;
                         case 'contribution_amount':
                             $params['amount'] = $selectedPriceOptionID;
                             $this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
                             $this->_values[$selectedPriceOptionID]['value'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
                             $this->_values[$selectedPriceOptionID]['label'] = CRM_Utils_Array::value('label', $priceOptions[$selectedPriceOptionID]);
                             $this->_values[$selectedPriceOptionID]['amount_id'] = CRM_Utils_Array::value('id', $priceOptions[$selectedPriceOptionID]);
                             $this->_values[$selectedPriceOptionID]['weight'] = CRM_Utils_Array::value('weight', $priceOptions[$selectedPriceOptionID]);
                             break;
                         case 'other_amount':
                             $params['amount_other'] = $selectedPriceOptionID;
                             break;
                     }
                 }
             }
         }
     }
     if ($this->_values['is_pay_later'] && empty($this->_paymentProcessor) && !array_key_exists('hidden_processor', $params) || !empty($params['payment_processor_id']) && $params['payment_processor_id'] == 0) {
         $params['is_pay_later'] = 1;
     } else {
         $params['is_pay_later'] = 0;
     }
     $this->set('is_pay_later', $params['is_pay_later']);
     // assign pay later stuff
     $this->_params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, FALSE);
     $this->assign('is_pay_later', $params['is_pay_later']);
     if ($params['is_pay_later']) {
         $this->assign('pay_later_text', $this->_values['pay_later_text']);
         $this->assign('pay_later_receipt', $this->_values['pay_later_receipt']);
     }
     // from here on down, $params['amount'] holds a monetary value (or null) rather than an option ID
     $params['amount'] = self::computeAmount($params, $this->_values);
     $params['separate_amount'] = $params['amount'];
     $memFee = NULL;
     if (!empty($params['selectMembership'])) {
         if (!empty($this->_membershipTypeValues)) {
             $membershipTypeValues = $this->_membershipTypeValues[$params['selectMembership']];
         } else {
             $membershipTypeValues = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, (array) $params['selectMembership']);
         }
         $memFee = $membershipTypeValues['minimum_fee'];
         if (!$params['amount'] && !$this->_separateMembershipPayment) {
             $params['amount'] = $memFee ? $memFee : 0;
         }
     }
     //If the membership & contribution is used in contribution page & not separate payment
     $fieldId = $memPresent = $membershipLabel = $fieldOption = $is_quick_config = NULL;
     $proceFieldAmount = 0;
     if (property_exists($this, '_separateMembershipPayment') && $this->_separateMembershipPayment == 0) {
         $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
         if ($is_quick_config) {
             foreach ($this->_priceSet['fields'] as $fieldKey => $fieldVal) {
                 if ($fieldVal['name'] == 'membership_amount' && !empty($params['price_' . $fieldKey])) {
                     $fieldId = $fieldVal['id'];
                     $fieldOption = $params['price_' . $fieldId];
                     $proceFieldAmount += $fieldVal['options'][$this->_submitValues['price_' . $fieldId]]['amount'];
                     $memPresent = TRUE;
                 } else {
                     if (!empty($params['price_' . $fieldKey]) && $memPresent && ($fieldVal['name'] == 'other_amount' || $fieldVal['name'] == 'contribution_amount')) {
                         $fieldId = $fieldVal['id'];
                         if ($fieldVal['name'] == 'other_amount') {
                             $proceFieldAmount += $this->_submitValues['price_' . $fieldId];
                         } elseif ($fieldVal['name'] == 'contribution_amount' && $this->_submitValues['price_' . $fieldId] > 0) {
                             $proceFieldAmount += $fieldVal['options'][$this->_submitValues['price_' . $fieldId]]['amount'];
//.........这里部分代码省略.........
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:101,代码来源:Main.php

示例11: postProcess

 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     $config = CRM_Core_Config::singleton();
     // we first reset the confirm page so it accepts new values
     $this->controller->resetPage('Confirm');
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     //carry campaign from profile.
     if (array_key_exists('contribution_campaign_id', $params)) {
         $params['campaign_id'] = $params['contribution_campaign_id'];
     }
     if (CRM_Utils_Array::value('onbehalfof_id', $params)) {
         $params['organization_id'] = $params['onbehalfof_id'];
     }
     $params['currencyID'] = $config->defaultCurrency;
     $params['amount'] = self::computeAmount($params, $this);
     $memFee = null;
     if (CRM_Utils_Array::value('selectMembership', $params)) {
         if (!empty($this->_membershipTypeValues)) {
             $membershipTypeValues = $this->_membershipTypeValues[$params['selectMembership']];
         } else {
             $membershipTypeValues = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $params['selectMembership']);
         }
         $memFee = $membershipTypeValues['minimum_fee'];
         if (!$params['amount'] && !$this->_separateMembershipPayment) {
             $params['amount'] = $memFee ? $memFee : 0;
         }
     }
     if (!isset($params['amount_other'])) {
         $this->set('amount_level', CRM_Utils_Array::value('amount_level', $params));
     }
     if ($priceSetId = CRM_Utils_Array::value('priceSetId', $params)) {
         $lineItem = array();
         require_once 'CRM/Price/BAO/Set.php';
         CRM_Price_BAO_Set::processAmount($this->_values['fee'], $params, $lineItem[$priceSetId]);
         $this->set('lineItem', $lineItem);
     }
     $this->set('amount', $params['amount']);
     // generate and set an invoiceID for this transaction
     $invoiceID = md5(uniqid(rand(), true));
     $this->set('invoiceID', $invoiceID);
     // required only if is_monetary and valid postive amount
     if ($this->_values['is_monetary'] && is_array($this->_paymentProcessor) && ((double) $params['amount'] > 0.0 || $memFee > 0.0)) {
         // default mode is direct
         $this->set('contributeMode', 'direct');
         if ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) {
             //get the button name
             $buttonName = $this->controller->getButtonName();
             if (in_array($buttonName, array($this->_expressButtonName, $this->_expressButtonName . '_x', $this->_expressButtonName . '_y')) && !isset($params['is_pay_later'])) {
                 $this->set('contributeMode', 'express');
                 $donateURL = CRM_Utils_System::url('civicrm/contribute', '_qf_Contribute_display=1');
                 $params['cancelURL'] = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=1&qfKey={$params['qfKey']}", true, null, false);
                 $params['returnURL'] = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Confirm_display=1&rfp=1&qfKey={$params['qfKey']}", true, null, false);
                 $params['invoiceID'] = $invoiceID;
                 //default action is Sale
                 $params['payment_action'] = 'Sale';
                 $payment =& CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
                 $token = $payment->setExpressCheckout($params);
                 if (is_a($token, 'CRM_Core_Error')) {
                     CRM_Core_Error::displaySessionError($token);
                     CRM_Utils_System::redirect($params['cancelURL']);
                 }
                 $this->set('token', $token);
                 $paymentURL = $this->_paymentProcessor['url_site'] . "/cgi-bin/webscr?cmd=_express-checkout&token={$token}";
                 CRM_Utils_System::redirect($paymentURL);
             }
         } else {
             if ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_NOTIFY) {
                 $this->set('contributeMode', 'notify');
             }
         }
     }
 }
开发者ID:rajeshrhino,项目名称:Civicrm-Direct-Debit-Integration,代码行数:79,代码来源:Main.php

示例12: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     if ($this->_cdType) {
         CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     parent::buildQuickForm();
     $defaults = parent::setDefaultValues();
     $this->_memType = $defaults['membership_type_id'];
     $this->assign('customDataType', 'Membership');
     $this->assign('customDataSubType', $this->_memType);
     $this->assign('entityID', $this->_id);
     $selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -');
     $allMemberships = CRM_Member_BAO_Membership::buildMembershipTypeValues($this);
     $allMembershipInfo = $membershipType = array();
     // auto renew options if enabled for the membership
     $options = CRM_Core_SelectValues::memberAutoRenew();
     foreach ($allMemberships as $key => $values) {
         if (!empty($values['is_active'])) {
             $membershipType[$key] = CRM_Utils_Array::value('name', $values);
             if ($this->_mode && empty($values['minimum_fee'])) {
                 continue;
             } else {
                 $memberOfContactId = CRM_Utils_Array::value('member_of_contact_id', $values);
                 if (empty($selMemTypeOrg[$memberOfContactId])) {
                     $selMemTypeOrg[$memberOfContactId] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $memberOfContactId, 'display_name', 'id');
                     $selOrgMemType[$memberOfContactId][0] = ts('- select -');
                 }
                 if (empty($selOrgMemType[$memberOfContactId][$key])) {
                     $selOrgMemType[$memberOfContactId][$key] = CRM_Utils_Array::value('name', $values);
                 }
             }
             // build membership info array, which is used to set the payment information block when
             // membership type is selected.
             $allMembershipInfo[$key] = array('financial_type_id' => CRM_Utils_Array::value('financial_type_id', $values), 'total_amount' => CRM_Utils_Money::format($values['minimum_fee'], NULL, '%a'), 'total_amount_numeric' => CRM_Utils_Array::value('minimum_fee', $values));
             if (!empty($values['auto_renew'])) {
                 $allMembershipInfo[$key]['auto_renew'] = $options[$values['auto_renew']];
             }
         }
     }
     $this->assign('allMembershipInfo', json_encode($allMembershipInfo));
     if ($this->_memType) {
         $this->assign('orgName', $selMemTypeOrg[$allMemberships[$this->_memType]['member_of_contact_id']]);
         $this->assign('memType', $allMemberships[$this->_memType]['name']);
     }
     // force select of organization by default, if only one organization in
     // the list
     if (count($selMemTypeOrg) == 2) {
         unset($selMemTypeOrg[0], $selOrgMemType[0][0]);
     }
     //sort membership organization and type, CRM-6099
     natcasesort($selMemTypeOrg);
     foreach ($selOrgMemType as $index => $orgMembershipType) {
         natcasesort($orgMembershipType);
         $selOrgMemType[$index] = $orgMembershipType;
     }
     $js = array('onChange' => "setPaymentBlock( ); CRM.buildCustomData( 'Membership', this.value );");
     $sel =& $this->addElement('hierselect', 'membership_type_id', ts('Renewal Membership Organization and Type'), $js);
     $sel->setOptions(array($selMemTypeOrg, $selOrgMemType));
     $elements = array();
     if ($sel) {
         $elements[] = $sel;
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->addDate('renewal_date', ts('Date Renewal Entered'), FALSE, array('formatType' => 'activityDate'));
     $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType());
     if (CRM_Core_Permission::access('CiviContribute') && !$this->_mode) {
         $this->addElement('checkbox', 'record_contribution', ts('Record Renewal Payment?'), NULL, array('onclick' => "checkPayment();"));
         $this->add('text', 'total_amount', ts('Amount'));
         $this->addRule('total_amount', ts('Please enter a valid amount.'), 'money');
         $this->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime'));
         $this->add('text', 'num_terms', ts('Extend Membership by'), array('onchange' => "setPaymentBlock();"), TRUE);
         $this->addRule('num_terms', ts('Please enter a whole number for how many periods to renew.'), 'integer');
         $this->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);"));
         $this->add('text', 'trxn_id', ts('Transaction ID'));
         $this->addRule('trxn_id', ts('Transaction ID already exists in Database.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $this->_id, 'trxn_id'));
         $this->add('select', 'contribution_status_id', ts('Payment Status'), CRM_Contribute_PseudoConstant::contributionStatus());
         $this->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number'));
     } else {
         $this->add('text', 'total_amount', ts('Amount'));
         $this->addRule('total_amount', ts('Please enter a valid amount.'), 'money');
     }
     $this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), NULL, array('onclick' => "showHideByValue( 'send_receipt', '', 'notice', 'table-row', 'radio', false ); showHideByValue( 'send_receipt', '', 'fromEmail', 'table-row', 'radio',false);"));
     $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails);
     $this->add('textarea', 'receipt_text_renewal', ts('Renewal Message'));
     // Retrieve the name and email of the contact - this will be the TO for receipt email
     list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
     $this->assign('email', $this->_contributorEmail);
     // The member form uses emailExists. Assigning both while we transition / synchronise.
     $this->assign('emailExists', $this->_contributorEmail);
     $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend');
     $this->assign('outBound_option', $mailingInfo['outBound_option']);
     if (CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'contribution_recur_id')) {
         if (CRM_Member_BAO_Membership::isCancelSubscriptionSupported($this->_id)) {
             $this->assign('cancelAutoRenew', CRM_Utils_System::url('civicrm/contribute/unsubscribe', "reset=1&mid={$this->_id}"));
         }
     }
     $this->addFormRule(array('CRM_Member_Form_MembershipRenewal', 'formRule'));
//.........这里部分代码省略.........
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:101,代码来源:MembershipRenewal.php


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