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

$link = mysql_connect($dbserver, $dbuser, $dbpass);
if (!$link) {
	die('数据库链接出错: ' . mysql_error());
	exit;
}
else
{	
	mysql_query("set names gbk");
	$sql="select * from user where ddusername='".$username."'";
	mysql_select_db($dbname);
	$rs = mysql_query($sql);
	while ($row = mysql_fetch_array($rs)){
		$tbusername=$row[tbusername];
	}	
}
?><!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: #FF0000;
	font-size:14px;
	text-decoration:none;}
.STYLE4 {color: #FF3300}
-->
</style>
<script language="javascript" type="text/javascript">
function checkje()

{
	var str=document.getElementById("payje").value;
	if(str)
	{
		if(isNaN(str)){ 
		   document.getElementById("ckpayje").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>交易金额必须填写数字！</font>';
		   return false; 
		}
		else
		{
			document.getElementById("ckpayje").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>交易金额填写正确！</font>';
			return true; 
		} 
	}
	else
	{
		document.getElementById("ckpayje").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>请填写交易金额</font>';
				return true;
	}
}

function checkdd()
{
		var str1 = document.getElementById("tbcode").value; 
        if(str1=="")
		{       
				document.getElementById("ckdd").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>请填写淘宝订单号</font>';
				return false;
		}
		else if(str1.length<5||str1.length>20)
		{
				document.getElementById("ckdd").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>淘宝订单号填写有误</font>';
				return false;
		}
		else
		{
				document.getElementById("ckdd").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>淘宝订单号填写正确</font>';
				return true;
		}
} 

function checksp()
{
		var str1 = document.getElementById("tbname").value; 
        if(str1=="")
		{       
				document.getElementById("cksp").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>请填写淘宝商品名称</font>';
				return false;
		}
		else if(str1.length<2||str1.length>20)
		{
				document.getElementById("cksp").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>淘宝商品名称填写有误</font>';
				return false;
		}
		else
		{
				document.getElementById("cksp").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>淘宝商品名称填写正确</font>';
				return true;
		}
} 

function checkpaytime()
{
		var str = document.getElementById("paytime").value;   
        if(str.length!=0)
		{   
			reg=/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/; 
			if(!reg.test(str))
			{    
				document.getElementById("ckpaytime").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>日期格式错误，如：2010-01-01</font>';
				return false;
			}
			else
			{
				document.getElementById("ckpaytime").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>确认收货时间正确</font>';
				return true;
			}
		}
		else
		{
			document.getElementById("ckpaytime").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>请填写确认收货时间</font>';
				return false;
						}
}  
function checkall()
{
	if(checkdd()&&checkpaytime()&&checkpayje())
	{
		return true;
	}
	else
	{
		return false;
	}
}
</script>
</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="6"></td>
  </tr>
</table>
<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="100%" height="248" style="border:1px  solid #DCEAF7;">
            <tr>
              <td height="30" colspan="2" bgcolor="E9F2FB" class="bigtext"><strong>&nbsp;&nbsp;<img src="../images/arrow.gif" width="16" height="22" align="absmiddle" /> 增加交易</strong></td>
            </tr>
            <tr>
              <td width="100%" height="216" colspan="2"><form id="form1" name="form1" action="savetrade.php" method="post" onsubmit="return checkall()">
<br />
<table width="565" border="0" align="center" cellpadding="5" cellspacing="0" style="border:1px  solid #b6e0f8;">
                  <tr>
                    <td width="553" height="54" bgcolor="f2faff">注意：我们只有在您在淘宝的交易中已经<span class="STYLE4">确认收货并付款</span>的情况下，才能取得您交易的返还比率、返还金额等数据，所以请您在还没有在淘宝确认收货并付款的情况下耐心等待订单的确认！</td>
                  </tr>
                </table>
                <br />
                <table width="695" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="226" height="30" align="right"  class="bigtext">淘宝订单编号：</td>
                  <td>&nbsp;&nbsp;<input name="tbcode" type="text" class="btn3" id="tbcode" onblur="checkdd();" maxlength="20" /></td>
                  <td  class="bigtext" id="ckdd"><a href="../mian.htm" target="_blank"><span class=" STYLE3">怎么看订单编号？</span></a></td>
                </tr>   
                <tr>
                  <td width="226" height="30" align="right"  class="bigtext">商品名称：</td>
                  <td>&nbsp;&nbsp;<input name="tbname" type="text" class="btn3" id="tbname" onblur="checksp();" maxlength="20" /></td>
                  <td  class="bigtext" id="cksp"><span class=" STYLE3">该商品的标题名称</span></a></td>
                </tr> 
				<tr>
                  <td height="30" align="right"  class="bigtext">交易金额：</td>
                  <td width="202" height="30">&nbsp;&nbsp;<input name="payje" type="text" class="btn3" id="payje" onblur="checkje();" size="15" maxlength="10"/>
                  <span class="bigtext">元</span></td>
                  <td width="267" class="bigtext" id="ckpayje">淘宝网购物支付的费用(不含快递)</td>
                </tr> 
                <tr>
                  <td height="30" align="right"  class="bigtext">确认收货时间：</td>
                  <td width="202" height="30">&nbsp;&nbsp;<input name="paytime" type="text" class="btn3" id="paytime" onblur="checkpaytime();" value="<?php date_default_timezone_set('PRC');echo date('Y-m-d');?>" maxlength="10" /></td>
                  <td width="267" class="bigtext" id="ckpaytime">格式如：2010-02-14</td>
                </tr>
				 <tr>
                  <td height="30" align="right"  class="bigtext">淘宝用户名：</td>
                  <td height="30">&nbsp;&nbsp;<span class="bigtext"><input name="tbusername" type="text" class="btn3" id="tbusername" value="<?php echo $tbusername?>" maxlength="30" />
                  </span></td>
                  <td height="30" class="bigtext" id="">可空，尽量填写，便于审核</td>
                </tr>
                <tr>
                  <td height="30" align="right">&nbsp;</td>
                  <td height="30" colspan="2">&nbsp;&nbsp;<input type="submit" name="Submit" value=" 保存交易 " class="btn2" /></td>
                </tr>
              </table>
              </form></td>
            </tr>
          </table></td>
        </tr>
    </table></td>
  </tr>
</table>
<?php
include("../comm/footer.php");
?>
</body>
</html>
<?php mysql_close($link);?>