* Static field for default price set details
*
* @var array
- * @static
*/
static $_defaultPriceSet = NULL;
* @param array $params
* (reference) an assoc array of name/value pairs.
*
- * @return CRM_Price_DAO_PriceSet object
- * @static
+ * @return CRM_Price_DAO_PriceSet
*/
public static function create(&$params) {
if (empty($params['id']) && empty($params['name'])) {
* @param array $defaults
* (reference ) an assoc array to hold the flattened values.
*
- * @return CRM_Price_DAO_PriceSet object
- * @static
+ * @return CRM_Price_DAO_PriceSet
*/
public static function retrieve(&$params, &$defaults) {
return CRM_Core_DAO::commonRetrieve('CRM_Price_DAO_PriceSet', $params, $defaults);
*
* @internal param bool $is_active value we want to set the is_active field
*
- * @return Object DAO object on sucess, null otherwise
- * @static
+ * @return Object
+ * DAO object on sucess, null otherwise
*/
public static function setIsActive($id, $isActive) {
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $id, 'is_active', $isActive);
*
* @param string $entity
*
- * @return array $defaultPriceSet default price set
- *
- * @static
+ * @return array
+ * default price set
*
*/
public static function getDefaultPriceSet($entity = 'contribution') {
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,
);
}
* @param int $id
* Id of price set.
*
- * @return string title
- *
- * @static
+ * @return string
+ * title
*
*/
public static function getTitle($id) {
* @param int $id
* Price Set id.
*
- * @return boolean false if fields exist for this set, true if the
- * set could be deleted
+ * @return bool
+ * false if fields exist for this set, true if the
+ * set could be deleted
*
- * @static
*/
public static function deleteSet($id) {
// remove from all inactive forms
* @return mixed
*/
public static function removeFrom($entityTable, $entityId) {
- $dao = new CRM_Price_DAO_PriceSetEntity();
+ $dao = new CRM_Price_DAO_PriceSetEntity();
$dao->entity_table = $entityTable;
- $dao->entity_id = $entityId;
+ $dao->entity_id = $entityId;
return $dao->delete();
}
* @param null $isQuickConfig
* @param null $setName
*
- * @return integer|false price_set_id, or false if none found
+ * @return int|false
+ * price_set_id, or false if none found
*/
public static function getFor($entityTable, $entityId, $usedFor = NULL, $isQuickConfig = NULL, &$setName = NULL) {
if (!$entityTable || !$entityId) {
$sql .= ' AND ps.is_quick_config = 0 ';
}
$params = array(
- 1 => array($entityTable, 'String'),
- 2 => array($entityId, 'Integer'),
+ 1 => array($entityTable, 'String'),
+ 2 => array($entityId, 'Integer'),
);
if ($usedFor) {
$sql .= " AND ps.extends LIKE '%%3%' ";
* array may contain either option id or
* price field id
*
- * @return integer|NULL price set id on success, null otherwise
- * @static
+ * @return int|NULL
+ * price set id on success, null otherwise
*/
public static function getSetId(&$params) {
$fid = NULL;
* Whether or not to include inactive entries.
* @param bool|string $extendComponentName name of the component like 'CiviEvent','CiviContribute'
*
- * @return array associative array of id => name
+ * @return array
+ * associative array of id => name
*/
public static function getAssoc($withInactive = FALSE, $extendComponentName = FALSE) {
$query = '
*
* @internal param int $setId - price set id whose details are needed
*
- * @return array $setTree - array consisting of field details
+ * @return array
+ * array consisting of field details
*/
public static function getSetDetail($setID, $required = TRUE, $validOnly = FALSE) {
// create a new tree
$select = 'SELECT ' . implode(',', $priceFields);
$from = ' FROM civicrm_price_field';
- $params = array();
+ $params = array();
$params[1] = array($setID, 'Integer');
- $where = '
+ $where = '
WHERE price_set_id = %1
AND is_active = 1
';
$params['amount_priceset_level_checkbox']["{$field['options'][$optionId]['id']}"] = $optionLabel;
if (isset($checkboxLevel)) {
$checkboxLevel = array_unique(array_merge(
- $checkboxLevel,
- array_keys($params['amount_priceset_level_checkbox'])
+ $checkboxLevel,
+ array_keys($params['amount_priceset_level_checkbox'])
)
);
}
unset($autoRenew[$dontCare]);
}
}
- if (count($autoRenew) > 1 ) {
+ if (count($autoRenew) > 1) {
$params['autoRenew'] = $autoRenew;
}
}
$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',
+ ))) {
$validFieldsOnly = FALSE;
}
- $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')) {
* @param CRM_Core_Form $form
* @param $defaults
*
- * @return array $defaults
+ * @return array
*/
public static function setDefaultPriceSet(&$form, &$defaults) {
if (!isset($form->_priceSet) || empty($form->_priceSet['fields'])) {
//}
}
}
+
/**
* Get field ids of a price set
*
* @param int $id
* Price Set id.
*
- * @return array of the field ids
+ * @return array
+ * Array of the field ids
*
- * @static
*/
public static function getFieldIds($id) {
$priceField = new CRM_Price_DAO_PriceField();
}
/**
- * This function is to make a copy of a price set, including
- * all the fields
+ * Copy a price set, including all the fields
*
* @param int $id
* The price set id to copy.
*
- * @return the copy object
- * @static
+ * @return CRM_Price_DAO_PriceSet
*/
public static function copy($id) {
$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) . '_',
+ 'title' => ' ' . $title,
+ 'name' => '__Copy_id_' . ($maxId + 1) . '_',
),
);
$copy = &CRM_Core_DAO::copyGeneric('CRM_Price_DAO_PriceSet',
- array('id' => $id),
- NULL,
- $fieldsFix
+ array('id' => $id),
+ NULL,
+ $fieldsFix
);
//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));
}
/**
- * This function is to check price set permission
+ * check price set permission
*
* @param int $sid
* The price set id.
* @param bool $onlyActive
*
* @return int|null|string
- * @static
*/
public static function getPricesetCount($sid, $onlyActive = TRUE) {
$count = 0;
* @param int $priceSetId
* Price set id.
*
- * @return int $autoRenewOption ( 0:hide, 1:optional 2:required )
+ * @return int
+ * $autoRenewOption ( 0:hide, 1:optional 2:required )
*/
public static function checkAutoRenewForPriceSet($priceSetId) {
// auto-renew option should be visible if membership types associated with all the fields has
$params = array(1 => array($priceSetId, 'Integer'));
- $dao = CRM_Core_DAO::executeQuery($query, $params);
+ $dao = CRM_Core_DAO::executeQuery($query, $params);
$autoRenewOption = 2;
- $interval = $unit = array();
+ $interval = $unit = array();
while ($dao->fetch()) {
if (!$dao->auto_renew) {
$autoRenewOption = 0;
* @param int $priceSetId
* Price set id.
*
- * @return array associate array of frequency interval and unit
- * @static
+ * @return array
+ * associate array of frequency interval and unit
*/
public static function getRecurDetails($priceSetId) {
$query = 'SELECT mt.duration_interval, mt.duration_unit
*
* @param int $id
* Id of the database record.
- * @param bool $isQuickConfigValue we want to set the is_quick_config field.
+ * @param bool $isQuickConfig we want to set the is_quick_config field.
* Value we want to set the is_quick_config field.
*
- * @return Object DAO object on sucess, null otherwise
- * @static
+ * @return Object
+ * DAO object on sucess, null otherwise
*/
public static function setIsQuickConfig($id, $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
*
- * @static
- *
*/
public static function checkMembershipPriceSet($id) {
- $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
}
}
- /*
+ /**
* Function to set tax_amount and tax_rate in LineItem
*
+ * @param array $field
+ * @param array $lineItem
+ * @param int $optionValueId
*
+ * @return array
*/
public static function setLineItem($field, $lineItem, $optionValueId) {
if ($field['html_type'] == 'Text') {