本文整理汇总了PHP中CRM_Price_BAO_PriceField::htmlTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_PriceField::htmlTypes方法的具体用法?PHP CRM_Price_BAO_PriceField::htmlTypes怎么用?PHP CRM_Price_BAO_PriceField::htmlTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Price_BAO_PriceField
的用法示例。
在下文中一共展示了CRM_Price_BAO_PriceField::htmlTypes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
// lets trim all the whitespace
$this->applyFilter('__ALL__', 'trim');
// add a hidden field to remember the price set id
// this get around the browser tab issue
$this->add('hidden', 'sid', $this->_sid);
$this->add('hidden', 'fid', $this->_fid);
// label
$this->add('text', 'label', ts('Field Label'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceField', 'label'), TRUE);
// html_type
$javascript = 'onchange="option_html_type(this.form)";';
$htmlTypes = CRM_Price_BAO_PriceField::htmlTypes();
// Text box for Participant Count for a field
// Financial Type
$financialType = CRM_Financial_BAO_FinancialType::getIncomeFinancialType();
foreach ($financialType as $finTypeId => $type) {
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('add contributions of type ' . $type)) {
unset($financialType[$finTypeId]);
}
}
if (count($financialType)) {
$this->assign('financialType', $financialType);
}
$enabledComponents = CRM_Core_Component::getEnabledComponents();
$eventComponentId = $memberComponentId = NULL;
if (array_key_exists('CiviEvent', $enabledComponents)) {
$eventComponentId = CRM_Core_Component::getComponentID('CiviEvent');
}
if (array_key_exists('CiviMember', $enabledComponents)) {
$memberComponentId = CRM_Core_Component::getComponentID('CiviMember');
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceFieldValue');
$this->add('select', 'financial_type_id', ts('Financial Type'), array(' ' => ts('- select -')) + $financialType);
$this->assign('useForMember', FALSE);
if (in_array($eventComponentId, $this->_extendComponentId)) {
$this->add('text', 'count', ts('Participant Count'), $attributes['count']);
$this->addRule('count', ts('Participant Count should be a positive number'), 'positiveInteger');
$this->add('text', 'max_value', ts('Max Participants'), $attributes['max_value']);
$this->addRule('max_value', ts('Please enter a valid Max Participants.'), 'positiveInteger');
$this->assign('useForEvent', TRUE);
} else {
if (in_array($memberComponentId, $this->_extendComponentId)) {
$this->_useForMember = 1;
$this->assign('useForMember', $this->_useForMember);
}
$this->assign('useForEvent', FALSE);
}
$sel = $this->add('select', 'html_type', ts('Input Field Type'), $htmlTypes, TRUE, $javascript);
// price (for text inputs)
$this->add('text', 'price', ts('Price'));
$this->registerRule('price', 'callback', 'money', 'CRM_Utils_Rule');
$this->addRule('price', ts('must be a monetary value'), 'money');
if ($this->_action == CRM_Core_Action::UPDATE) {
$this->freeze('html_type');
}
// form fields of Custom Option rows
$_showHide = new CRM_Core_ShowHideBlocks('', '');
for ($i = 1; $i <= self::NUM_OPTION; $i++) {
//the show hide blocks
$showBlocks = 'optionField_' . $i;
if ($i > 2) {
$_showHide->addHide($showBlocks);
if ($i == self::NUM_OPTION) {
$_showHide->addHide('additionalOption');
}
} else {
$_showHide->addShow($showBlocks);
}
// label
$attributes['label']['size'] = 25;
$this->add('text', 'option_label[' . $i . ']', ts('Label'), $attributes['label']);
// amount
$this->add('text', 'option_amount[' . $i . ']', ts('Amount'), $attributes['amount']);
$this->addRule('option_amount[' . $i . ']', ts('Please enter a valid amount for this field.'), 'money');
//Financial Type
$this->add('select', 'option_financial_type_id[' . $i . ']', ts('Financial Type'), array('' => ts('- select -')) + $financialType);
if (in_array($eventComponentId, $this->_extendComponentId)) {
// count
$this->add('text', 'option_count[' . $i . ']', ts('Participant Count'), $attributes['count']);
$this->addRule('option_count[' . $i . ']', ts('Please enter a valid Participants Count.'), 'positiveInteger');
// max_value
$this->add('text', 'option_max_value[' . $i . ']', ts('Max Participants'), $attributes['max_value']);
$this->addRule('option_max_value[' . $i . ']', ts('Please enter a valid Max Participants.'), 'positiveInteger');
// description
//$this->add('textArea', 'option_description['.$i.']', ts('Description'), array('rows' => 1, 'cols' => 40 ));
} elseif (in_array($memberComponentId, $this->_extendComponentId)) {
$membershipTypes = CRM_Member_PseudoConstant::membershipType();
$js = array('onchange' => "calculateRowValues( {$i} );");
$this->add('select', 'membership_type_id[' . $i . ']', ts('Membership Type'), array('' => ' ') + $membershipTypes, FALSE, $js);
$this->add('text', 'membership_num_terms[' . $i . ']', ts('Number of Terms'), CRM_Utils_Array::value('membership_num_terms', $attributes));
}
// weight
$this->add('text', 'option_weight[' . $i . ']', ts('Order'), $attributes['weight']);
// is active ?
$this->add('checkbox', 'option_status[' . $i . ']', ts('Active?'));
$defaultOption[$i] = $this->createElement('radio', NULL, NULL, NULL, $i);
//.........这里部分代码省略.........
示例2: browse
/**
* Browse all price set fields.
*
* @param null
*
* @return void
* @access public
*/
function browse()
{
$resourceManager = CRM_Core_Resources::singleton();
if (!empty($_GET['new']) && $resourceManager->ajaxPopupsEnabled) {
$resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999);
}
$priceField = array();
$priceFieldBAO = new CRM_Price_BAO_PriceField();
// fkey is sid
$priceFieldBAO->price_set_id = $this->_sid;
$priceFieldBAO->orderBy('weight, label');
$priceFieldBAO->find();
while ($priceFieldBAO->fetch()) {
$priceField[$priceFieldBAO->id] = array();
CRM_Core_DAO::storeValues($priceFieldBAO, $priceField[$priceFieldBAO->id]);
// get price if it's a text field
if ($priceFieldBAO->html_type == 'Text') {
$optionValues = array();
$params = array('price_field_id' => $priceFieldBAO->id);
CRM_Price_BAO_PriceFieldValue::retrieve($params, $optionValues);
$priceField[$priceFieldBAO->id]['price'] = CRM_Utils_Array::value('amount', $optionValues);
}
$action = array_sum(array_keys($this->actionLinks()));
if ($this->_isSetReserved) {
$action -= CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE + CRM_Core_Action::ENABLE + CRM_Core_Action::DISABLE;
} else {
if ($priceFieldBAO->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
}
if ($priceFieldBAO->active_on == '0000-00-00 00:00:00') {
$priceField[$priceFieldBAO->id]['active_on'] = '';
}
if ($priceFieldBAO->expire_on == '0000-00-00 00:00:00') {
$priceField[$priceFieldBAO->id]['expire_on'] = '';
}
// need to translate html types from the db
$htmlTypes = CRM_Price_BAO_PriceField::htmlTypes();
$priceField[$priceFieldBAO->id]['html_type_display'] = $htmlTypes[$priceField[$priceFieldBAO->id]['html_type']];
$priceField[$priceFieldBAO->id]['order'] = $priceField[$priceFieldBAO->id]['weight'];
$priceField[$priceFieldBAO->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('fid' => $priceFieldBAO->id, 'sid' => $this->_sid), ts('more'), FALSE, 'priceField.row.actions', 'PriceField', $priceFieldBAO->id);
}
$returnURL = CRM_Utils_System::url('civicrm/admin/price/field', "reset=1&action=browse&sid={$this->_sid}");
$filter = "price_set_id = {$this->_sid}";
CRM_Utils_Weight::addOrder($priceField, 'CRM_Price_DAO_PriceField', 'id', $returnURL, $filter);
$this->assign('priceField', $priceField);
}
示例3: browse
/**
* Browse all price set fields.
*
* @return void
*/
public function browse()
{
$resourceManager = CRM_Core_Resources::singleton();
if (!empty($_GET['new']) && $resourceManager->ajaxPopupsEnabled) {
$resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999, 'html-header');
}
$priceField = array();
$priceFieldBAO = new CRM_Price_BAO_PriceField();
// fkey is sid
$priceFieldBAO->price_set_id = $this->_sid;
$priceFieldBAO->orderBy('weight, label');
$priceFieldBAO->find();
// display taxTerm for priceFields
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$getTaxDetails = FALSE;
$taxRate = CRM_Core_PseudoConstant::getTaxRates();
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes);
while ($priceFieldBAO->fetch()) {
$priceField[$priceFieldBAO->id] = array();
CRM_Core_DAO::storeValues($priceFieldBAO, $priceField[$priceFieldBAO->id]);
// get price if it's a text field
if ($priceFieldBAO->html_type == 'Text') {
$optionValues = array();
$params = array('price_field_id' => $priceFieldBAO->id);
CRM_Price_BAO_PriceFieldValue::retrieve($params, $optionValues);
$financialTypeId = $optionValues['financial_type_id'];
if (!array_key_exists($financialTypeId, $financialTypes)) {
unset($priceField[$priceFieldBAO->id]);
continue;
}
$priceField[$priceFieldBAO->id]['price'] = CRM_Utils_Array::value('amount', $optionValues);
if ($invoicing && isset($taxRate[$financialTypeId])) {
$priceField[$priceFieldBAO->id]['tax_rate'] = $taxRate[$financialTypeId];
$getTaxDetails = TRUE;
}
if (isset($priceField[$priceFieldBAO->id]['tax_rate'])) {
$taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($priceField[$priceFieldBAO->id]['price'], $priceField[$priceFieldBAO->id]['tax_rate']);
$priceField[$priceFieldBAO->id]['tax_amount'] = $taxAmount['tax_amount'];
}
}
$action = array_sum(array_keys(self::actionLinks()));
if ($this->_isSetReserved) {
$action -= CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE + CRM_Core_Action::ENABLE + CRM_Core_Action::DISABLE;
} else {
if ($priceFieldBAO->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
}
if ($priceFieldBAO->active_on == '0000-00-00 00:00:00') {
$priceField[$priceFieldBAO->id]['active_on'] = '';
}
if ($priceFieldBAO->expire_on == '0000-00-00 00:00:00') {
$priceField[$priceFieldBAO->id]['expire_on'] = '';
}
// need to translate html types from the db
$htmlTypes = CRM_Price_BAO_PriceField::htmlTypes();
$priceField[$priceFieldBAO->id]['html_type_display'] = $htmlTypes[$priceField[$priceFieldBAO->id]['html_type']];
$priceField[$priceFieldBAO->id]['order'] = $priceField[$priceFieldBAO->id]['weight'];
$priceField[$priceFieldBAO->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('fid' => $priceFieldBAO->id, 'sid' => $this->_sid), ts('more'), FALSE, 'priceField.row.actions', 'PriceField', $priceFieldBAO->id);
$this->assign('taxTerm', $taxTerm);
$this->assign('getTaxDetails', $getTaxDetails);
}
$returnURL = CRM_Utils_System::url('civicrm/admin/price/field', "reset=1&action=browse&sid={$this->_sid}");
$filter = "price_set_id = {$this->_sid}";
CRM_Utils_Weight::addOrder($priceField, 'CRM_Price_DAO_PriceField', 'id', $returnURL, $filter);
$this->assign('priceField', $priceField);
}