You are here

function uc_taxes_admin_settings in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_taxes/uc_taxes.module \uc_taxes_admin_settings()
  2. 7.3 uc_taxes/uc_taxes.admin.inc \uc_taxes_admin_settings()

Displays a list of tax rates.

1 string reference to 'uc_taxes_admin_settings'
uc_taxes_menu in uc_taxes/uc_taxes.module
Implements hook_menu().

File

uc_taxes/uc_taxes.admin.inc, line 11
Taxes administration menu items.

Code

function uc_taxes_admin_settings() {
  $rows = array();
  $header = array(
    t('Name'),
    t('Rate'),
    t('Taxed products'),
    t('Taxed product types'),
    t('Taxed line items'),
    t('Weight'),
    'data' => t('Operations'),
  );

  // Loop through all the defined tax rates.
  foreach (uc_taxes_rate_load() as $rate_id => $rate) {

    // Build the operations links for the tax rate.
    $ops = array(
      l(t('edit'), 'admin/store/settings/taxes/' . $rate_id . '/edit'),
      l(t('conditions'), CA_UI_PATH . '/uc_taxes_' . $rate_id . '/edit/conditions'),
      l(t('clone'), 'admin/store/settings/taxes/' . $rate_id . '/clone'),
      l(t('delete'), 'admin/store/settings/taxes/' . $rate_id . '/delete'),
    );

    // Add the row to the table.
    $rows[] = array(
      check_plain($rate->name),
      $rate->rate * 100 . '%',
      $rate->shippable ? t('Shippable products') : t('Any product'),
      implode(', ', $rate->taxed_product_types),
      implode(', ', $rate->taxed_line_items),
      $rate->weight,
      implode(' | ', $ops),
    );
  }

  // Let the user know if no tax rates are defined.
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('No rates available.'),
        'colspan' => 7,
      ),
    );
  }

  // Build the output including the table and a link to add a new rate.
  $output = theme('table', $header, $rows) . l(t('Add a tax rate'), 'admin/store/settings/taxes/add');
  return $output;
}