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

$shop = & singleton('shop');

if (isset($_REQUEST['edit_city']))
{
	$param['id'] = to_str($_REQUEST['edit_city']);
}

$param['name'] = to_str($_REQUEST['city_name']);

$param['location_id'] = to_str($_REQUEST['shop_location_id']);

$param['shop_city_order'] = to_int($_REQUEST['shop_city_order']);

if ($city = $shop->InsertCity($param))
{
	$admin_forms = new admin_forms();
	$window_id = $admin_forms->GetWindowId();
	?><script type="text/javascript">
	$.appendInput('<?php echo $window_id?>', 'EditAddCity', 'edit_city', '<?php echo $city?>');
	</script><?php

	if (isset($_REQUEST['edit_city']))
	{
		show_message($GLOBALS['MSG_shops']['success_update_city']);
	}
	else
	{
		show_message($GLOBALS['MSG_shops']['success_add_city']);
	}
}
else
{
	if (isset($_REQUEST['edit_city']))
	{
		show_error_message($GLOBALS['MSG_shops']['list_of_properties_edit_error']);
	}
	else
	{
		show_error_message($GLOBALS['MSG_shops']['error_add_city']);
	}
}
?>