<!--#include file="conn.asp"-->
<!--#include file="adminset.asp"-->
<%if session("admin")="" then
response.Write "<script language='javascript'>alert('网络超时或您还没有登陆！');window.location.href='login.asp';</script>"
response.End
end if
if session("flag")>1 then
response.Write "<div align=center><font size=80 color=red><b>您没有此项目管理权限！</b></font></div>"
response.End
end if
if qx2<>1 then
response.Write "<div align=center><font size=80 color=red><b>您没有此项目管理权限！</b></font></div>"
response.End
end if

day1=trim(Request.Form("year1"))&"-"&trim(Request.Form("month1"))&"-"&trim(Request.Form("day1"))
day2=trim(Request.Form("year2"))&"-"&trim(Request.Form("month2"))&"-"&trim(Request.Form("day2"))

year1=trim(Request.Form("year1"))
month1=trim(Request.Form("month1"))
year2=trim(Request.Form("year2"))
month2=trim(Request.Form("month2"))
totaltype=Request.Form("totaltype")
totalanclass=Request.Form("totalanclass")
totalnclass=Request.Form("totalnclass")

'day1="#"&trim(Request.Form("month1"))&"-"&trim(Request.Form("day1"))&"-"&trim(Request.Form("year1"))&"#"
'day2="#"&trim(Request.Form("month2"))&"-"&trim(Request.Form("day2"))&"-"&trim(Request.Form("year2"))&"#"
%>
<html>
<head>
<title>网软志成在线购物系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
.STYLE3 {color: #000000}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
}
-->
</style>
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="1%" height="28">&nbsp;</td>
    <td width="99%"><table width="100%" border="0" cellspacing="0" cellpadding="5">
      <tr>
        <td width="77%" height="27" style="font-size:14px;color:#ffffff">&nbsp;<strong><font color="#000000">网软志成购物后台管理系统 &gt;&gt; 订单管理 &gt;&gt; 会员统计报表</font></strong></td>
        <td width="23%" style="font-size:14px;color:#ffffff"><span class="STYLE1">* 为必添项目</span></td>
      </tr>
      
    </table></td>
  </tr>
</table>
<br>
<table width="95%" border="0" align="center"cellpadding="3" cellspacing="1" bgcolor="#999999">

  <tr> 
    <td height="22" bgcolor="cccccc"> 
      <div align="center"><font color="#000000"><span id="title"></span></font></div>
    </td>
  </tr>
  <tr> 
<%
year1=trim(Request.Form("year1"))
month1=trim(Request.Form("month1"))
year2=trim(Request.Form("year2"))
month2=trim(Request.Form("month2"))
totaltype=Request.Form("totaltype")
totalanclass=Request.Form("totalanclass")
totalnclass=Request.Form("totalnclass")
if Request.Form("reporttype")="销售报表" then '销售报表
    set rs=server.createobject("adodb.recordset")
	if totaltype="1" then  '普通报表
	    sql="SELECT top "&Request.Form("recordcount")&" wygkcn_shop.shopid,wygkcn_shop.shopname,wygkcn_shop.shopchuban,wygkcn_shop.jj,sum(isnull(shopcount,0)),sum(isnull(zonger,0)) FROM wygkcn_shop,shop_action WHERE shop_action.shopid=wygkcn_shop.shopid and (datediff(d,fhsj,'"&day2&"')>=0) AND (datediff(d,'"&day1&"',fhsj)>=0) "
		msg=Request.Form("reporttype")&" [日期范围："&day1&"至"&day2
    elseif totaltype="2" then  '日报表
	    sql="SELECT top "&Request.Form("recordcount")&" wygkcn_shop.shopid,wygkcn_shop.shopname,wygkcn_shop.shopchuban,wygkcn_shop.jj,sum(isnull(shopcount,0)),sum(isnull(zonger,0)) FROM wygkcn_shop,shop_action WHERE shop_action.shopid=wygkcn_shop.shopid and (datediff(d,fhsj,'"&day2&"')=0) "
		msg=Request.Form("reporttype")&" [统计日期："&day2
	elseif totaltype="3" then  '月报表
	    sql="SELECT top "&Request.Form("recordcount")&" wygkcn_shop.shopid,wygkcn_shop.shopname,wygkcn_shop.shopchuban,wygkcn_shop.jj,sum(isnull(shopcount,0)),sum(isnull(zonger,0)) FROM wygkcn_shop,shop_action WHERE shop_action.shopid=wygkcn_shop.shopid and (datediff(m,fhsj,'"&day2&"')=0) "
		msg=Request.Form("reporttype")&" [统计月份："&year2&"-"&month2
	elseif totaltype="4" then  '年报表
	    sql="SELECT top "&Request.Form("recordcount")&" wygkcn_shop.shopid,wygkcn_shop.shopname,wygkcn_shop.shopchuban,wygkcn_shop.jj,sum(isnull(shopcount,0)),sum(isnull(zonger,0)) FROM wygkcn_shop,shop_action WHERE shop_action.shopid=wygkcn_shop.shopid and (datediff(yy,fhsj,'"&day2&"')=0) "
		msg=Request.Form("reporttype")&" [统计年份："&year2
	end if
	if totalanclass<>"0" then 
	    sql=sql&" and wygkcn_shop.anclassid="&totalanclass  '大类
		msg=msg&" 大类："&Request.Form("anclass")
	end if
	if totalnclass<>"0" then 
	    sql=sql&" and wygkcn_shop.nclassid="&totalnclass '小类
		msg=msg&" 小类："&Request.Form("nclass")
	end if
	msg=msg&"]"
	sql=sql&" GROUP BY wygkcn_shop.shopid,wygkcn_shop.shopname,wygkcn_shop.shopchuban,wygkcn_shop.jj  ORDER BY wygkcn_shop.shopid "
	rs.open sql,conn,1,1
%>

    <td height="107" bgcolor="#FFFFFF"> 
      <table width="95%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#999999">
        <tr align="center" bgcolor="#cccccc"> 
          <td width="11%">商品ID</td>
          <td width="41%">商品名称</td>
<%
    if not rs.eof then
%>
          <td width="17%"><%=rs(3)%></td>
<%
    else
%>
          <td width="17%">商品单位</td>
<%
    end if
%>
          <td width="14%">销售数量</td>
          <td width="17%">销售额</td>
        </tr>
<%
    while not rs.eof
%>
        <tr bgcolor="#FFFFFF"> 
          <td align="center" width="11%"><%=rs(0)%></td>
          <td width="41%" height="22"><a href="good_edit.asp?id=<%=rs(0)%>"><%=rs(1)%></a></td>
          <td width="17%" align="center"><%=rs(2)%></td>
          <td align="center" width="14%"><%=rs(4)%></td>
          <td align="center" width="17%"><%=formatnumber(round(rs(5),1),2)%></td>
        </tr>
<%
        rs.movenext
    wend
    set rs=nothing
%>
<%
elseif Request.Form("reporttype")="库存报表" then '库存报表
%>
<%
    set rs=server.createobject("adodb.recordset")

	if totaltype="1" then  '普通报表
	    sql="SELECT top "&Request.Form("recordcount")&" wygkcn_shop.shopid,wygkcn_shop.shopname,wygkcn_shop.shopchuban,wygkcn_shop.jj,wygkcn_shop.kucun FROM wygkcn_shop WHERE (datediff(d,adddate,'"&day2&"')>=0) AND (datediff(d,'"&day1&"',adddate)>=0) "
		msg=Request.Form("reporttype")&" [日期范围："&day1&"至"&day2
    elseif totaltype="2" then  '日报表
	    sql="SELECT top "&Request.Form("recordcount")&" wygkcn_shop.shopid,wygkcn_shop.shopname,wygkcn_shop.shopchuban,wygkcn_shop.jj,wygkcn_shop.kucun FROM wygkcn_shop WHERE (datediff(d,adddate,'"&day2&"')=0) "
		msg=Request.Form("reporttype")&" [统计日期："&day2
	elseif totaltype="3" then  '月报表
	    sql="SELECT top "&Request.Form("recordcount")&" wygkcn_shop.shopid,wygkcn_shop.shopname,wygkcn_shop.shopchuban,wygkcn_shop.jj,wygkcn_shop.kucun FROM wygkcn_shop WHERE (datediff(m,adddate,'"&day2&"')=0) "
		msg=Request.Form("reporttype")&" [统计月份："&year2&"-"&month2
	elseif totaltype="4" then  '年报表
	    sql="SELECT top "&Request.Form("recordcount")&" wygkcn_shop.shopid,wygkcn_shop.shopname,wygkcn_shop.shopchuban,wygkcn_shop.jj,wygkcn_shop.kucun FROM wygkcn_shop WHERE (datediff(yy,adddate,'"&day2&"')=0) "
		msg=Request.Form("reporttype")&" [统计年份："&year2
	end if
	if totalanclass<>"0" then 
	    sql=sql&" and wygkcn_shop.anclassid="&totalanclass  '大类
		msg=msg&" 大类："&Request.Form("anclass")
	end if
	if totalnclass<>"0" then 
	    sql=sql&" and wygkcn_shop.nclassid="&totalnclass '小类
		msg=msg&" 小类："&Request.Form("nclass")
	end if
	msg=msg&"]"
	sql=sql&" ORDER BY wygkcn_shop.shopid "


	rs.open sql,conn,1,1
%><input type="button" class="go-wenbenkuang" name="Submit4" value="打 印" onClick="javascript:window.print()"><br><br>
    <td height="107" bgcolor="#FFFFFF"> 
      <table width="95%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#999999">
        <tr align="center" bgcolor="#cccccc"> 
          <td width="11%">商品ID</td>
          <td width="41%">商品名称</td>
<%
    if not rs.eof then
%>
          <td width="17%"><%=rs(3)%></td>
<%
    else
%>
          <td width="17%">商品单位</td>
<%
    end if
%>
          <td width="14%">库存量</td>
        </tr>
<%
    while not rs.eof
%>
        <tr bgcolor="#FFFFFF"> 
          <td align="center" width="11%"><%=rs(0)%></td>
          <td width="41%" height="22"><a href="good_edit.asp?id=<%=rs(0)%>"><%=rs(1)%></a></td>
          <td width="17%" align="center"><%=rs(2)%></td>
          <td align="center" width="14%"><%=rs(4)%></td>
        </tr>
<%
        rs.movenext
    wend
    set rs=nothing
%>
<%
end if
%>
        <tr bgcolor="#FFFFFF"> 
          <td height="22" colspan="5"> 
            <div align="center"> 
              <input type="button" name="Submit" class="go-wenbenkuang" value="返回" onClick="javascript:history.go(-1)">
			   <input type="button" name="Submit" class="go-wenbenkuang" value="导入EXCEL" onClick="javascript:openexcel();">
			   <input type="button" class="go-wenbenkuang" name="Submit42" value="打 印" onClick="javascript:window.print()">
			   <font color="red"><span id="excelfile" ></span></font>            </div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<br>
<!--#include file="copyright.asp"-->
<p>&nbsp;</p>
<p>&nbsp;</p>
    </body>
</html>
<script>
    document.all.title.innerHTML="<%=msg%>";

function openexcel(){
    window.open("tjbb_result_excel.asp?report=<%=Request.Form("reporttype")%>&sql=<%=sql%>");
}
</script>