<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Include/conn.asp" -->
<!--#include file="../Include/ConnDatabase.asp" -->
<!--#include file="../Include/NoHackSql.Asp" -->
<!--#include file="Siteinfo.asp" -->
<%
'=====================================
'天天企业网站管理系统  TianTianCMS
'天天网络科技工作室版权所有
'官方网站http://www.ip126.com
'技术支持论坛 http://bbs.ip126.com/
'QQ:530051328 mail:bbfhq@163.com
'=====================================
%>
<%call SiteInfo
headid=0
SeoTitle="Order Product"
%>
<!--#include file="Head.Asp" -->
<%
dim mMemID,mMemName,mGroupIdName,mRealName,mSex,mQuestion,mCompany,mAddress,mZipCode,mTelephone,mFax,mMobile,mUserqq,mEmail,mHomepage,mAddTime,mLoginTimes,mLastLoginTime,mLastLoginIP
dim Products,total,Quatity,Products_id,Products_num,amount,Payment_goods,freight,tax,strMth
if session("MemName")<>"" and session("MemLogin")="Succeed" then
call MemInfo()
else
  mSex="Male"
  mMemID=0
end if
%>
<TABLE width="960" border=0 align="center" cellPadding=0 cellSpacing=0 bgcolor="#FFFFFF">
  <TR>
    <TD height="5"></TD>
  </TR>
  <TR> 
    <TD height="172" ><table width="960" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td class="tdbg_left"  width="190" height="179" valign="top" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td height="34" class="title_left">&nbsp;&nbsp;&nbsp;<img src="../images/smallbook.jpg" width="10" height="10">&nbsp;&nbsp;Usre Login
                </td>
              </tr>
              <tr> 
                <td height="5"></td>
              </tr>
              <tr> 
                <td height="10"><table width="88%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr> 
                      <td> 

	<iframe src="login.asp"  frameborder="0" border="0px" scrolling="no" class="frame" height="120px" width="160px"></iframe>
                      </td>
                    </tr>
                  </table></td>
              </tr>
              <tr> 
                <td height="5"></td>
              </tr>
            </table>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td height="34" class="title_left">&nbsp;&nbsp;&nbsp;<img src="../images/smallbook.jpg" width="10" height="10">&nbsp;&nbsp;Product List</td>
              </tr>
              <tr> 
                <td height="5"></td>
              </tr>
              <tr> 
                <td height="10"><table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr> 
                      <td><%=ProductCategory(0)%></td>
                    </tr>
                  </table></td>
              </tr>
              <tr> 
                <td height="5"></td>
              </tr>
            </table> 
</td>
          <td width="6"></td>
          <td  valign="top"><table Class=border width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
              <tr> 
                <td height="206" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td class="title_right" height="32">&nbsp;&nbsp;&nbsp;<img src="../images/smallbook.jpg" width="10" height="10">&nbsp;Purchase products</td>
                    </tr>
					
                    
                  </table>
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <TR> 
          <TD width="453" height=28><%=WebLocationcp()%></TD>
              <TD width="102"> </TD>
            </TR>
            <TR> 
              <TD 
                  height=1 colspan="2" background=images/naBialym.gif></TD>
            </TR>
 <TR> 
 <TD height=42 colspan="2" align="left"> 		  
<table cellspacing="0" cellpadding="0" width="90%" border="0" heihgt="" align="center" style="margin-left:20px;">
		  <%If shopping=0 Then
		  response.write "I'm sorry, not open shopping function."
		  response.End
		  End If
		  
          '找出送货方式发货费用		  
	      If request("deliveryid")="" Then
	      session("deliveryid")=1
		  else
		  session("deliveryid")=request("deliveryid")
		  End if		     
      set rs = server.createobject("adodb.recordset")
      rs.open "select * from TianTianCMS_Delivery where id="&int(session("deliveryid")),conn,1,1
	  if rs.eof and rs.bof then
	  strMth = "The way has been deleted, please choose again"
	  LngMth = 0
	  Else
	  strMth = rs("subject")'发货方式名称
	  LngMth = rs("fee")'发货费
      end If      
      Call CloseRs(rs)

      '是否要发票
	      If request("invoice")="" Then
	      session("invoice")=0
		  else
		  session("invoice")=request("invoice")
		  End If		  %>
    <tbody>
        <tr>
          <td height="18">&nbsp;</td>
        </tr>
        <tr>
          <td><% call ProductList() %></td>
        </tr>
        <tr>
          <td><table width="98%" border="0" align="center" cellpadding="3" cellspacing="5">
              <form action="Pay.asp?MemberID=<%=mMemID%>&deliveryid=<%=session("deliveryid")%>&invoice=<%=session("invoice")%>" method="post" name="formBuy" id="formBuy">
                <tr>
                  <td width="200" align="right">Title:</td>
                  <td><input name="OrderName" type="text" id="OrderName" value="Order product" size="40" maxlength="100" />
                    <font color="red">*</font></td>
                </tr>
                <tr>
                  <td align="right">Comments:</td>
                  <td>
                    <textarea name="Remark" cols="40" rows="8" id="Remark" style="border:1px solid #99CCFF"></textarea></td>
                </tr>
                <tr>
                  <td align="right">Consignee:</td>
                  <td><input name="RealName" type="text" id="RealName" value="<%=mRealName%>" size="20" maxlength="50" />
                    <font color="red">*</font></td>
                </tr>
                <tr>
                  <td align="right">Sex:</td>
                  <td><input name="Sex" type="radio" value="Male" class="inputnoborder" <%if mSex="先生" then response.write ("checked")%> />
                    M
                    <input type="radio" name="Sex" value="Ms" class="inputnoborder" <%if mSex="女士" then response.write ("checked")%> />
                    F <font color="red">*</font></td></tr>
                <tr>
                  <td align="right">Company/Name:</td>
                  <td><input name="Company" type="text" id="Company" value="<%=mCompany%>" size="40" maxlength="100" />
                    （Invoice looked up to）</td>
                </tr>
                <tr>
                  <td align="right">Address:</td>
                  <td><input name="Address" type="text" id="Address" value="<%=mAddress%>" size="40" maxlength="100" />
                    <font color="red">*</font></td>
                </tr>
                <tr>
                  <td align="right">Postal Code:</td>
                  <td><input name="ZipCode" type="text" id="ZipCode" value="<%=mZipCode%>" size="20" maxlength="20" onKeyUp="if(isNaN(value)){alert('Only allow you to enter Numbers.');value='';}"/>
                  <font color="red">*</font></td>
                </tr>
                <tr>
                  <td align="right">Mobile:</td>
                  <td><input name="Mobile" type="text" id="Mobile" value="<%=mMobile%>" size="20" maxlength="50" onKeyUp="if(isNaN(value)){alert('Only allow you to enter Numbers.');value='';}"/>  <font color="red">*</font> （Contact phone number and mobile phone can't At the same time for empty.）</td>
                </tr>
                <tr>
                  <td align="right">Tel:</td>
                  <td><input name="Telephone" type="text" id="Telephone" value="<%=mTelephone%>" size="20" maxlength="50" onKeyUp="if(isNaN(value)){alert('Only allow you to enter Numbers.');value='';}"/></td>
                </tr>

                <tr>
                  <td align="right">Fax:</td>
                  <td><input name="Fax" type="text" id="Fax" value="<%=mFax%>" size="20" maxlength="50" onKeyUp="if(isNaN(value)){alert('Only allow you to enter Numbers.');value='';}"/>
                  </td>
                </tr>
                <tr>
                  <td align="right">QQ：</td>
                  <td><input name="userqq" type="text" id="userqq" value="<%=muserqq%>" size="30" maxlength="50" />
                    </td>
                </tr>
                <tr>
                  <td align="right">Email:</td>
                  <td><input name="Email" type="text" id="Email" value="<%=mEmail%>" size="30" maxlength="50" />
                  </td>
                </tr>
                <tr>
                  <td align="right">&nbsp;</td>
                  <td><input name="Submit" type="submit" value="To generate orders" />&nbsp;&nbsp;&nbsp;<a href="javascript:window.close()">Continue to choose and buy</a></td>
                </tr>
                      <input type="hidden" name="Products" value="<%=Products%>" />
				      <input type="hidden" name="total" value="<%=total%>" />
					  <input type="hidden" name="Products_id" value="<%=Products_id%>" />
					  <input type="hidden" name="Products_num" value="<%=Products_num%>" />
					  <input type="hidden" name="amount" value="<%=amount%>" />
					  <input type="hidden" name="Payment_goods" value="<%=Payment_goods%>" />
					  <input type="hidden" name="freight" value="<%=LngMth%>" />
					  <input type="hidden" name="tax" value="<%=tax%>" />
					  <input type="hidden" name="strMth" value="<%=strMth%>" />
              </form>
            </table></td>
        </tr>
        <tr>
          <td height="20">&nbsp;</td>
        </tr>
      </table>
</td>
        </tr>
        <tr>
          <td height="20">&nbsp;</td>
        </tr>
      </table>		
		</TD>
            </TR>
           
                  </table></td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
<!--#include file="Foot.Asp"-->
<%

function WebLocationcp()
      If ISHTML =1 Then 
	  WebLocation="&nbsp;<a href=""index."&HTMLName&""">Home</a>&gt;&gt;<a href=""html/"&ProSortName&"."&HTMLName&""">Product Center</a>&gt;&gt;Orders"&VbCrLf
	  Else
	  WebLocation="&nbsp;<a href=""index.asp"">Home</a>&gt;&gt;<a href=""ProductList.asp"">Product Center</a>&gt;&gt;Orders"&VbCrLf
	  End if
end Function


function NoList()
  if request("UpdateOrder")="Up_date" then
    Session("NoList")=""
  end if
  dim ProductNo,NoArray,i
  if trim(request("ProductNo"))<>"" then ProductNo=trim(request("ProductNo"))&","
  if session("NoList")="" and trim(request("ProductNo"))="" then
    NoList=""
    exit function
  end if
  if instr(ProductNo,",")>0 then
  	NoArray=split(ProductNo, ",")
  	for i = 0 to ubound(NoArray)
      if not instr(session("NoList"),NoArray(i)&",")>0 then session("NoList")=session("NoList")&NoArray(i)&","
  	next
  end if
  for i = 0 to ubound(split(session("NoList"), ","))
    NoList=NoList&"'"&trim(split(session("NoList"),",")(i))&"',"
  next
  NoList=left(NoList,len(NoList)-4)
end Function

function ProductList()
Dim price
If session("GroupLevel")="" Or session("GroupLevel")=0 Then price="N_price"
If session("GroupLevel")=1 Then price="M_price"
If session("GroupLevel")=2 Then price="V_price"
If session("GroupLevel")=3 Then price="P_price"
	Response.Write "<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"">"&VbCrLf
	Response.Write "  <form action=""ProductBuy.asp"" method=""POST"" name=""check"">"&VbCrLf
	Response.Write "    <tr>"&VbCrLf
	Response.Write "      <td height=""28"" colspan=""4"" style=""background:url(Images/bg2.gif) repeat-x left bottom;"">The product that you make choice of purchase：</td>"&VbCrLf
	Response.Write "    </tr>"&VbCrLf
if Nolist()="" then
	Response.Write "    <tr>"&VbCrLf
	Response.Write "      <td height=""28"" colspan=""4"" align=""center"">No Information</td>"&VbCrLf
	Response.Write "    </tr>"&VbCrLf
Else
    Response.Write "   <table border=""1"" cellpadding=""0"" cellspacing=""0"" bordercolor=""#ADAED6"" align=""center""  width=""100%""><tr>"&VbCrLf
    Response.Write "    <td>Select</td><td width=""500"">Product Name</td><td width=""150"">Product No</td><td width=""30"">number</td><td width=""100"">unit price("&Tian47&")</td><td width=""100"">combined("&Tian47&")</td>"&VbCrLf
    Response.Write "    </tr>"&VbCrLf
	dim rs,sql
	set rs = server.createobject("adodb.recordset")
	sql="select * from TianTianCMS_Products where ProductNo in ("&NoList()&") order by id"
	rs.open sql,conn,1,1
	total=0
	while not rs.eof

Quatity = CInt( Request.Form( "Q_" & rs("ID")) )
If Quatity <= 0 Then 
Quatity = CInt( Session(rs("ID")) )
If Quatity <= 0 Then Quatity = 1
End If
Session(rs("ID")) = Quatity
IF rs("Stock") < Quatity Then
Quatity = 1
Session(rs("ID")) = 1
response.write "<script language=javascript>alert('sorry，"&rs("ProductName"&Language&"")&"For the time being for inventory is not enough, please come back later to buy the goods.');window.close();</script>" 
Call CloseRs(rs)
Call CloseDB(conn)
response.End()
End If

	If ISHTML = 1 Then
		AutoLink = "html/"&ProName&""&Separated&""&rs("ID")&"."&HTMLName&""
	Else
		AutoLink = "ProductShow.Asp?ID="&rs("ID")&""
	End If
	Response.Write "    <tr>"&VbCrLf
	Response.Write "      <td width=""50"" height=""28"" style=""background:url(Images/bg2.gif) repeat-x left bottom;""><input type=""CheckBox"" name=""ProductNo"" value="""&rs("ProductNo")&""" class=""inputnoborder"" Checked></td>"&VbCrLf
	Response.Write "      <td  width=""500"" style=""background:url(Images/bg2.gif) repeat-x left bottom;""><a href="""&AutoLink&""" title="""&rs("ProductName"&Language&"")&""">"&rs("ProductName"&Language&"")&"</td>"&VbCrLf
	Response.Write "<td width=""100"" style=""background:url(Images/bg2.gif) repeat-x left bottom;"">["&rs("ProductNo")&"]</a></td>"&VbCrLf
    Response.Write "<td><input type=""Text"" name="""&"Q_" & rs("ID")&""" value="""&Quatity&""" size=""4"" class=""form"" onKeyUp=""if(isNaN(value)){alert('Only allow you to enter Numbers.');value='';}""></td>"&VbCrLf
	Response.Write "<td width=""150"" style=""background:url(Images/bg2.gif) repeat-x left bottom;"">"&Round(rs(""&price&""),2)&"</td>"&VbCrLf
	Response.Write "<td width=""150"" style=""background:url(Images/bg2.gif) repeat-x left bottom;"">"&Round(rs(""&price&"")*Quatity,2)&"</td>"&VbCrLf
	Response.Write "    </tr>"&VbCrLf
	Products=Products&"ID:"&rs("id")&" No:"&rs("ProductNo")&" Name:"&rs("ProductName"&Language)&" Num:"&Quatity&" unit price:"&Round(rs(""&price&""),2)&""&Tian47&" amount:"&Round(rs(""&price&"")*Quatity,2)&""&Tian47&"<br>"
	total=Round(total+rs(""&price&"")*Quatity,2)'总计金额
	Products_id=Products_id&"|"&rs("id")'销售商品ID集
	Products_num=Products_num&"|"&Quatity'销售商品数量集
	amount=amount&"|"&Round(rs(""&price&"")*Quatity,2)'销售商品金额
	rs.movenext
    Wend
	Products=Products&"Total amount of payment for goods："&total&" "&Tian47&"<br>"
	Response.Write "    <tr>"&VbCrLf
	Response.Write "      <td width=""50"" height=""28"" style=""background:url(Images/bg2.gif) repeat-x left bottom;"" colspan=""5"">A total of </td>"&VbCrLf
	Response.Write "<td width=""150"" style=""background:url(Images/bg2.gif) repeat-x left bottom;"">"&total&"</td>"&VbCrLf
	Response.Write "    </tr>"&VbCrLf
	
		Response.Write "    <tr>"&VbCrLf
	Response.Write "      <td width=""50"" height=""28"" style=""background:url(Images/bg2.gif) repeat-x left bottom;"" colspan=""5"">The freight</td>"&VbCrLf
	Response.Write "<td width=""150"" style=""background:url(Images/bg2.gif) repeat-x left bottom;"">"&strMth&"－"&LngMth&"yuan</td>"&VbCrLf
	Response.Write "    </tr>"&VbCrLf 
	Response.Write "    <tr>"&VbCrLf
	Response.Write "      <td width=""50"" height=""28"" style=""background:url(Images/bg2.gif) repeat-x left bottom;"" colspan=""5"">Tax invoice("&taxrate&"%)</td>"&VbCrLf
	Response.Write "<td width=""150"" style=""background:url(Images/bg2.gif) repeat-x left bottom;"">"
	If session("invoice")=1 Then
	Response.Write ""&Formatnumber((taxrate*(total+LngMth)),2,-1,-1,0)
	tax=Formatnumber((taxrate*(total+LngMth)),2,-1,-1,0)
	else
	Response.Write "0"
	tax=0
	End if
	Response.Write " yuan</td>"&VbCrLf
	Response.Write "    </tr>"&VbCrLf
	Response.Write "    <tr>"&VbCrLf
	Response.Write "      <td width=""50"" height=""28"" style=""background:url(Images/bg2.gif) repeat-x left bottom;"" colspan=""5"">The accounts payable</td>"&VbCrLf
	Response.Write "<td width=""150"" style=""background:url(Images/bg2.gif) repeat-x left bottom;"">"&Formatnumber((total+LngMth+tax),2,-1,-1,0)&"yuan</td>"&VbCrLf
	Payment_goods=total'货款总额
	total=total+LngMth+tax'应付款总额发送给下页
	Response.Write "    </tr>"&VbCrLf 	
	Response.Write "    </table><tr>"&VbCrLf
	Response.Write "      <td colspan=""2"" height=""35"">The delivery way:"	
	      set rs3=server.CreateObject("adodb.recordset")
          rs3.Open "select * from TianTianCMS_Delivery where methord=0 order by deliveryidorder",conn,1,1
          response.Write "<select name=deliveryid size=1 id=deliveryid>"
		  response.Write "<option value="""">Choose the delivery way</option>"
          do while not rs3.EOF
          response.Write "<option value="&rs3("id")		  
          if rs3("id")=int(session("deliveryid")) then 
          response.Write " selected>"
          else
          response.Write ">"
          end if
          response.Write ""&trim(rs3("subject"))&"-"&rs3("fee")&"yuan</option>"
          rs3.MoveNext
          loop
          response.Write "</select>"
          rs3.Close
          set rs3=Nothing

          response.Write "&nbsp;&nbsp;&nbsp;&nbsp;invoice:<select name=invoice size=1 id=invoice>"
		  response.Write "<option value="""">Invoice option</option>"
          response.Write "<option value=""1"""		  
          if int(session("invoice"))=1 then 
          response.Write " selected>Need to be </option>"
          else
          response.Write ">Need to be </option>"
          end If
          response.Write "<option value=""0"""		  
          if int(session("invoice"))=0 then 
          response.Write " selected>Don't need</option>"
          else
          response.Write ">Don't need</option>"
          end if
          response.Write "</select>"

	Response.Write " &nbsp;&nbsp;&nbsp;&nbsp;<input type=""submit"" name=""UpdateOrder"" value=""Up_date"">&nbsp;&nbsp;&nbsp;<a href=""javascript:window.close()"">Continue to choose and buy</a></td>"&VbCrLf
	Response.Write "    </tr>"&VbCrLf
    rs.close
    set rs=nothing
end if
	Response.Write "  </form>"&VbCrLf
	Response.Write "</table>"&VbCrLf
end function
%>
