<%@ LANGUAGE = VBScript.Encode %>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312" />
<TITLE>销售统计</TITLE>
<link rel="stylesheet" href="Images/Admin.css">
<script language="javascript" src="../Script/Admin.js"></script>
</HEAD>
<!--#include file="../Include/conn.asp" -->
<!--#include file="../Include/ConnDatabase.asp" -->
<!--#include file="CheckAdmin.asp"-->
<%
'=====================================
'天天企业网站管理系统  TianTianCMS
'天天网络科技工作室版权所有
'官方客服中心 http://www.ip126.com
'微信公众号 ip126com
'QQ:530051328 mail:bbfhq@163.com
'=====================================
%>
<BODY>
<%
if Instr(session("AdminPurview"),"|18,")=0 then
  response.write ("<br><br><div align=""center""><font style=""color:red; font-size:9pt; "")>您没有管理该模块的权限！</font></div>")
  response.end
end if
%>
<%

dim i,day1,day2,z_xs_sl,z_xs_je,rs2,xs_sl,xs_je
day1=""&trim(Request("year1"))&"-"&trim(Request("month1"))&"-"&trim(Request("day1"))&""
day2=""&trim(Request("year2"))&"-"&trim(Request("month2"))&"-"&trim(Request("day2"))&""
%>

<body>
<table class="tableBorder" width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
<tr class=backs><td align="center" class=td height=18><font color="#FFFFFF">统计报表查看</font></b></td>
</tr>
<tr>
<%'=============分页定义开始，可放在数据库打开前或后
                 dim action
    action=request.QueryString("action")   
    Const MaxPerPage=10   '定义每页显示记录数，可根据实际自定义
       dim totalPut   
       dim CurrentPage
       dim TotalPages
       dim j

        if Not isempty(request("page")) And request("page")<>"" then
          currentPage=Cint(request("page"))
       else
          currentPage=1
       end if        
'=============分页定义结束%>
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from TianTianCMS_Products order by id",conn,1,1
%>
<%'=============分页类代码开始，需放在数据库数据表打开后
   
    if err.number<>0 then
    response.write "<p align='center'>数据库中暂时无数据</p>"
    end if    
      if rs.eof And rs.bof then
           Response.Write "<p align='center'>对不起，没有符合条件记录！</p>"
       else
      totalPut=rs.recordcount
          if currentpage<1 then
              currentpage=1
          end if

          if (currentpage-1)*MaxPerPage>totalput then
         if (totalPut mod MaxPerPage)=0 then
           currentpage= totalPut \ MaxPerPage
         else
            currentpage= totalPut \ MaxPerPage + 1
         end if
          end if

           if currentPage=1 then
               showContent               
               
               showpage totalput,MaxPerPage,""&request.ServerVariables("script_name")&""  
           else
              if (currentPage-1)*MaxPerPage<totalPut then
                rs.move  (currentPage-1)*MaxPerPage
                dim bookmark
                bookmark=rs.bookmark
                showContent
                 showpage totalput,MaxPerPage,""&request.ServerVariables("script_name")&""  
            else
             currentPage=1
                showContent
                
                showpage totalput,MaxPerPage,""&request.ServerVariables("script_name")&""  
                
           end if
        end if
           end if
'=============分页类代码结束%>
 <%'=============分页从循环体开始
   sub showContent
   dim i
   i=0  %>
<td height="107"> 
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
<tr align="center" bgcolor="#D9E6FF"> 
<td width="11%">商品ID</td>
<td width="15%">商品编号</td>
<td width="41%">商品名称</td>
<td width="14%">销售数量</td>
<td width="17%">销售额</td>
</tr>
                                <%	z_xs_sl=0
									z_xs_je=0
									while not rs.eof

									set rs2=server.createobject("adodb.recordset")
									rs2.open "select * from TianTianCMS_Sales where (datediff(""d"",ddshsj,'"&day2&"')>=0)  and (datediff(""d"",'"&day1&"',ddshsj)>=0)  and (goodsid='"&rs("id")&"')",conn,1,1							
									xs_sl=0
									xs_je=0
									while not rs2.eof
										xs_sl=xs_sl+rs2("sales_num")
										xs_je=xs_je+rs2("sales_amount")
										rs2.movenext
									wend
									rs2.close
									set rs2=nothing
								%>
<tr bgcolor="#D9E6FF"> 
<td align="center" ><%=rs("id")%></td>
<td  STYLE='PADDING-LEFT: 10px'><%=rs("ProductNo")%></td>
<td  STYLE='PADDING-LEFT: 10px'><a href=../Ch/ProductShow.Asp?ID=<%=rs("id")%> target=_blank><%=rs("ProductNameCH")%></a></td>
<td align="center"  bgcolor="#D9E6FF"><%=xs_sl%></td>
<td align="center" ><%=xs_je%></td>
</tr>
                                <%z_xs_sl=z_xs_sl+xs_sl
								z_xs_je=z_xs_je+xs_je

								rs.movenext
								wend
								rs.close
								set rs=nothing
								%>


</table>
</td>
</tr>
</table>
<%End Sub%>
<tr bgcolor="#D9E6FF"> 

								<%'=============放置分页显示开始 
  Function showpage(totalnumber,maxperpage,filename)  
      Dim n      
    If totalnumber Mod maxperpage=0 Then  
     n= totalnumber \ maxperpage  
    Else
     n= totalnumber \ maxperpage+1  
    End If %>
    <form method=Post action=<%=filename%>>
    <p align="center"> 
<%If CurrentPage<2 Then  %>
    首 页 上一页
    <% Else  %>
    <a href=<% = filename %>?page=1&all=<%=Request("all")%>&month1=<%=Request("month1")%>&day1=<%=Request("day1")%>&year1=<%=Request("year1")%>&month2=<%=Request("month2")%>&day2=<%=Request("day2")%>&year2=<%=Request("year2")%>>首 页</a>
    <a href=<% = filename %>?page=<% = CurrentPage-1 %>&all=<%=Request("all")%>&month1=<%=Request("month1")%>&day1=<%=Request("day1")%>&year1=<%=Request("year1")%>&month2=<%=Request("month2")%>&day2=<%=Request("day2")%>&year2=<%=Request("year2")%>>上一页</a> 
    <% End If 
    If n-currentpage<1 Then  %>
    下一页 尾 页
    <%  Else  %>
    <a href=<% = filename %>?page=<% = (CurrentPage+1) %>&all=<%=Request("all")%>&month1=<%=Request("month1")%>&day1=<%=Request("day1")%>&year1=<%=Request("year1")%>&month2=<%=Request("month2")%>&day2=<%=Request("day2")%>&year2=<%=Request("year2")%>>下一页</a> 
    <a href=<% = filename %>?page=<% = n %>&all=<%=Request("all")%>&month1=<%=Request("month1")%>&day1=<%=Request("day1")%>&year1=<%=Request("year1")%>&month2=<%=Request("month2")%>&day2=<%=Request("day2")%>&year2=<%=Request("year2")%>>尾 页</a>&nbsp;&nbsp;
    <% End If  %>
 页次：<b><font color=red><% = CurrentPage %></font></b>/<b><% = n %></b>页 <b><%=maxperpage%></b>个记录/页  共<b><%=totalnumber %></b>个记录    
转到：<select name="cndok" onchange="javascript:location=this.options[this.selectedIndex].value;">
<%
for i = 1 to n
if i = CurrentPage then%>
<option value="<% = filename %>?page=<%=i%>&all=<%=Request("all")%>&month1=<%=Request("month1")%>&day1=<%=Request("day1")%>&year1=<%=Request("year1")%>&month2=<%=Request("month2")%>&day2=<%=Request("day2")%>&year2=<%=Request("year2")%>" selected>第<%=i%>页</option>  
<%else%>
<option value="<% = filename %>?page=<%=i%>&all=<%=Request("all")%>&month1=<%=Request("month1")%>&day1=<%=Request("day1")%>&year1=<%=Request("year1")%>&month2=<%=Request("month2")%>&day2=<%=Request("day2")%>&year2=<%=Request("year2")%>">第<%=i%>页</option>  
<%
end if
next
%>
</select></font>
</form>
<%End Function 
'=============放置分页显示结束%>
</tr>
</body>
</html>