本文整理汇总了PHP中CRM_Price_BAO_PriceSet::buildPriceSet方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_PriceSet::buildPriceSet方法的具体用法?PHP CRM_Price_BAO_PriceSet::buildPriceSet怎么用?PHP CRM_Price_BAO_PriceSet::buildPriceSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Price_BAO_PriceSet
的用法示例。
在下文中一共展示了CRM_Price_BAO_PriceSet::buildPriceSet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
}
//.........这里部分代码省略.........
示例2: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
// build profiles first so that we can determine address fields etc
// and then show copy address checkbox
if (empty($this->_ccid)) {
$this->buildCustom($this->_values['custom_pre_id'], 'customPre');
$this->buildCustom($this->_values['custom_post_id'], 'customPost');
// CRM-18399: used by template to pass pre profile id as a url arg
$this->assign('custom_pre_id', $this->_values['custom_pre_id']);
$this->buildComponentForm($this->_id, $this);
}
// Build payment processor form
CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
$config = CRM_Core_Config::singleton();
$contactID = $this->getContactID();
if ($contactID) {
$this->assign('contact_id', $contactID);
$this->assign('display_name', CRM_Contact_BAO_Contact::displayName($contactID));
}
$this->applyFilter('__ALL__', 'trim');
if (empty($this->_ccid)) {
$this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60, 'class' => 'email'), TRUE);
$this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
} else {
$this->addElement('hidden', "email-{$this->_bltID}", 1);
$this->add('text', 'total_amount', ts('Total Amount'), array('readonly' => TRUE), FALSE);
}
$pps = array();
//@todo - this should be replaced by a check as to whether billing fields are set
$onlinePaymentProcessorEnabled = FALSE;
if (!empty($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $key => $name) {
if ($name['billing_mode'] == 1) {
$onlinePaymentProcessorEnabled = TRUE;
}
$pps[$key] = $name['name'];
}
}
if (!empty($this->_values['is_pay_later'])) {
$pps[0] = $this->_values['pay_later_text'];
}
if (count($pps) > 1) {
$this->addRadio('payment_processor_id', ts('Payment Method'), $pps, NULL, " ");
} elseif (!empty($pps)) {
$key = array_keys($pps);
$key = array_pop($key);
$this->addElement('hidden', 'payment_processor_id', $key);
if ($key === 0) {
$this->assign('is_pay_later', $this->_values['is_pay_later']);
$this->assign('pay_later_text', $this->_values['pay_later_text']);
}
}
$contactID = $this->getContactID();
if ($this->getContactID() === 0) {
$this->addCidZeroOptions($onlinePaymentProcessorEnabled);
}
//build pledge block.
$this->_useForMember = 0;
//don't build membership block when pledge_id is passed
if (empty($this->_values['pledge_id']) && empty($this->_ccid)) {
$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 = $this->buildMembershipBlock($this->_membershipContactID, TRUE, NULL, FALSE, $isTest);
}
$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);
if (empty($this->_ccid)) {
CRM_Price_BAO_PriceSet::buildPriceSet($this);
}
if ($this->_values['is_monetary'] && $this->_values['is_recur'] && empty($this->_values['pledge_id'])) {
self::buildRecur($this);
}
}
if ($this->_priceSetId && empty($this->_ccid)) {
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
if ($is_quick_config) {
$this->_useForMember = 0;
$this->set('useForMember', $this->_useForMember);
}
}
//we allow premium for pledge during pledge creation only.
//.........这里部分代码省略.........
示例3: buildQuickForm
/**
* Function to build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
if ($this->_cdType) {
CRM_Custom_Form_CustomData::buildQuickForm($this);
return;
}
$allPanes = array();
// build price set form.
$buildPriceSet = FALSE;
if (empty($this->_lineItems) && ($this->_priceSetId || !empty($_POST['price_set_id']))) {
$buildPriceSet = TRUE;
$getOnlyPriceSetElements = TRUE;
if (!$this->_priceSetId) {
$this->_priceSetId = $_POST['price_set_id'];
$getOnlyPriceSetElements = FALSE;
}
$this->set('priceSetId', $this->_priceSetId);
CRM_Price_BAO_PriceSet::buildPriceSet($this);
// get only price set form elements.
if ($getOnlyPriceSetElements) {
return;
}
}
// use to build form during form rule.
$this->assign('buildPriceSet', $buildPriceSet);
$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;
}
}
if ($this->_productDAO) {
if ($this->_productDAO->product_id) {
$defaults['hidden_Premium'] = 1;
}
}
if ($this->_noteID && isset($this->_values['note'])) {
$defaults['hidden_AdditionalDetail'] = 1;
}
$paneNames = array(ts('Additional Details') => 'AdditionalDetail');
//Add Premium pane only if Premium is exists.
$dao = new CRM_Contribute_DAO_Product();
$dao->is_active = 1;
if ($dao->find(TRUE)) {
$paneNames[ts('Premium Information')] = 'Premium';
}
$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 || !empty($_POST["hidden_{$type}"]) || 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 {
$additionalInfoFormFunction = 'build' . $type;
CRM_Contribute_Form_AdditionalInfo::$additionalInfoFormFunction($this);
}
}
if (empty($this->_recurPaymentProcessors)) {
$buildRecurBlock = FALSE;
}
if ($buildRecurBlock) {
CRM_Contribute_Form_Contribution_Main::buildRecur($this);
//.........这里部分代码省略.........
示例4: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
// FIXME: This probably needs to be done in preprocess
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && $this->_action & CRM_Core_Action::UPDATE && CRM_Utils_Array::value('financial_type_id', $this->_values)) {
$financialTypeID = CRM_Contribute_PseudoConstant::financialType($this->_values['financial_type_id']);
CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($this->_id, 'edit');
if (!CRM_Core_Permission::check('edit contributions of type ' . $financialTypeID)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
}
$allPanes = array();
$recurJs = NULL;
//tax rate from financialType
$this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
$this->assign('currencies', json_encode(CRM_Core_OptionGroup::values('currencies_enabled')));
// build price set form.
$buildPriceSet = FALSE;
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$this->assign('invoicing', $invoicing);
// display tax amount on edit contribution page
if ($invoicing && $this->_action & CRM_Core_Action::UPDATE && isset($this->_values['tax_amount'])) {
$this->assign('totalTaxAmount', $this->_values['tax_amount']);
}
if (empty($this->_lineItems) && ($this->_priceSetId || !empty($_POST['price_set_id']))) {
$buildPriceSet = TRUE;
$getOnlyPriceSetElements = TRUE;
if (!$this->_priceSetId) {
$this->_priceSetId = $_POST['price_set_id'];
$getOnlyPriceSetElements = FALSE;
}
$this->set('priceSetId', $this->_priceSetId);
CRM_Price_BAO_PriceSet::buildPriceSet($this);
// get only price set form elements.
if ($getOnlyPriceSetElements) {
return;
}
}
// use to build form during form rule.
$this->assign('buildPriceSet', $buildPriceSet);
$defaults = $this->_values;
$additionalDetailFields = array('note', 'thankyou_date', 'invoice_id', 'non_deductible_amount', 'fee_amount', 'net_amount');
foreach ($additionalDetailFields as $key) {
if (!empty($defaults[$key])) {
$defaults['hidden_AdditionalDetail'] = 1;
break;
}
}
if ($this->_productDAO) {
if ($this->_productDAO->product_id) {
$defaults['hidden_Premium'] = 1;
}
}
if ($this->_noteID && isset($this->_values['note'])) {
$defaults['hidden_AdditionalDetail'] = 1;
}
$paneNames = array(ts('Additional Details') => 'AdditionalDetail');
//Add Premium pane only if Premium is exists.
$dao = new CRM_Contribute_DAO_Product();
$dao->is_active = 1;
if ($dao->find(TRUE)) {
$paneNames[ts('Premium Information')] = 'Premium';
}
if ($this->_mode) {
if (CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE) == TRUE) {
if (!empty($this->_recurPaymentProcessors)) {
$buildRecurBlock = TRUE;
if ($this->_ppID) {
// ppID denotes a pledge payment.
foreach ($this->_paymentProcessors as $processor) {
if (!empty($processor['is_recur']) && !empty($processor['object']) && $processor['object']->supports('recurContributionsForPledges')) {
$buildRecurBlock = TRUE;
break;
}
$buildRecurBlock = FALSE;
}
}
if ($buildRecurBlock) {
CRM_Contribute_Form_Contribution_Main::buildRecur($this);
$this->setDefaults(array('is_recur' => 0));
$this->assign('buildRecurBlock', TRUE);
$recurJs = array('onChange' => "buildRecurBlock( this.value ); return false;");
}
}
}
}
foreach ($paneNames as $name => $type) {
$allPanes[$name] = $this->generatePane($type, $defaults);
}
$qfKey = $this->controller->_key;
$this->assign('qfKey', $qfKey);
$this->assign('allPanes', $allPanes);
$this->addFormRule(array('CRM_Contribute_Form_Contribution', 'formRule'), $this);
if ($this->_formType) {
$this->assign('formType', $this->_formType);
return;
}
//.........这里部分代码省略.........
示例5: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
$this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
$this->assign('currency', CRM_Core_Config::singleton()->defaultCurrencySymbol);
$invoiceSettings = Civi::settings()->get('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 -');
// Throw status bounce when no Membership type or priceset is present
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && empty($this->allMembershipTypeDetails) && empty($priceSets)) {
CRM_Core_Error::statusBounce(ts('You do not have all the permissions needed for this page.'));
}
// retrieve all memberships
$allMembershipInfo = array();
foreach ($this->allMembershipTypeDetails as $key => $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);
}
}
$totalAmount = CRM_Utils_Array::value('minimum_fee', $values);
//CRM-18827 - override the default value if total_amount is submitted
if (!empty($this->_submitValues['total_amount'])) {
$totalAmount = $this->_submitValues['total_amount'];
}
// 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($totalAmount, NULL, '%a'), 'total_amount_numeric' => $totalAmount, '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));
}
$this->assign('allMembershipInfo', json_encode($allMembershipInfo));
// show organization by default, if only one organization in
// the list
if (count($selMemTypeOrg) == 2) {
//.........这里部分代码省略.........