<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../HSK_Cls/HSK.CommonCls.asp"-->
<!--#include file="../HSK_Cls/HSK.Label.BaseFunCls.asp"-->
<!--#include file="../HSK_Cls/HSK.AdministratorCls.asp"-->
<!--#include file="../HSK_Cls/HSK.UpFileCls.asp"-->
<!--#include file="Include/Session.asp"-->
<%

Dim KSCls
Set KSCls = New Admin_EnterPrise
KSCls.HSK_Run()
Set KSCls = Nothing

Class Admin_EnterPrise
        Private KS,Param,KSCls
		Private Action,i,strClass,RS,SQL
        Private Sub Class_Initialize()
		  Set KS=New PublicCls
		  Set KSCls=New ManageCls
		End Sub
        Private Sub Class_Terminate()
		 Call CloseConn()
		 Set KS=Nothing
		End Sub

		Public Sub HSK_Run()
		
		 If Request("Action")= "export" Then
		   DoExport
		   Exit Sub
		 End If
		
		 With Response
			  .Write "<html>"
			  .Write"<head>"
			  .Write"<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"
			  .Write"<link href=""Include/Admin_Style.CSS"" rel=""stylesheet"" type=""text/css"">"
			  .Write "<script src=""../HSK_JS/common.js"" language=""JavaScript""></script>"
			  .Write "<script language='JavaScript' src='../HSK_JS/jquery.js'></script>" & vbCrLf
			  .Write"</head>"
			  .Write"<body leftmargin=""0"" topmargin=""0"" marginwidth=""0"" marginheight=""0"">"
			  .Write "<div class='topdashed sort'><a href='?action=Custom'"
			  If KS.G("Action")="Custom" Then .Write " style='color:red'"
			  .Write ">客户统计</a> | <a href='?action=Order'"
			  If KS.G("Action")="Order" Then .Write " style='color:red'"
			  .Write ">订单统计</a> | <a href='?action=Sale'"
			  If KS.G("Action")="Sale" Then .Write " style='color:red'"
			  .Write ">销售概况</a> | <a href='?action=SalePM'"
			  If KS.G("Action")="SalePM" Then .Write " style='color:red'"
			  .Write ">销售排名</a> </div>"
		End With
	   	If Not KS.ReturnPowerResult(5, "M510017") Then  Call KS.ReturnErr(1, ""):Exit Sub   
		Select Case KS.G("action")
		 Case "SalePM"
		  SalePM
		 Case "Custom"
		  Custom
		 Case "Order" 
		  Order
		 Case "Sale" 
		  Sale
		 Case Else
		End Select
		
		
End Sub

Sub DoExport()
   Response.AddHeader "Content-Disposition", "attachment;filename=addressbook.xls" 
   Response.ContentType = "application/vnd.ms-excel" 
   Response.write "<meta http-equiv=""Content-Type"" content=""text/html; charset=GB2312"">"
   Response.Write Request.Form("content")
End Sub

Sub SalePM()
%>
<div class="sort" style="padding-left:10px;text-align:left;line-height:30px"><a href='?action=SalePM'<%If request("d")="" then response.write " style='color:red'"%>>所有时间</a> <a href='?action=SalePM&d=1'<%If request("d")="1" then response.write " style='color:red'"%>>今日排名</a> <a href='?action=SalePM&d=2'<%If request("d")="2" then response.write " style='color:red'"%>>本周排名</a> <a href='?action=SalePM&d=3'<%If request("d")="3" then response.write " style='color:red'"%>>本月排名</a> <a href='?action=SalePM&d=6'<%If request("d")="6" then response.write " style='color:red'"%>>上个月排名</a> <a href='?action=SalePM&d=4'<%If request("d")="4" then response.write " style='color:red'"%>>本年度排名</a></div>
<table width="99%" style="margin-top:10px" border="0" align="center" cellpadding="1" cellspacing="1" class="ctable">
					  <tr class="tdbg">
						<td height='25' class='clefttitle' colspan='4' style="text-align:left"><strong>按时间段统计</strong> </td>
					  </tr>
					  <form name="myform" action="?action=SalePM" method="post">
					  <tr class="tdbg">
						<td height="30">&nbsp;&nbsp;开始日期<input name='BeginDate' type='text' id='BeginDate' value='<%=Year(Now) & "-" & Month(NOW) & "-1"%>' size='20'  class='textbox'>                 <a href='#' onClick="OpenThenSetValue('Include/DateDialog.asp',160,170,window,document.myform.BeginDate);document.myform.BeginDate.focus();"><img src='Images/date.gif' border='0' align='absmiddle' title='选择日期'></a>
						&nbsp;&nbsp;
						结束日期<input name='EndDate' type='text' id='EndDate' value='<%=formatdatetime(Now,2)%>' size='20'  class='textbox'>                 <a href='#' onClick="OpenThenSetValue('Include/DateDialog.asp',160,170,window,document.myform.EndDate);document.myform.EndDate.focus();"><img src='Images/date.gif' border='0' align='absmiddle' title='选择日期'></a> </td>
						<td>
					    <input type="hidden" name="d" value="5"/>
					    <input class="button" type="submit" value=" 开 始 统 计 ">
					   </td>
					  </tr>
					   </form>

</table>
<br/>
<%
 dim rs,sql,MaxPerPage,CurrentPage,i,TotalPut,Param,str
 MaxPerPage=50
 CurrentPage=KS.ChkClng(KS.G("Page"))
 If CurrentPage<=0 Then CurrentPage=1

  Param="where o.status<>0 and o.status<>3"
		  
 str="<div style=""padding:5px;color:green;font-weight:bold"">"
If request("d")<>"" then
 
   select case KS.ChkClng(Request("d"))
     case 1 
	  str=str & "今日销售排行"
	  Param=Param & " and year(inputtime)=" & year(now) & " and month(inputtime)=" & month(now) & " and day(inputtime)=" & day(now)
	 case 2
	  str=str & "本周销售排行"
	  Param=Param & " and datediff(" & DataPart_W & ",[inputtime]," & SQLNowString & ")=0"
	 case 3
	  str=str & "本月销售排行"
	  Param=Param & " and datediff(" & DataPart_M & ",[inputtime]," & SQLNowString & ")=0"
	 case 6
	  str=str & "上个月销售排行"
	  Param=Param & " and datediff(" & DataPart_M & ",[inputtime]," & SQLNowString & ")=1"
	 case 4
	  str=str & "本年度销售排行"
	  Param=Param & " and datediff(" & DataPart_Y & ",[inputtime]," & SQLNowString & ")=0"
	 case 5
	  str=str &  "时间段 <font color=red>" & KS.S("BeginDate") & " 至 " & KS.S("EndDate") & "</font> 的销售排行"
			If KS.S("BeginDate")<>"" and IsDate(KS.S("BeginDate")) Then 
			  If DataBaseType=1 Then
			   Param=Param & " and inputtime>='" & KS.S("BeginDate") & "'"
			  Else
			   Param=Param & " and inputtime>=#" & KS.S("BeginDate") & "#"
			  End if
			End If
			If KS.S("EndDate")<>"" and IsDate(KS.S("EndDate")) Then 
			  If DataBaseType=1 Then
			   Param=Param & " and inputtime<='" & DateAdd("d", 1,KS.S("EndDate")) & "'"
			  Else
			   Param=Param & " and inputtime<=#" & DateAdd("d", 1,KS.S("EndDate")) & "#"
			  End if
			End If
   end select 
     
else
 str=str & "所有时间的商品销售排行"
end if
str=str & "</div>"

         str=str & "<table width=""99%"" style=""margin-top:10px"" border=""{$border}"" align=""center"" cellpadding=""1"" cellspacing=""1"" class=""ctable"">"
		 str=str &"<tr class=""sort"">"
		 str=str & "<th class='splittd' height='26' style=""text-align:center;font-size:12px""><strong>商品名称</strong> </th>"
		 str=str &"	<th class='splittd' style=""text-align:center;font-size:12px""><strong>销售量</strong> </th>"
		 str=str &"	<th class='splittd' style=""text-align:center;font-size:12px""><strong>总销售额(元)</strong> </th>"
		 str=str &"</tr>"
		  sql="select p.title,p.unit,a.proid,sum(a.Amount) as SaleNum,sum(TotalPrice) as SaleMoney from (ks_orderitem a inner join ks_product p on a.proid=p.id) inner join ks_order o on a.orderid=o.orderid " & Param & " group by a.proid,p.title,p.unit order by sum(Amount) desc"
		  set rs=server.CreateObject("adodb.recordset")
		  rs.open sql,conn,1,1
		  If RS.Eof And RS.Bof Then
		    str=str & "<tr><td colspan=5 class='splittd' style='text-align:center'>找不到任何销售的商品!</td></tr>"
		  Else
		      totalPut = conn.execute("select count(1) from (ks_orderitem a inner join ks_product p on a.proid=p.id) inner join ks_order o on a.orderid=o.orderid " & Param)(0)
			  If CurrentPage < 1 Then	CurrentPage = 1
			  If CurrentPage > 1  and (CurrentPage - 1) * MaxPerPage < totalPut Then
						RS.Move (CurrentPage - 1) * MaxPerPage
			  Else
				  	CurrentPage = 1
			  End If
		      i=0
			  do while not rs.eof 
				 str=str & "<tr><td class='splittd'><a href='../item/show.asp?m=5&d=" & rs("proid") & "' target='_blank'>" & rs(0) & "</a></td>"
				 str=str & "<td class='splittd' style='text-align:center'>" & rs("salenum") & " " & rs(1) & "</td>"
				 str=str & "<td class='splittd' style='text-align:center'>￥" & formatnumber(rs("salemoney"),2,-1,-1) & "</td>"
				 str=str & "</tr>"
				 i=i+1
				 If I>=MaxPerPage Then Exit Do
			  rs.movenext
			  loop
		  End If
			  rs.close
			  set rs=nothing
		str=str &"</table>"
		response.write replace(str,"{$border}",0)
		
Call KS.ShowPage(totalput, MaxPerPage, "", CurrentPage,true,true)
%>
<br/><br/><br/>
<form name="form1" action="ShopStats.asp" method="post">
 <textarea name="content" style="display:none"><%=replace(str,"{$border}",1)%></textarea>
 <input type="hidden" name="action" value="export" />
 <input type="submit" class="button" value="将以上数据导出到Excel" />
</form>
<div class="attention">
		<font color=red><strong>说明：</strong><br/>
		1、这里统计到的数据不包括非确认及无效订单;<br/>
		2、您可以选择按时间段统计，这里每页显示50条记录;
		</font>
		</div>
<%
End Sub

Sub Custom()
%>			  
				 
				 <table width="99%" style="margin-top:10px" border="0" align="center" cellpadding="1" cellspacing="1" class="ctable">
					  <tr class="tdbg">
						<td height='25' class='clefttitle' colspan='4' style="text-align:left"><strong>会员购买率</strong> （会员购买率 = 会员有效订单数 ÷ 会员订单总数） </td>
					  </tr>
					  <tr class="tdbg">
						<td height="30" style="text-align:center">会员总数</td>
						<td height="30" style="text-align:center">会员有效订单数</td>
						<td height="30" style="text-align:center">会员订单总数</td>
						<td height="30" style="text-align:center">会员购买率 </td>
					  </tr>
					  <tr>
						<td height="30" style="text-align:center"><%
						Dim TotalUser:TotalUser=Conn.Execute("Select count(*) From KS_User")(0)
						Response.Write TotalUser
						%></td>
						<td height="30" style="text-align:center"><%
						Dim HasOrderUserTotal:HasOrderUserTotal=Conn.Execute("Select count(*) From KS_User Where UserName in(select username from ks_order where status<>0 and Status<>3)")(0)
						Response.Write HasOrderUserTotal%></td>
						<td height="30" style="text-align:center"><%
						Dim UserTotalOrder:UserTotalOrder=Conn.Execute("Select count(*) From KS_order Where UserName<>'游客'")(0)
						response.write UserTotalOrder
						%></td>
						<td height="30" style="text-align:center">
						<%
						 if HasOrderUserTotal<>0 and UserTotalOrder<>0 Then
						  Response.Write formatpercent(HasOrderUserTotal/UserTotalOrder,2)
						 else
						  response.write "0%"
						 end if
						%>
						</td>
					  </tr>
					</table>
					
				 <table width="99%" style="margin-top:10px" border="0" align="center" cellpadding="1" cellspacing="1" class="ctable">
					  <tr class="tdbg">
						<td height='25' class='clefttitle' colspan='4' style="text-align:left"><strong>每会员平均订单数及购物额</strong> （每会员订单数 = 会员订单总数 ÷ 会员总数） （每会员购物额 = 会员购物总额 ÷ 会员总数） </td>
					  </tr>
					  <tr class="tdbg">
						<td height="30" style="text-align:center">会员购物总额</td>
						<td height="30" style="text-align:center">每会员订单数</td>
						<td height="30" style="text-align:center">每会员购物额</td>
					  </tr>
					  <tr>
						<td height="30" align="center">￥<%
						Dim AllTotalMoney:AllTotalMoney=Conn.Execute("Select Sum(NoUseCouponMoney) From KS_Order where username<>'游客' and status<>0 and Status<>3")(0)
						if AllTotalMoney="" Or IsNull(AllTotalMoney) Then
						 response.write "0"
						Else
						 Response.Write AllTotalMoney
						End If
						%> 元</td>
						<td height="30" align="center">
						<%
						Dim AllUserOrder:AllUserOrder=Conn.Execute("Select count(*) From KS_Order where username<>'游客' and status<>0 and Status<>3")(0)
						If TotalUser<>0 and AllUserOrder<>0 Then
						 Response.Write AllUserOrder/TotalUser
						else
						Response.Write "0"
						end if%></td>
						<td height="30" align="center">
						￥<%
						 if AllTotalMoney<>0 and not isnull(AllTotalMoney) and TotalUser<>0 and not isnull(TotalUser) Then
						  response.write AllTotalMoney/TotalUser
						 else
						  response.write "0"
						 end if
						%>元</td>
						
					  </tr>
					</table>
					
					 <table width="99%" style="margin-top:10px" border="0" align="center" cellpadding="1" cellspacing="1" class="ctable">
					  <tr class="tdbg">
						<td height='25' class='clefttitle' colspan='4' style="text-align:left"><strong>匿名会员平均订单额及购物总额</strong> （匿名会员平均订单额 = 匿名会员购物总额 ÷ 匿名会员订单总数）  </td>
					  </tr>
					  <tr class="tdbg">
						<td height="30" style="text-align:center">匿名会员购物总额</td>
						<td height="30" style="text-align:center">匿名会员订单总数</td>
						<td height="30" style="text-align:center">匿名会员平均订单额</td>
					  </tr>
					  <tr>
						<td height="30" align="center">￥<%
						Dim AllNMTotalMoney:AllNMTotalMoney=Conn.Execute("Select Sum(NoUseCouponMoney) From KS_Order where username='游客' and status<>0 and Status<>3")(0)
						if AllNMTotalMoney="" Or IsNull(AllNMTotalMoney) Then
						 response.write "0"
						Else
						 Response.Write AllNMTotalMoney
						End If
						%> 元</td>
						<td height="30" align="center">
						<%
						Dim AllNMOrder:AllNMOrder=Conn.Execute("Select count(*) From KS_Order where username='游客' and status<>0 and Status<>3")(0)
						If AllNMOrder<>0 Then
						 Response.Write AllNMOrder
						else
						Response.Write "0"
						end if%></td>
						<td height="30" align="center">
						￥<%
						 if AllNMTotalMoney<>0 and not isnull(AllNMTotalMoney) and AllNMOrder<>0 and not isnull(AllNMOrder) Then
						  response.write AllNMTotalMoney/AllNMOrder
						 else
						  response.write "0"
						 end if
						%>元</td>
						
					  </tr>
					</table>
					
					<table width="99%" style="margin-top:10px" border="0" align="center" cellpadding="1" cellspacing="1" class="ctable">
					  <tr class="tdbg">
						<td height='25' class='clefttitle' colspan='4' style="text-align:left"><strong>综合统计</strong>  </td>
					  </tr>
					  <tr class="tdbg">
						<td height="30" style="text-align:center">总订单数 ／ 总购买金额</td>
						<td height="30" style="text-align:center">会员订单% ／非会员订单%　</td>
						<td height="30" style="text-align:center">会员购买金额% ／非会员购买金额%</td>
					  </tr>
					  <tr>
						<td height="30" align="center">
						<%
						Dim TotalOrder:TotalOrder=Conn.Execute("Select count(*) From KS_Order Where Status<>0 and Status<>3")(0)
						Dim TotalMoney:TotalMoney=Conn.Execute("Select sum(NoUseCouponMoney) From KS_Order Where Status<>0 and Status<>3")(0)
						Response.Write TotalOrder
						%>／￥<%=TotalMoney%> 元</td>
						<td height="30" align="center">
						<%
						 if AllUserOrder<>0 and TotalOrder<>0 then
						 response.write formatpercent(AllUserOrder/TotalOrder,2)
						 else
						 response.write "0%"
						 end if
						%>／
						<%
						if TotalOrder<>0 and AllNMOrder<>0 then
						 response.write formatpercent(AllNMOrder/TotalOrder,2)
						else
						 response.write "0%"
						end if
						%>
						</td>
						<td height="30" align="center">
						<%
						 if AllTotalMoney<>0 and TotalMoney<>0 Then
						   response.write formatpercent(AllTotalMoney/TotalMoney,2)
						 Else
						   response.write "0%"
						 end if
						 %>
						／
						 <%
						 if AllNMTotalMoney<>0 and TotalMoney<>0 Then
						   response.write formatpercent(AllNMTotalMoney/TotalMoney,2)
						 Else
						   response.write "0%"
						 end if
						
						%></td>
						
					  </tr>
					</table>
					
				<%
End Sub

Sub Order()
%>
         <table width="99%" style="margin-top:10px" border="0" align="center" cellpadding="1" cellspacing="1" class="ctable">
					  <tr class="tdbg">
						<td height='25' class='clefttitle' colspan='4' style="text-align:left"><strong>按时间段统计</strong> </td>
					  </tr>
					  <form name="myform" action="?action=Order" method="post">
					  <tr class="tdbg">
						<td height="30">&nbsp;&nbsp;开始日期<input name='BeginDate' type='text' id='BeginDate' value='<%=Year(Now) & "-" & Month(NOW) & "-1"%>' size='20'  class='textbox'>                 <a href='#' onClick="OpenThenSetValue('Include/DateDialog.asp',160,170,window,document.myform.BeginDate);document.myform.BeginDate.focus();"><img src='Images/date.gif' border='0' align='absmiddle' title='选择日期'></a>
						&nbsp;&nbsp;
						结束日期<input name='EndDate' type='text' id='EndDate' value='<%=formatdatetime(Now,2)%>' size='20'  class='textbox'>                 <a href='#' onClick="OpenThenSetValue('Include/DateDialog.asp',160,170,window,document.myform.EndDate);document.myform.EndDate.focus();"><img src='Images/date.gif' border='0' align='absmiddle' title='选择日期'></a> </td>
					  </tr>
					  <tr class="tdbg">
					   <td style="text-align:center">
					    <input class="button" type="submit" value=" 开 始 统 计 ">
					   </td>
					   </form>
					  </tr>
		</table>
<%
Dim Param:Param=" Where 1=1"
If KS.S("BeginDate")<>"" and IsDate(KS.S("BeginDate")) Then 
  If DataBaseType=1 Then
   Param=Param & " and InputTime>='" & KS.S("BeginDate") & "'"
  Else
   Param=Param & " and InputTime>=#" & KS.S("BeginDate") & "#"
  End if
End If
If KS.S("EndDate")<>"" and IsDate(KS.S("EndDate")) Then 
  If DataBaseType=1 Then
   Param=Param & " and InputTime<='" & DateAdd("d", 1,KS.S("EndDate")) & "'"
  Else
   Param=Param & " and InputTime<=#" & DateAdd("d", 1,KS.S("EndDate")) & "#"
  End if
End If

Dim WQR:WQR=KS.ChkCLng(Conn.Execute("Select count(*) From KS_Order " &Param & " and Status=0")(0))
Dim YQR:YQR=KS.ChkCLng(Conn.Execute("Select count(*) From KS_Order " &Param & " and Status=1")(0))
Dim YCJ:YCJ=KS.ChkCLng(Conn.Execute("Select count(*) From KS_Order " &Param & " and Status=2")(0))
Dim wx:wx=KS.ChkCLng(Conn.Execute("Select count(*) From KS_Order " &Param & " and Status=3")(0))
%>

 <table width="90%" cellspacing="0" cellpadding="3" id="order_circs-table">
      <tr>
        <td align="center">
                <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="650" HEIGHT="400" id="OrderGeneral" ALIGN="middle">
          <PARAM NAME="FlashVars" value="&dataXML=<graph caption='订单概况' decimalPrecision='2' showPercentageValues='0' showNames='1' showValues='1' showPercentageInLabel='0' pieYScale='45' pieBorderAlpha='40' pieFillAlpha='70' pieSliceDepth='15' pieRadius='100' outCnvBaseFontSize='13' baseFontSize='12'><set value='<%=YQR%>' name='已确认' color='FFCC33' /><set value='<%=YCJ%>' name='已成交' color='33FF66' /><set value='<%=WQR%>' name='未确认' color='FF6600'  /><set value='<%=Wx%>' name='无效订单' color='999999'  /></graph>">
          <PARAM NAME="movie" VALUE="../HSK_JS/pie3d.swf?chartWidth=650&chartHeight=400">
          <PARAM NAME="quality" VALUE="high">
          <PARAM NAME=bgcolor VALUE="#FFFFFF">
          <param name="wmode" value="opaque" />
          <EMBED src="../HSK_JS/pie3d.swf?chartWidth=650&chartHeight=400" FlashVars="&dataXML=<graph caption='订单概况' decimalPrecision='2' showPercentageValues='0' showNames='1' showValues='1' showPercentageInLabel='0' pieYScale='45' pieBorderAlpha='40' pieFillAlpha='70' pieSliceDepth='15' pieRadius='100' outCnvBaseFontSize='13' baseFontSize='12'><set value='<%=YQR%>' name='已确认' color='FFCC33' /><set value='<%=YCJ%>' name='已成交' color='33FF66' /><set value='<%=WQR%>' name='未确认' color='FF6600'  /><set value='<%=Wx%>' name='无效' color='999999'  /></graph>" quality="high" bgcolor="#FFFFFF" WIDTH="650" HEIGHT="400" wmode="opaque" NAME="OrderGeneral" ALIGN="middle" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
          </OBJECT>
                </td>
      </tr>
    </table>
<%
End Sub

Sub Sale
Dim K,Y,OrderTotal,OrderXmlStr,SalesTotal,SalesXmlStr
Dim StartYear:StartYear=KS.G("StartYear")
Dim EndYear:EndYear=KS.G("EndYear")
Dim StartMonth:StartMonth=KS.G("StartMonth")
Dim EndMonth:EndMonth=KS.G("EndMonth")
If Not IsNumeric(StartYear) Then StartYear=Year(Now)
If Not IsNumeric(EndYear) Then EndYear=Year(Now)
If Not Isnumeric(StartMonth) Then StartMonth=1
If Not IsNumeric(EndMonth) Then EndMonth=Month(Now)

If KS.G("saletype")="year" Then
	For Y=StartYear To EndYear
		 OrderTotal=Conn.Execute("Select Count(*) From KS_Order Where Year(inputtime)=" & Y)(0)
		 OrderXmlStr=OrderXmlStr & "<set label='" & Y & "年' value='" & OrderTotal & "' />"
		 OrderTotal=Conn.Execute("Select Sum(NoUseCouponMoney) From KS_Order Where status<>0 and Status<>3 and Year(inputtime)=" & Y)(0)
		 SalesXmlStr=SalesXmlStr & "<set label='" & Y & "年' value='" & OrderTotal & "' />"
	Next
Else
	For Y=StartYear To EndYear
		For K=StartMonth To 12
		 OrderTotal=Conn.Execute("Select Count(*) From KS_Order Where Year(inputtime)=" & Y & " and Month(inputtime)=" & K)(0)
		 OrderXmlStr=OrderXmlStr & "<set label='" & Y & "年" & Right("0" & K,2) & "月' value='" & OrderTotal & "' />"
		 OrderTotal=Conn.Execute("Select Sum(NoUseCouponMoney) From KS_Order Where status<>0 and Status<>3 and Year(inputtime)=" & Y & " and Month(inputtime)=" & K)(0)
		 SalesXmlStr=SalesXmlStr & "<set label='" & Y & "年" & Right("0" & K,2) & "月' value='" & OrderTotal & "' />"
			 If Cint(Y)=Cint(EndYear) And Cint(K)=Cint(EndMonth) Then Exit For
		Next
		If Y=EndYear And K=EndMonth Then Exit For
	Next
End If
%>

 <table width="99%" style="margin-top:10px" border="0" align="center" cellpadding="1" cellspacing="1" class="ctable">
					  <tr class="tdbg">
						<td height='25' class='clefttitle' colspan='4' style="text-align:left"><strong>按月查看走势</strong> </td>
					  </tr>
					  <form name="myform" action="?action=Sale" method="post">
					  <tr class="tdbg">
						<td height="30">&nbsp;&nbsp;
						<select name="StartYear">
						 <%
						  for k=year(now)-2 to year(Now)
						   if k=cint(startyear) then
						   response.write "<option  value=" & k & " selected>" & k & "</option>"
						   else
						   response.write "<option  value=" & k & ">" & k & "</option>"
						   end if
						  next
						 %>
						</select>年
						<select name="StartMonth">
						 <%
						  for k=1 to 12
						   if k=cint(startmonth) then
						   response.write "<option  value=" & k & " selected>" & k & "</option>"
						   else
						   response.write "<option  value=" & k & ">" & k & "</option>"
						   end if
						  next
						 %>
						</select>月
						至
						<select name="EndYear">
						 <%
						  for k=year(now)-2 to year(Now)
						   if k=cint(endyear) then
						   response.write "<option  value=" & k & " selected>" & k & "</option>"
						   else
						   response.write "<option  value=" & k & ">" & k & "</option>"
						   end if
						  next
						 %>
						</select>年
						<select name="EndMonth">
						 <%
						  for k=1 to 12
						   if k=cint(endmonth) then
						   response.write "<option  value=" & k & " selected>" & k & "</option>"
						   else
						   response.write "<option  value=" & k & ">" & k & "</option>"
						   end if
						  next
						 %>
						</select>月
						
						<input class="button" type="submit" value=" 查看走势 ">
						</td>
					  </tr>
					   </form>
		</table>
 <table width="99%" style="margin-top:10px" border="0" align="center" cellpadding="1" cellspacing="1" class="ctable">
					  <tr class="tdbg">
						<td height='25' class='clefttitle' colspan='4' style="text-align:left"><strong>按年查看走势</strong> </td>
					  </tr>
					  <form name="myform" action="?action=Sale" method="post">
					  <input type="hidden" name="saletype" value="year">
					  <tr class="tdbg">
						<td height="30">&nbsp;&nbsp;
						<select name="StartYear">
						 <%
						  for k=year(now)-5 to year(Now)
						   if k=cint(startyear) then
						   response.write "<option  value=" & k & " selected>" & k & "</option>"
						   else
						   response.write "<option  value=" & k & ">" & k & "</option>"
						   end if
						  next
						 %>
						</select>年
						至
						<select name="EndYear">
						 <%
						  for k=year(now)-5 to year(Now)
						   if k=cint(endyear) then
						   response.write "<option  value=" & k & " selected>" & k & "</option>"
						   else
						   response.write "<option  value=" & k & ">" & k & "</option>"
						   end if
						  next
						 %>
						</select>年
						
						
						<input class="button" type="submit" value=" 查看走势 ">
						</td>
					  </tr>
					   </form>
		</table>


   <div style="margin:10px;font-weight:Bold;color:#ff6600;font-size:14px">订单走势</div>
   <div id="tabbody-div">
      <!-- 订单数量 -->
      <table width="90%" id="order-table">
        <tr><td align="center">
          <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="665" height="420" id="FCColumn2" align="middle">
            <param NAME="movie" VALUE="../HSK_JS/column3d.swf?dataXML=<chart caption='' xAxisName='订单数(单位:个)' showValues='0' decimals='0' formatNumberScale='0'><%=OrderXmlStr%></chart>">
            <param NAME="quality" VALUE="high">
            <param NAME="bgcolor" VALUE="#FFFFFF">
            <embed src="../HSK_JS/column3d.swf?dataXML=<chart caption='' xAxisName='订单数(单位:个)' showValues='0' decimals='0' formatNumberScale='0'><%=OrderXmlStr%></chart>" quality="high" bgcolor="#FFFFFF"  width="665" height="420" name="FCColumn2" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
          </object>
        </td></tr>
      </table>

      <!-- 营业额 -->
	  <div style="margin:10px;font-weight:Bold;color:#ff6600;font-size:14px">销售额走势</div>
      <table width="90%" id="turnover-table">
        <tr><td align="center">
          <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="665" height="420" id="FCColumn2" align="middle">
            <param NAME="movie" VALUE="../HSK_JS/column3d.swf?dataXML=<chart caption='' xAxisName='营业额(单位:元)' showValues='0' decimals='0' formatNumberScale='0'><%=SalesXmlStr%></chart>">
            <param NAME="quality" VALUE="high">
            <param NAME="bgcolor" VALUE="#FFFFFF">
            <embed src="../HSK_JS/column3d.swf?dataXML=<chart caption='' xAxisName='营业额(单位:元)' showValues='0' decimals='0' formatNumberScale='0'><%=SalesXmlStr%></chart>" quality="high" bgcolor="#FFFFFF"  width="665" height="420" name="FCColumn2" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
          </object>
        </td></tr>
      </table>
    </div>
</div>
<%
End Sub

End Class
%> 
