You are here

function uc_taxes_form_submit in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_taxes/uc_taxes.admin.inc \uc_taxes_form_submit()
  2. 7.3 uc_taxes/uc_taxes.admin.inc \uc_taxes_form_submit()

Submit handler for uc_taxes_form().

File

uc_taxes/uc_taxes.module, line 260

Code

function uc_taxes_form_submit($form_id, $form_values) {
  if ($form_values['op'] == t('Submit')) {
    if (strpos($form_values['rate'], '%')) {
      $rate = floatval($form_values['rate']) / 100;
    }
    else {
      $rate = floatval($form_values['rate']);
    }
    if ($form_values['id'] != '') {
      db_query("UPDATE {uc_taxes} SET name = '%s', rate = %f, taxed_product_types = '%s', taxed_line_items = '%s', weight = %d, shippable = %d WHERE id = %d", $form_values['name'], $rate, serialize(array_filter($form_values['taxed_product_types'])), serialize(array_filter($form_values['taxed_line_items'])), $form_values['weight'], $form_values['shippable'], $form_values['id']);
    }
    else {
      db_query("INSERT INTO {uc_taxes} (id, name, rate, taxed_product_types, taxed_line_items, weight, shippable) VALUES (%d, '%s', %f, '%s', '%s', %d, %d)", db_next_id('{uc_taxes}_id'), $form_values['name'], $rate, serialize(array_filter($form_values['taxed_product_types'])), serialize(array_filter($form_values['taxed_line_items'])), $form_values['weight'], $form_values['shippable']);
    }
    drupal_set_message(t('%name settings have been saved.', array(
      '%name' => $form_values['name'],
    )));
  }
  return 'admin/store/settings/taxes';
}