<!--#include file="check.asp"-->
<%
Call hrPower(3.3,0)
dim action
action=request.QueryString("action")
upline=request.QueryString("upline")
Nowpage=cint(request.QueryString("page"))

%>

<!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>商户支付</title>
<link href="images/main.css" rel="stylesheet" type="text/css" media="all" />
</head>
<!--#include file="top.asp"-->

<div id="systime"><p id="servertime"></p></div>
<div id="mainBody" >

<div class="space">&nbsp;</div>
<div class="list">


		
		<%
		select case action
		case "pay"
		%>

<script language="javascript">
try{
    var nav="H04";
    var subnav="L0405";
	
    document.getElementById(nav).className="current";
    document.getElementById(subnav).className="first current";
    document.getElementById(subnav).parentNode.parentNode.style.display="block";

}catch(e){
	document.getElementById("H04").className="current";
}
</script>


<script   language="JavaScript">   
  function   ValidateInput()   
  {   
	if(confirm('确定操作吗...'))
	{
      document.form1.submit();   
      document.form1.Submit.disabled=true;   
	}
  }   
  </script> 


<table class="search_form">

<td align="right" width="100%"><b>商户支付</b></td>
</tr></form></table>


<table class="listtable">
  <thead>
    <tr>
      <th scope="col">商户ID</th>
	  <th scope="col">商户名</th>
            <th scope="col">结算总金额</th>
            <th scope="col">已结算金额</th>
            <th scope="col">应支付金额</th>
            <th scope="col">支付</th>
            <th scope="col">操作</th>
    </tr>
  </thead>
  <tbody> 



           <%
		   if not upline="" then 
		   		set Rs=GrateRs("select * from member where username='"&upline&"' and state=1 and moneyTotal-removeMoney>=100   order by moneyTotal-removeMoney desc,moneyTotal desc",1)
			 else
			    set Rs=GrateRs("select * from member where state=1 and moneyTotal-removeMoney>=100  order by moneyTotal-removeMoney desc,moneyTotal desc",1)
		   end if
		   Rs.PageSize=50
		   if not Rs.eof then 
		   If Nowpage=0 then Nowpage=1
		   Rs.AbsolutePage=Nowpage 
		   i=1
		   do while not Rs.eof and i<=Rs.pagesize
			gmm=gmm+(Rs("moneyTotal")-Rs("removeMoney"))
		   %>
		   <form name="form1" action="pay1.asp?action=up&upline=<%=upline%>" method="post">
<%if i mod 2 =0 then%>
         <tr class="listtr1" >
<%else%>
         <tr class="listtr2" >
<%end IF%>
              <td><%=Rs("id")%></td>
              <td><%=Rs("username")%></td>
              <td><%=Rs("moneyTotal")%></td>
              <td><%=Rs("removeMoney")%></td>
              <td><%=zero(formatnumber(Rs("moneyTotal")-Rs("removeMoney")))%></td>
              <td><input name="pay_<%=Rs("id")%>" type="text" value="0" class="inputbox" id="pay_<%=Rs("id")%>" size="10"></td>
              <td>
<a href="paycard.asp?id=<%=Rs("id")%>" target="_blank">银行帐号</a> / <a href="siter.asp?action=show&id=<%=Rs("id")%>">商户资料</a> / <a href="ship.asp?action=show&upline=<%=Rs("username")%>">结算详单</a> / <a href="meber.asp?Action=search&upline=<%=Rs("username")%>">定制详单</a></td>
            </tr>
			
			<%
		   i=i+1
		   Rs.movenext
		   loop
		   else
		   %>
<tr onmouseover="this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='infobackground'" onmouseout="this.style.backgroundColor=this.oldcolor" style="color:#284775;background-color:White;">
              <td height="26" colspan="7">对不起，商户应支付金额不足，不能支付！</td>
              </tr>
		   <%
		   end if
		   
		  %> 
<tr align="center" onmouseover="this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='infobackground'" onmouseout="this.style.backgroundColor=this.oldcolor" style="color:#284775;background-color:White;">
              <td height="26" colspan="7"><input type="button" name="Submit" onClick="JavaScript:ValidateInput();" value="立即支付" id="Submit" /></td>

              </tr>
			  </form>
<tr onmouseover="this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='infobackground'" onmouseout="this.style.backgroundColor=this.oldcolor" style="color:#284775;background-color:White;">
		      <td height="26" colspan="7">&nbsp;<strong>翻页: :</strong>
<%
  myurl="pay1.asp?action=pay&upline="&upline&"&"
 response.write("共："&Rs.recordcount&"条记录，共:"&Rs.PageCount&"页,"&Rs.PageSize&"条/页,第"&NowPage&"页&nbsp;")
  response.write("<a href='"&myurl&"page=1'>"&"首页</a>&nbsp;")
  if NowPage>1 then response.write("<a href='"&myurl&"page="&Nowpage-1&"'>上一页</a>&nbsp;")
  if NowPage<Rs.PageCount then response.write("<a href='"&myurl&"page="&Nowpage+1&"'>下一页</a>&nbsp;")
  response.write("<a href='"&myurl&"page="&Rs.PageCount&"'>尾页</a>&nbsp;")
		%><font color="red">总金额： <b><%=gmm%></b>元</font>&nbsp;</td>
		      </tr>
		 
          </table>
		  <%
		  case "up"
		   if not upline="" then 
		   		set Rs=GrateRs("select * from member where username='"&upline&"' and state=1  and moneyTotal-removeMoney>=100",3)
			 else
			    set Rs=GrateRs("select * from member where state=1  and moneyTotal-removeMoney>=100",3)
		   end if
		    %>


<table class="listtable">
  <thead>
    <tr>
      <th scope="col">商户ID</th>
	  <th scope="col">本次支付金额</th>
    </tr>
  </thead>
  <tbody> 





          <%
		   do while not Rs.eof
		       if Isnumeric(request.form("pay_"&Rs("id"))) then 
			     
		  %>
         <tr class="listtr1" >
              <td><%=Rs("username")%></td>
              <td><%=request.form("pay_"&Rs("id"))%></td>
              </tr>
             <%
			    Rs("removeMoney")=Rs("removeMoney")+request.form("pay_"&Rs("id"))
				  Rs.update

			if request.form("pay_"&Rs("id")) > 0 then



		   	set Rss=GrateRs("select * from M_tixian",3)
		   	Rss.addnew
		   	Rss("username")=Rs("username")
		   	Rss("userid")=Rs("id")
		   	Rss("money")=request.form("pay_"&Rs("id"))
		   	Rss("addtime")=now()
		   	Rss("huakuan")=request.form("pay_"&Rs("id"))
		   	Rss("beizhu")="支付成功"
		   	Rss("shouxufei")="0"
		   	Rss("lastdate")=now()
		   	Rss("state")=1
		   	Rss.update



			end if

			   end if






			   Rs.movenext
		   loop
		   %>
<tr align="center" onmouseover="this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='infobackground'" onmouseout="this.style.backgroundColor=this.oldcolor" style="color:#284775;background-color:White;">
                   <td align="center" colspan="2"><input name="Submit" type="submit" class="inputbutton" value=" 继续结算 " onclick="Submit.disabled=true;window.location='<%=Request.ServerVariables("HTTP_REFERER")%>';"></td>



              </tr>   
			  


		   <%
		  end select
		  %>
          </table>
       </td>
      </tr>
	  

    </table></td>
  </tr>
</table>
</body>
</html>
<%
call DBConnEnd
%>