+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
protected $_options;
/**
- * Takes an associative array and creates a price field object
+ * Takes an associative array and creates a price field object.
*
* the function extract all the params it needs to initialize the create a
* price field object. the params array could contain additional unused name/value
}
/**
- * Takes an associative array and creates a price field object
+ * Takes an associative array and creates a price field object.
*
* This function is invoked from within the web form layer and also from the api layer
*
}
/**
- * Fetch object based on array of properties
+ * Fetch object based on array of properties.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
}
/**
- * Update the is_active flag in the db
+ * Update the is_active flag in the db.
*
* @param int $id
* Id of the database record.
* Value we want to set the is_active field.
*
* @return Object
- * DAO object on sucess, null otherwise
- *
+ * DAO object on success, null otherwise.
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceField', $id, 'is_active', $is_active);
}
+ /**
+ * Freeze form if the event is full.
+ *
+ * @param $element
+ * @param $fieldOptions
+ *
+ * @return null
+ */
public static function freezeIfEnabled(&$element, $fieldOptions) {
if (!empty($fieldOptions['is_full'])) {
$element->freeze();
}
/**
- * This function for building custom fields
+ * This function for building custom fields.
*
* @param CRM_Core_Form $qf
* Form object (reference).
$extra = array();
if (!empty($qf->_quickConfig) && !empty($qf->_contributionAmount)) {
foreach ($fieldOptions as &$fieldOption) {
- if ($fieldOption['name'] == 'other_amount') {
+ if (strtolower($fieldOption['name']) == 'other_amount') {
$fieldOption['label'] = $fieldOption['label'] . ' ' . $currencySymbol;
}
}
// CRM-6902 - Add "max" option for a price set field
if (in_array($optionKey, $freezeOptions)) {
- self::freezeIfEnabled($element, $freezeOptions);
+ self::freezeIfEnabled($element, $fieldOptions[$optionKey]);
// CRM-14696 - Improve display for sold out price set options
$element->setLabel($label . ' <span class="sold-out-option">' . ts('Sold out') . '</span>');
}
}
}
- $selectOption[$opt['id']] = $opt['label'];
$priceVal[$opt['id']] = implode($seperator, array($opt[$valueFieldName] + $taxAmount, $count, $max_value));
if (!in_array($opt['id'], $freezeOptions)) {
}
// CRM-14696 - Improve display for sold out price set options
else {
+ $opt['id'] = 'crm_disabled_opt-' . $opt['id'];
$opt['label'] = $opt['label'] . ' (' . ts('Sold out') . ')';
}
'' => ts('- select -'),
) + $selectOption,
$useRequired && $field->is_required,
- array('price' => json_encode($priceVal))
+ array('price' => json_encode($priceVal), 'class' => 'crm-select2')
);
// CRM-6902 - Add "max" option for a price set field
}
/**
- * Retrieve a list of options for the specified field
+ * Retrieve a list of options for the specified field.
*
* @param int $fieldId
* Price field ID.
}
/**
- * Validate the priceset
+ * Validate the priceset.
*
* @param int $priceSetId
* , array $fields.