<?
define("ADMIN_AUTHORIZATION",1);
include("../../../includes/common.php");


$id = $_GET['id']==""?$_POST['id']:$_GET['id'];
$action = $_GET['action']==""?$_POST['action']:$_GET['action'];
$page = $_GET['page']==""?$_POST['page']:$_GET['page'];
$sort_by = $_GET['sort_by']==""?$_POST['sort_by']:$_GET['sort_by'];
$sort_ord = $_GET['sort_ord']==""?$_POST['sort_ord']:$_GET['sort_ord'];
$sort = "page=$page&sort_by=$sort_by&sort_ord=$sort_ord";

if (!is_numeric($id)){
	$_SESSION['ERROR_MSG'] = "Ошибка при передаче данных!";
	header("Location: $SITE_URL/$ADMIN_DIR/orders/index.php?l_pager");
	exit;
}
else{
	/* tranfering money */
	$row = @mysql_fetch_object(@mysql_query("select * from orders where id=$id and status=1 and to_status=1 and from_status=0"));

	if($row->id!=""){
		if(CompleteExchange($row->id)){
			$_SESSION['STATUS_MSG'] = "Деньги успешно переведены!";
			header("Location: $SITE_URL/$ADMIN_DIR/orders/index.php?l_pager");
			exit;
		}
		else{	
			$_SESSION['ERROR_MSG'] = "Ошибка переводе!<br><small>".$_SESSION["EGOLD_ERROR"]."</small>";
			header("Location: $SITE_URL/$ADMIN_DIR/orders/index.php?l_pager");
			exit;
		}
	}
}
exit;
?>