<?
session_start();
if (file_exists("../includes/merchant/common.php"))
{
	include("../includes/merchant/common.php");
}
else
{
	include("../includes/common.php");
}


if ((isset($_GET['IS_MERCHANT']) && 1 == $_GET['IS_MERCHANT'])
	||
	(isset($_POST['IS_MERCHANT']) && 1 == $_POST['IS_MERCHANT']))
{
	if (file_exists("../includes/merchant/merchant_user_class.php")) //merchant module installed
	{
		require("../includes/merchant/merchant_user_class.php");
		$order_id = isset($_GET['LMI_PAYMENT_NO'])?$_GET['LMI_PAYMENT_NO']:$_POST['LMI_PAYMENT_NO'];
		
		$db->query("SELECT * FROM merchant_orders WHERE id=".intval($order_id));
		$res = $db->getRow();
		$merchant_user = new MerchantUser($db);
		if ($merchant_user->loadFromDb($res->merchant_id))
		{
			$merchant_user->failure($order_id);
		}
	}
}

$error = trim($_GET['error']=="")?trim($_POST['error']):trim($_GET['error']);

$smarty->assign("title", $SETTINGS['site_name']);
$smarty->assign("info", "Добро пожаловать в универсальную обменную систему!");
$smarty->assign("ex_currencies", $ex_currencies);
$smarty->assign("main_class", "main");
$smarty->assign("money_cources", get_currency_cources());
$smarty->assign("metal_cources", get_metal_cources());
$smarty->assign("error", $error);
$smarty->display("smartex_fail.tpl");
?>