本文整理汇总了PHP中CRM_Price_BAO_PriceSet::getFor方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_PriceSet::getFor方法的具体用法?PHP CRM_Price_BAO_PriceSet::getFor怎么用?PHP CRM_Price_BAO_PriceSet::getFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Price_BAO_PriceSet
的用法示例。
在下文中一共展示了CRM_Price_BAO_PriceSet::getFor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build_price_options
/**
* Build price options.
*
* @param CRM_Event_BAO_Event $event
*
* @return array
*/
public function build_price_options($event)
{
$price_fields_for_event = array();
$base_field_name = "event_{$event->id}_amount";
$price_set_id = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $event->id);
//CRM-14492 display admin fields only if user is admin
$adminFieldVisible = FALSE;
if (CRM_Core_Permission::check('administer CiviCRM')) {
$adminFieldVisible = TRUE;
}
if ($price_set_id) {
$price_sets = CRM_Price_BAO_PriceSet::getSetDetail($price_set_id, TRUE, TRUE);
$price_set = $price_sets[$price_set_id];
$index = -1;
foreach ($price_set['fields'] as $field) {
$index++;
if (CRM_Utils_Array::value('visibility', $field) == 'public' || CRM_Utils_Array::value('visibility', $field) == 'admin' && $adminFieldVisible == TRUE) {
$field_name = "event_{$event->id}_price_{$field['id']}";
CRM_Price_BAO_PriceField::addQuickFormElement($this, $field_name, $field['id'], FALSE);
$price_fields_for_event[] = $field_name;
}
}
}
return $price_fields_for_event;
}
示例2:
/**
* takes an associative array and creates a contribution page object
*
* @param array $params (reference ) an assoc array of name/value pairs
*
* @return object CRM_Contribute_DAO_ContributionPage object
* @access public
* @static
*/
public static function &create(&$params)
{
$financialTypeId = NULL;
if (!empty($params['id']) && !CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $params['id'], NULL, 1)) {
$financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $params['id'], 'financial_type_id');
}
$dao = new CRM_Contribute_DAO_ContributionPage();
$dao->copyValues($params);
$dao->save();
if ($financialTypeId && !empty($params['financial_type_id']) && $financialTypeId != $params['financial_type_id']) {
CRM_Price_BAO_PriceFieldValue::updateFinancialType($params['id'], 'civicrm_contribution_page', $params['financial_type_id']);
}
return $dao;
}
示例3: empty
/**
* Takes an associative array and creates a contribution page object.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
*
* @return CRM_Contribute_DAO_ContributionPage
*/
public static function &create(&$params)
{
$financialTypeId = NULL;
if (!empty($params['id']) && !CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $params['id'], NULL, 1)) {
$financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $params['id'], 'financial_type_id');
}
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, 'ContributionPage', CRM_Utils_Array::value('id', $params), $params);
$dao = new CRM_Contribute_DAO_ContributionPage();
$dao->copyValues($params);
$dao->save();
if ($financialTypeId && !empty($params['financial_type_id']) && $financialTypeId != $params['financial_type_id']) {
CRM_Price_BAO_PriceFieldValue::updateFinancialType($params['id'], 'civicrm_contribution_page', $params['financial_type_id']);
}
CRM_Utils_Hook::post($hook, 'ContributionPage', $dao->id, $dao);
return $dao;
}
示例4: build_price_options
function build_price_options($event)
{
$price_fields_for_event = array();
$base_field_name = "event_{$event->id}_amount";
$price_set_id = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $event->id);
if ($price_set_id) {
$price_sets = CRM_Price_BAO_PriceSet::getSetDetail($price_set_id, TRUE, TRUE);
$price_set = $price_sets[$price_set_id];
$index = -1;
foreach ($price_set['fields'] as $field) {
$index++;
$field_name = "event_{$event->id}_price_{$field['id']}";
CRM_Price_BAO_PriceField::addQuickFormElement($this, $field_name, $field['id'], FALSE);
$price_fields_for_event[] = $field_name;
}
}
return $price_fields_for_event;
}
示例5: deleteContribution
/**
* Delete the indirect records associated with this contribution first.
*
* @param int $id
*
* @return mixed|null
* $results no of deleted Contribution on success, false otherwise
*/
public static function deleteContribution($id)
{
CRM_Utils_Hook::pre('delete', 'Contribution', $id, CRM_Core_DAO::$_nullArray);
$transaction = new CRM_Core_Transaction();
$results = NULL;
//delete activity record
$params = array('source_record_id' => $id, 'activity_type_id' => 6);
CRM_Activity_BAO_Activity::deleteActivity($params);
//delete billing address if exists for this contribution.
self::deleteAddress($id);
//update pledge and pledge payment, CRM-3961
CRM_Pledge_BAO_PledgePayment::resetPledgePayment($id);
// remove entry from civicrm_price_set_entity, CRM-5095
if (CRM_Price_BAO_PriceSet::getFor('civicrm_contribution', $id)) {
CRM_Price_BAO_PriceSet::removeFrom('civicrm_contribution', $id);
}
// cleanup line items.
$participantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $id, 'participant_id', 'contribution_id');
// delete any related entity_financial_trxn, financial_trxn and financial_item records.
CRM_Core_BAO_FinancialTrxn::deleteFinancialTrxn($id);
if ($participantId) {
CRM_Price_BAO_LineItem::deleteLineItems($participantId, 'civicrm_participant');
} else {
CRM_Price_BAO_LineItem::deleteLineItems($id, 'civicrm_contribution');
}
//delete note.
$note = CRM_Core_BAO_Note::getNote($id, 'civicrm_contribution');
$noteId = key($note);
if ($noteId) {
CRM_Core_BAO_Note::del($noteId, FALSE);
}
$dao = new CRM_Contribute_DAO_Contribution();
$dao->id = $id;
$results = $dao->delete();
$transaction->commit();
CRM_Utils_Hook::post('delete', 'Contribution', $dao->id, $dao);
// delete the recently created Contribution
$contributionRecent = array('id' => $id, 'type' => 'Contribution');
CRM_Utils_Recent::del($contributionRecent);
return $results;
}
示例6: postProcess
/**
* Process the form.
*
* @return void
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
$deletePriceSet = 0;
if ($params['membership_type']) {
// we do this in case the user has hit the forward/back button
$dao = new CRM_Member_DAO_MembershipBlock();
$dao->entity_table = 'civicrm_contribution_page';
$dao->entity_id = $this->_id;
$dao->find(TRUE);
$membershipID = $dao->id;
if ($membershipID) {
$params['id'] = $membershipID;
}
$membershipTypes = array();
if (is_array($params['membership_type'])) {
foreach ($params['membership_type'] as $k => $v) {
if ($v) {
$membershipTypes[$k] = CRM_Utils_Array::value("auto_renew_{$k}", $params);
}
}
}
if ($this->_id && !empty($params['member_price_set_id'])) {
CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'amount_block_is_active', 0);
}
// check for price set.
$priceSetID = CRM_Utils_Array::value('member_price_set_id', $params);
if (!empty($params['member_is_active']) && is_array($membershipTypes) && !$priceSetID) {
$usedPriceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 2);
if (empty($params['mem_price_field_id']) && !$usedPriceSetId) {
$pageTitle = strtolower(CRM_Utils_String::munge($this->_values['title'], '_', 245));
$setParams['title'] = $this->_values['title'];
if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle, 'id', 'name')) {
$setParams['name'] = $pageTitle;
} elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle . '_' . $this->_id, 'id', 'name')) {
$setParams['name'] = $pageTitle . '_' . $this->_id;
} else {
$timeSec = explode(".", microtime(TRUE));
$setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
}
$setParams['is_quick_config'] = 1;
$setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
$setParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values);
$priceSet = CRM_Price_BAO_PriceSet::create($setParams);
$priceSetID = $priceSet->id;
$fieldParams['price_set_id'] = $priceSet->id;
} elseif ($usedPriceSetId) {
$setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
$setParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values);
$setParams['id'] = $usedPriceSetId;
$priceSet = CRM_Price_BAO_PriceSet::create($setParams);
$priceSetID = $priceSet->id;
$fieldParams['price_set_id'] = $priceSet->id;
} else {
$fieldParams['id'] = CRM_Utils_Array::value('mem_price_field_id', $params);
$priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('mem_price_field_id', $params), 'price_set_id');
}
$editedFieldParams = array('price_set_id' => $priceSetID, 'name' => 'membership_amount');
$editedResults = array();
CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults);
if (empty($editedResults['id'])) {
$fieldParams['name'] = strtolower(CRM_Utils_String::munge('Membership Amount', '_', 245));
if (empty($params['mem_price_field_id'])) {
CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceField', 0, 1, array('price_set_id' => $priceSetID));
}
$fieldParams['weight'] = 1;
} else {
$fieldParams['id'] = CRM_Utils_Array::value('id', $editedResults);
}
$fieldParams['label'] = !empty($params['membership_type_label']) ? $params['membership_type_label'] : ts('Membership');
$fieldParams['is_active'] = 1;
$fieldParams['html_type'] = 'Radio';
$fieldParams['is_required'] = !empty($params['is_required']) ? 1 : 0;
$fieldParams['is_display_amounts'] = !empty($params['display_min_fee']) ? 1 : 0;
$rowCount = 1;
$options = array();
if (!empty($fieldParams['id'])) {
CRM_Core_PseudoConstant::populate($options, 'CRM_Price_DAO_PriceFieldValue', TRUE, 'membership_type_id', NULL, " price_field_id = {$fieldParams['id']} ");
}
foreach ($membershipTypes as $memType => $memAutoRenew) {
if ($priceFieldID = CRM_Utils_Array::key($memType, $options)) {
$fieldParams['option_id'][$rowCount] = $priceFieldID;
unset($options[$priceFieldID]);
}
$membetype = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($memType);
$fieldParams['option_label'][$rowCount] = CRM_Utils_Array::value('name', $membetype);
$fieldParams['option_amount'][$rowCount] = CRM_Utils_Array::value('minimum_fee', $membetype, 0);
$fieldParams['option_weight'][$rowCount] = CRM_Utils_Array::value('weight', $membetype);
$fieldParams['option_description'][$rowCount] = CRM_Utils_Array::value('description', $membetype);
$fieldParams['default_option'] = CRM_Utils_Array::value('membership_type_default', $params);
$fieldParams['option_financial_type_id'][$rowCount] = CRM_Utils_Array::value('financial_type_id', $membetype);
$fieldParams['membership_type_id'][$rowCount] = $memType;
// [$rowCount] = $membetype[''];
$rowCount++;
//.........这里部分代码省略.........
示例7: getFormParams
/**
* Helper function for static submit function.
*
* Set relevant params - help us to build up an array that we can pass in.
*
* @param int $id
* @param array $params
*
* @return array
* @throws CiviCRM_API3_Exception
*/
public static function getFormParams($id, array $params)
{
if (!isset($params['is_pay_later'])) {
if (!empty($params['payment_processor_id'])) {
$params['is_pay_later'] = 0;
} else {
$params['is_pay_later'] = civicrm_api3('contribution_page', 'getvalue', array('id' => $id, 'return' => 'is_pay_later'));
}
}
if (empty($params['price_set_id'])) {
$params['price_set_id'] = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $params['id']);
}
return $params;
}
示例8: setDefaultValues
/**
* Set default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
*
* @return array
* defaults
*/
public function setDefaultValues()
{
//some child classes calling setdefaults directly w/o preprocess.
$this->_values = $this->get('values');
if (!is_array($this->_values)) {
$this->_values = array();
if (isset($this->_id) && $this->_id) {
$params = array('id' => $this->_id);
CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $this->_values);
}
$this->set('values', $this->_values);
}
$defaults = $this->_values;
$config = CRM_Core_Config::singleton();
if (isset($this->_id)) {
//set defaults for pledgeBlock values.
$pledgeBlockParams = array('entity_id' => $this->_id, 'entity_table' => ts('civicrm_contribution_page'));
$pledgeBlockDefaults = array();
CRM_Pledge_BAO_PledgeBlock::retrieve($pledgeBlockParams, $pledgeBlockDefaults);
if ($this->_pledgeBlockID = CRM_Utils_Array::value('id', $pledgeBlockDefaults)) {
$defaults['is_pledge_active'] = TRUE;
}
$pledgeBlock = array('is_pledge_interval', 'max_reminders', 'initial_reminder_day', 'additional_reminder_day');
foreach ($pledgeBlock as $key) {
$defaults[$key] = CRM_Utils_Array::value($key, $pledgeBlockDefaults);
}
if (!empty($pledgeBlockDefaults['pledge_frequency_unit'])) {
$defaults['pledge_frequency_unit'] = array_fill_keys(explode(CRM_Core_DAO::VALUE_SEPARATOR, $pledgeBlockDefaults['pledge_frequency_unit']), '1');
}
// fix the display of the monetary value, CRM-4038
if (isset($defaults['goal_amount'])) {
$defaults['goal_amount'] = CRM_Utils_Money::format($defaults['goal_amount'], NULL, '%a');
}
// get price set of type contributions
//this is the value for stored in db if price set extends contribution
$usedFor = 2;
$this->_priceSetID = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, $usedFor, 1);
if ($this->_priceSetID) {
$defaults['price_set_id'] = $this->_priceSetID;
}
if (!empty($defaults['end_date'])) {
list($defaults['end_date'], $defaults['end_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['end_date']);
}
if (!empty($defaults['start_date'])) {
list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['start_date']);
}
} else {
$defaults['is_active'] = 1;
// set current date as start date
list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults();
}
if (!isset($defaults['for_organization'])) {
$defaults['for_organization'] = ts('I am contributing on behalf of an organization.');
}
if (!empty($defaults['recur_frequency_unit'])) {
$defaults['recur_frequency_unit'] = array_fill_keys(explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaults['recur_frequency_unit']), '1');
} else {
# CRM 10860
$defaults['recur_frequency_unit'] = array('month' => 1);
}
if (!empty($defaults['is_for_organization'])) {
$defaults['is_organization'] = 1;
} else {
$defaults['is_for_organization'] = 1;
}
// confirm page starts out enabled
if (!isset($defaults['is_confirm_enabled'])) {
$defaults['is_confirm_enabled'] = 1;
}
return $defaults;
}
示例9: usesPriceSet
/**
* This is sometimes called in a loop (during event search)
* hence we cache the values to prevent repeated calls to the db
*/
static function usesPriceSet($id)
{
static $usesPriceSet = array();
if (!array_key_exists($id, $usesPriceSet)) {
$usesPriceSet[$id] = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $id);
}
return $usesPriceSet[$id];
}
示例10: setIsQuickConfig
/**
* Change is_quick_config priceSet to complex.
*
*/
public static function setIsQuickConfig()
{
$id = $context = NULL;
if (!empty($_REQUEST['id'])) {
$id = CRM_Utils_Type::escape($_REQUEST['id'], 'Integer');
}
if (!empty($_REQUEST['context'])) {
$context = CRM_Utils_Type::escape($_REQUEST['context'], 'String');
}
// return false if $id is null and
// $context is not civicrm_event or civicrm_contribution_page
if (!$id || !in_array($context, array('civicrm_event', 'civicrm_contribution_page'))) {
return FALSE;
}
$priceSetId = CRM_Price_BAO_PriceSet::getFor($context, $id, NULL);
if ($priceSetId) {
$result = CRM_Price_BAO_PriceSet::setIsQuickConfig($priceSetId, 0);
if ($context == 'civicrm_event') {
$sql = "UPDATE\n civicrm_price_set cps\n INNER JOIN civicrm_discount cd ON cd.price_set_id = cps.id\n SET cps.is_quick_config = 0\n WHERE cd.entity_id = (%1) AND cd.entity_table = 'civicrm_event' ";
$params = array(1 => array($id, 'Integer'));
CRM_Core_DAO::executeQuery($sql, $params);
CRM_Core_BAO_Discount::del($id, $context);
}
}
if (!$result) {
$priceSetId = NULL;
}
CRM_Utils_JSON::output($priceSetId);
}
示例11: postProcess
/**
* Process the form.
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
//update 'is_billing_required'
if (empty($params['is_pay_later'])) {
$params['is_billing_required'] = 0;
}
if (array_key_exists('payment_processor', $params)) {
if (array_key_exists(CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor', 'AuthNet', 'id', 'payment_processor_type_id'), CRM_Utils_Array::value('payment_processor', $params))) {
CRM_Core_Session::setStatus(ts(' Please note that the Authorize.net payment processor only allows recurring contributions and auto-renew memberships with payment intervals from 7-365 days or 1-12 months (i.e. not greater than 1 year).'), '', 'alert');
}
}
// check for price set.
$priceSetID = CRM_Utils_Array::value('price_set_id', $params);
// get required fields.
$fields = array('id' => $this->_id, 'is_recur' => FALSE, 'min_amount' => "null", 'max_amount' => "null", 'is_monetary' => FALSE, 'is_pay_later' => FALSE, 'is_billing_required' => FALSE, 'is_recur_interval' => FALSE, 'is_recur_installments' => FALSE, 'recur_frequency_unit' => "null", 'default_amount_id' => "null", 'is_allow_other_amount' => FALSE, 'amount_block_is_active' => FALSE);
$resetFields = array();
if ($priceSetID) {
$resetFields = array('min_amount', 'max_amount', 'is_allow_other_amount');
}
if (empty($params['is_recur'])) {
$resetFields = array_merge($resetFields, array('is_recur_interval', 'recur_frequency_unit'));
}
foreach ($fields as $field => $defaultVal) {
$val = CRM_Utils_Array::value($field, $params, $defaultVal);
if (in_array($field, $resetFields)) {
$val = $defaultVal;
}
if (in_array($field, array('min_amount', 'max_amount'))) {
$val = CRM_Utils_Rule::cleanMoney($val);
}
$params[$field] = $val;
}
if ($params['is_recur']) {
$params['recur_frequency_unit'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['recur_frequency_unit']));
$params['is_recur_interval'] = CRM_Utils_Array::value('is_recur_interval', $params, FALSE);
$params['is_recur_installments'] = CRM_Utils_Array::value('is_recur_installments', $params, FALSE);
}
if (array_key_exists('payment_processor', $params) && !CRM_Utils_System::isNull($params['payment_processor'])) {
$params['payment_processor'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['payment_processor']));
} else {
$params['payment_processor'] = 'null';
}
$contributionPage = CRM_Contribute_BAO_ContributionPage::create($params);
$contributionPageID = $contributionPage->id;
// prepare for data cleanup.
$deleteAmountBlk = $deletePledgeBlk = $deletePriceSet = FALSE;
if ($this->_priceSetID) {
$deletePriceSet = TRUE;
}
if ($this->_pledgeBlockID) {
$deletePledgeBlk = TRUE;
}
if (!empty($this->_amountBlock)) {
$deleteAmountBlk = TRUE;
}
if ($contributionPageID) {
if (!empty($params['amount_block_is_active'])) {
// handle price set.
if ($priceSetID) {
// add/update price set.
$deletePriceSet = FALSE;
if (!empty($params['price_field_id']) || !empty($params['price_field_other'])) {
$deleteAmountBlk = TRUE;
}
CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $contributionPageID, $priceSetID);
} else {
$deletePriceSet = FALSE;
// process contribution amount block
$deleteAmountBlk = FALSE;
$labels = CRM_Utils_Array::value('label', $params);
$values = CRM_Utils_Array::value('value', $params);
$default = CRM_Utils_Array::value('default', $params);
$options = array();
for ($i = 1; $i < self::NUM_OPTION; $i++) {
if (isset($values[$i]) && strlen(trim($values[$i])) > 0) {
$options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
}
}
/* || !empty($params['price_field_value']) || CRM_Utils_Array::value( 'price_field_other', $params )*/
if (!empty($options) || !empty($params['is_allow_other_amount'])) {
$fieldParams['is_quick_config'] = 1;
$noContriAmount = NULL;
$usedPriceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 3);
if (!(!empty($params['price_field_id']) || !empty($params['price_field_other'])) && !$usedPriceSetId) {
$pageTitle = strtolower(CRM_Utils_String::munge($this->_values['title'], '_', 245));
$setParams['title'] = $this->_values['title'];
if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle, 'id', 'name')) {
$setParams['name'] = $pageTitle;
} elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle . '_' . $this->_id, 'id', 'name')) {
$setParams['name'] = $pageTitle . '_' . $this->_id;
} else {
$timeSec = explode(".", microtime(TRUE));
$setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
}
$setParams['is_quick_config'] = 1;
//.........这里部分代码省略.........
示例12: getUnDiscountedAmountForEventPriceSetFieldValue
/**
* Get the amount for the undiscounted version of the field.
*
* Note this function is part of the refactoring process rather than the best approach.
*
* @param int $eventID
* @param int $discountedPriceFieldOptionID
* @param string $feeLevel (deprecated)
*
* @return null|string
*/
public static function getUnDiscountedAmountForEventPriceSetFieldValue($eventID, $discountedPriceFieldOptionID, $feeLevel)
{
$priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventID, NULL);
$params = array(1 => array($priceSetId, 'Integer'));
if ($discountedPriceFieldOptionID) {
$query = "SELECT cpfv.amount FROM `civicrm_price_field_value` cpfv\nLEFT JOIN civicrm_price_field cpf ON cpfv.price_field_id = cpf.id\nWHERE cpf.price_set_id = %1 AND cpfv.label = (SELECT label from civicrm_price_field_value WHERE id = %2)";
$params[2] = array($discountedPriceFieldOptionID, 'Integer');
} else {
$feeLevel = current($feeLevel);
$query = "SELECT cpfv.amount FROM `civicrm_price_field_value` cpfv\nLEFT JOIN civicrm_price_field cpf ON cpfv.price_field_id = cpf.id\nWHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2";
$params[2] = array($feeLevel, 'String');
}
return CRM_Core_DAO::singleValueQuery($query, $params);
}
示例13: civicrm_api3_event_get
/**
* Get Event record.
*
* @param array $params
*
* @return array
* Array of all found event property values.
*/
function civicrm_api3_event_get($params)
{
//legacy support for $params['return.sort']
if (!empty($params['return.sort'])) {
$params['options']['sort'] = $params['return.sort'];
unset($params['return.sort']);
}
//legacy support for $params['return.offset']
if (!empty($params['return.offset'])) {
$params['options']['offset'] = $params['return.offset'];
unset($params['return.offset']);
}
//legacy support for $params['return.max_results']
if (!empty($params['return.max_results'])) {
$params['options']['limit'] = $params['return.max_results'];
unset($params['return.max_results']);
}
$sql = CRM_Utils_SQL_Select::fragment();
if (!empty($params['isCurrent'])) {
$sql->where('(start_date >= CURDATE() || end_date >= CURDATE())');
}
$events = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Event', $sql, TRUE);
$options = _civicrm_api3_get_options_from_params($params);
if ($options['is_count']) {
return civicrm_api3_create_success($events, $params, 'Event', 'get');
}
foreach ($events as $id => $event) {
if (!empty($params['return.is_full'])) {
_civicrm_api3_event_getisfull($events, $id);
}
_civicrm_api3_event_get_legacy_support_42($events, $id);
if (!empty($options['return'])) {
$events[$id]['price_set_id'] = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $id);
}
}
return civicrm_api3_create_success($events, $params, 'Event', 'get');
}
示例14: copyPriceSet
/**
* Copy priceSet when event/contibution page is copied
*
* @param string $baoName
* BAO name.
* @param int $id
* Old event/contribution page id.
* @param int $newId
* Newly created event/contribution page id.
*/
public static function copyPriceSet($baoName, $id, $newId)
{
$priceSetId = CRM_Price_BAO_PriceSet::getFor($baoName, $id);
if ($priceSetId) {
$isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
if ($isQuickConfig) {
$copyPriceSet = CRM_Price_BAO_PriceSet::copy($priceSetId);
CRM_Price_BAO_PriceSet::addTo($baoName, $newId, $copyPriceSet->id);
} else {
$copyPriceSet =& CRM_Core_DAO::copyGeneric('CRM_Price_DAO_PriceSetEntity', array('entity_id' => $id, 'entity_table' => $baoName), array('entity_id' => $newId));
}
// copy event discount
if ($baoName == 'civicrm_event') {
$discount = CRM_Core_BAO_Discount::getOptionGroup($id, 'civicrm_event');
foreach ($discount as $discountId => $setId) {
$copyPriceSet =& CRM_Price_BAO_PriceSet::copy($setId);
CRM_Core_DAO::copyGeneric('CRM_Core_DAO_Discount', array('id' => $discountId), array('entity_id' => $newId, 'price_set_id' => $copyPriceSet->id));
}
}
}
}
示例15: process_event_line_item
/**
* Process line item for event.
*
* @param bool $event_in_cart
* @param string $class
*/
public function process_event_line_item(&$event_in_cart, $class = NULL)
{
$cost = 0;
$price_set_id = CRM_Price_BAO_PriceSet::getFor("civicrm_event", $event_in_cart->event_id);
$amount_level = NULL;
if ($price_set_id) {
$event_price_values = array();
foreach ($this->_price_values as $key => $value) {
if (preg_match("/event_{$event_in_cart->event_id}_(price.*)/", $key, $matches)) {
$event_price_values[$matches[1]] = $value;
}
}
$price_sets = CRM_Price_BAO_PriceSet::getSetDetail($price_set_id, TRUE);
$price_set = $price_sets[$price_set_id];
$price_set_amount = array();
CRM_Price_BAO_PriceSet::processAmount($price_set['fields'], $event_price_values, $price_set_amount);
$discountCode = $this->_price_values['discountcode'];
if (!empty($discountCode)) {
$ret = $this->apply_discount($discountCode, $price_set_amount, $cost, $event_in_cart->event_id);
if ($ret == FALSE) {
$cost = $event_price_values['amount'];
}
} else {
$cost = $event_price_values['amount'];
}
// @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel
// function to get correct amount level consistently. Remove setting of the amount level in
// CRM_Price_BAO_PriceSet::processAmount. Extend the unit tests in CRM_Price_BAO_PriceSetTest
// to cover all variants.
$amount_level = $event_price_values['amount_level'];
$price_details[$price_set_id] = $price_set_amount;
}
// iterate over each participant in event
foreach ($event_in_cart->participants as &$participant) {
$participant->cost = $cost;
$participant->fee_level = $amount_level;
$participant->price_details = $price_details;
}
$this->add_line_item($event_in_cart, $class);
}