| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*
* 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
* pairs
*
*
* 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
* pairs
*
$params['name'] = strtolower(CRM_Utils_String::munge($params['label'], '_', 242));
}
$transaction = new CRM_Core_Transaction();
$params['name'] = strtolower(CRM_Utils_String::munge($params['label'], '_', 242));
}
$transaction = new CRM_Core_Transaction();
$options['membership_num_terms'] = CRM_Utils_Array::value($index, CRM_Utils_Array::value('membership_num_terms', $params), 1);
}
$options['membership_num_terms'] = CRM_Utils_Array::value($index, CRM_Utils_Array::value('membership_num_terms', $params), 1);
}
- if (CRM_Utils_Array::value( $index, CRM_Utils_Array::value('option_financial_type_id', $params))) {
- $options['financial_type_id'] = $params['option_financial_type_id'][$index];
- } elseif (!empty($params['financial_type_id'])) {
+ if (CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_financial_type_id', $params))) {
+ $options['financial_type_id'] = $params['option_financial_type_id'][$index];
+ }
+ elseif (!empty($params['financial_type_id'])) {
$options['financial_type_id'] = $params['financial_type_id'];
}
if ($opIds = CRM_Utils_Array::value('option_id', $params)) {
if ($opId = CRM_Utils_Array::value($index, $opIds)) {
$optionsIds['id'] = $opId;
$options['financial_type_id'] = $params['financial_type_id'];
}
if ($opIds = CRM_Utils_Array::value('option_id', $params)) {
if ($opId = CRM_Utils_Array::value($index, $opIds)) {
$optionsIds['id'] = $opId;
- * @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.
- * @param int $id Id of the database record
- * @param boolean $is_active Value we want to set the is_active field
+ * @param int $id
+ * Id of the database record.
+ * @param bool $is_active
+ * Value we want to set the is_active field.
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceField', $id, 'is_active', $is_active);
}
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceField', $id, 'is_active', $is_active);
}
- * @param CRM_Core_Form $qf form object (reference)
- * @param string $elementName name of the custom field
+ * @param CRM_Core_Form $qf
+ * Form object (reference).
+ * @param string $elementName
+ * Name of the custom field.
- * @param boolean $inactiveNeeded
- * @param boolean $useRequired true if required else false
- * @param string $label label for custom field
+ * @param bool $inactiveNeeded
+ * @param bool $useRequired
+ * True if required else false.
+ * @param string $label
+ * Label for custom field.
*
* @param null $fieldOptions
* @param array $freezeOptions
*
* @return null
* @internal param bool $search true if used for search else false
*
* @param null $fieldOptions
* @param array $freezeOptions
*
* @return null
* @internal param bool $search true if used for search else false
- $currencySymbol = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_Currency',$config->defaultCurrency,'symbol','name');
+ $currencySymbol = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_Currency', $config->defaultCurrency, 'symbol', 'name');
$qf->assign('currencySymbol', $currencySymbol);
// get currency name for price field and option attributes
$currencyName = $config->defaultCurrency;
$qf->assign('currencySymbol', $currencySymbol);
// get currency name for price field and option attributes
$currencyName = $config->defaultCurrency;
$qf->assign('taxTerm', $taxTerm);
$qf->assign('invoicing', $invoicing);
}
$qf->assign('taxTerm', $taxTerm);
$qf->assign('invoicing', $invoicing);
}
- $priceVal = implode($seperator, array($customOption[$optionKey][$valueFieldName] + $taxAmount, $count, $max_value));
+ $priceVal = implode($seperator, array(
+ $customOption[$optionKey][$valueFieldName] + $taxAmount,
+ $count,
+ $max_value,
+ ));
if ($fieldOption['name'] == 'other_amount') {
$fieldOption['label'] = $fieldOption['label'] . ' ' . $currencySymbol;
}
if ($fieldOption['name'] == 'other_amount') {
$fieldOption['label'] = $fieldOption['label'] . ' ' . $currencySymbol;
}
$label = $fieldOptions[$optionKey]['label'];
}
$element = &$qf->add('text', $elementName, $label,
$label = $fieldOptions[$optionKey]['label'];
}
$element = &$qf->add('text', $elementName, $label,
- array_merge($extra,
- array('price' => json_encode(array($optionKey, $priceVal)),
- 'size' => '4',
- )
- ),
- $useRequired && $field->is_required
+ array_merge($extra,
+ array(
+ 'price' => json_encode(array($optionKey, $priceVal)),
+ 'size' => '4',
+ )
+ ),
+ $useRequired && $field->is_required
- $qf->add( 'text', 'txt-'.$elementName, $label, array( 'size' => '4'));
+ $qf->add('text', 'txt-' . $elementName, $label, array('size' => '4'));
}
// CRM-6902 - Add "max" option for a price set field
if (in_array($optionKey, $freezeOptions)) {
}
// CRM-6902 - Add "max" option for a price set field
if (in_array($optionKey, $freezeOptions)) {
// CRM-14696 - Improve display for sold out price set options
$element->setLabel($label . ' <span class="sold-out-option">' . ts('Sold out') . '</span>');
}
// CRM-14696 - Improve display for sold out price set options
$element->setLabel($label . ' <span class="sold-out-option">' . ts('Sold out') . '</span>');
}
$opt['label'] = !empty($opt['label']) ? $opt['label'] . ' - ' : '';
if (isset($taxAmount) && $invoicing) {
if ($displayOpt == 'Do_not_show') {
$opt['label'] = !empty($opt['label']) ? $opt['label'] . ' - ' : '';
if (isset($taxAmount) && $invoicing) {
if ($displayOpt == 'Do_not_show') {
$opt['label'] = '<span class="crm-price-amount-label">' . $opt['label'] . '</span>' . '<span class="crm-price-amount-amount">' . CRM_Utils_Money::format($opt[$valueFieldName] + $taxAmount) . '</span>';
$opt['label'] .= '<span class="crm-price-amount-tax"> (includes ' . $taxTerm . ' of ' . CRM_Utils_Money::format($opt['tax_amount']) . ')</span>';
}
else {
$opt['label'] = '<span class="crm-price-amount-label">' . $opt['label'] . '</span>' . '<span class="crm-price-amount-amount">' . CRM_Utils_Money::format($opt[$valueFieldName] + $taxAmount) . '</span>';
$opt['label'] .= '<span class="crm-price-amount-tax"> (includes ' . $taxTerm . ' of ' . CRM_Utils_Money::format($opt['tax_amount']) . ')</span>';
}
else {
- $opt['label'] = '<span class="crm-price-amount-label">' . $opt['label'] . '</span>' . '<span class="crm-price-amount-amount">' . CRM_Utils_Money::format($opt[$valueFieldName]) . '</span>';
- $opt['label'] .= '<span class="crm-price-amount-tax"> + '. CRM_Utils_Money::format($opt['tax_amount']) . ' ' . $taxTerm . '</span>';
+ $opt['label'] = '<span class="crm-price-amount-label">' . $opt['label'] . '</span>' . '<span class="crm-price-amount-amount">' . CRM_Utils_Money::format($opt[$valueFieldName]) . '</span>';
+ $opt['label'] .= '<span class="crm-price-amount-tax"> + ' . CRM_Utils_Money::format($opt['tax_amount']) . ' ' . $taxTerm . '</span>';
$count = CRM_Utils_Array::value('count', $opt, '');
$max_value = CRM_Utils_Array::value('max_value', $opt, '');
$priceVal = implode($seperator, array($opt[$valueFieldName] + $taxAmount, $count, $max_value));
$count = CRM_Utils_Array::value('count', $opt, '');
$max_value = CRM_Utils_Array::value('max_value', $opt, '');
$priceVal = implode($seperator, array($opt[$valueFieldName] + $taxAmount, $count, $max_value));
- $extra = array('price' => json_encode(array($elementName, $priceVal)),
- 'data-amount' => $opt[$valueFieldName],
- 'data-currency' => $currencyName,
+ $extra = array(
+ 'price' => json_encode(array($elementName, $priceVal)),
+ 'data-amount' => $opt[$valueFieldName],
+ 'data-currency' => $currencyName,
);
if (!empty($qf->_quickConfig) && $field->name == 'contribution_amount') {
$extra += array('onclick' => 'clearAmountOther();');
);
if (!empty($qf->_quickConfig) && $field->name == 'contribution_amount') {
$extra += array('onclick' => 'clearAmountOther();');
'onclick' => "return showHideAutoRenew({$opt['membership_type_id']});",
'membership-type' => $opt['membership_type_id'],
);
'onclick' => "return showHideAutoRenew({$opt['membership_type_id']});",
'membership-type' => $opt['membership_type_id'],
);
}
$choice[$opId] = $qf->createElement('radio', NULL, '', $opt['label'], $opt['id'], $extra);
if ($is_pay_later) {
}
$choice[$opId] = $qf->createElement('radio', NULL, '', $opt['label'], $opt['id'], $extra);
if ($is_pay_later) {
- $qf->add( 'text', 'txt-'.$elementName, $label, array( 'size' => '4'));
+ $qf->add('text', 'txt-' . $elementName, $label, array('size' => '4'));
// make contribution field required for quick config when membership block is enabled
if (($field->name == 'membership_amount' || $field->name == 'contribution_amount')
// make contribution field required for quick config when membership block is enabled
if (($field->name == 'membership_amount' || $field->name == 'contribution_amount')
$opt['label'] = $opt['label'] . self::getTaxLabel($opt, $valueFieldName, $displayOpt, $taxTerm);
}
else {
$opt['label'] = $opt['label'] . self::getTaxLabel($opt, $valueFieldName, $displayOpt, $taxTerm);
}
else {
$priceVal[$opt['id']] = implode($seperator, array($opt[$valueFieldName] + $taxAmount, $count, $max_value));
if (!in_array($opt['id'], $freezeOptions)) {
$priceVal[$opt['id']] = implode($seperator, array($opt[$valueFieldName] + $taxAmount, $count, $max_value));
if (!in_array($opt['id'], $freezeOptions)) {
$opt['label'] = $opt['label'] . ' (' . ts('Sold out') . ')';
}
$selectOption[$opt['id']] = $opt['label'];
if ($is_pay_later) {
$opt['label'] = $opt['label'] . ' (' . ts('Sold out') . ')';
}
$selectOption[$opt['id']] = $opt['label'];
if ($is_pay_later) {
- $qf->add( 'text', 'txt-'.$elementName, $label, array( 'size' => '4'));
+ $qf->add('text', 'txt-' . $elementName, $label, array('size' => '4'));
}
}
$element = &$qf->add('select', $elementName, $label,
array(
}
}
$element = &$qf->add('select', $elementName, $label,
array(
- '' => ts('- select -')) + $selectOption,
- $useRequired && $field->is_required,
- array('price' => json_encode($priceVal))
- );
+ '' => ts('- select -'),
+ ) + $selectOption,
+ $useRequired && $field->is_required,
+ array('price' => json_encode($priceVal), 'class' => 'crm-select2')
+ );
// CRM-6902 - Add "max" option for a price set field
$button = substr($qf->controller->getButtonName(), -4);
// CRM-6902 - Add "max" option for a price set field
$button = substr($qf->controller->getButtonName(), -4);
}
$priceVal = implode($seperator, array($opt[$valueFieldName] + $taxAmount, $count, $max_value));
$check[$opId] = &$qf->createElement('checkbox', $opt['id'], NULL, $opt['label'],
}
$priceVal = implode($seperator, array($opt[$valueFieldName] + $taxAmount, $count, $max_value));
$check[$opId] = &$qf->createElement('checkbox', $opt['id'], NULL, $opt['label'],
- array('price' => json_encode(array($opt['id'], $priceVal)),
- 'data-amount' => $opt[$valueFieldName],
- 'data-currency' => $currencyName,
+ array(
+ 'price' => json_encode(array($opt['id'], $priceVal)),
+ 'data-amount' => $opt[$valueFieldName],
+ 'data-currency' => $currencyName,
- $txtcheck[$opId] =& $qf->createElement( 'text', $opId, $opt['label'], array( 'size' => '4' ) );
- $qf->addGroup($txtcheck, 'txt-'.$elementName, $label);
+ $txtcheck[$opId] =& $qf->createElement('text', $opId, $opt['label'], array('size' => '4'));
+ $qf->addGroup($txtcheck, 'txt-' . $elementName, $label);
}
// CRM-6902 - Add "max" option for a price set field
if (in_array($opId, $freezeOptions)) {
}
// CRM-6902 - Add "max" option for a price set field
if (in_array($opId, $freezeOptions)) {
- * @param int $fieldId price field ID
- * @param bool $inactiveNeeded include inactive options
- * @param bool $reset ignore stored values\
+ * @param int $fieldId
+ * Price field ID.
+ * @param bool $inactiveNeeded
+ * Include inactive options.
+ * @param bool $reset
+ * Ignore stored values\.
*/
public static function getOptions($fieldId, $inactiveNeeded = FALSE, $reset = FALSE) {
static $options = array();
*/
public static function getOptions($fieldId, $inactiveNeeded = FALSE, $reset = FALSE) {
static $options = array();
if (isset($priceFieldValues['financial_type_id']) && array_key_exists($priceFieldValues['financial_type_id'], $taxRates)) {
$options[$fieldId][$priceFieldId]['tax_rate'] = $taxRates[$priceFieldValues['financial_type_id']];
$taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($priceFieldValues['amount'], $options[$fieldId][$priceFieldId]['tax_rate']);
if (isset($priceFieldValues['financial_type_id']) && array_key_exists($priceFieldValues['financial_type_id'], $taxRates)) {
$options[$fieldId][$priceFieldId]['tax_rate'] = $taxRates[$priceFieldValues['financial_type_id']];
$taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($priceFieldValues['amount'], $options[$fieldId][$priceFieldId]['tax_rate']);
- $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($optionGroupName, 'String'), 2 => array($optionLabel, 'String')));
+ $dao = CRM_Core_DAO::executeQuery($query, array(
+ 1 => array($optionGroupName, 'String'),
+ 2 => array($optionLabel, 'String'),
+ ));
public static function priceSetValidation($priceSetId, $fields, &$error, $allowNoneSelection = FALSE) {
// check for at least one positive
// amount price field should be selected.
public static function priceSetValidation($priceSetId, $fields, &$error, $allowNoneSelection = FALSE) {
// check for at least one positive
// amount price field should be selected.
if (empty($noneSelectedPriceFields)) {
$error['_qf_default'] = ts('Please select at least one option from price set.');
}
if (empty($noneSelectedPriceFields)) {
$error['_qf_default'] = ts('Please select at least one option from price set.');
}
- * @param string $valueFieldName amount
- * @param string $displayOpt tax display setting option
+ * @param string $valueFieldName
+ * Amount.
+ * @param string $displayOpt
+ * Tax display setting option.
*
*/
public static function getTaxLabel($opt, $valueFieldName, $displayOpt, $taxTerm) {
if ($displayOpt == 'Do_not_show') {
$label = CRM_Utils_Money::format($opt[$valueFieldName] + $opt['tax_amount']);
}
*
*/
public static function getTaxLabel($opt, $valueFieldName, $displayOpt, $taxTerm) {
if ($displayOpt == 'Do_not_show') {
$label = CRM_Utils_Money::format($opt[$valueFieldName] + $opt['tax_amount']);
}
$label = CRM_Utils_Money::format($opt[$valueFieldName] + $opt['tax_amount']);
$label .= '<span class="crm-price-amount-tax"> (includes ' . $taxTerm . ' of ' . CRM_Utils_Money::format($opt['tax_amount']) . ')</span>';
}
else {
$label = CRM_Utils_Money::format($opt[$valueFieldName]);
$label = CRM_Utils_Money::format($opt[$valueFieldName] + $opt['tax_amount']);
$label .= '<span class="crm-price-amount-tax"> (includes ' . $taxTerm . ' of ' . CRM_Utils_Money::format($opt['tax_amount']) . ')</span>';
}
else {
$label = CRM_Utils_Money::format($opt[$valueFieldName]);