<?php 
/**
 * Система управления сайтом HostCMS v. 5.xx
 * Copyright © 2005-2010 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru
 *
 * Обработчик добавления/редактирования налога.
 * 
 * Файл: /admin/shop/action/add_tax.php
 * 
 * @author Hostmake LLC
 * @version 5.x
 */
$param = array();

$shop = & singleton('shop');

if (isset($_REQUEST['edit_tax']))
{
	$param['shop_tax_id'] = to_int($_REQUEST['edit_tax']);
}

$param['shop_tax_name'] = to_str($_REQUEST['tax_name']);

$param['shop_tax_rate'] = to_float($_REQUEST['tax_rate']);

if (isset($_REQUEST['tax_is_in_price']))
{
	$param['shop_tax_is_in_price'] = 1;
}
else 
{
	$param['shop_tax_is_in_price'] = 0;
}

$param['shop_tax_cml_id'] = to_str($_REQUEST['tax_cml_id']);

if ($tax = $shop->InsertTax($param))
{
	$admin_forms = new admin_forms();
	$window_id = $admin_forms->GetWindowId();
	?><script type="text/javascript">
	$.appendInput('<?php echo $window_id?>', 'EditAddTax', 'edit_tax', '<?php echo $tax?>');
	</script><?php

	if (isset($_REQUEST['edit_tax']))
	{
		show_message($GLOBALS['MSG_shops']['success_update_tax']);
	}
	else 
	{
		show_message($GLOBALS['MSG_shops']['success_add_tax']);
	}
}
else 
{
	if (isset($_REQUEST['edit_tax']))
	{
		show_error_message($GLOBALS['MSG_shops']['error_update_tax']);
	}
	else 
	{
		show_error_message($GLOBALS['MSG_shops']['error_add_tax']);
	}
}
?>