<!--#include file="check.asp"-->
<%
Call hrPower(7.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">

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

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

		
		<%
		select case action
		case "pay"
		%>

<table class="listtable">
  <thead>
    <tr>
      <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 agent where username='"&upline&"' order by nopay-pay desc,nopay desc",1)
			 else
			    set Rs=GrateRs("select * from agent order by nopay-pay desc,nopay desc",1)
		   end if
		   Rs.PageSize=30
		   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
		   %>
		   <form action="dl_pay.asp?action=up&upline=<%=upline%>" method="post">
<%if i mod 2 =0 then%>
         <tr class="listtr1" >
<%else%>
         <tr class="listtr2" >
<%end IF%>
              <td><%=Rs("username")%></td>
              <td><%=Rs("nopay")%></td>
              <td><%=Rs("pay")%></td>
              <td><%=zero(formatnumber(Rs("nopay")-Rs("pay")))%></td>
              <td><input name="pay_<%=Rs("adminid")%>" type="text" class="inputbox" id="pay_<%=Rs("adminid")%>" size="10"></td>
              <td><a href="agent.asp?action=show&id=<%=Rs("adminid")%>">代理资料</a> </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="6">对不起，商户应支付金额为零，不能支付！</td>
              </tr>
		   <%
		   end if
		   
		  %> 
		  <tr align="center" bgcolor="#F1F1F1">
              <td height="26" colspan="6"><input name="Submit" type="submit" class="inputbutton" value=" 立即支付 "></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="6">&nbsp;<strong>翻页: :</strong>
<%
  myurl="dl_pay.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;")
		%>&nbsp;</td>
		      </tr>
		 
          </table>
		  <%
		  case "up"
		   if not upline="" then 
		   		set Rs=GrateRs("select * from agent where username='"&upline&"' and nopay>pay",3)
			 else
			    set Rs=GrateRs("select * from agent where  nopay>pay",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("adminid"))) then 
			     
		  %>
<tr onmouseover="this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='infobackground'" onmouseout="this.style.backgroundColor=this.oldcolor" style="color:#284775;background-color:White;">
              <td>&nbsp;&nbsp;<%=Rs("username")%></td>
              <td>&nbsp;&nbsp;<%=request.form("pay_"&Rs("adminid"))%></td>
              </tr>
             <%
			    Rs("pay")=Rs("pay")+request.form("pay_"&Rs("adminid"))
				  Rs.update



			   end if




			   Rs.movenext
		   loop
		   %>

		  <tr align="center" bgcolor="#F1F1F1">
              <td height="26" colspan="6"><input name="Submit" type="submit" class="inputbutton" value=" 继续结算 "onclick="window.location='<%=Request.ServerVariables("HTTP_REFERER")%>';"></td>
              </tr>

			  

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

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