<?php 
include '../comm/conn.php';
include '../comm/checkpostandget.php';
include 'check.php';
include '../comm/config.php';

$page = !($_GET['page'])?'1':intval($_GET['page']);
$page2=($page-1)*10;
$num1=10;

$link = mysql_connect($dbserver, $dbuser, $dbpass);
if (!$link) {
	die('数据库链接出错: ' . mysql_error());
	exit;
}
else
{
	mysql_query("set names gbk");
	$sql="select * from tbjy where ddusername='".$username."'";
	mysql_select_db($dbname);
	$rs = mysql_query($sql);
	$num = mysql_num_rows($rs);	
	
	$sql="select * from tbjy where ddusername='".$username."' order by id desc limit $page2,$num1";
	//echo $sql;
	$rs = mysql_query($sql);
	//$num1 = mysql_num_rows($rs);	
	
}
?><!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>交易管理 - <?php echo $usercenter;?> - <?php echo $webtitle;?></title>
<link href="../images/style1.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.STYLE1 {
	color: #FFFFFF;
	font-weight: bold;
	font-size:14px;
	text-decoration:none;
}
.STYLE2 {
	color: #555555;
	font-weight: bold;
	font-size:14px;
	text-decoration:none;
}
.STYLE3 {color: #FF3300}
.STYLE5 {color: #555555}
-->
</style>
</head>

<body topmargin="0" leftmargin="0">
<?php
include("../comm/header.php");
?>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="282" valign="top"><table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td colspan="2"><table cellspacing="0" width="950" height="248" style="border:1px  solid #DCEAF7;">
          <tr>
            <td width="693" height="30" bgcolor="E9F2FB" class="bigtext"><strong>&nbsp;&nbsp;<img src="../images/arrow.gif" width="16" height="22" align="absmiddle" /> 交易管理 [ <a href="addtrade.php"><span class="bigtext STYLE3">增加新的交易</span></a> ] </strong></td>
            <td width="251" height="30" align="right" bgcolor="E9F2FB" class="bigtext">共有 <b><?php echo $num;?></b> 条交易记录&nbsp;&nbsp;</td>
          </tr>
          <tr>
            <td height="216" colspan="2" valign="top"><table width="948" style="border:1px  solid #64A4E2;" cellpadding="0">
                <tr>
                  <td width="120" height="30" align="left" bgcolor="#CEFC8F" class="bigtext STYLE5">&nbsp;<strong>淘宝交易号</strong></td>
                  <td width="261" height="30" align="left" bgcolor="#CEFC8F" class="bigtext STYLE5">&nbsp;<strong>商品名称</strong></td>
                  <td width="91" align="left" bgcolor="#CEFC8F" class="bigtext"><span class="STYLE5"><strong>&nbsp;交易金额</strong></span></td>
                  <td width="77" align="left" bgcolor="#CEFC8F" class="bigtext"><span class="STYLE5"><strong>&nbsp;返现金额</strong></span></td>
                  <td width="75" align="left" bgcolor="#CEFC8F" class="bigtext"><strong>&nbsp;返现比率</strong></td>
                  <td width="111" bgcolor="#CEFC8F" class="bigtext"><span class="STYLE5"><strong>&nbsp;支付时间</strong></span></td>
                  <td width="69" bgcolor="#CEFC8F" class="bigtext"><span class="STYLE5"><strong>&nbsp;状&nbsp;态</strong></span></td>
                  <td width="124" bgcolor="#CEFC8F" class="bigtext"><span class="STYLE5"><strong>&nbsp;提交时间</strong></span></td>
                </tr>
                <?php
	while ($row = mysql_fetch_array($rs)){
	 $st="<font color=#0066CC>未结算</font>";
						 if($row[fxje]==0)
						 {
							$fxje2="确认中...";
							$fxbl2="确认中...";
						 }
						 else
						 {
							$fxje2=$row[fxje]*$fxbl;
							$fxbl2=round($fxje2/$row[payje],4)*100;
							$fxbl2=$fxbl2."%";
						 }
						 if($row[jystate]==0)
							{ $st= "<font color=#0066CC>未结算</font>";}
						 else if($row[jystate]==1)
							{$st= "<font color=#009900>已结算</font>";}
						 else
						 {$st= "<font color=#ff3300>信息有误</font>";
						 	$fxje2="0";
							$fxbl2="0%";
						  }
		echo "<tr><td height=30 align=left class=bigtext bgcolor=#F5F5F5>&nbsp;".$row[tbcode]."</td><td align=left class=bigtext bgcolor=#F5F5F5>&nbsp;".$row[tbname]."</td><td align=left class=bigtext bgcolor=#F5F5F5>&nbsp;".$row[payje]." 元 </td><td align=left class=bigtext bgcolor=#F5F5F5>&nbsp;".$fxje2."</td><td align=left class=bigtext bgcolor=#F5F5F5>&nbsp;".$fxbl2."</td><td class=bigtext bgcolor=#F5F5F5>&nbsp;".$row[paytime]."</td><td class=bigtext bgcolor=#F5F5F5>&nbsp;".$st."</td><td class=bigtext bgcolor=#F5F5F5>&nbsp;".$row[addtime]."</td></tr>";
	}
	?>
                <tr>
                  <td height="30" colspan="7"><div id="pages">
                      <?php  
require_once("../comm/pages.php");    
  $page_size=10;    
  $nums=$num;     
  $sub_pages=10;   
  $pageCurrent=$_GET["page"];     
     
  $subPages=new SubPages($page_size,$nums,$pageCurrent,$sub_pages,"trade.php?page=",2);
?>
                  </div></td>
                </tr>
            </table></td>
          </tr>
        </table></td>
        </tr>
      
    </table></td>
  </tr>
</table>
<?php
include("../comm/footer.php");
?>
</body>
</html>
<?php mysql_close($link);?>