function uc_taxes_form in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_taxes/uc_taxes.module \uc_taxes_form()
- 6.2 uc_taxes/uc_taxes.admin.inc \uc_taxes_form()
Builds a form to add or edit a tax rate.
Parameters
$rate_id: The ID of the tax rate to edit; leave NULL to add a new rate.
See also
1 string reference to 'uc_taxes_form'
- uc_taxes_menu in uc_taxes/
uc_taxes.module - Implements hook_menu().
File
- uc_taxes/
uc_taxes.admin.inc, line 51 - Taxes administration menu items.
Code
function uc_taxes_form($form, &$form_state, $rate_id = NULL) {
// If a rate ID was specified...
if ($rate_id) {
// Load the tax rate and set the page title.
$rate = uc_taxes_rate_load($rate_id);
drupal_set_title($rate->name);
}
$form['id'] = array(
'#type' => 'value',
'#value' => $rate_id,
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#description' => t('This name will appear to the customer when this tax is applied to an order.'),
'#default_value' => $rate_id ? $rate->name : '',
'#required' => TRUE,
);
$form['rate'] = array(
'#type' => 'textfield',
'#title' => t('Rate'),
'#description' => t('The tax rate as a percent or decimal. Examples: 6%, .06'),
'#default_value' => $rate_id ? $rate->rate * 100 . '%' : '',
'#size' => 15,
'#required' => TRUE,
);
$form['shippable'] = array(
'#type' => 'radios',
'#title' => t('Taxed products'),
'#options' => array(
t('Apply tax to any product regardless of its shippability.'),
t('Apply tax to shippable products only.'),
),
'#default_value' => $rate_id ? $rate->shippable : 0,
);
// TODO: Remove the need for a special case for product kit module.
$options = uc_product_type_names();
unset($options['product_kit']);
$options['blank-line'] = t('"Blank line" product');
$form['taxed_product_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Taxed product types'),
'#description' => t('Apply taxes to the specified product types/classes.'),
'#options' => $options,
'#default_value' => $rate_id ? $rate->taxed_product_types : array(),
);
$options = array();
foreach (_uc_line_item_list() as $id => $line_item) {
if (!in_array($id, array(
'subtotal',
'tax_subtotal',
'total',
'tax_display',
))) {
$options[$id] = $line_item['title'];
}
}
$form['taxed_line_items'] = array(
'#type' => 'checkboxes',
'#title' => t('Taxed line items'),
'#description' => t('Adds the checked line item types to the total before applying this tax.'),
'#options' => $options,
'#default_value' => $rate_id ? $rate->taxed_line_items : array(),
);
$form['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#description' => t('Taxes are sorted by weight and then applied to the order sequentially. This value is important when taxes need to include other tax line items.'),
'#default_value' => $rate_id ? $rate->weight : 0,
);
$form['display_include'] = array(
'#type' => 'checkbox',
'#title' => t('Include this tax when displaying product prices.'),
'#default_value' => $rate_id ? $rate->display_include : 0,
);
$form['inclusion_text'] = array(
'#type' => 'textfield',
'#title' => t('Tax inclusion text'),
'#description' => t('This text will be displayed near the price to indicate that it includes tax.'),
'#default_value' => $rate_id ? $rate->inclusion_text : '',
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#suffix' => l(t('Cancel'), 'admin/store/settings/taxes'),
);
return $form;
}