本文整理汇总了PHP中CRM_Price_BAO_Set::buildPriceSet方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_Set::buildPriceSet方法的具体用法?PHP CRM_Price_BAO_Set::buildPriceSet怎么用?PHP CRM_Price_BAO_Set::buildPriceSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Price_BAO_Set
的用法示例。
在下文中一共展示了CRM_Price_BAO_Set::buildPriceSet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
// build price set form.
$buildPriceSet = FALSE;
if ($this->_priceSetId || CRM_Utils_Array::value('price_set_id', $_POST)) {
if (CRM_Utils_Array::value('price_set_id', $_POST)) {
$buildPriceSet = TRUE;
}
$getOnlyPriceSetElements = TRUE;
if (!$this->_priceSetId) {
$this->_priceSetId = $_POST['price_set_id'];
$getOnlyPriceSetElements = FALSE;
}
$this->set('priceSetId', $this->_priceSetId);
CRM_Price_BAO_Set::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_Set::checkAutoRenewForPriceSet($this->_priceSetId));
$this->assign('optionsMembershipTypes', $optionsMembershipTypes);
$this->assign('contributionType', CRM_Utils_Array::value('contribution_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_Set::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') {
CRM_Contact_Form_NewContact::buildQuickForm($this);
}
$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 (CRM_Utils_Array::value('is_active', $values)) {
$membershipType[$key] = CRM_Utils_Array::value('name', $values);
if ($this->_mode && !CRM_Utils_Array::value('minimum_fee', $values)) {
continue;
} else {
$memberOfContactId = CRM_Utils_Array::value('member_of_contact_id', $values);
if (!CRM_Utils_Array::value($memberOfContactId, $selMemTypeOrg)) {
$selMemTypeOrg[$memberOfContactId] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $memberOfContactId, 'display_name', 'id');
$selOrgMemType[$memberOfContactId][0] = ts('- select -');
}
if (!CRM_Utils_Array::value($key, $selOrgMemType[$memberOfContactId])) {
$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('contribution_type_id' => CRM_Utils_Array::value('contribution_type_id', $values), 'total_amount' => CRM_Utils_Money::format($values['minimum_fee'], NULL, '%a'), 'auto_renew' => CRM_Utils_Array::value('auto_renew', $values));
}
}
$this->assign('allMembershipInfo', json_encode($allMembershipInfo));
// show 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);
//.........这里部分代码省略.........
示例2: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_ppType) {
return CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
}
$config = CRM_Core_Config::singleton();
if (CRM_Utils_Array::value('is_for_organization', $this->_values) == 2) {
$this->assign('onBehalfRequired', TRUE);
$this->_onBehalfRequired = 1;
}
if ($this->_onbehalf) {
$this->assign('onbehalf', TRUE);
return CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60), TRUE);
$this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
$this->_paymentProcessors = $this->get('paymentProcessors');
$pps = array();
if (!empty($this->_paymentProcessors)) {
$pps = $this->_paymentProcessors;
foreach ($pps as $key => &$name) {
$pps[$key] = $name['name'];
}
}
if (CRM_Utils_Array::value('is_pay_later', $this->_values)) {
$pps[0] = $this->_values['pay_later_text'];
}
if (count($pps) > 1) {
$this->addRadio('payment_processor', ts('Payment Method'), $pps, NULL, " ", TRUE);
} elseif (!empty($pps)) {
$key = array_pop(array_keys($pps));
$this->addElement('hidden', 'payment_processor', $key);
if ($key === 0) {
$this->assign('is_pay_later', $this->_values['is_pay_later']);
$this->assign('pay_later_text', $this->_values['pay_later_text']);
}
}
//build pledge block.
$this->_useForMember = 0;
//don't build membership block when pledge_id is passed
if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
$this->_separateMembershipPayment = FALSE;
if (in_array('CiviMember', $config->enableComponents)) {
$isTest = 0;
if ($this->_action & CRM_Core_Action::PREVIEW) {
$isTest = 1;
}
if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) {
$this->_useForMember = 1;
$this->set('useForMember', $this->_useForMember);
}
$this->_separateMembershipPayment = CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, TRUE, NULL, FALSE, $isTest, $this->_membershipContactID);
}
$this->set('separateMembershipPayment', $this->_separateMembershipPayment);
}
$this->assign('useForMember', $this->_useForMember);
// If we configured price set for contribution page
// we are not allow membership signup as well as any
// other contribution amount field, CRM-5095
if (isset($this->_priceSetId) && $this->_priceSetId) {
$this->add('hidden', 'priceSetId', $this->_priceSetId);
// build price set form.
$this->set('priceSetId', $this->_priceSetId);
CRM_Price_BAO_Set::buildPriceSet($this);
if ($this->_values['is_monetary'] && $this->_values['is_recur'] && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
self::buildRecur($this);
}
} elseif (CRM_Utils_Array::value('amount_block_is_active', $this->_values) && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
$this->buildAmount($this->_separateMembershipPayment);
}
if ($this->_priceSetId) {
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_priceSetId, 'is_quick_config');
if ($is_quick_config) {
$this->_useForMember = 0;
$this->set('useForMember', $this->_useForMember);
}
}
if ($this->_values['is_for_organization']) {
$this->buildOnBehalfOrganization();
}
//we allow premium for pledge during pledge creation only.
if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
}
if ($this->_values['honor_block_is_active']) {
$this->buildHonorBlock();
}
//don't build pledge block when mid is passed
if (!$this->_mid) {
$config = CRM_Core_Config::singleton();
if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
}
//.........这里部分代码省略.........
示例3: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
$config = CRM_Core_Config::singleton();
if ($this->_values['is_for_organization'] == 2) {
$this->assign('onBehalfRequired', true);
}
if ($this->_onbehalf) {
$this->assign('onbehalf', true);
return CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60), true);
$this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
//build pledge block.
$this->_useForMember = 0;
//don't build membership block when pledge_id is passed
if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
$this->_separateMembershipPayment = false;
if (in_array('CiviMember', $config->enableComponents)) {
$isTest = 0;
if ($this->_action & CRM_Core_Action::PREVIEW) {
$isTest = 1;
}
if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) {
$this->_useForMember = 1;
$this->set('useForMember', $this->_useForMember);
}
require_once 'CRM/Member/BAO/Membership.php';
$this->_separateMembershipPayment = CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, true, null, false, $isTest, $this->_membershipContactID);
}
$this->set('separateMembershipPayment', $this->_separateMembershipPayment);
}
$this->assign('useForMember', $this->_useForMember);
// If we configured price set for contribution page
// we are not allow membership signup as well as any
// other contribution amount field, CRM-5095
if (isset($this->_priceSetId) && $this->_priceSetId) {
$this->add('hidden', 'priceSetId', $this->_priceSetId);
// build price set form.
$this->set('priceSetId', $this->_priceSetId);
require_once 'CRM/Price/BAO/Set.php';
CRM_Price_BAO_Set::buildPriceSet($this);
} else {
if (CRM_Utils_Array::value('amount_block_is_active', $this->_values) && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
$this->buildAmount($this->_separateMembershipPayment);
if ($this->_values['is_monetary'] && $this->_values['is_recur'] && $this->_paymentProcessor['is_recur']) {
self::buildRecur($this);
}
}
}
if (CRM_Utils_Array::value('is_pay_later', $this->_values)) {
$this->buildPayLater();
}
if ($this->_values['is_for_organization']) {
$this->buildOnBehalfOrganization();
}
//we allow premium for pledge during pledge creation only.
if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
require_once 'CRM/Contribute/BAO/Premium.php';
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, true);
}
if ($this->_values['honor_block_is_active']) {
$this->buildHonorBlock();
}
//don't build pledge block when mid is passed
if (!$this->_mid) {
$config = CRM_Core_Config::singleton();
if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
require_once 'CRM/Pledge/BAO/PledgeBlock.php';
CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
}
}
$this->buildCustom($this->_values['custom_pre_id'], 'customPre');
$this->buildCustom($this->_values['custom_post_id'], 'customPost');
// doing this later since the express button type depends if there is an upload or not
if ($this->_values['is_monetary']) {
require_once 'CRM/Core/Payment/Form.php';
if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
CRM_Core_Payment_Form::buildDirectDebit($this);
} else {
CRM_Core_Payment_Form::buildCreditCard($this);
}
}
//to create an cms user
if (!$this->_userID) {
$createCMSUser = false;
if ($this->_values['custom_pre_id']) {
$profileID = $this->_values['custom_pre_id'];
$createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
}
if (!$createCMSUser && $this->_values['custom_post_id']) {
$profileID = $this->_values['custom_post_id'];
$createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
}
//.........这里部分代码省略.........
示例4: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
// build price set form.
$buildPriceSet = false;
if (empty($this->_lineItems) && ($this->_priceSetId || CRM_Utils_Array::value('price_set_id', $_POST))) {
$buildPriceSet = true;
$getOnlyPriceSetElements = true;
if (!$this->_priceSetId) {
$this->_priceSetId = $_POST['price_set_id'];
$getOnlyPriceSetElements = false;
}
$this->set('priceSetId', $this->_priceSetId);
require_once 'CRM/Price/BAO/Set.php';
CRM_Price_BAO_Set::buildPriceSet($this);
// get only price set form elements.
if ($getOnlyPriceSetElements) {
return;
}
}
// use to build form during form rule.
$this->assign('buildPriceSet', $buildPriceSet);
$showAdditionalInfo = false;
require_once 'CRM/Contribute/Form/AdditionalInfo.php';
$defaults = $this->_values;
$additionalDetailFields = array('note', 'thankyou_date', 'invoice_id', 'non_deductible_amount', 'fee_amount', 'net_amount');
foreach ($additionalDetailFields as $key) {
if (!empty($defaults[$key])) {
$defaults['hidden_AdditionalDetail'] = 1;
break;
}
}
$honorFields = array('honor_type_id', 'honor_prefix_id', 'honor_first_name', 'honor_lastname', 'honor_email');
foreach ($honorFields as $key) {
if (!empty($defaults[$key])) {
$defaults['hidden_Honoree'] = 1;
break;
}
}
//check for honoree pane.
if ($this->_ppID && CRM_Utils_Array::value('honor_contact_id', $this->_pledgeValues)) {
$defaults['hidden_Honoree'] = 1;
}
if ($this->_productDAO) {
if ($this->_productDAO->product_id) {
$defaults['hidden_Premium'] = 1;
}
}
if ($this->_noteID && isset($this->_values['note'])) {
$defaults['hidden_AdditionalDetail'] = 1;
}
$paneNames = array('Additional Details' => 'AdditionalDetail', 'Honoree Information' => 'Honoree');
//Add Premium pane only if Premium is exists.
require_once 'CRM/Contribute/DAO/Product.php';
$dao =& new CRM_Contribute_DAO_Product();
$dao->is_active = 1;
if ($dao->find(true)) {
$paneNames['Premium Information'] = 'Premium';
}
$ccPane = null;
if ($this->_mode) {
if ($this->_processors['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
$ccPane = array(ts('Direct Debit Information') => 'DirectDebit');
} else {
$ccPane = array('Credit Card Information' => 'CreditCard');
}
}
if (is_array($ccPane)) {
$paneNames = array_merge($ccPane, $paneNames);
}
foreach ($paneNames as $name => $type) {
$urlParams = "snippet=4&formType={$type}";
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
$open = 'false';
if ($type == 'CreditCard' || $type == 'DirectDebit') {
$open = 'true';
}
$allPanes[$name] = array('url' => CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams), 'open' => $open, 'id' => $type);
// see if we need to include this paneName in the current form
if ($this->_formType == $type || CRM_Utils_Array::value("hidden_{$type}", $_POST) || CRM_Utils_Array::value("hidden_{$type}", $defaults)) {
$showAdditionalInfo = true;
$allPanes[$name]['open'] = 'true';
}
if ($type == 'CreditCard') {
$this->add('hidden', 'hidden_CreditCard', 1);
CRM_Core_Payment_Form::buildCreditCard($this, true);
} else {
if ($type == 'DirectDebit') {
$this->add('hidden', 'hidden_DirectDebit', 1);
CRM_Core_Payment_Form::buildDirectDebit($this, true);
//.........这里部分代码省略.........
示例5: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
// build price set form.
$buildPriceSet = FALSE;
if (empty($this->_lineItems) && ($this->_priceSetId || CRM_Utils_Array::value('price_set_id', $_POST))) {
$buildPriceSet = TRUE;
$getOnlyPriceSetElements = TRUE;
if (!$this->_priceSetId) {
$this->_priceSetId = $_POST['price_set_id'];
$getOnlyPriceSetElements = FALSE;
}
$this->set('priceSetId', $this->_priceSetId);
CRM_Price_BAO_Set::buildPriceSet($this);
// get only price set form elements.
if ($getOnlyPriceSetElements) {
return;
}
}
// use to build form during form rule.
$this->assign('buildPriceSet', $buildPriceSet);
$showAdditionalInfo = FALSE;
$defaults = $this->_values;
$additionalDetailFields = array('note', 'thankyou_date', 'invoice_id', 'non_deductible_amount', 'fee_amount', 'net_amount');
foreach ($additionalDetailFields as $key) {
if (!empty($defaults[$key])) {
$defaults['hidden_AdditionalDetail'] = 1;
break;
}
}
$honorFields = array('honor_type_id', 'honor_prefix_id', 'honor_first_name', 'honor_lastname', 'honor_email');
foreach ($honorFields as $key) {
if (!empty($defaults[$key])) {
$defaults['hidden_Honoree'] = 1;
break;
}
}
//check for honoree pane.
if ($this->_ppID && CRM_Utils_Array::value('honor_contact_id', $this->_pledgeValues)) {
$defaults['hidden_Honoree'] = 1;
}
if ($this->_productDAO) {
if ($this->_productDAO->product_id) {
$defaults['hidden_Premium'] = 1;
}
}
if ($this->_noteID && isset($this->_values['note'])) {
$defaults['hidden_AdditionalDetail'] = 1;
}
$paneNames = array(ts('Additional Details') => 'AdditionalDetail', ts('Honoree Information') => 'Honoree');
//Add Premium pane only if Premium is exists.
$dao = new CRM_Contribute_DAO_Product();
$dao->is_active = 1;
if ($dao->find(TRUE)) {
$paneNames[ts('Premium Information')] = 'Premium';
}
$ccPane = NULL;
if ($this->_mode) {
if (CRM_Utils_Array::value('payment_type', $this->_processors) & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
$ccPane = array(ts('Direct Debit Information') => 'DirectDebit');
} else {
$ccPane = array(ts('Credit Card Information') => 'CreditCard');
}
}
if (is_array($ccPane)) {
$paneNames = array_merge($ccPane, $paneNames);
}
$buildRecurBlock = FALSE;
foreach ($paneNames as $name => $type) {
$urlParams = "snippet=4&formType={$type}";
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
$open = 'false';
if ($type == 'CreditCard' || $type == 'DirectDebit') {
$open = 'true';
}
$allPanes[$name] = array('url' => CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams), 'open' => $open, 'id' => $type);
// see if we need to include this paneName in the current form
if ($this->_formType == $type || CRM_Utils_Array::value("hidden_{$type}", $_POST) || CRM_Utils_Array::value("hidden_{$type}", $defaults)) {
$showAdditionalInfo = TRUE;
$allPanes[$name]['open'] = 'true';
}
if ($type == 'CreditCard') {
$buildRecurBlock = TRUE;
$this->add('hidden', 'hidden_CreditCard', 1);
CRM_Core_Payment_Form::buildCreditCard($this, TRUE);
} elseif ($type == 'DirectDebit') {
$buildRecurBlock = TRUE;
$this->add('hidden', 'hidden_DirectDebit', 1);
CRM_Core_Payment_Form::buildDirectDebit($this, TRUE);
} else {
//.........这里部分代码省略.........