<?
require("../login_session.php");

mysql_connect("140.117.74.200", "db_09", "db_09") or die("<a href='index.php'>無法連結主機</a>");
mysql_select_db("db_09") or die("<a href='index.php'>無法連結資料庫</a>");
@mysql_query("SET CHARACTER SET UTF8");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>BTFM - 確認付款</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<link rel="stylesheet" href="../style/btfm_beta.css" type="text/css" />
</head>

<body>

<div id="roll">
	<div id="header">
		<h1><a href="../index.php">BTFM&nbsp;</a></h1>
		<div class="desc">線上遊戲金幣購買系統</div>
		
		<ul class="topmenu">
		<li><a href="../index.php">首頁</a></li>
		<li><a href="../readme.php">使用說明</a></li>
		<li><a href="../order.php">線上購幣</a></li>
		<li><a href="../register/time.php">會員註冊</a></li>
		<? if(!$_SESSION['login']){	?>
		<li><a href="../login/test5.php">會員登入</a></li>
		<? }else{	?>
		<li><a href="../login/logout.php">會員登出</a></li>
		<? }	?>
		<li class="alt"><a href="../check/data.php">確認付款</a></li>
		<li class="admin"><a href="../vAdmin/index.php">有刺勿近</a></li>
		</ul>
		
	</div>
	<div id="chest">
		
		<div class="leftmenu">
			<ul>
			<li><a href="../order.php?gameId=1">添糖二</a></li>
			<li><a href="../order.php?gameId=2">瘋豬谷</a></li>
			<li><a href="../order.php?gameId=3">卡芭樂島</a></li>
			</ul>
		</div>

		<div class="content">
<?	
	$query = "select * from transaction where mId = '$username' AND isDone = '0'";
	$sql = mysql_query($query);
	$result = mysql_num_rows( $sql );

	if( $result!=0 ){	
?>
		<h2>您最近的交易如下：</h2>
		
		<form method="post" name="form1" action="confirm.php"> 
		<table>
   <tr>
       <td>遊戲名稱</td>
       <td>伺服器名稱</td>
	   <td>交易金額</td>
	   <td>付款確認</td>
	   <td>收款確認</td>
   </tr>
<? 
   while($row = mysql_fetch_object($sql))
   {
		$sId = $row->sId;
		$query2 = "select * from server where sId = '$sId' limit 1";
		$sql2 = mysql_query($query2);
		$row2 = mysql_fetch_object($sql2);  // for table `server`
		$gId = $row2->gId;
		
		$sql3 = mysql_query("select * from `game` where `id` = '$gId' limit 1");
		$row3 = mysql_fetch_object($sql3);	// for table `game`
?>   <tr> 
      <td><? echo $row3->gName;?></td>
	   <td><? echo $row2->sName;?></td>
	   <td align="center"><? echo $row->cashAmount;?></td>
	   <? if($row->isPaid == 0){                        //使用者未確認?>
	   			<td align="center"><input type="checkbox" name="check[]" value="<? echo $row->tTime;?>"></td>
				<td align="center">--</td>
	   <? 	} ?>
	   <? if($row->isPaid == 1){       
	         if($row->isConfirmed ==0){                 //管理者未確認?>
			<td align="center"><img src="mark.gif"></td>
	        <td align="center">--</td>
	   <?  } else if($row->isConfirmed==1){?>
			<td align="center"><img src="mark.gif"></td>
			<td align="center"><img src="mark.gif"></td>
			<td align="center"><a href="withdraw.php?tTime=<? echo $row->tTime;?>" >已可領幣　按我</a></td>
       <?  }  }?>
   </tr>
<?   }  ?>
   <tr>
   	   <td colspan="5" align="center"><input type="submit" value="確認" name="submit"></td>
   </tr>
</table>
</form> 
<?
	}else{
?>
		<h2>您最近並無交易紀錄。</h2>
		<p><a href="../order.php">我也想要買遊戲金幣！</a></p>
<?
	}
?>		
		</div>
		
	</div>
	
	<div id="footer">
		<p>BTFM &copy; mis97 db_09 2006</p>
	</div>
	
</div>

</body>
</html>