<!-- #include file="include/config.asp" -->
<%
tit="订单浏览"
dim otype:otype=trim(request.querystring("type"))

call web_head(0,0,0,0,0)
call shop_load()
'----------------------------左边 开始----------------------------
call shop_left()
call shop_left_nsort(0)
call shop_top(10,10)
'----------------------------左边 结束----------------------------
call web_center(0)
'----------------------------中间 开始----------------------------
select case otype
case "emoney"
  call emoney_order_view()
case else
  call shop_order_view()
end select
'----------------------------中间 结束----------------------------
call shop_end()
call web_end(0,0)

sub shop_order_view()
  dim id,ordernum,isuser,username,nname,carry_price,tmp1
  ordernum=joekoe_cms.code_form(request.querystring("ordernum"))
  if ordernum="" then
    response.write vbcrlf&joekoe_cms.js_put("alert('订单号为空！');location.href='order.asp';",1)
    exit sub
  end if
  sql="select top 1 * from shop_orders where ordernum='"&ordernum&"'"
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    rs.close
    response.write vbcrlf&joekoe_cms.js_put("alert('订单号（"&ordernum&"）不存在！');location.href='order.asp';",1)
    exit sub
  end if
  id=rs("id")
  isuser=rs("isuser")
  username=rs("username")
  carry_price=rs("carry_price")
  if isuser then
    if login_username<>username then
      rs.close
      response.write vbcrlf&joekoe_cms.js_put("alert('该订单只能由提交的登陆用户才可以浏览！');location.href='order.asp';",1)
      exit sub
    end if
  end if

 tmp1=vbcrlf&"<table cellspacing=1 cellpadding=4 class=table>" & _
       vbcrlf&"<tr class=bg_td>" & _
       vbcrlf&"<td "&dd1&">付款方式：</td>" & _
       vbcrlf&"<td "&dd2&">"&rs("payment")&"</td>" & _
       vbcrlf&"</tr>" & _
       vbcrlf&"<tr class=bg_td>" & _
       vbcrlf&"<td>运送方式：</td>" & _
       vbcrlf&"<td>"&rs("carry")&"&nbsp;（"
  if int(carry_price)>0 then
    tmp1=tmp1&"加"&carry_price&web_dim(45)
  else
    tmp1=tmp1&"免费"
  end if
    tmp1=tmp1&"）</td>" & _
       vbcrlf&"</tr>" & _
       vbcrlf&"<tr class=bg_td>" & _
       vbcrlf&"<td>订单总金额：</td>" & _
       vbcrlf&"<td><font class=red>"&fm_price(rs("prices"),1)&"</font>&nbsp;"&web_dim(45)&"</td>" & _
       vbcrlf&"</tr>" & _
       vbcrlf&"<tr class=trz>" & _
       vbcrlf&"<td>客户姓名：</td>" & _
       vbcrlf&"<td>"&rs("nname")&"</td>" & _
       vbcrlf&"</tr>" & _
       vbcrlf&"<tr class=trz>" & _
       vbcrlf&"<td>客户地址：</td>" & _
       vbcrlf&"<td>"&rs("address")&"</td>" & _
       vbcrlf&"</tr>" & _
       vbcrlf&"<tr class=trz>" & _
       vbcrlf&"<td>邮政编码：</td>" & _
       vbcrlf&"<td>"&rs("code")&"</td>" & _
       vbcrlf&"</tr>" & _
       vbcrlf&"<tr class=trz>" & _
       vbcrlf&"<td>联系电话：</td>" & _
       vbcrlf&"<td>"&rs("phone")&"</td>" & _
       vbcrlf&"</tr>" & _
       vbcrlf&"<tr class=trz>" & _
       vbcrlf&"<td>电子信箱：</td>" & _
       vbcrlf&"<td>"&rs("email")&"</td>" & _
       vbcrlf&"</tr>" & _
       vbcrlf&"<tr class=trz>" & _
       vbcrlf&"<td>备注信息：</td>" & _
       vbcrlf&"<td>" & _
       vbcrlf&"  <table border=0 width='100%' class=tf>" & _
       vbcrlf&"  <tr><td class=bw>"&joekoe_cms.code_html(rs("remark"),2,0)&"</td></tr>" & _
       vbcrlf&"  </table>" & _
       vbcrlf&"</td>" & _
       vbcrlf&"</tr>" & _
       vbcrlf&"<tr class=bg_td>" & _
       vbcrlf&"<td>上次处理时间：</td>" & _
       vbcrlf&"<td>"&rs("dis_tim")&"</td>" & _
       vbcrlf&"</tr>" & _
       vbcrlf&"<tr class=bg_td>" & _
       vbcrlf&"<td>处理信息：</td>" & _
       vbcrlf&"<td>" & _
       vbcrlf&"  <table border=0 width='100%' class=tf>" & _
       vbcrlf&"  <tr><td class=bw>"&joekoe_cms.code_html(rs("dis_remark"),2,0)&"</td></tr>" & _
       vbcrlf&"  </table>" & _
       vbcrlf&"</td>" & _
       vbcrlf&"</tr>" & _
       vbcrlf&"</table>"
  rs.close
  call shop_center_table(tit,tmp1,1,0)
  call shop_order_product(id)
end sub

sub shop_order_product(oid)
  dim ssum,nid,nnum,price,price_now,discount,name,tmp1
  ssum=0
  tmp1=vbcrlf&"<table cellspacing=1 cellpadding=4 class=table>" & _
       vbcrlf&"<tr><td class=bg_td colspan=7 height=30 align=center><font class=red>以下是您所选购的"&web_dim(44)&"清单</font></td></tr>" & _
       vbcrlf&"<tr align=center>" & _
       vbcrlf&"<td width='7%' class=trs>序号</td>" & _
       vbcrlf&"<td width='34%' class=trs>"&web_dim(44)&"名称</td>" & _
       vbcrlf&"<td width='18%' class=trs>"&web_dim(44)&"编号</td>" & _
       vbcrlf&"<td width='7%' class=trs>数量</td>" & _
       vbcrlf&"<td width='13%' class=trs>原价("&web_dim(45)&")</td>" & _
       vbcrlf&"<td width='8%' class=trs>折扣</td>" & _
       vbcrlf&"<td width='13%' class=trs>购买("&web_dim(45)&")</td>" & _
       vbcrlf&"</tr>"
  sql="select * from shop_oorders where oid="&oid
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    nid=rs("pid")
    nnum=rs("num")
    name=rs("name")
    price=fm_price(rs("price"),1)
    discount=rs("discount")
    price_now=fm_price(price*(discount/100),1)
    discount=fm_discount(discount)
    ssum=ssum+price_now*nnum
    tmp1=tmp1&vbcrlf&"<tr class=bg_td align=center>" & _
         vbcrlf&"<td>"&i+1&"</td>" & _
         vbcrlf&"<td align=left><a href='###' alt='点击浏览"&web_dim(44)&"详细信息'onclick=""javascript:open_view('view.asp?id="&nid&"',1);"">"&name&"</a></td>" & _
         vbcrlf&"<td align=left>"&rs("serial")&"</td>" & _
         vbcrlf&"<td>"&nnum&"</td>" & _
         vbcrlf&"<td align=right>"&price&"</td>" & _
         vbcrlf&"<td>"
        if discount=fm_discount(100) then
          tmp1=tmp1&"<font class=gray>"&discount&"</font>"
        else
          tmp1=tmp1&"<font class=red2>"&discount&"</font>"
        end if
    tmp1=tmp1&vbcrlf&"</td>" & _
         vbcrlf&"<td align=right><font class=blue>"&price_now&"</font></td>" & _
         vbcrlf&"</tr>" & _
    rs.movenext
  loop
  rs.close
tmp1=tmp1&vbcrlf&"<tr class=trz><td colspan=7 height=30 align=right>"&"您所选购的"&web_dim(44)&"总的有效金额：<font class=red>"&fm_price(ssum,1)&"</font>&nbsp;"&web_dim(45)&"&nbsp;</td></tr>" & _
          vbcrlf&"</table>"
  call shop_center_table(tit,tmp1,1,0)
end sub

sub emoney_order_view()
  dim id,ordernum,isuser,username,nname,pid,name,serial,num,emoney,ptim,emoneys,tmp1,nid
  ordernum=joekoe_cms.code_form(request.querystring("ordernum"))
  if ordernum="" then
    response.write vbcrlf&"alert('订单号为空！');location.href='order.asp';"
    exit sub
  end if
  sql="select top 1 * from shop_emoney_notes where ordernum='"&ordernum&"'"
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    rs.close
    response.write vbcrlf&"alert('订单号（"&ordernum&"）不存在！');location.href='order.asp';"
    exit sub
  end if
  id=rs("id")
  username=rs("username")
  pid=rs("pid")
  name=rs("name")
  serial=rs("serial")
  num=rs("num")
  emoney=rs("emoney")
  ptim=rs("tim")
  emoneys=rs("emoneys")
  if login_username<>username then
    rs.close
    response.write vbcrlf&"alert('该订单只能由提交的登陆用户才可以浏览！');location.href='order.asp';"
    exit sub
  end if

tmp1=vbcrlf&"<table cellspacing=1 cellpadding=4 class=table>" & _
     vbcrlf&"<tr class=bg_td>" & _
     vbcrlf&"<td width='20%'>付款方式：</td>" & _
     vbcrlf&"<td width='80%'><font class=red2><b>"&joekoe_cms.web_unit&"</b></font>&nbsp;支付</td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=trz>" & _
     vbcrlf&"<td>名称：</td>" & _
     vbcrlf&"<td><a href='###' alt='点击浏览"&web_dim(44)&"详细信息'onclick=""javascript:open_view('view.asp?id="&nid&"',1);"">"&name&"</a></td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=trz>" & _
     vbcrlf&"<td>编号：</td>" & _
     vbcrlf&"<td>"&rs("serial")&"</td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=bg_td>" & _
     vbcrlf&"<td>单价：</td>" & _
     vbcrlf&"<td><font class=red2>"&emoney&"</font> "&joekoe_cms.web_unit&"　购买数量：<font class=red>"&num&"</font></td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=bg_td>" & _
     vbcrlf&"<td>订单总"&joekoe_cms.web_unit&"：</td>" & _
     vbcrlf&"<td><font class=red2><b>"&rs("emoney")&"</b></font>&nbsp;"&joekoe_cms.web_unit&"</td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=bg_td>" & _
     vbcrlf&"<td>购买时间：</td>" & _
     vbcrlf&"<td>"&joekoe_cms.time_type(ptim,2)&"</td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=trz>" & _
     vbcrlf&"<td>客户姓名：</td>" & _
     vbcrlf&"<td>"&rs("nname")&"</td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=trz>" & _
     vbcrlf&"<td>客户地址：</td>" & _
     vbcrlf&"<td>"&rs("address")&"</td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=trz>" & _
     vbcrlf&"<td>邮政编码：</td>" & _
     vbcrlf&"<td>"&rs("code")&"</td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=trz>" & _
     vbcrlf&"<td>联系电话：</td>" & _
     vbcrlf&"<td>"&rs("phone")&"</td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=trz>" & _
     vbcrlf&"<td>电子信箱：</td>" & _
     vbcrlf&"<td>"&rs("email")&"</td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=trz>" & _
     vbcrlf&"<td>备注信息：</td>" & _
     vbcrlf&"<td>" & _
     vbcrlf&"  <table border=0 width='100%' class=tf>" & _
     vbcrlf&"  <tr><td class=bw>"&joekoe_cms.code_html(rs("remark"),2,0)&"</td></tr>" & _
     vbcrlf&"  </table>" & _
     vbcrlf&"</td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=bg_td>" & _
     vbcrlf&"<td>上次处理时间：</td>" & _
     vbcrlf&"<td>"&rs("dis_tim")&"</td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=bg_td>" & _
     vbcrlf&"<td>处理信息：</td>" & _
     vbcrlf&"<td>" & _
     vbcrlf&"  <table border=0 width='100%' class=tf>" & _
     vbcrlf&"  <tr><td class=bw>"&joekoe_cms.code_html(rs("dis_remark"),2,0)&"</td></tr>" & _
     vbcrlf&"  </table>" & _
     vbcrlf&"</td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"</table>"
   rs.close
  call shop_center_table(tit,tmp1,1,0)
  call shop_emoney_notes(id)
end sub

sub shop_emoney_notes(id)
  dim ssum,nid,name,nnum,emoney,emoneys,tmp1,serial
  ssum=0
  sql="select * from shop_emoney_notes where id="&id
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    nid=rs("pid")
    nnum=rs("num")
	serial=rs("serial")
    name=rs("name")
	emoney=rs("emoney")
	emoneys=rs("emoneys")
    rs.movenext
  loop
  rs.close
 tmp1=vbcrlf&"<table cellspacing=1 cellpadding=4 class=table>" & _
     vbcrlf&"<tr class=bg><td colspan=7 height=30 align=center><font class=red>以下是您所选购的"&web_dim(44)&"清单</font></td></tr>" & _
     vbcrlf&"<tr height=22 align=center>" & _
     vbcrlf&"<td width='10%' class=trs>序号</td>" & _
     vbcrlf&"<td width='20%' class=trs>"&web_dim(44)&"名称</td>" & _
     vbcrlf&"<td width='20%' class=trs>"&web_dim(44)&"编号</td>" & _
     vbcrlf&"<td width='10%' class=trs>数量</td>" & _
     vbcrlf&"<td width='20%' class=trs>原价（"&joekoe_cms.web_unit&"）</td>" & _
     vbcrlf&"<td width='20%' class=trs>购买（"&joekoe_cms.web_unit&"）</td>" & _
     vbcrlf&"</tr>" & _
	 vbcrlf&"<tr class=bg_td align=center>" & _
     vbcrlf&"<td>"&i+1&"</td>" & _
     vbcrlf&"<td align=center><a href='###' alt='点击浏览"&web_dim(44)&"详细信息'onclick=""javascript:open_view('view.asp?id="&nid&"',1);"">"&name&"</a></td>" & _
     vbcrlf&"<td align=center>"&serial&"</td>" & _
     vbcrlf&"<td>"&nnum&"</td>" & _
     vbcrlf&"<td align=center>"&emoney&"</td>" & _
     vbcrlf&"<td align=center>"&emoneys&"</td>" & _
     vbcrlf&"</tr>" & _
     vbcrlf&"<tr class=trz><td colspan=7 height=30 align=right>"&"您所选购的"&web_dim(44)&"总的有效金额：<font class=red>"&emoneys&"</font>&nbsp;"&joekoe_cms.web_unit&"&nbsp;</td></tr>" & _
     vbcrlf&"</table>"
call shop_center_table(tit,tmp1,1,0)
end sub
%>