<?php 
/**
 * Система управления сайтом HostCMS v. 5.xx
 * Copyright © 2005-2010 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru
 *
 * Ajax загрузчик формы списка сопутствующих товаров.
 * 
 * Файл: /admin/shop/action/load_tying_products.php
 * 
 * @author Hostmake LLC
 * @version 5.x
 */
function LoadAjaxData(&$admin_forms)
{
	$on_page = $admin_forms->GetOnPageCount();

	$page = to_int($_REQUEST['limit']);
	$begin = ($page == 0) ? 0 : ($page - 1) * $on_page;

	$param = array();

	$param['limit']['all'] = array('begin' => $begin, 'count' => $on_page);

	$DataBase = & singleton('DataBase');

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

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

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

	$shop = & singleton('shop');

	// Получаем имя товара
	$res = $shop->GetItem($shop_items_catalog_item_id);

	$row = $shop->GetShop($shop_shops_id);

	// Строим хлебные крошки.
	$path_array = $shop->GetShopPathArray($shop_groups_parent_id, false);

	// Преобразуем идентификаторы групп в ссылки на группы.
	$param['path_array'] = array();
	$param['path_array'][0]['name'] = $GLOBALS['MSG_shops']['header_admin__list_forms'];
	$param['path_array'][0]['link'] = $admin_forms->GetHtmlCallDoLoadAjax('/admin/shop/shop.php', '', 54, 'load_data');
	$param['path_array'][0]['onclick'] = $admin_forms->GetOnClickCallDoLoadAjax('/admin/shop/shop.php', '', 54, 'load_data');

	$param['path_array'][1]['name'] = $row['shop_shops_name'];
	$param['path_array'][1]['link'] = $admin_forms->GetHtmlCallDoLoadAjax('/admin/shop/shop.php', "&shop_groups_parent_id=0&shop_shops_id=$shop_shops_id", 65, 'load_data');
	$param['path_array'][1]['onclick'] = $admin_forms->GetOnClickCallDoLoadAjax('/admin/shop/shop.php', "&shop_groups_parent_id=0&shop_shops_id=$shop_shops_id", 65, 'load_data');

	if ($path_array)
	{
		foreach ($path_array as $key => $value)
		{
			$param['path_array'][] = array (
			'link' => $admin_forms->GetHtmlCallDoLoadAjax('/admin/shop/shop.php', "&shop_groups_parent_id=$key&shop_shops_id=$shop_shops_id", 65, 'load_data'),
			'onclick' => $admin_forms->GetOnClickCallDoLoadAjax('/admin/shop/shop.php', "&shop_groups_parent_id=$key&shop_shops_id=$shop_shops_id", 65, 'load_data'),
			'name' => $value);
		}
	}

	// Если мы пришли сюда из формы списка модификаций
	if (isset($_REQUEST['shop_items_catalog_modification_id']))
	{
		$shop_items_catalog_modification_id = to_int($_REQUEST['shop_items_catalog_modification_id']);
		// Получаем имя товара от которого пришли
		$row = $shop->GetItem($shop_items_catalog_modification_id);

		$param['path_array'][] = array("name" => sprintf($GLOBALS['MSG_shops']['item_modification_title'], $row['shop_items_catalog_name']),
		"link" => $admin_forms->GetHtmlCallDoLoadAjax('/admin/shop/shop.php', "&shop_shops_id=$shop_shops_id&shop_groups_parent_id=$shop_groups_parent_id&shop_items_catalog_modification_id=$shop_items_catalog_modification_id", 81, 'load_data'),
		"onclick" => $admin_forms->GetOnClickCallDoLoadAjax('/admin/shop/shop.php', "&shop_shops_id=$shop_shops_id&shop_groups_parent_id=$shop_groups_parent_id&shop_items_catalog_modification_id=$shop_items_catalog_modification_id", 81, 'load_data')
		);
	}

	$param['path_array'][] = array("name" => sprintf($GLOBALS['MSG_shops']['show_tying_products_title'], $res['shop_items_catalog_name']),
	"link" => $admin_forms->GetHtmlCallDoLoadAjax('/admin/shop/shop.php', "&shop_shops_id=$shop_shops_id&shop_groups_parent_id=$shop_groups_parent_id&shop_items_catalog_item_id=$shop_items_catalog_item_id&some_new_id=0", 79, 'load_data'),
	"onclick" => $admin_forms->GetOnClickCallDoLoadAjax('/admin/shop/shop.php', "&shop_shops_id=$shop_shops_id&shop_groups_parent_id=$shop_groups_parent_id&shop_items_catalog_item_id=$shop_items_catalog_item_id&some_new_id=0", 79, 'load_data')
	);

	if(isset($_REQUEST['some_new_id']))
	{
		$some_new_id = intval($_REQUEST['some_new_id']);
	}
	else
	{
		$some_new_id = to_int($_REQUEST['shop_groups_parent_id']);
	}

	// Строим хлебные крошки внутри текущего уровня
	$path_array2 = $shop->GetShopPathArray($some_new_id, false);

	if ($some_new_id == 0)
	{
		$path_array2 = array();
	}

	if ($path_array2)
	{
		foreach ($path_array2 as $key => $value)
		{
			$param['path_array'][] = array (
			'link' => $admin_forms->GetHtmlCallDoLoadAjax('/admin/shop/shop.php', "&shop_groups_parent_id=$shop_groups_parent_id&shop_shops_id=$shop_shops_id&shop_id=$shop_shops_id&shop_group_id=$some_new_id&shop_items_catalog_item_id=$shop_items_catalog_item_id&some_new_id=$key", 79, 'load_data'),
			'onclick' => $admin_forms->GetOnClickCallDoLoadAjax('/admin/shop/shop.php', "&shop_groups_parent_id=$shop_groups_parent_id&shop_shops_id=$shop_shops_id&shop_id=$shop_shops_id&shop_group_id=$some_new_id&shop_items_catalog_item_id=$shop_items_catalog_item_id&some_new_id=$key", 79, 'load_data'),
			'name' => $value);
		}
	}
	
	// Отображаем каталоги только на первой странице.
	/*if ($page == 0 || $page == 1)
	{*/
	// Запрос для выборки каталогов магазина
	$param['data'][] = "SELECT *, shop_groups_id AS keyfield,
	shop_groups_name AS name,
	shop_groups_indexation AS indexing, 
	shop_groups_activity AS activity,
	shop_groups_parent_id AS current_group,
	shop_groups_order AS orderr
	FROM `shop_groups_table`
	WHERE `shop_groups_parent_id` = '$some_new_id'
	AND `shop_shops_id` = '$shop_shops_id'
	{FILTER_STRING} {ORDER_STRING} {LIMIT}";
	/*}
	else
	{
		$param['data'][] = array();
	}*/

	// Запрос на количество элементов
	$count_groups = "SELECT count(*) AS count
	FROM `shop_groups_table`
	WHERE `shop_groups_parent_id` = '$some_new_id'
	AND `shop_shops_id` = '$shop_shops_id'
	{FILTER_STRING}";
	
	$param['data'][] = "SELECT * ,
	shop_items_catalog_table.shop_items_catalog_item_id AS keyfield,
	IF( shop_intermediate_table.shop_items_catalog_item_id =$shop_items_catalog_item_id, 1, 0 ) AS action_type,
	shop_items_catalog_table.shop_items_catalog_name AS name,
	shop_items_catalog_table.shop_items_catalog_shortcut_id as view,
	shop_intermediate_count AS item_count,
	shop_items_catalog_marking AS articul,
	shop_items_catalog_weight AS ves, 
	shop_items_catalog_order AS orderr, shop_items_catalog_price AS price,
	shop_items_catalog_yandex_market_bid AS price_ym_bid,
	shop_items_catalog_yandex_market_allow AS ym_allow,
	shop_items_catalog_is_active AS activity,
	shop_items_catalog_indexation AS indexing,
	shop_items_catalog_table.shop_items_catalog_item_id AS addons,
	shop_items_catalog_date_time AS data,
	shop_groups_id AS current_group,	
	shop_items_catalog_type
	
	FROM shop_items_catalog_table
	LEFT JOIN shop_intermediate_table ON shop_items_catalog_table.shop_items_catalog_item_id = shop_intermediate_table.sho_shop_items_catalog_item_id
	AND shop_intermediate_table.shop_items_catalog_item_id =$shop_items_catalog_item_id
	WHERE shop_items_catalog_table.shop_items_catalog_item_id !=$shop_items_catalog_item_id
	AND `shop_groups_id` = '$some_new_id' 
	AND `shop_shops_id` = '$shop_shops_id' 
	AND shop_items_catalog_table.shop_items_catalog_modification_id = 0
	{FILTER_STRING} {ORDER_STRING} {LIMIT}";

	// Запрос на количество элементов
	$count = "SELECT count(*) AS count
	FROM shop_items_catalog_table LEFT JOIN shop_intermediate_table ON shop_items_catalog_table.shop_items_catalog_item_id = shop_intermediate_table.sho_shop_items_catalog_item_id
	AND shop_intermediate_table.shop_items_catalog_item_id =$shop_items_catalog_item_id
	WHERE shop_items_catalog_table.shop_items_catalog_item_id !=$shop_items_catalog_item_id
	AND `shop_groups_id` = '$some_new_id'
	AND `shop_shops_id` = '$shop_shops_id'
	AND shop_items_catalog_table.shop_items_catalog_modification_id = 0
	{FILTER_STRING}";

	// Переопределеяем некоторые параметры формы
	// В поле с картинкой отображаем значек папки.
	$param['field_params'][0]['view']['admin_forms_field_image'] = "=/admin/images/folder.gif";
	
	// Определяем ссылки для групп товаров
	$param['field_params'][0]['name']['admin_forms_field_type'] = 4; // Ссылка.
	$param['field_params'][0]['name']['admin_forms_field_link'] = $admin_forms->GetHtmlCallDoLoadAjax('/admin/shop/shop.php', "&shop_shops_id=$shop_shops_id&shop_groups_parent_id=$shop_groups_parent_id&some_new_id={keyfield}&shop_items_catalog_item_id=$shop_items_catalog_item_id", 79, 'load_data');
	$param['field_params'][0]['name']['admin_forms_field_onclick'] = $admin_forms->GetOnClickCallDoLoadAjax('/admin/shop/shop.php', "&shop_shops_id=$shop_shops_id&shop_groups_parent_id=$shop_groups_parent_id=&some_new_id={keyfield}&shop_items_catalog_item_id=$shop_items_catalog_item_id", 79, 'load_data');

	// Определяем ссылку для изменения статуса сопутствующего товара
	$param['field_params'][1]['action_type']['admin_forms_field_link'] = $admin_forms->GetHtmlCallTrigerSingleAction('active', 'check_1_{keyfield}', 79, 0, 0);
	$param['field_params'][1]['action_type']['admin_forms_field_onclick'] = $admin_forms->GetOnClickCallTrigerSingleAction('active', 'check_1_{keyfield}', 79, 0, 0);

	// Затираем изображения для групп товаров
	$param['field_params'][0]['action_type']['admin_forms_field_type'] = 0;

$param['field_params'][0]['name']['admin_forms_field_type'] = 10;// вычисляемое поле
	$param['field_params'][0]['name']['callback_function'] = 'callback_function_group_name';

	// Функция обратного вызова для названия группы
	function callback_function_group_name($field_value, $value, $row)
	{
		$admin_forms = & singleton('admin_forms');

		$shop = & singleton('shop');
		
		$link = $field_value['admin_forms_field_link'];
		$onclick = to_str($field_value['admin_forms_field_onclick']);

		$link = $admin_forms->DoReplaces(false, $row, $link);
		$onclick = $admin_forms->DoReplaces(false, $row, $onclick);

		if ($row['activity'] == 0)
		{
			$prefix = '<div style="text-decoration: line-through">';
			$suffix = '</div>';
		}
		else
		{
			$prefix = '';
			$suffix = '';
		}
		
		?><?php echo $prefix?><a href="<?php echo $link?>" onclick="<?php echo $onclick?>"><?php echo $value?></a><?php echo $suffix?><?php
		
		// Группа активна - выводим ссылку на клиентский раздел
		if ($row['activity'] == 1)
		{
			// Получаем данные о магазине
			$shop_row = $shop->GetShop($row['shop_shops_id']);
			
			if ($shop_row)
			{
				$Structure = & singleton('Structure');
				
				$site = & singleton('site');
				$current_alias = $site->GetCurrentAlias($shop_row['site_id']);
				
				// Получаем путь к магазину
				$shop_path = $Structure->GetStructurePath($shop_row['structure_id'], 0);
		
				if ($shop_path != '/')
				{
					$shop_path = '/'.$shop_path;
				}
				?>&nbsp;<a href="<?php echo 'http://' . $current_alias . $shop_path . $shop->GetPathGroup($row['shop_groups_id'], '')?>" target="_blank"><img src="/admin/images/new_window.gif" class="img_line" /></a><?php
			}
		}
	}

	$param['field_params'][1]['name']['admin_forms_field_type'] = 10;// вычисляемое поле
	$param['field_params'][1]['name']['callback_function'] = 'callback_function_item_name';

	// Функция обратного вызова для названия товара
	function callback_function_item_name($field_value, $value, $row)
	{
		$shop = & singleton('shop');
		
		// Элемент является ярлыком
		if ($row['shop_items_catalog_shortcut_id'] != 0)
		{
			//Получаем информацию о информационном элементе, на который ссылается ярлык
			$item_row = $shop->GetItem($row['shop_items_catalog_shortcut_id'], array('cache_off' => true));
			$row['name'] = $item_row['shop_items_catalog_name'];
			$row['shop_items_catalog_putend_date'] = $item_row['shop_items_catalog_putend_date'];
			$row['activity'] = $item_row['shop_items_catalog_is_active'];
		}

		if ($row['shop_items_catalog_putend_date'] != "0000-00-00 00:00:00"
		&& $row['shop_items_catalog_putend_date'] < date("Y-m-d H:i:s")
		|| $row['activity'] == 0)
		{
			?><div style="text-decoration: line-through"><?php echo $row['name']?></div><?php
		}
		else
		{
			// Получаем данные о магазине
			$shop_row = $shop->GetShop($row['shop_shops_id']);
			
			if ($shop_row)
			{
				$Structure = & singleton('Structure');
				
				$site = & singleton('site');
				$current_alias = $site->GetCurrentAlias($shop_row['site_id']);
				
				// Получаем путь к магазину
				$shop_path = $Structure->GetStructurePath($shop_row['structure_id'], 0);
		
				if ($shop_path != '/')
				{
					$shop_path = '/'.$shop_path;
				}
			
				echo $row['name'];
				?>&nbsp;<a href="<?php echo 'http://' . $current_alias . $shop_path . $shop->GetPathItem($row['shop_items_catalog_item_id']).rawurlencode($row['shop_items_catalog_path']).'/'?>" target="_blank"><img src="/admin/images/new_window.gif" class="img_line" /></a><?php
			}
		}
	}
	
	// Формируем массив меню.
	$menu_array = array();

	$param['total_count'][] = $count_groups;
	$param['total_count'][] = $count;
	
	$param['current_page'] = $page;
	$param['on_page'] = $on_page;
	$param['menus'] = $menu_array;
	$param['title'] = sprintf($GLOBALS['MSG_shops']['show_tying_products_title'], $res['shop_items_catalog_name']);

	return $param;
}

/**
 * Необязательная функция для определения реального имени столбца по псевдониму.
 *
 * @param string $field_name
 * @param integer $dataset_id
 */
function ResolveFieldName(&$field_name, $dataset_id)
{
	switch ($dataset_id)
	{
		case 0: // Список каталогов документов.
		{
			switch ($field_name)
			{
				case 'keyfield':
					{
						$field_name = 'shop_groups_id';
						break;
					}
				case 'name':
					{
						$field_name = 'shop_groups_name';
						break;
					}
				case 'item_count':
					{
						$field_name = '';
						break;
					}
			}
		}
		case 1: // Список документов.
		{
			switch ($field_name)
			{
				case 'keyfield':
					{
						$field_name = 'shop_items_catalog_table.shop_items_catalog_item_id';
						break;
					}
				case 'name':
					{
						$field_name = 'shop_items_catalog_name';
						break;
					}
				case 'item_count':
					{
						$field_name = 'shop_intermediate_count';
						break;
					}
			}
		}
	}
	return true;
}

/**
 * Изменение статуса активности сопутствующего товара
 *
 * @param array $param
 */
function active(&$param)
{
	ob_start();
	if (defined('READ_ONLY') && READ_ONLY)
	{
		$kernel = & singleton('kernel');
		$kernel->ReadMode();
	}
	else
	{
		$DataBase = & singleton('DataBase');

		$shop = & singleton('shop');
		
		$kernel = & singleton('kernel');
		$current_user = $kernel->GetCurrentUser();

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

		if (isset($param['data']))
		{
			if (isset($param['data'][1]))
			{
				foreach ($param['data'][1] as $key => $value)
				{
					$key = to_int($key);

					$query = "SELECT * FROM `shop_intermediate_table`
					WHERE `shop_items_catalog_item_id`='$shop_items_catalog_item_id' 
					AND `sho_shop_items_catalog_item_id`='$key'";

					$result = $DataBase->query($query);

					$result_row = mysql_fetch_assoc($result);

					if(mysql_num_rows($result) > 0)
					{
						// Определяем режим доступа пользователя и принадлежит ли объект пользователю
						$user_access = new user_access();

						if ($result_row)
						{
							$object_user_id = $result_row['users_id'];
						}
						else
						{
							$object_user_id = 0;
						}

						if ($user_access->IssetUserAccessForObject($object_user_id))
						{
							// Удаляем запись
							$query = "DELETE FROM `shop_intermediate_table`
							WHERE `shop_items_catalog_item_id`='$shop_items_catalog_item_id'
							AND `sho_shop_items_catalog_item_id`='$key'";
						}
						else
						{
							$user_access->MessageOnlyOwn();
						}
					}
					else
					{
						if (isset($value['item_count']) && $value['item_count'] > 0)
						{
							$value['item_count'] = to_int($value['item_count']);
						}
						else
						{
							$value['item_count'] = 0;
						}
						
						$shop->InsertTyingProducts(array(
							'shop_items_catalog_item_id' => $shop_items_catalog_item_id,
							'sho_shop_items_catalog_item_id' => $key,
							'shop_intermediate_count' => $value['item_count']));
					}

					$DataBase->query($query);
				}
			}
		}
	}
	$error = ob_get_clean();

	$param['error'] = $error;
}

function all_on(&$param)
{
	ob_start();
	if (defined('READ_ONLY') && READ_ONLY)
	{
		$kernel = & singleton('kernel');
		$kernel->ReadMode();
	}
	else
	{
		$DataBase = & singleton('DataBase');

		$shop = & singleton('shop');

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

		if (isset($param['data']))
		{
			if (isset($param['data'][1]))
			{
				foreach ($param['data'][1] as $key => $value)
				{
					$query = "SELECT * FROM `shop_intermediate_table`
					WHERE `shop_items_catalog_item_id`='$shop_items_catalog_item_id' 
					AND `sho_shop_items_catalog_item_id`='$key'";

					$result = $DataBase->query($query);

					$result_row = mysql_fetch_assoc($result);

					// Определяем режим доступа пользователя и принадлежит ли объект пользователю
					$user_access = new user_access();

					// Определяем информацию об объекте
					$object_row = $shop->GetItem($key);

					if ($result_row)
					{
						$object_user_id = $result_row['users_id'];
					}
					else
					{
						$object_user_id = 0;
					}

					if ($user_access->IssetUserAccessForObject($object_user_id))
					{
						$key = to_int($key);

						if (isset($value['item_count']) && $value['item_count'] > 0)
						{
							$value['item_count'] = to_int($value['item_count']);
						}
						else
						{
							$value['item_count'] = 0;
						}
						
						$query = "SELECT * FROM `shop_intermediate_table`
						WHERE `shop_items_catalog_item_id`='$shop_items_catalog_item_id' 
						AND `sho_shop_items_catalog_item_id`='$key'";

						if(mysql_num_rows($DataBase->query($query)) == 0)
						{
							$shop->InsertTyingProducts(array(
							'shop_items_catalog_item_id' => $shop_items_catalog_item_id,
							'sho_shop_items_catalog_item_id' => $key,
							'shop_intermediate_count' => $value['item_count']));
						}
						else
						{
							$DataBase->query("UPDATE `shop_intermediate_table`
							SET `shop_intermediate_count`='{$value['item_count']}'
							WHERE `shop_items_catalog_item_id`='$shop_items_catalog_item_id'
							AND `sho_shop_items_catalog_item_id`='$key'");
						}
					}
					else
					{
						$user_access->MessageOnlyOwn();
					}
				}
			}
		}
	}
	$error = ob_get_clean();

	$param['error'] = $error;
}

function all_off(&$param)
{
	ob_start();
	if (defined('READ_ONLY') && READ_ONLY)
	{
		$kernel = & singleton('kernel');

		$kernel->ReadMode();
	}
	else
	{
		$DataBase = & singleton('DataBase');

		$shop = new shop();

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

		if (isset($param['data']))
		{
			if (isset($param['data'][1]))
			{
				foreach ($param['data'][1] as $key => $value)
				{
					$query = "SELECT * FROM `shop_intermediate_table`
					WHERE `shop_items_catalog_item_id`='$shop_items_catalog_item_id' 
					AND `sho_shop_items_catalog_item_id`='$key'";

					$result = $DataBase->query($query);

					$result_row = mysql_fetch_assoc($result);

					// Определяем режим доступа пользователя и принадлежит ли объект пользователю
					$user_access = new user_access();

					$shop = & singleton('shop');

					// Определяем информацию об объекте
					$object_row = $shop->GetItem($key);

					if ($result_row)
					{
						$object_user_id = $result_row['users_id'];
					}
					else
					{
						$object_user_id = 0;
					}

					if ($user_access->IssetUserAccessForObject($object_user_id))
					{
						$key = to_int($key);

						$query = "SELECT * FROM `shop_intermediate_table`
					WHERE `shop_items_catalog_item_id`='$shop_items_catalog_item_id' 
					AND `sho_shop_items_catalog_item_id`='$key'";

						if(mysql_num_rows($DataBase->query($query)) > 0)
						{
							// Удаляем запись
							$query = "DELETE FROM `shop_intermediate_table` WHERE `shop_items_catalog_item_id`='$shop_items_catalog_item_id'
					AND `sho_shop_items_catalog_item_id`='$key'";

							$DataBase->query($query);
						}
					}
					else
					{
						$user_access->MessageOnlyOwn();
					}
				}
			}
		}
	}
	$error = ob_get_clean();

	$param['error'] = $error;
}


/**
 * Применить изменения
 *
 * @param array $param
 */
function apply(&$param)
{
	ob_start();
	
	if (defined('READ_ONLY') && READ_ONLY)
	{
		$kernel = & singleton('kernel');

		$kernel->ReadMode();
	}
	else
	{
		$shop_groups_parent_id = to_int($_REQUEST['shop_groups_parent_id']);
		$shop_shops_id = to_int($_REQUEST['shop_shops_id']);

		$shop = & singleton('shop');
		$DataBase = & singleton('DataBase');
		
		$shop_items_catalog_item_id = to_int($_REQUEST['shop_items_catalog_item_id']);

		if (isset($param['data']) && isset($param['data'][1]))
		{
			foreach($param['data'][1] AS $key => $value)
			{
				$key = to_int($key);
				$value['item_count'] = to_int($value['item_count']);
				
				$DataBase->select("SELECT * FROM `shop_intermediate_table`
				WHERE `shop_items_catalog_item_id`='$shop_items_catalog_item_id'
				AND `sho_shop_items_catalog_item_id`='$key'");
				
				if ($DataBase->get_count_row() == 0)
				{
					$shop->InsertTyingProducts(array(
					'shop_items_catalog_item_id' => $shop_items_catalog_item_id,
					'sho_shop_items_catalog_item_id' => $key,
					'shop_intermediate_count' => $value['item_count']));
				}
				else
				{
					$DataBase->query("UPDATE `shop_intermediate_table`
					SET `shop_intermediate_count`='{$value['item_count']}'
					WHERE `shop_items_catalog_item_id`='$shop_items_catalog_item_id'
					AND `sho_shop_items_catalog_item_id`='$key'");
				}
			}
		}
	}

	$error = ob_get_clean();
	$param['error'] = $error;
}

?>