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

$shop = & singleton('shop');

$date = new DateClass();

$shop_shops_id = to_int($_REQUEST['shop_shops_id']);

if (isset($_REQUEST['edit_list_of_properties']))
{
	$param['shop_properties_group_id'] = to_int($_REQUEST['edit_list_of_properties']);
}

/* Формируем массив с параметрами для дополнительного свойства товара */
$param['shop_properties_group_name'] = to_str($_REQUEST['list_of_properties_name']);
$param['shop_properties_group_xml_name'] = to_str($_REQUEST['list_of_properties_xml_name']);
$param['shop_properties_group_order'] = to_str($_REQUEST['list_of_properties_order']);
$param['shop_properties_group_type'] = to_int($_REQUEST['list_of_properties_type']);
$param['shop_properties_groups_dir_id'] = to_int($_REQUEST['shop_properties_groups_dir_id']);

// checkbox
if ($param['shop_properties_group_type'] == 7)
{
	$param['shop_properties_group_default_value'] = isset($_REQUEST['checkbox']) ? 1 : 0;
}
// тип данных - дата
elseif ($param['shop_properties_group_type'] == 5)
{
	$param['shop_properties_group_default_value'] = $date->date_format_sql($_REQUEST['date_without_time']);
}
// тип данных - датавремя
elseif ($param['shop_properties_group_type'] == 6)
{
	$param['shop_properties_group_default_value'] = $date->datetime_format_sql($_REQUEST['date_with_time']);
}
else 
{
	$param['shop_properties_group_default_value'] = to_str($_REQUEST['list_of_properties_default_value']);
}

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

$param['shop_mesures_id'] = to_int($_REQUEST['list_of_properties_mesures']);

$param['shop_properties_group_default_big_width'] = to_int($_REQUEST['shop_properties_group_default_big_width']);
$param['shop_properties_group_default_big_height'] = to_int($_REQUEST['shop_properties_group_default_big_height']);
$param['shop_properties_group_default_small_width'] = to_int($_REQUEST['shop_properties_group_default_small_width']);
$param['shop_properties_group_default_small_height'] = to_int($_REQUEST['shop_properties_group_default_small_height']);
$param['shop_properties_group_cml'] = to_str($_REQUEST['shop_properties_group_cml']);


$param['lists_id'] = to_int($_REQUEST['list_of_properties_lists_id']);

/* Осуществляем вставку дополнительного свойства */
if ($prop = $shop->InsertPropretyOfGroup($param))
{
	$admin_forms = new admin_forms();
	$window_id = $admin_forms->GetWindowId();
	?><script type="text/javascript">
	$.appendInput('<?php echo $window_id?>', 'EditAddGroupProperty', 'edit_list_of_properties', '<?php echo $prop?>');
	</script><?php

	if (isset($_REQUEST['edit_list_of_properties']))
	{
		show_message($GLOBALS['MSG_shops']['success_edit_group_properties']);
	}
	else
	{
		show_message($GLOBALS['MSG_shops']['success_add_group_properties']);
	}
}
else
{
	if (isset($_REQUEST['edit_list_of_properties']))
	{
		show_error_message($GLOBALS['MSG_shops']['error_edit_group_properties']);
	}
	else
	{
		show_error_message($GLOBALS['MSG_shops']['error_add_group_properties']);
	}
}

?>