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


PHP CRM_Price_BAO_PriceFieldValue::getValues方法代码示例

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


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

示例1: setDefaultValues

 /**
  * Set default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     //parent::setDefaultValues();
     $defaults = array();
     if (isset($this->_id)) {
         $defaults = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
     }
     $defaults['member_is_active'] = $defaults['is_active'];
     // Set Display Minimum Fee default to true if we are adding a new membership block
     if (!isset($defaults['id'])) {
         $defaults['display_min_fee'] = 1;
     } else {
         $this->assign('membershipBlockId', $defaults['id']);
     }
     if ($this->_id && ($priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 3, 1))) {
         $defaults['member_price_set_id'] = $priceSetId;
         $this->_memPriceSetId = $priceSetId;
     } else {
         // for membership_types
         // if ( isset( $defaults['membership_types'] ) ) {
         $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 3);
         $this->assign('isQuick', 1);
         $this->_memPriceSetId = $priceSetId;
         $pFIDs = array();
         if ($priceSetId) {
             CRM_Core_DAO::commonRetrieveAll('CRM_Price_DAO_PriceField', 'price_set_id', $priceSetId, $pFIDs, $return = array('html_type', 'name', 'label'));
             foreach ($pFIDs as $pid => $pValue) {
                 if ($pValue['html_type'] == 'Radio' && $pValue['name'] == 'membership_amount') {
                     $defaults['mem_price_field_id'] = $pValue['id'];
                     $defaults['membership_type_label'] = $pValue['label'];
                 }
             }
             if (!empty($defaults['mem_price_field_id'])) {
                 $options = array();
                 $priceFieldOptions = CRM_Price_BAO_PriceFieldValue::getValues($defaults['mem_price_field_id'], $options, 'id', 1);
                 foreach ($options as $k => $v) {
                     $newMembershipType[$v['membership_type_id']] = 1;
                     if (!empty($defaults['auto_renew'])) {
                         $defaults["auto_renew_" . $v['membership_type_id']] = $defaults['auto_renew'][$v['membership_type_id']];
                     }
                 }
                 $defaults['membership_type'] = $newMembershipType;
             }
         }
     }
     return $defaults;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:54,代码来源:MembershipBlock.php

示例2: setDefaultValues

 /**
  * Set default values for the form.
  *
  * For edit/view mode the default values are retrieved from the database.
  */
 public function setDefaultValues()
 {
     $parentDefaults = parent::setDefaultValues();
     $eventId = $this->_id;
     $params = array();
     $defaults = array();
     if (isset($eventId)) {
         $params = array('id' => $eventId);
     }
     CRM_Event_BAO_Event::retrieve($params, $defaults);
     if (isset($eventId)) {
         $price_set_id = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventId, NULL, 1);
         if ($price_set_id) {
             $defaults['price_set_id'] = $price_set_id;
         } else {
             $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventId, NULL);
             if ($priceSetId) {
                 if ($isQuick = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) {
                     $this->assign('isQuick', $isQuick);
                     $priceField = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $priceSetId, 'id', 'price_set_id');
                     $options = array();
                     $priceFieldOptions = CRM_Price_BAO_PriceFieldValue::getValues($priceField, $options, 'weight', TRUE);
                     $defaults['price_field_id'] = $priceField;
                     $countRow = 0;
                     foreach ($options as $optionId => $optionValue) {
                         $countRow++;
                         $defaults['value'][$countRow] = CRM_Utils_Money::format($optionValue['amount'], NULL, '%a');
                         $defaults['label'][$countRow] = $optionValue['label'];
                         $defaults['name'][$countRow] = $optionValue['name'];
                         $defaults['weight'][$countRow] = $optionValue['weight'];
                         $defaults['price_field_value'][$countRow] = $optionValue['id'];
                         if ($optionValue['is_default']) {
                             $defaults['default'] = $countRow;
                         }
                     }
                 }
             }
         }
     }
     //check if discounted
     $discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($this->_id, 'civicrm_event');
     if (!empty($discountedEvent)) {
         $defaults['is_discount'] = $i = 1;
         $totalLables = $maxSize = $defaultDiscounts = array();
         foreach ($discountedEvent as $optionGroupId) {
             $defaults['discount_price_set'][] = $optionGroupId;
             $name = $defaults["discount_name[{$i}]"] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $optionGroupId, 'title');
             list($defaults["discount_start_date[{$i}]"]) = CRM_Utils_Date::setDateDefaults(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $optionGroupId, 'start_date', 'price_set_id'));
             list($defaults["discount_end_date[{$i}]"]) = CRM_Utils_Date::setDateDefaults(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $optionGroupId, 'end_date', 'price_set_id'));
             $defaultDiscounts[] = CRM_Price_BAO_PriceSet::getSetDetail($optionGroupId);
             $i++;
         }
         //avoid moving up value of lable when some labels don't
         //have a value ,fixed for CRM-3088
         $rowCount = 1;
         foreach ($defaultDiscounts as $val) {
             $discountFields = current($val);
             $discountFields = current($discountFields['fields']);
             foreach ($discountFields['options'] as $discountFieldsval) {
                 $defaults['discounted_label'][$discountFieldsval['weight']] = $discountFieldsval['label'];
                 $defaults['discounted_value'][$discountFieldsval['weight']][$rowCount] = CRM_Utils_Money::format($discountFieldsval['amount'], NULL, '%a');
                 $defaults['discount_option_id'][$rowCount][$discountFieldsval['weight']] = $discountFieldsval['id'];
                 if (!empty($discountFieldsval['is_default'])) {
                     $defaults['discounted_default'] = $discountFieldsval['weight'];
                 }
             }
             $rowCount++;
         }
         //CRM-12970
         ksort($defaults['discounted_value']);
         ksort($defaults['discounted_label']);
         $rowCount = 1;
         foreach ($defaults['discounted_label'] as $key => $value) {
             if ($key != $rowCount) {
                 $defaults['discounted_label'][$rowCount] = $value;
                 $defaults['discounted_value'][$rowCount] = $defaults['discounted_value'][$key];
                 unset($defaults['discounted_value'][$key]);
                 unset($defaults['discounted_label'][$key]);
                 foreach ($defaults['discount_option_id'] as &$optionIds) {
                     if (array_key_exists($key, $optionIds)) {
                         $optionIds[$rowCount] = $optionIds[$key];
                         unset($optionIds[$key]);
                     }
                 }
             }
             $rowCount++;
         }
         $this->set('discountSection', 1);
         $this->buildQuickForm();
     } elseif (!empty($defaults['label'])) {
         //if Regular Fees are present in DB and event fee page is in update mode
         $defaults['discounted_label'] = $defaults['label'];
     } elseif (!empty($this->_submitValues['label'])) {
         //if event is newly created, use submitted values for
         //discount labels
//.........这里部分代码省略.........
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:101,代码来源:Fee.php

示例3: browse

 /**
  * Browse all price fields.
  *
  * @param null
  *
  * @return void
  * @access public
  */
 function browse()
 {
     $customOption = array();
     CRM_Price_BAO_PriceFieldValue::getValues($this->_fid, $customOption);
     $config = CRM_Core_Config::singleton();
     $financialType = CRM_Contribute_PseudoConstant::financialType();
     foreach ($customOption as $id => $values) {
         $action = array_sum(array_keys($this->actionLinks()));
         if (CRM_Utils_Array::value('financial_type_id', $values)) {
             $customOption[$id]['financial_type_id'] = $financialType[$values['financial_type_id']];
         }
         // update enable/disable links depending on price_field properties.
         if ($this->_isSetReserved) {
             $action -= CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE + CRM_Core_Action::DISABLE + CRM_Core_Action::ENABLE;
         } else {
             if ($values['is_active']) {
                 $action -= CRM_Core_Action::ENABLE;
             } else {
                 $action -= CRM_Core_Action::DISABLE;
             }
         }
         if (CRM_Utils_Array::value('is_default', $customOption[$id])) {
             $customOption[$id]['is_default'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
         } else {
             $customOption[$id]['is_default'] = '';
         }
         $customOption[$id]['order'] = $customOption[$id]['weight'];
         $customOption[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('oid' => $id, 'fid' => $this->_fid, 'sid' => $this->_sid));
     }
     // Add order changing widget to selector
     $returnURL = CRM_Utils_System::url('civicrm/admin/price/field/option', "action=browse&reset=1&fid={$this->_fid}&sid={$this->_sid}");
     $filter = "price_field_id = {$this->_fid}";
     CRM_Utils_Weight::addOrder($customOption, 'CRM_Price_DAO_PriceFieldValue', 'id', $returnURL, $filter);
     $this->assign('customOption', $customOption);
     $this->assign('sid', $this->_sid);
 }
开发者ID:hguru,项目名称:224Civi,代码行数:44,代码来源:Option.php

示例4: priceSetValidation

 /**
  * Validate the priceset
  *
  * @param int $priceSetId , array $fields
  *
  * retrun the error string
  *
  * @param $fields
  * @param $error
  * @param bool $allowNoneSelection
  *
  * @access public
  * @static
  */
 public static function priceSetValidation($priceSetId, $fields, &$error, $allowNoneSelection = FALSE)
 {
     // check for at least one positive
     // amount price field should be selected.
     $priceField = new CRM_Price_DAO_PriceField();
     $priceField->price_set_id = $priceSetId;
     $priceField->find();
     $priceFields = array();
     if ($allowNoneSelection) {
         $noneSelectedPriceFields = array();
     }
     while ($priceField->fetch()) {
         $key = "price_{$priceField->id}";
         if ($allowNoneSelection) {
             if (array_key_exists($key, $fields)) {
                 if ($fields[$key] == 0 && !$priceField->is_required) {
                     $noneSelectedPriceFields[] = $priceField->id;
                 }
             }
         }
         if (!empty($fields[$key])) {
             $priceFields[$priceField->id] = $fields[$key];
         }
     }
     if (!empty($priceFields)) {
         // we should has to have positive amount.
         $sql = "\nSELECT  id, html_type\nFROM  civicrm_price_field\nWHERE  id IN (" . implode(',', array_keys($priceFields)) . ')';
         $fieldDAO = CRM_Core_DAO::executeQuery($sql);
         $htmlTypes = array();
         while ($fieldDAO->fetch()) {
             $htmlTypes[$fieldDAO->id] = $fieldDAO->html_type;
         }
         $selectedAmounts = array();
         foreach ($htmlTypes as $fieldId => $type) {
             $options = array();
             CRM_Price_BAO_PriceFieldValue::getValues($fieldId, $options);
             if (empty($options)) {
                 continue;
             }
             if ($type == 'Text') {
                 foreach ($options as $opId => $option) {
                     $selectedAmounts[$opId] = $priceFields[$fieldId] * $option['amount'];
                     break;
                 }
             } elseif (is_array($fields["price_{$fieldId}"])) {
                 foreach (array_keys($fields["price_{$fieldId}"]) as $opId) {
                     $selectedAmounts[$opId] = $options[$opId]['amount'];
                 }
             } elseif (in_array($fields["price_{$fieldId}"], array_keys($options))) {
                 $selectedAmounts[$fields["price_{$fieldId}"]] = $options[$fields["price_{$fieldId}"]]['amount'];
             }
         }
         list($componentName) = explode(':', $fields['_qf_default']);
         // now we have all selected amount in hand.
         $totalAmount = array_sum($selectedAmounts);
         if ($totalAmount < 0) {
             $error['_qf_default'] = ts('%1 amount can not be less than zero. Please select the options accordingly.', array(1 => $componentName));
         }
     } else {
         if ($allowNoneSelection) {
             if (empty($noneSelectedPriceFields)) {
                 $error['_qf_default'] = ts('Please select at least one option from price set.');
             }
         } else {
             $error['_qf_default'] = ts('Please select at least one option from price set.');
         }
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:82,代码来源:PriceField.php

示例5: 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

示例6: format

 /**
  * This method will create the lineItem array required for
  * processAmount method
  *
  * @param int $fid
  *   Price set field id.
  * @param array $params
  *   Reference to form values.
  * @param array $fields
  *   Reference to array of fields belonging.
  *                          to the price set used for particular event
  * @param array $values
  *   Reference to the values array(.
  *   this is
  *                          lineItem array)
  *
  * @return void
  */
 public static function format($fid, &$params, &$fields, &$values)
 {
     if (empty($params["price_{$fid}"])) {
         return;
     }
     $optionIDs = implode(',', array_keys($params["price_{$fid}"]));
     //lets first check in fun parameter,
     //since user might modified w/ hooks.
     $options = array();
     if (array_key_exists('options', $fields)) {
         $options = $fields['options'];
     } else {
         CRM_Price_BAO_PriceFieldValue::getValues($fid, $options, 'weight', TRUE);
     }
     $fieldTitle = CRM_Utils_Array::value('label', $fields);
     if (!$fieldTitle) {
         $fieldTitle = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $fid, 'label');
     }
     foreach ($params["price_{$fid}"] as $oid => $qty) {
         $price = $options[$oid]['amount'];
         // lets clean the price in case it is not yet cleant
         // CRM-10974
         $price = CRM_Utils_Rule::cleanMoney($price);
         $participantsPerField = CRM_Utils_Array::value('count', $options[$oid], 0);
         $values[$oid] = array('price_field_id' => $fid, 'price_field_value_id' => $oid, 'label' => CRM_Utils_Array::value('label', $options[$oid]), 'field_title' => $fieldTitle, 'description' => CRM_Utils_Array::value('description', $options[$oid]), 'qty' => $qty, 'unit_price' => $price, 'line_total' => $qty * $price, 'participant_count' => $qty * $participantsPerField, 'max_value' => CRM_Utils_Array::value('max_value', $options[$oid]), 'membership_type_id' => CRM_Utils_Array::value('membership_type_id', $options[$oid]), 'membership_num_terms' => CRM_Utils_Array::value('membership_num_terms', $options[$oid]), 'auto_renew' => CRM_Utils_Array::value('auto_renew', $options[$oid]), 'html_type' => $fields['html_type'], 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $options[$oid]), 'tax_amount' => CRM_Utils_Array::value('tax_amount', $options[$oid]));
         if ($values[$oid]['membership_type_id'] && empty($values[$oid]['auto_renew'])) {
             $values[$oid]['auto_renew'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $values[$oid]['membership_type_id'], 'auto_renew');
         }
     }
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:48,代码来源:LineItem.php

示例7: browse

 /**
  * Browse all price fields.
  *
  * @return void
  */
 public function browse()
 {
     $customOption = array();
     CRM_Price_BAO_PriceFieldValue::getValues($this->_fid, $customOption);
     // CRM-15378 - check if these price options are in an Event price set
     $isEvent = FALSE;
     $extendComponentId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'extends', 'id');
     $allComponents = explode(CRM_Core_DAO::VALUE_SEPARATOR, $extendComponentId);
     $eventComponentId = CRM_Core_Component::getComponentID('CiviEvent');
     if (in_array($eventComponentId, $allComponents)) {
         $isEvent = TRUE;
     }
     $config = CRM_Core_Config::singleton();
     $financialType = CRM_Contribute_PseudoConstant::financialType();
     $taxRate = CRM_Core_PseudoConstant::getTaxRates();
     // display taxTerm for priceFields
     $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
     $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
     $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
     $getTaxDetails = FALSE;
     foreach ($customOption as $id => $values) {
         $action = array_sum(array_keys($this->actionLinks()));
         // Adding the required fields in the array
         if (isset($taxRate[$values['financial_type_id']])) {
             $customOption[$id]['tax_rate'] = $taxRate[$values['financial_type_id']];
             if ($invoicing && isset($customOption[$id]['tax_rate'])) {
                 $getTaxDetails = TRUE;
             }
             $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($customOption[$id]['amount'], $customOption[$id]['tax_rate']);
             $customOption[$id]['tax_amount'] = $taxAmount['tax_amount'];
         }
         if (!empty($values['financial_type_id'])) {
             $customOption[$id]['financial_type_id'] = $financialType[$values['financial_type_id']];
         }
         // update enable/disable links depending on price_field properties.
         if ($this->_isSetReserved) {
             $action -= CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE + CRM_Core_Action::DISABLE + CRM_Core_Action::ENABLE;
         } else {
             if ($values['is_active']) {
                 $action -= CRM_Core_Action::ENABLE;
             } else {
                 $action -= CRM_Core_Action::DISABLE;
             }
         }
         if (!empty($customOption[$id]['is_default'])) {
             $customOption[$id]['is_default'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
         } else {
             $customOption[$id]['is_default'] = '';
         }
         $customOption[$id]['order'] = $customOption[$id]['weight'];
         $customOption[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('oid' => $id, 'fid' => $this->_fid, 'sid' => $this->_sid), ts('more'), FALSE, 'priceFieldValue.row.actions', 'PriceFieldValue', $id);
     }
     // Add order changing widget to selector
     $returnURL = CRM_Utils_System::url('civicrm/admin/price/field/option', "action=browse&reset=1&fid={$this->_fid}&sid={$this->_sid}");
     $filter = "price_field_id = {$this->_fid}";
     CRM_Utils_Weight::addOrder($customOption, 'CRM_Price_DAO_PriceFieldValue', 'id', $returnURL, $filter);
     $this->assign('taxTerm', $taxTerm);
     $this->assign('getTaxDetails', $getTaxDetails);
     $this->assign('customOption', $customOption);
     $this->assign('sid', $this->_sid);
     $this->assign('isEvent', $isEvent);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:67,代码来源:Option.php

示例8: setDefaultValues

 /**
  * Set default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @return array
  */
 public function setDefaultValues()
 {
     $defaults = parent::setDefaultValues();
     if (empty($defaults['pay_later_text'])) {
         $defaults['pay_later_text'] = ts('I will send payment by check');
     }
     if (!empty($defaults['amount_block_is_active'])) {
         if ($priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, NULL)) {
             if ($isQuick = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) {
                 $this->assign('isQuick', $isQuick);
                 //$priceField = CRM_Core_DAO::getFieldValue( 'CRM_Price_DAO_PriceField', $priceSetId, 'id', 'price_set_id' );
                 $options = $pFIDs = array();
                 $priceFieldParams = array('price_set_id' => $priceSetId);
                 $priceFields = CRM_Core_DAO::commonRetrieveAll('CRM_Price_DAO_PriceField', 'price_set_id', $priceSetId, $pFIDs, $return = array('html_type', 'name', 'is_active', 'label'));
                 foreach ($priceFields as $priceField) {
                     if ($priceField['id'] && $priceField['html_type'] == 'Radio' && $priceField['name'] == 'contribution_amount') {
                         $defaults['price_field_id'] = $priceField['id'];
                         $priceFieldOptions = CRM_Price_BAO_PriceFieldValue::getValues($priceField['id'], $options, 'id', 1);
                         if (empty($priceFieldOptions)) {
                             continue;
                         }
                         $countRow = 0;
                         $defaults['amount_label'] = $priceField['label'];
                         foreach ($options as $optionId => $optionValue) {
                             $countRow++;
                             $defaults['value'][$countRow] = $optionValue['amount'];
                             $defaults['label'][$countRow] = CRM_Utils_Array::value('label', $optionValue);
                             $defaults['name'][$countRow] = CRM_Utils_Array::value('name', $optionValue);
                             $defaults['weight'][$countRow] = $optionValue['weight'];
                             $defaults["price_field_value"][$countRow] = $optionValue['id'];
                             if ($optionValue['is_default']) {
                                 $defaults['default'] = $countRow;
                             }
                         }
                     } elseif ($priceField['id'] && $priceField['html_type'] == 'Text' && ($priceField['name'] = 'other_amount' && $priceField['is_active'])) {
                         $defaults['price_field_other'] = $priceField['id'];
                         if (!isset($defaults['amount_label'])) {
                             $defaults['amount_label'] = $priceField['label'];
                         }
                     }
                 }
             }
         }
         if (empty($defaults['amount_label'])) {
             $defaults['amount_label'] = ts('Contribution Amount');
         }
         if (!empty($defaults['value']) && is_array($defaults['value'])) {
             // CRM-4038: fix value display
             foreach ($defaults['value'] as &$amount) {
                 $amount = trim(CRM_Utils_Money::format($amount, ' '));
             }
         }
     }
     // fix the display of the monetary value, CRM-4038
     if (isset($defaults['min_amount'])) {
         $defaults['min_amount'] = CRM_Utils_Money::format($defaults['min_amount'], NULL, '%a');
     }
     if (isset($defaults['max_amount'])) {
         $defaults['max_amount'] = CRM_Utils_Money::format($defaults['max_amount'], NULL, '%a');
     }
     if (!empty($defaults['payment_processor'])) {
         $defaults['payment_processor'] = array_fill_keys(explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaults['payment_processor']), '1');
     }
     return $defaults;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:72,代码来源:Amount.php

示例9: 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

示例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


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