/** * Insert/update a new entry in the database. * * @param array $params * (reference), array $ids. * * @param $ids * * @return CRM_Price_DAO_PriceFieldValue */ public static function add(&$params, $ids = array()) { $fieldValueBAO = new CRM_Price_BAO_PriceFieldValue(); $fieldValueBAO->copyValues($params); if ($id = CRM_Utils_Array::value('id', $ids)) { $fieldValueBAO->id = $id; } if (!empty($params['is_default'])) { $query = 'UPDATE civicrm_price_field_value SET is_default = 0 WHERE price_field_id = %1'; $p = array(1 => array($params['price_field_id'], 'Integer')); CRM_Core_DAO::executeQuery($query, $p); } $fieldValueBAO->save(); // Reset the cached values in this function. CRM_Price_BAO_PriceField::getOptions(CRM_Utils_Array::value('price_field_id', $params), FALSE, TRUE); return $fieldValueBAO; }
/** * This function for building custom fields * * @param CRM_Core_Form $qf form object (reference) * @param string $elementName name of the custom field * @param $fieldId * @param boolean $inactiveNeeded * @param boolean $useRequired true if required else false * @param string $label label for custom field * * @param null $fieldOptions * @param array $feezeOptions * * @return null * @internal param bool $search true if used for search else false * @access public * @static */ public static function addQuickFormElement(&$qf, $elementName, $fieldId, $inactiveNeeded, $useRequired = TRUE, $label = NULL, $fieldOptions = NULL, $feezeOptions = array()) { $field = new CRM_Price_DAO_PriceField(); $field->id = $fieldId; if (!$field->find(TRUE)) { /* FIXME: failure! */ return NULL; } $is_pay_later = 0; if (isset($qf->_mode) && empty($qf->_mode)) { $is_pay_later = 1; } elseif (isset($qf->_values)) { $is_pay_later = CRM_Utils_Array::value('is_pay_later', $qf->_values); } $otherAmount = $qf->get('values'); $config = CRM_Core_Config::singleton(); $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; if (!isset($label)) { $label = !empty($qf->_membershipBlock) && $field->name == 'contribution_amount' ? ts('Additional Contribution') : $field->label; } if ($field->name == 'contribution_amount') { $qf->_contributionAmount = 1; } if (isset($qf->_online) && $qf->_online) { $useRequired = FALSE; } $customOption = $fieldOptions; if (!is_array($customOption)) { $customOption = CRM_Price_BAO_PriceField::getOptions($field->id, $inactiveNeeded); } //use value field. $valueFieldName = 'amount'; $seperator = '|'; switch ($field->html_type) { case 'Text': $optionKey = key($customOption); $count = CRM_Utils_Array::value('count', $customOption[$optionKey], ''); $max_value = CRM_Utils_Array::value('max_value', $customOption[$optionKey], ''); $priceVal = implode($seperator, array($customOption[$optionKey][$valueFieldName], $count, $max_value)); $extra = array(); if (!empty($qf->_quickConfig) && !empty($qf->_contributionAmount)) { foreach ($fieldOptions as &$fieldOption) { if ($fieldOption['name'] == 'other_amount') { $fieldOption['label'] = $fieldOption['label'] . ' ' . $currencySymbol; } } $qf->assign('priceset', $elementName); $extra = array('onclick' => 'useAmountOther();'); } if (!empty($qf->_membershipBlock) && !empty($qf->_quickConfig) && $field->name == 'other_amount' && empty($qf->_contributionAmount)) { $useRequired = 0; } elseif (!empty($fieldOptions[$optionKey]['label'])) { //check for 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); if ($is_pay_later) { $qf->add('text', 'txt-' . $elementName, $label, array('size' => '4')); } // CRM-6902 if (in_array($optionKey, $feezeOptions)) { $element->freeze(); } //CRM-10117 if (!empty($qf->_quickConfig)) { $message = ts('Please enter a valid amount.'); $type = 'money'; } else { $message = ts('%1 must be an integer (whole number).', array(1 => $label)); $type = 'positiveInteger'; } // integers will have numeric rule applied to them. $qf->addRule($elementName, $message, $type); break; case 'Radio': $choice = array(); if (!empty($qf->_quickConfig) && !empty($qf->_contributionAmount)) { $qf->assign('contriPriceset', $elementName); } foreach ($customOption as $opId => $opt) { if ($field->is_display_amounts) { $opt['label'] = !empty($opt['label']) ? $opt['label'] : ''; $opt['label'] = '<span class="crm-price-amount-amount">' . CRM_Utils_Money::format($opt[$valueFieldName]) . '</span> <span class="crm-price-amount-label">' . $opt['label'] . '</span>'; } $count = CRM_Utils_Array::value('count', $opt, ''); $max_value = CRM_Utils_Array::value('max_value', $opt, ''); $priceVal = implode($seperator, array($opt[$valueFieldName], $count, $max_value)); $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();'); } elseif (!empty($qf->_quickConfig) && $field->name == 'membership_amount') { $extra += array('onclick' => "return showHideAutoRenew({$opt['membership_type_id']});", 'membership-type' => $opt['membership_type_id']); $qf->assign('membershipFieldID', $field->id); } $choice[$opId] = $qf->createElement('radio', NULL, '', $opt['label'], $opt['id'], $extra); if ($is_pay_later) { $qf->add('text', 'txt-' . $elementName, $label, array('size' => '4')); } // CRM-6902 if (in_array($opId, $feezeOptions)) { $choice[$opId]->freeze(); } } if (!empty($qf->_membershipBlock) && $field->name == 'contribution_amount') { $choice[] = $qf->createElement('radio', NULL, '', ts('No thank you'), '-1', array('onclick' => 'clearAmountOther();')); } if (!$field->is_required) { // add "none" option if (!empty($otherAmount['is_allow_other_amount']) && $field->name == 'contribution_amount') { $none = ts('Other Amount'); } elseif (!empty($qf->_membershipBlock) && empty($qf->_membershipBlock['is_required']) && $field->name == 'membership_amount') { $none = ts('No thank you'); } else { $none = ts('- none -'); } $choice[] = $qf->createElement('radio', NULL, '', $none, '0', array('price' => json_encode(array($elementName, '0')))); } $element =& $qf->addGroup($choice, $elementName, $label); // make contribution field required for quick config when membership block is enabled if (($field->name == 'membership_amount' || $field->name == 'contribution_amount') && !empty($qf->_membershipBlock) && !$field->is_required) { $useRequired = $field->is_required = TRUE; } if ($useRequired && $field->is_required) { $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required'); } break; case 'Select': $selectOption = $allowedOptions = $priceVal = array(); foreach ($customOption as $opt) { $count = CRM_Utils_Array::value('count', $opt, ''); $max_value = CRM_Utils_Array::value('max_value', $opt, ''); $priceVal[$opt['id']] = implode($seperator, array($opt[$valueFieldName], $count, $max_value)); if ($field->is_display_amounts) { $opt['label'] .= ' - '; $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]); } $selectOption[$opt['id']] = $opt['label']; if (!in_array($opt['id'], $feezeOptions)) { $allowedOptions[] = $opt['id']; } if ($is_pay_later) { $qf->add('text', 'txt-' . $elementName, $label, array('size' => '4')); } } $element =& $qf->add('select', $elementName, $label, array('' => ts('- select -')) + $selectOption, $useRequired && $field->is_required, array('price' => json_encode($priceVal))); // CRM-6902 $button = substr($qf->controller->getButtonName(), -4); if (!empty($feezeOptions) && $button != 'skip') { $qf->addRule($elementName, ts('Sorry, this option is currently sold out.'), 'regex', "/" . implode('|', $allowedOptions) . "/"); } break; case 'CheckBox': $check = array(); foreach ($customOption as $opId => $opt) { $count = CRM_Utils_Array::value('count', $opt, ''); $max_value = CRM_Utils_Array::value('max_value', $opt, ''); $priceVal = implode($seperator, array($opt[$valueFieldName], $count, $max_value)); if ($field->is_display_amounts) { $opt['label'] .= ' - '; $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]); } $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)); if ($is_pay_later) { $txtcheck[$opId] =& $qf->createElement('text', $opId, $opt['label'], array('size' => '4')); $qf->addGroup($txtcheck, 'txt-' . $elementName, $label); } // CRM-6902 if (in_array($opId, $feezeOptions)) { $check[$opId]->freeze(); } } $element =& $qf->addGroup($check, $elementName, $label); if ($useRequired && $field->is_required) { $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required'); } break; } if (isset($qf->_online) && $qf->_online) { $element->freeze(); } }
/** * Get price set details. * * An array containing price set details (including price fields) is returned * * @param int $setID * Price Set ID. * @param bool $required * Appears to have no effect based on reading the code. * @param bool $validOnly * Should only fields where today's date falls within the valid range be returned? * * @return array * Array consisting of field details */ public static function getSetDetail($setID, $required = TRUE, $validOnly = FALSE) { // create a new tree $setTree = array(); $priceFields = array('id', 'name', 'label', 'html_type', 'is_enter_qty', 'help_pre', 'help_post', 'weight', 'is_display_amounts', 'options_per_line', 'is_active', 'active_on', 'expire_on', 'javascript', 'visibility_id', 'is_required'); if ($required == TRUE) { $priceFields[] = 'is_required'; } // create select $select = 'SELECT ' . implode(',', $priceFields); $from = ' FROM civicrm_price_field'; $params = array(); $params[1] = array($setID, 'Integer'); $where = ' WHERE price_set_id = %1 AND is_active = 1 '; $dateSelect = ''; if ($validOnly) { $currentTime = date('YmdHis'); $dateSelect = "\nAND ( active_on IS NULL OR active_on <= {$currentTime} )\nAND ( expire_on IS NULL OR expire_on >= {$currentTime} )\n"; } $orderBy = ' ORDER BY weight'; $sql = $select . $from . $where . $dateSelect . $orderBy; $dao = CRM_Core_DAO::executeQuery($sql, $params); $visibility = CRM_Core_PseudoConstant::visibility('name'); while ($dao->fetch()) { $fieldID = $dao->id; $setTree[$setID]['fields'][$fieldID] = array(); $setTree[$setID]['fields'][$fieldID]['id'] = $fieldID; foreach ($priceFields as $field) { if ($field == 'id' || is_null($dao->{$field})) { continue; } if ($field == 'visibility_id') { $setTree[$setID]['fields'][$fieldID]['visibility'] = $visibility[$dao->{$field}]; } $setTree[$setID]['fields'][$fieldID][$field] = $dao->{$field}; } $setTree[$setID]['fields'][$fieldID]['options'] = CRM_Price_BAO_PriceField::getOptions($fieldID, FALSE); } // also get the pre and post help from this price set $sql = "\nSELECT extends, financial_type_id, help_pre, help_post, is_quick_config\nFROM civicrm_price_set\nWHERE id = %1"; $dao = CRM_Core_DAO::executeQuery($sql, $params); if ($dao->fetch()) { $setTree[$setID]['extends'] = $dao->extends; $setTree[$setID]['financial_type_id'] = $dao->financial_type_id; $setTree[$setID]['help_pre'] = $dao->help_pre; $setTree[$setID]['help_post'] = $dao->help_post; $setTree[$setID]['is_quick_config'] = $dao->is_quick_config; } return $setTree; }
/** * This function for building custom fields. * * @param CRM_Core_Form $qf * Form object (reference). * @param string $elementName * Name of the custom field. * @param int $fieldId * @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 */ public static function addQuickFormElement(&$qf, $elementName, $fieldId, $inactiveNeeded, $useRequired = TRUE, $label = NULL, $fieldOptions = NULL, $freezeOptions = array()) { $field = new CRM_Price_DAO_PriceField(); $field->id = $fieldId; if (!$field->find(TRUE)) { /* FIXME: failure! */ return NULL; } $is_pay_later = 0; if (isset($qf->_mode) && empty($qf->_mode)) { $is_pay_later = 1; } elseif (isset($qf->_values)) { $is_pay_later = CRM_Utils_Array::value('is_pay_later', $qf->_values); } $otherAmount = $qf->get('values'); $config = CRM_Core_Config::singleton(); $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; if (!isset($label)) { $label = !empty($qf->_membershipBlock) && $field->name == 'contribution_amount' ? ts('Additional Contribution') : $field->label; } if ($field->name == 'contribution_amount') { $qf->_contributionAmount = 1; } if (isset($qf->_online) && $qf->_online) { $useRequired = FALSE; } $customOption = $fieldOptions; if (!is_array($customOption)) { $customOption = CRM_Price_BAO_PriceField::getOptions($field->id, $inactiveNeeded); } //use value field. $valueFieldName = 'amount'; $seperator = '|'; $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); $displayOpt = CRM_Utils_Array::value('tax_display_settings', $invoiceSettings); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); switch ($field->html_type) { case 'Text': $optionKey = key($customOption); $count = CRM_Utils_Array::value('count', $customOption[$optionKey], ''); $max_value = CRM_Utils_Array::value('max_value', $customOption[$optionKey], ''); $taxAmount = CRM_Utils_Array::value('tax_amount', $customOption[$optionKey]); if (isset($taxAmount) && $displayOpt && $invoicing) { $qf->assign('displayOpt', $displayOpt); $qf->assign('taxTerm', $taxTerm); $qf->assign('invoicing', $invoicing); } $priceVal = implode($seperator, array($customOption[$optionKey][$valueFieldName] + $taxAmount, $count, $max_value)); $extra = array(); if (!empty($qf->_membershipBlock) && !empty($qf->_quickConfig) && $field->name == 'other_amount' && empty($qf->_contributionAmount)) { $useRequired = 0; } elseif (!empty($fieldOptions[$optionKey]['label'])) { //check for label. $label = $fieldOptions[$optionKey]['label']; if (!empty($qf->_quickConfig) && !empty($qf->_contributionAmount) && strtolower($fieldOptions[$optionKey]['name']) == 'other_amount') { $label .= ' ' . $currencySymbol; $qf->assign('priceset', $elementName); $extra = array('onclick' => 'useAmountOther();'); } } $element =& $qf->add('text', $elementName, $label, array_merge($extra, array('price' => json_encode(array($optionKey, $priceVal)), 'size' => '4')), $useRequired && $field->is_required); if ($is_pay_later) { $qf->add('text', 'txt-' . $elementName, $label, array('size' => '4')); } // CRM-6902 - Add "max" option for a price set field if (in_array($optionKey, $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>'); } //CRM-10117 if (!empty($qf->_quickConfig)) { $message = ts('Please enter a valid amount.'); $type = 'money'; } else { $message = ts('%1 must be a number (with or without decimal point).', array(1 => $label)); $type = 'numeric'; } // integers will have numeric rule applied to them. $qf->addRule($elementName, $message, $type); break; case 'Radio': $choice = array(); if (!empty($qf->_quickConfig) && !empty($qf->_contributionAmount)) { $qf->assign('contriPriceset', $elementName); } foreach ($customOption as $opId => $opt) { $taxAmount = CRM_Utils_Array::value('tax_amount', $opt); if ($field->is_display_amounts) { $opt['label'] = !empty($opt['label']) ? $opt['label'] . '<span class="crm-price-amount-label-separator"> - </span>' : ''; $preHelpText = $postHelpText = ''; if (isset($opt['help_pre'])) { $preHelpText = '<span class="crm-price-amount-help-pre description">' . $opt['help_pre'] . '</span>: '; } if (isset($opt['help_post'])) { $postHelpText = ': <span class="crm-price-amount-help-post description">' . $opt['help_post'] . '</span>'; } 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>'; } elseif ($displayOpt == 'Inclusive') { $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>'; } } 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'] = $preHelpText . $opt['label'] . $postHelpText; } $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, 'data-price-field-values' => json_encode($customOption)); if (!empty($qf->_quickConfig) && $field->name == 'contribution_amount') { $extra += array('onclick' => 'clearAmountOther();'); } elseif (!empty($qf->_quickConfig) && $field->name == 'membership_amount') { $extra += array('onclick' => "return showHideAutoRenew({$opt['membership_type_id']});", 'membership-type' => $opt['membership_type_id']); $qf->assign('membershipFieldID', $field->id); } $choice[$opId] = $qf->createElement('radio', NULL, '', $opt['label'], $opt['id'], $extra); if ($is_pay_later) { $qf->add('text', 'txt-' . $elementName, $label, array('size' => '4')); } // CRM-6902 - Add "max" option for a price set field if (in_array($opId, $freezeOptions)) { self::freezeIfEnabled($choice[$opId], $customOption[$opId]); // CRM-14696 - Improve display for sold out price set options $choice[$opId]->setText('<span class="sold-out-option">' . $choice[$opId]->getText() . ' (' . ts('Sold out') . ')</span>'); } } if (!empty($qf->_membershipBlock) && $field->name == 'contribution_amount') { $choice[] = $qf->createElement('radio', NULL, '', ts('No thank you'), '-1', array('price' => json_encode(array($elementName, '0|0')), 'data-currency' => $currencyName, 'onclick' => 'clearAmountOther();')); } if (!$field->is_required) { // add "none" option if (!empty($otherAmount['is_allow_other_amount']) && $field->name == 'contribution_amount') { $none = ts('Other Amount'); } elseif (!empty($qf->_membershipBlock) && empty($qf->_membershipBlock['is_required']) && $field->name == 'membership_amount') { $none = ts('No thank you'); } else { $none = ts('- none -'); } $choice[] = $qf->createElement('radio', NULL, '', $none, '0', array('price' => json_encode(array($elementName, '0')))); } $element =& $qf->addGroup($choice, $elementName, $label); // make contribution field required for quick config when membership block is enabled if (($field->name == 'membership_amount' || $field->name == 'contribution_amount') && !empty($qf->_membershipBlock) && !$field->is_required) { $useRequired = $field->is_required = TRUE; } if ($useRequired && $field->is_required) { $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required'); } break; case 'Select': $selectOption = $allowedOptions = $priceVal = array(); foreach ($customOption as $opt) { $taxAmount = CRM_Utils_Array::value('tax_amount', $opt); $count = CRM_Utils_Array::value('count', $opt, ''); $max_value = CRM_Utils_Array::value('max_value', $opt, ''); if ($field->is_display_amounts) { $opt['label'] .= ' - '; if (isset($taxAmount) && $invoicing) { $opt['label'] = $opt['label'] . self::getTaxLabel($opt, $valueFieldName, $displayOpt, $taxTerm); } else { $opt['label'] = $opt['label'] . CRM_Utils_Money::format($opt[$valueFieldName]); } } $priceVal[$opt['id']] = implode($seperator, array($opt[$valueFieldName] + $taxAmount, $count, $max_value)); if (!in_array($opt['id'], $freezeOptions)) { $allowedOptions[] = $opt['id']; } else { $opt['id'] = 'crm_disabled_opt-' . $opt['id']; $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')); } } $element =& $qf->add('select', $elementName, $label, array('' => ts('- select -')) + $selectOption, $useRequired && $field->is_required, array('price' => json_encode($priceVal), 'class' => 'crm-select2', 'data-price-field-values' => json_encode($customOption))); // CRM-6902 - Add "max" option for a price set field $button = substr($qf->controller->getButtonName(), -4); if (!empty($freezeOptions) && $button != 'skip') { $qf->addRule($elementName, ts('Sorry, this option is currently sold out.'), 'regex', "/" . implode('|', $allowedOptions) . "/"); } break; case 'CheckBox': $check = array(); foreach ($customOption as $opId => $opt) { $taxAmount = CRM_Utils_Array::value('tax_amount', $opt); $count = CRM_Utils_Array::value('count', $opt, ''); $max_value = CRM_Utils_Array::value('max_value', $opt, ''); if ($field->is_display_amounts) { $preHelpText = $postHelpText = ''; if (isset($opt['help_pre'])) { $preHelpText = '<span class="crm-price-amount-help-pre description">' . $opt['help_pre'] . '</span>: '; } if (isset($opt['help_post'])) { $postHelpText = ': <span class="crm-price-amount-help-post description">' . $opt['help_post'] . '</span>'; } $opt['label'] = '<span class="crm-price-amount-label">' . $opt['label'] . '</span> - '; if (isset($taxAmount) && $invoicing) { $opt['label'] .= self::getTaxLabel($opt, $valueFieldName, $displayOpt, $taxTerm); } else { $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]); } $opt['label'] = $preHelpText . $opt['label'] . $postHelpText; } $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)); if ($is_pay_later) { $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)) { self::freezeIfEnabled($check[$opId], $customOption[$opId]); // CRM-14696 - Improve display for sold out price set options $check[$opId]->setText('<span class="sold-out-option">' . $check[$opId]->getText() . ' (' . ts('Sold out') . ')</span>'); } } $element =& $qf->addGroup($check, $elementName, $label); if ($useRequired && $field->is_required) { $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required'); } break; } if (isset($qf->_online) && $qf->_online) { $element->freeze(); } }