<?php 
/**
 * Система управления сайтом HostCMS v. 5.xx
 * Copyright © 2005-2010 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru
 *
 * Обработчик добавления/редактирования области.
 * 
 * Файл: /admin/shop/action/add_location.php
 * 
 * @author Hostmake LLC
 * @version 5.x
 */
$param = array();
$shop = & singleton('shop');
if (isset($_REQUEST['edit_location']))
{
	$param['id'] = to_int($_REQUEST['edit_location']);
}

$param['name'] = to_str($_REQUEST['location_name']);
$param['shop_country_id']=to_int($_REQUEST['shop_country_id']);
$param['shop_location_order'] = to_int($_REQUEST['shop_location_order']);

if ($location = $shop->InsertLocation($param))
{
	$admin_forms = new admin_forms();
	$window_id = $admin_forms->GetWindowId();
	?><script type="text/javascript">
	$.appendInput('<?php echo $window_id?>', 'EditAddLocation', 'edit_location', '<?php echo $location?>');
	</script><?php

	if (isset($_REQUEST['edit_location'])) 
	{
		show_message($GLOBALS['MSG_shops']['success_edit_location']);
	}
	else 
	{
		show_message($GLOBALS['MSG_shops']['success_add_location']);
	}
}
else 
{
	if (isset($_REQUEST['edit_location'])) 
	{
		show_error_message($GLOBALS['MSG_shops']['error_edit_location']);
	}
	else 
	{
		show_error_message($GLOBALS['MSG_shops']['error_add_location']);
	}
}
?>