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


PHP CRM_Utils_Hook::buildAmount方法代码示例

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


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

示例1: buildAmount

 /**
  * build the radio/text form elements for the amount field
  *
  * @param object   $form form object
  * @param boolean  $required  true if you want to add formRule
  * @param int      $discountId discount id for the event
  *
  * @return void
  * @access public
  * @static
  */
 public static function buildAmount(&$form, $required = TRUE, $discountId = NULL)
 {
     //if payment done, no need to build the fee block.
     if (!empty($form->_paymentId)) {
         //fix to display line item in update mode.
         $form->assign('priceSet', isset($form->_priceSet) ? $form->_priceSet : NULL);
         return;
     }
     $feeFields = CRM_Utils_Array::value('fee', $form->_values);
     if (is_array($feeFields)) {
         $form->_feeBlock =& $form->_values['fee'];
     }
     //check for discount.
     $discountedFee = CRM_Utils_Array::value('discount', $form->_values);
     if (is_array($discountedFee) && !empty($discountedFee)) {
         if (!$discountId) {
             $form->_discountId = $discountId = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
         }
         if ($discountId) {
             $form->_feeBlock =& $form->_values['discount'][$discountId];
         }
     }
     if (!is_array($form->_feeBlock)) {
         $form->_feeBlock = array();
     }
     //its time to call the hook.
     CRM_Utils_Hook::buildAmount('event', $form, $form->_feeBlock);
     //reset required if participant is skipped.
     $button = substr($form->controller->getButtonName(), -4);
     if ($required && $button == 'skip') {
         $required = FALSE;
     }
     $className = CRM_Utils_System::getClassName($form);
     //build the priceset fields.
     if (isset($form->_priceSetId) && $form->_priceSetId) {
         //format price set fields across option full.
         self::formatFieldsForOptionFull($form);
         if (CRM_Utils_Array::value('is_quick_config', $form->_priceSet)) {
             $form->_quickConfig = $form->_priceSet['is_quick_config'];
         }
         $form->add('hidden', 'priceSetId', $form->_priceSetId);
         foreach ($form->_feeBlock as $field) {
             if (CRM_Utils_Array::value('visibility', $field) == 'public' || $className == 'CRM_Event_Form_Participant') {
                 $fieldId = $field['id'];
                 $elementName = 'price_' . $fieldId;
                 $isRequire = CRM_Utils_Array::value('is_required', $field);
                 if ($button == 'skip') {
                     $isRequire = FALSE;
                 }
                 //user might modified w/ hook.
                 $options = CRM_Utils_Array::value('options', $field);
                 if (!is_array($options)) {
                     continue;
                 }
                 $optionFullIds = CRM_Utils_Array::value('option_full_ids', $field, array());
                 //soft suppress required rule when option is full.
                 if (!empty($optionFullIds) && count($options) == count($optionFullIds)) {
                     $isRequire = FALSE;
                 }
                 //build the element.
                 CRM_Price_BAO_PriceField::addQuickFormElement($form, $elementName, $fieldId, FALSE, $isRequire, NULL, $options, $optionFullIds);
             }
         }
         $form->assign('priceSet', $form->_priceSet);
     } else {
         $eventFeeBlockValues = array();
         foreach ($form->_feeBlock as $fee) {
             if (is_array($fee)) {
                 //CRM-7632, CRM-6201
                 $totalAmountJs = NULL;
                 if ($className == 'CRM_Event_Form_Participant') {
                     $totalAmountJs = array('onClick' => "fillTotalAmount(" . $fee['value'] . ")");
                 }
                 $eventFeeBlockValues['amount_id_' . $fee['amount_id']] = $fee['value'];
                 $elements[] =& $form->createElement('radio', NULL, '', CRM_Utils_Money::format($fee['value']) . ' ' . $fee['label'], $fee['amount_id'], $totalAmountJs);
             }
         }
         $form->assign('eventFeeBlockValues', json_encode($eventFeeBlockValues));
         $form->_defaults['amount'] = CRM_Utils_Array::value('default_fee_id', $form->_values['event']);
         $element =& $form->addGroup($elements, 'amount', ts('Event Fee(s)'), '<br />');
         if (isset($form->_online) && $form->_online) {
             $element->freeze();
         }
         if ($required) {
             $form->addRule('amount', ts('Fee Level is a required field.'), 'required');
         }
     }
 }
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:99,代码来源:Register.php

示例2: buildPriceSet

 /**
  * Build the price set form.
  *
  * @param CRM_Core_Form $form
  *
  * @return void
  */
 public static function buildPriceSet(&$form)
 {
     $priceSetId = $form->get('priceSetId');
     if (!$priceSetId) {
         return;
     }
     $validFieldsOnly = TRUE;
     $className = CRM_Utils_System::getClassName($form);
     if (in_array($className, array('CRM_Contribute_Form_Contribution', 'CRM_Member_Form_Membership'))) {
         $validFieldsOnly = FALSE;
     }
     $priceSet = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly);
     $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
     $validPriceFieldIds = array_keys($form->_priceSet['fields']);
     $form->_quickConfig = $quickConfig = 0;
     if (CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) {
         $quickConfig = 1;
     }
     $form->assign('quickConfig', $quickConfig);
     if ($className == 'CRM_Contribute_Form_Contribution_Main') {
         $form->_quickConfig = $quickConfig;
     }
     $form->assign('priceSet', $form->_priceSet);
     $component = 'contribution';
     if ($className == 'CRM_Member_Form_Membership') {
         $component = 'membership';
     }
     if ($className == 'CRM_Contribute_Form_Contribution_Main') {
         $feeBlock =& $form->_values['fee'];
         if (!empty($form->_useForMember)) {
             $component = 'membership';
         }
     } else {
         $feeBlock =& $form->_priceSet['fields'];
     }
     // call the hook.
     CRM_Utils_Hook::buildAmount($component, $form, $feeBlock);
     // CRM-14492 Admin price fields should show up on event registration if user has 'administer CiviCRM' permissions
     $adminFieldVisible = FALSE;
     if (CRM_Core_Permission::check('administer CiviCRM')) {
         $adminFieldVisible = TRUE;
     }
     foreach ($feeBlock as $id => $field) {
         if (CRM_Utils_Array::value('visibility', $field) == 'public' || CRM_Utils_Array::value('visibility', $field) == 'admin' && $adminFieldVisible == TRUE || !$validFieldsOnly) {
             $options = CRM_Utils_Array::value('options', $field);
             if ($className == 'CRM_Contribute_Form_Contribution_Main' && ($component = 'membership')) {
                 $userid = $form->getVar('_membershipContactID');
                 $checklifetime = self::checkCurrentMembership($options, $userid);
                 if ($checklifetime) {
                     $form->assign('ispricelifetime', TRUE);
                 }
             }
             if (!is_array($options) || !in_array($id, $validPriceFieldIds)) {
                 continue;
             }
             CRM_Price_BAO_PriceField::addQuickFormElement($form, 'price_' . $field['id'], $field['id'], FALSE, CRM_Utils_Array::value('is_required', $field, FALSE), NULL, $options);
         }
     }
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:66,代码来源:PriceSet.php

示例3: buildPriceSet

 /**
  * Build the price set form.
  *
  * @param CRM_Core_Form $form
  *
  * @return void
  */
 public static function buildPriceSet(&$form)
 {
     $priceSetId = $form->get('priceSetId');
     $userid = $form->getVar('_userID');
     if (!$priceSetId) {
         return;
     }
     $validFieldsOnly = TRUE;
     $className = CRM_Utils_System::getClassName($form);
     if (in_array($className, array('CRM_Contribute_Form_Contribution', 'CRM_Member_Form_Membership'))) {
         $validFieldsOnly = FALSE;
     }
     $priceSet = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly);
     $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
     $form->_quickConfig = $quickConfig = 0;
     if (CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $priceSetId, 'is_quick_config')) {
         $quickConfig = 1;
     }
     $form->assign('quickConfig', $quickConfig);
     if ($className == "CRM_Contribute_Form_Contribution_Main") {
         $form->_quickConfig = $quickConfig;
     }
     $form->assign('priceSet', $form->_priceSet);
     $component = 'contribution';
     if ($className == 'CRM_Member_Form_Membership') {
         $component = 'membership';
     }
     if ($className == 'CRM_Contribute_Form_Contribution_Main') {
         $feeBlock =& $form->_values['fee'];
         if (!empty($form->_useForMember)) {
             $component = 'membership';
         }
     } else {
         $feeBlock =& $form->_priceSet['fields'];
     }
     // call the hook.
     CRM_Utils_Hook::buildAmount($component, $form, $feeBlock);
     foreach ($feeBlock as $field) {
         if (CRM_Utils_Array::value('visibility', $field) == 'public' || !$validFieldsOnly) {
             $options = CRM_Utils_Array::value('options', $field);
             if ($className == 'CRM_Contribute_Form_Contribution_Main' && ($component = 'membership')) {
                 $checklifetime = self::checkCurrentMembership($options, $userid);
                 if ($checklifetime) {
                     $form->assign('ispricelifetime', TRUE);
                 }
             }
             if (!is_array($options)) {
                 continue;
             }
             CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::addQuickFormElement($form, 'price_' . $field['id'], $field['id'], FALSE, CRM_Utils_Array::value('is_required', $field, FALSE), NULL, $options);
         }
     }
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:60,代码来源:Set.php

示例4: buildAmount

 /**
  * build the radio/text form elements for the amount field
  *
  * @return void
  * @access private
  */
 function buildAmount($separateMembershipPayment = FALSE)
 {
     $elements = array();
     if (!empty($this->_values['amount'])) {
         // first build the radio boxes
         CRM_Utils_Hook::buildAmount('contribution', $this, $this->_values['amount']);
         foreach ($this->_values['amount'] as $amount) {
             $elements[] =& $this->createElement('radio', NULL, '', CRM_Utils_Money::format($amount['value']) . ' ' . $amount['label'], $amount['amount_id'], array('onclick' => 'clearAmountOther();'));
         }
     }
     if ($separateMembershipPayment) {
         $elements[''] = $this->createElement('radio', NULL, NULL, ts('No thank you'), 'no_thanks', array('onclick' => 'clearAmountOther();'));
         $this->assign('is_separate_payment', TRUE);
     }
     if (isset($this->_values['default_amount_id'])) {
         $this->_defaults['amount'] = $this->_values['default_amount_id'];
     }
     $title = ts('Contribution Amount');
     if ($this->_values['is_allow_other_amount']) {
         if (!empty($this->_values['amount'])) {
             $elements[] =& $this->createElement('radio', NULL, '', ts('Other Amount'), 'amount_other_radio');
             $this->addGroup($elements, 'amount', $title, '<br />');
             if (!$separateMembershipPayment) {
                 $this->addRule('amount', ts('%1 is a required field.', array(1 => ts('Amount'))), 'required');
             }
             $this->add('text', 'amount_other', ts('Other Amount'), array('size' => 10, 'maxlength' => 10, 'onfocus' => 'useAmountOther();'));
         } else {
             if ($separateMembershipPayment) {
                 $title = ts('Additional Contribution');
             }
             $this->add('text', 'amount_other', $title, array('size' => 10, 'maxlength' => 10, 'onfocus' => 'useAmountOther();'));
             if (!$separateMembershipPayment) {
                 $this->addRule('amount_other', ts('%1 is a required field.', array(1 => $title)), 'required');
             }
         }
         $this->assign('is_allow_other_amount', TRUE);
         $this->addRule('amount_other', ts('Please enter a valid amount (numbers and decimal point only).'), 'money');
     } else {
         if (!empty($this->_values['amount'])) {
             if ($separateMembershipPayment) {
                 $title = ts('Additional Contribution');
             }
             $this->addGroup($elements, 'amount', $title, '<br />');
             if (!$separateMembershipPayment) {
                 $this->addRule('amount', ts('%1 is a required field.', array(1 => ts('Amount'))), 'required');
             }
         }
         $this->assign('is_allow_other_amount', FALSE);
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:56,代码来源:Main.php

示例5: buildPriceSet

 /**
  * Build the price set form.
  *
  * @param CRM_Core_Form $form
  *
  * @return void
  */
 public static function buildPriceSet(&$form)
 {
     $priceSetId = $form->get('priceSetId');
     if (!$priceSetId) {
         return;
     }
     $validFieldsOnly = TRUE;
     $className = CRM_Utils_System::getClassName($form);
     if (in_array($className, array('CRM_Contribute_Form_Contribution', 'CRM_Member_Form_Membership'))) {
         $validFieldsOnly = FALSE;
     }
     $priceSet = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly);
     $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
     $validPriceFieldIds = array_keys($form->_priceSet['fields']);
     $form->_quickConfig = $quickConfig = 0;
     if (CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) {
         $quickConfig = 1;
     }
     $form->assign('quickConfig', $quickConfig);
     if ($className == 'CRM_Contribute_Form_Contribution_Main') {
         $form->_quickConfig = $quickConfig;
     }
     // Mark which field should have the auto-renew checkbox, if any. CRM-18305
     if (!empty($form->_membershipTypeValues) && is_array($form->_membershipTypeValues)) {
         $autoRenewMembershipTypes = array();
         foreach ($form->_membershipTypeValues as $membershiptTypeValue) {
             if ($membershiptTypeValue['auto_renew']) {
                 $autoRenewMembershipTypes[] = $membershiptTypeValue['id'];
             }
         }
         foreach ($form->_priceSet['fields'] as &$field) {
             if (array_key_exists('options', $field) && is_array($field['options'])) {
                 foreach ($field['options'] as $option) {
                     if (!empty($option['membership_type_id'])) {
                         if (in_array($option['membership_type_id'], $autoRenewMembershipTypes)) {
                             $form->_priceSet['auto_renew_membership_field'] = $field['id'];
                             // Only one field can offer auto_renew memberships, so break here.
                             break;
                         }
                     }
                 }
             }
         }
     }
     $form->assign('priceSet', $form->_priceSet);
     $component = 'contribution';
     if ($className == 'CRM_Member_Form_Membership') {
         $component = 'membership';
     }
     if ($className == 'CRM_Contribute_Form_Contribution_Main') {
         $feeBlock =& $form->_values['fee'];
         if (!empty($form->_useForMember)) {
             $component = 'membership';
         }
     } else {
         $feeBlock =& $form->_priceSet['fields'];
     }
     if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
         foreach ($feeBlock as $key => $value) {
             foreach ($value['options'] as $k => $options) {
                 if (!CRM_Core_Permission::check('add contributions of type ' . CRM_Contribute_PseudoConstant::financialType($options['financial_type_id']))) {
                     unset($feeBlock[$key]['options'][$k]);
                 }
             }
             if (empty($feeBlock[$key]['options'])) {
                 unset($feeBlock[$key]);
             }
         }
     }
     // call the hook.
     CRM_Utils_Hook::buildAmount($component, $form, $feeBlock);
     // CRM-14492 Admin price fields should show up on event registration if user has 'administer CiviCRM' permissions
     $adminFieldVisible = FALSE;
     if (CRM_Core_Permission::check('administer CiviCRM')) {
         $adminFieldVisible = TRUE;
     }
     foreach ($feeBlock as $id => $field) {
         if (CRM_Utils_Array::value('visibility', $field) == 'public' || CRM_Utils_Array::value('visibility', $field) == 'admin' && $adminFieldVisible == TRUE || !$validFieldsOnly) {
             $options = CRM_Utils_Array::value('options', $field);
             if ($className == 'CRM_Contribute_Form_Contribution_Main' && ($component = 'membership')) {
                 $userid = $form->getVar('_membershipContactID');
                 $checklifetime = self::checkCurrentMembership($options, $userid);
                 if ($checklifetime) {
                     $form->assign('ispricelifetime', TRUE);
                 }
             }
             if (!is_array($options) || !in_array($id, $validPriceFieldIds)) {
                 continue;
             }
             CRM_Price_BAO_PriceField::addQuickFormElement($form, 'price_' . $field['id'], $field['id'], FALSE, CRM_Utils_Array::value('is_required', $field, FALSE), NULL, $options);
         }
     }
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:100,代码来源:PriceSet.php

示例6: buildAmount

 /**
  * build the radio/text form elements for the amount field
  * 
  * @param object   $form form object
  * @param boolean  $required  true if you want to add formRule
  * @param int      $discountId discount id for the event
  *
  * @return void
  * @access public
  * @static
  */
 public static function buildAmount(&$form, $required = true, $discountId = null)
 {
     //get the button name.
     $button = substr($form->controller->getButtonName(), -4);
     if ($button == 'skip') {
         $required = false;
     }
     $elements = array();
     if (isset($form->_priceSetId)) {
         $form->addGroup($elements, 'amount', ts('Event Fee(s)'), '<br />');
         $form->add('hidden', 'priceSetId', $form->_priceSetId);
         $form->assign('priceSet', $form->_priceSet);
         require_once 'CRM/Price/BAO/Field.php';
         foreach ($form->_values['fee']['fields'] as $field) {
             $fieldId = $field['id'];
             $elementName = 'price_' . $fieldId;
             if ($button == 'skip') {
                 $isRequire = false;
             } else {
                 $isRequire = CRM_Utils_Array::value('is_required', $field);
             }
             CRM_Price_BAO_Field::addQuickFormElement($form, $elementName, $fieldId, false, $isRequire);
         }
     } else {
         if (!empty($form->_values['fee'])) {
             $form->_feeBlock =& $form->_values['fee'];
             if (isset($form->_values['discount'])) {
                 if (!isset($discountId) && $form->_action != CRM_Core_Action::UPDATE) {
                     require_once 'CRM/Core/BAO/Discount.php';
                     $form->_discountId = $discountId = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
                 }
                 if ($discountId) {
                     $form->_feeBlock =& $form->_values['discount'][$discountId];
                 }
             }
             require_once 'CRM/Utils/Hook.php';
             CRM_Utils_Hook::buildAmount('event', $form, $form->_feeBlock);
             if ($form->_action != CRM_Core_Action::UPDATE) {
                 require_once 'CRM/Utils/Money.php';
                 foreach ($form->_feeBlock as $fee) {
                     if (is_array($fee)) {
                         $elements[] =& $form->createElement('radio', null, '', CRM_Utils_Money::format($fee['value']) . ' ' . $fee['label'], $fee['amount_id']);
                     }
                 }
                 $form->_defaults['amount'] = CRM_Utils_Array::value('default_fee_id', $form->_values['event']);
                 $element =& $form->addGroup($elements, 'amount', ts('Event Fee(s)'), '<br />');
                 if (isset($form->_online) && $form->_online) {
                     $element->freeze();
                 }
                 if ($required) {
                     $form->addRule('amount', ts('Fee Level is a required field.'), 'required');
                 }
             }
         }
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:67,代码来源:Register.php

示例7: buildPriceSet

 /** 
  * Function to build the price set form.
  * 
  * @return None 
  * @access public 
  */
 static function buildPriceSet(&$form)
 {
     $priceSetId = $form->get('priceSetId');
     if (!$priceSetId) {
         return;
     }
     $priceSet = self::getSetDetail($priceSetId, true);
     $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
     $form->assign('priceSet', $form->_priceSet);
     require_once 'CRM/Core/PseudoConstant.php';
     $className = CRM_Utils_System::getClassName($form);
     if ($className == 'CRM_Contribute_Form_Contribution_Main') {
         $feeBlock =& $form->_values['fee'];
     } else {
         $feeBlock =& $form->_priceSet['fields'];
     }
     // call the hook.
     require_once 'CRM/Utils/Hook.php';
     CRM_Utils_Hook::buildAmount('contribution', $form, $feeBlock);
     foreach ($feeBlock as $field) {
         if (CRM_Utils_Array::value('visibility', $field) == 'public' || $className == 'CRM_Contribute_Form_Contribution') {
             $options = CRM_Utils_Array::value('options', $field);
             if (!is_array($options)) {
                 continue;
             }
             CRM_Price_BAO_Field::addQuickFormElement($form, 'price_' . $field['id'], $field['id'], false, CRM_Utils_Array::value('is_required', $field, false), null, $options);
         }
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:35,代码来源:Set.php


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