<?php
include_once("inc/conn.php");
include_once("inc/function.php");
login_check();

if($_GET["act"]=="del"){
	$query=$db->query("Select * From {$web_dbtop}exchange where uid=".intval($_COOKIE["usersid"])." and id=".intval($_GET["id"])."");
	if($rs=$db->fetch_array($query)){
		if($rs["mode"]!=1){
			$points=$rs["points"];
			$db->query("update {$web_dbtop}commodities set convertnum=convertnum-1 where id=".$rs["commoditiesid"]."");
			$db->query("update {$web_dbtop}users set points=points+$points,djcs=djcs-1,djpoints=djpoints-$points where id=".$rs["uid"]."");
			$db->query("update {$web_dbtop}game_log set dj_doudou=dj_doudou-$points where uid=".$rs["uid"]);
			userslog(4,"取消奖品兑换",$points,0);
			$db->query("delete from {$web_dbtop}exchange where id=".intval($_GET["id"])."");
			echo "<script language=javascript>alert('已经取消奖品兑换！');location.href='userprizes.php';</script>";
			exit;
		}else{
			echo "<script language=javascript>alert('对不起，已经发货的奖品无法执行取消操作!');history.go(-1);</script>";
			exit;
		}
	}else{
		echo "<script language=javascript>alert('你是想被注销号吧？？？？？？？');history.go(-1);</script>";
		exit;
	}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>用户中心-<?=$web_name;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="<?=$web_keywords;?>" />
<meta name="description" content="<?=$web_description;?>" />
<META http-equiv=X-UA-Compatible content=IE=EmulateIE7>
<link href="style/default.css" rel="stylesheet" type="text/css" />
</head>
<?php include_once("top.php");?>
<script language="javascript">
qiehuan(7);
document.getElementById("qh_con7").getElementsByTagName('li')[6].className="current";
</script>
<DIV class="wrapper">
	<DIV class="page_content">
  		<!--主体右边 Start-->
    	<div class="area260 fl">
			<DIV class="news-title">
				<span><a href="news_lest.php">更多&raquo;</a></span>
				 <H3>站内公告</H3>
			</DIV>
			<ul class="area260-info news-list">
				<?
				$query=$db->query("Select * from {$web_dbtop}news Order by top desc,id desc limit 10");
				while($rs=$db->fetch_array($query)){
				?>
				<LI><A title="<?=$rs["title"]?>" href="news_content.php?id=<?=$rs["id"]?>"><?=$rs["title"]?></A></LI>
				<?
				}
				?>
			</ul>
			 <DIV class="area260-b h5px"></DIV>
			 <DIV class=blank10></DIV>
			 <DIV class="news-title">
				<span><a href="help_lest.php">更多&raquo;</a></span>
				 <H3>用户帮助</H3>
			</DIV>
			<ul class="area260-info news-list">
				<?
				$query=$db->query("Select * from {$web_dbtop}help Order by top desc,id desc limit 10");
				while($rs=$db->fetch_array($query)){
				?>
				<LI><A title="<?=$rs["title"]?>" href="help_content.php?id=<?=$rs["id"]?>"><?=$rs["title"]?></A></LI>
				<?
				}
				?>
			</ul>
			 <DIV class="area260-b h5px"></DIV>
			 <DIV class=blank10></DIV>
		</div>
		<!--主体左边 Start-->
		<div class="area690 fr">
			<DIV class="users-title">
				 <H3>我的兑奖</H3>
			</DIV>
        	<div class="users-content">
        		<ul class="bgk">
					<li class="b250c">奖品名称</li>
					<li class="b84c">兑奖数量</li>
					<li class="b180c">兑奖时间</li>
					<li class="b100c">状态</li>
					<li class="b100c">操作</li>
					<?php
					$intpage = 14;
					if (isset($_GET['page'])) {
						$rsnum = (intval($_GET['page']) -1)*$intpage;
					}
					else {
						$rsnum = 0;
					}
					$sql="Select * from {$web_dbtop}exchange where uid=".intval($_COOKIE["usersid"])." Order by id desc";
					$query=$db->query($sql);
					if($db->fetch_array($query)) 
						$intnum=$db->num_rows($query);
					$query=$db->query($sql." limit $rsnum,$intpage");
					while($rs=$db->fetch_array($query)){
						echo"<LI class=b250><A href=\"prizes_content.php?id=".$rs["commoditiesid"]."\">".showcontent("commodities","name",$rs["commoditiesid"])."</A></LI>";
						echo"<LI class=b84>".$rs["num"]."</LI>";
						echo"<LI class=b180>".$rs["time"]."</LI>";
						echo"<LI class=b100>";
						if($rs["mode"]==1){
							echo"已发货";
						}else if($rs["mode"]==2){
							echo"待发货";
						}else{
							echo"待确认";
						}
						echo"</LI>";
						echo"<LI class=b100>".($rs["mode"]==0?"<A href=\"?act=del&id=".$rs["id"]."\" onClick=\"return confirm('确定要取消兑奖吗?');\">取消</a>":"")."</LI>";
					}
					include_once("inc/page_class.php");
					$page=new page(array('total'=>$intnum,'perpage'=>$intpage));
					echo "<li class=\"bb\">".$page->show(5,"","")."</li>";
					?>
				</ul>
			</div>
			<div class="area690-b h5px"></div>
        	<div class="blank10"></div>
		</div>
		<!--主体左边 End-->
	</DIV>
	<!--Flink End-->
	<div class="blank10"></div>
	<!--Footer Start-->
<?php include_once("footer.php");?>
<script language="JavaScript" src="inc/Calendar.js"></script>
</DIV>