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

$shop = & singleton('shop');
$kernel = & singleton('kernel');

$param_item = array ();
$param_group = array();

$target_group_id = to_int($_POST['shop_group_id']);

$shop_id = to_int($_POST['shop_shops_id']);

$flag_move_items = false;
$flag_move_groups = false;

foreach($_REQUEST as $key => $value)
{		
	if (ereg("^move_group_([0-9]*)$", $key, $regs))
	{			
		$param_group['shop_shops_id'] = $shop_id;
		$param_group['group_id'] = $regs[1]; 
		$param_group['shop_groups_parent_id'] = $target_group_id; 
		$shop->InsertGroup($param_group);
		
		$flag_move_groups = true;
	}
	
	if (ereg("^move_item_([0-9]*)$", $key, $regs))
	{	
		//$param_group['shop_shops_id'] = $shop_id;	
		$param_item['item_id'] = $regs[1]; 
		$param_item['groups_id'] = $target_group_id;				
		$shop->InsertItem($param_item);
		
		$flag_move_items = true;
	}
}

if ($flag_move_groups)
{
	show_message($GLOBALS['MSG_shops']['move_shop_groups_success']);
}

if ($flag_move_items)
{
	show_message($GLOBALS['MSG_shops']['move_shop_items_success']);
}

?>