+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
$priceSetBAO = new CRM_Price_BAO_PriceSet();
$priceSetBAO->copyValues($params);
if (self::eventPriceSetDomainID()) {
$priceSetBAO = new CRM_Price_BAO_PriceSet();
$priceSetBAO->copyValues($params);
if (self::eventPriceSetDomainID()) {
- * Takes a bunch of params that are needed to match certain criteria and
- * retrieves the relevant objects. Typically the valid params are only
- * contact_id. We'll tweak this function to be more full featured over a period
- * of time. This is the inverse function of create. It also stores all the retrieved
- * values in the default array
+ * Fetch object based on array of properties
- * @param array $params (reference ) an assoc array of name/value pairs
- * @param array $defaults (reference ) an assoc array to hold the flattened values
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
+ * @param array $defaults
+ * (reference ) an assoc array to hold the flattened values.
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $id, 'is_active', $isActive);
}
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $id, 'is_active', $isActive);
}
self::$_defaultPriceSet[$entity] = array();
while ($dao->fetch()) {
self::$_defaultPriceSet[$entity][$dao->priceFieldValueID] = array(
self::$_defaultPriceSet[$entity] = array();
while ($dao->fetch()) {
self::$_defaultPriceSet[$entity][$dao->priceFieldValueID] = array(
- 'setID' => $dao->setID,
- 'priceFieldID' => $dao->priceFieldID,
- 'name' => $dao->name,
- 'label' => $dao->label,
- 'priceFieldValueID' => $dao->priceFieldValueID,
- 'membership_type_id' => $dao->membership_type_id,
- 'amount' => $dao->amount,
- 'financial_type_id' => $dao->financial_type_id,
+ 'setID' => $dao->setID,
+ 'priceFieldID' => $dao->priceFieldID,
+ 'name' => $dao->name,
+ 'label' => $dao->label,
+ 'priceFieldValueID' => $dao->priceFieldValueID,
+ 'membership_type_id' => $dao->membership_type_id,
+ 'amount' => $dao->amount,
+ 'financial_type_id' => $dao->financial_type_id,
*/
public static function getFor($entityTable, $entityId, $usedFor = NULL, $isQuickConfig = NULL, &$setName = NULL) {
if (!$entityTable || !$entityId) {
*/
public static function getFor($entityTable, $entityId, $usedFor = NULL, $isQuickConfig = NULL, &$setName = NULL) {
if (!$entityTable || !$entityId) {
- $params = array(1 => array($entityTable, 'String'),
- 2 => array($entityId, 'Integer'),
+ $params = array(
+ 1 => array($entityTable, 'String'),
+ 2 => array($entityId, 'Integer'),
$select = 'SELECT ' . implode(',', $priceFields);
$from = ' FROM civicrm_price_field';
$select = 'SELECT ' . implode(',', $priceFields);
$from = ' FROM civicrm_price_field';
throw new CRM_Core_Exception(ts('expected only one price field to be in priceset but multiple are present'));
}
return (int) implode('_', array_keys($priceSet['fields']));
throw new CRM_Core_Exception(ts('expected only one price field to be in priceset but multiple are present'));
}
return (int) implode('_', array_keys($priceSet['fields']));
throw new CRM_Core_Exception(ts('expected only one price field to be in priceset but multiple are present'));
}
return (int) implode('_', array_keys($priceSet['fields'][$priceFieldID]['options']));
throw new CRM_Core_Exception(ts('expected only one price field to be in priceset but multiple are present'));
}
return (int) implode('_', array_keys($priceSet['fields'][$priceFieldID]['options']));
- static function initSet(&$form, $id, $entityTable = 'civicrm_event', $validOnly = FALSE, $priceSetId = NULL) {
+ public static function initSet(&$form, $id, $entityTable = 'civicrm_event', $validOnly = FALSE, $priceSetId = NULL) {
- static function processAmount(&$fields, &$params, &$lineItem, $component = '') {
+ public static function processAmount(&$fields, &$params, &$lineItem, $component = '') {
$params['amount_priceset_level_checkbox']["{$field['options'][$optionId]['id']}"] = $optionLabel;
if (isset($checkboxLevel)) {
$checkboxLevel = array_unique(array_merge(
$params['amount_priceset_level_checkbox']["{$field['options'][$optionId]['id']}"] = $optionLabel;
if (isset($checkboxLevel)) {
$checkboxLevel = array_unique(array_merge(
$validFieldsOnly = TRUE;
$className = CRM_Utils_System::getClassName($form);
if (in_array($className, array(
$validFieldsOnly = TRUE;
$className = CRM_Utils_System::getClassName($form);
if (in_array($className, array(
- 'CRM_Contribute_Form_Contribution', 'CRM_Member_Form_Membership'))) {
+ 'CRM_Contribute_Form_Contribution',
+ 'CRM_Member_Form_Membership',
+ ))) {
- $priceSet = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly);
- $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
+ $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')) {
$validPriceFieldIds = array_keys($form->_priceSet['fields']);
$form->_quickConfig = $quickConfig = 0;
if (CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) {
CRM_Utils_Hook::buildAmount($component, $form, $feeBlock);
// CRM-14492 Admin price fields should show up on event registration if user has 'administer CiviCRM' permissions
CRM_Utils_Hook::buildAmount($component, $form, $feeBlock);
// CRM-14492 Admin price fields should show up on event registration if user has 'administer CiviCRM' permissions
}
foreach ($feeBlock as $id => $field) {
if (CRM_Utils_Array::value('visibility', $field) == 'public' ||
}
foreach ($feeBlock as $id => $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') {
!$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);
$checklifetime = self::checkCurrentMembership($options, $userid);
if ($checklifetime) {
$form->assign('ispricelifetime', TRUE);
/**
* Supports event create function by setting up required price sets, not tested but expect
* it will work for contribution page
/**
* Supports event create function by setting up required price sets, not tested but expect
* it will work for contribution page
- * @param array $params as passed to api/bao create fn
- * @param CRM_Core_DAO $entity object for given entity
- * @param string $entityName name of entity - e.g event
+ * @param array $params
+ * As passed to api/bao create fn.
+ * @param CRM_Core_DAO $entity
+ * Object for given entity.
+ * @param string $entityName
+ * Name of entity - e.g event.
- static function setPriceSets(&$params, $entity, $entityName) {
- if(empty($params['price_set_id']) || !is_array($params['price_set_id'])) {
+ public static function setPriceSets(&$params, $entity, $entityName) {
+ if (empty($params['price_set_id']) || !is_array($params['price_set_id'])) {
// note an even more aggressive form of this deletion currently happens in event form
// past price sets discounts are made inaccessible by this as the discount_id is set to NULL
// on the participant record
if (CRM_Price_BAO_PriceSet::removeFrom('civicrm_' . $entityName, $entity->id)) {
// note an even more aggressive form of this deletion currently happens in event form
// past price sets discounts are made inaccessible by this as the discount_id is set to NULL
// on the participant record
if (CRM_Price_BAO_PriceSet::removeFrom('civicrm_' . $entityName, $entity->id)) {
$maxId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_price_set");
$title = ts('[Copy id %1]', array(1 => $maxId + 1));
$fieldsFix = array(
$maxId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_price_set");
$title = ts('[Copy id %1]', array(1 => $maxId + 1));
$fieldsFix = array(
- 'suffix' => array('title' => ' ' . $title,
- 'name' => '__Copy_id_' . ($maxId + 1) . '_',
+ 'suffix' => array(
+ 'title' => ' ' . $title,
+ 'name' => '__Copy_id_' . ($maxId + 1) . '_',
);
//copying all the blocks pertaining to the price set
$copyPriceField = &CRM_Core_DAO::copyGeneric('CRM_Price_DAO_PriceField',
);
//copying all the blocks pertaining to the price set
$copyPriceField = &CRM_Core_DAO::copyGeneric('CRM_Price_DAO_PriceField',
- array('price_set_id' => $id),
- array('price_set_id' => $copy->id)
+ array('price_set_id' => $id),
+ array('price_set_id' => $copy->id)
);
if (!empty($copyPriceField)) {
$price = array_combine(self::getFieldIds($id), self::getFieldIds($copy->id));
);
if (!empty($copyPriceField)) {
$price = array_combine(self::getFieldIds($id), self::getFieldIds($copy->id));
if ($sid && self::eventPriceSetDomainID()) {
$domain_id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $sid, 'domain_id', 'id');
if (CRM_Core_Config::domainID() != $domain_id) {
if ($sid && self::eventPriceSetDomainID()) {
$domain_id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $sid, 'domain_id', 'id');
if (CRM_Core_Config::domainID() != $domain_id) {
*/
public static function checkAutoRenewForPriceSet($priceSetId) {
// auto-renew option should be visible if membership types associated with all the fields has
*/
public static function checkAutoRenewForPriceSet($priceSetId) {
// auto-renew option should be visible if membership types associated with all the fields has
*/
public static function getRecurDetails($priceSetId) {
$query = 'SELECT mt.duration_interval, mt.duration_unit
*/
public static function getRecurDetails($priceSetId) {
$query = 'SELECT mt.duration_interval, mt.duration_unit
return CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME,
'event_price_set_domain_id',
NULL, FALSE
return CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME,
'event_price_set_domain_id',
NULL, FALSE
- * @param int $id id of the database record
- * @param boolean $isQuickConfig value we want to set the is_quick_config field
+ * @param int $id
+ * Id of the database record.
+ * @param bool $isQuickConfig we want to set the is_quick_config field.
+ * Value we want to set the is_quick_config field.
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $id, 'is_quick_config', $isQuickConfig);
}
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $id, 'is_quick_config', $isQuickConfig);
}
* Check if price set id provides option for
* user to select both auto-renew and non-auto-renew memberships
*
* Check if price set id provides option for
* user to select both auto-renew and non-auto-renew memberships
*
- $query =
-"
-SELECT pfv.id, pfv.price_field_id, pfv.name, pfv.membership_type_id, pf.html_type, mt.auto_renew
+ $query
+ = "SELECT pfv.id, pfv.price_field_id, pfv.name, pfv.membership_type_id, pf.html_type, mt.auto_renew
FROM civicrm_price_field_value pfv
LEFT JOIN civicrm_price_field pf ON pf.id = pfv.price_field_id
LEFT JOIN civicrm_price_set ps ON ps.id = pf.price_set_id
FROM civicrm_price_field_value pfv
LEFT JOIN civicrm_price_field pf ON pf.id = pfv.price_field_id
LEFT JOIN civicrm_price_set ps ON ps.id = pf.price_set_id
$priceSetId = CRM_Price_BAO_PriceSet::getFor($baoName, $id);
if ($priceSetId) {
$isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
$priceSetId = CRM_Price_BAO_PriceSet::getFor($baoName, $id);
if ($priceSetId) {
$isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
$copyPriceSet = &CRM_Price_BAO_PriceSet::copy($priceSetId);
CRM_Price_BAO_PriceSet::addTo($baoName, $newId, $copyPriceSet->id);
}
$copyPriceSet = &CRM_Price_BAO_PriceSet::copy($priceSetId);
CRM_Price_BAO_PriceSet::addTo($baoName, $newId, $copyPriceSet->id);
}
if ($field['html_type'] == 'Text') {
$taxAmount = $field['options'][$optionValueId]['tax_amount'] * $lineItem[$optionValueId]['qty'];
}
if ($field['html_type'] == 'Text') {
$taxAmount = $field['options'][$optionValueId]['tax_amount'] * $lineItem[$optionValueId]['qty'];
}