<!-- #include file="include/admin_onlogin.asp" -->
<!-- #include file="include/joekoe_pay.asp" -->
<%
'****************************************************
' 咪咪娱乐社区 2006V4.0      Power by www.mimi88.cn
' Email: 556248@qq.com  , master@szvsun.com
' Web: http://www.mimi88.cn
' Copyright (C) 2006 www.mimi88.cn All Rights Reserved.
'****************************************************
dim types
types=trim(request.querystring("types"))
if cstr(types)<>"1" and cstr(types)<>"5" then types="0"
if jk_mod="all" then types=""
index_url="shop"
call admin_master(1,0)
data_name="shop_orders"
tit_fir="订单"
tit="订单管理"
call admin_header(0,0)
%>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a href='?types=0'<%if cstr(types)="0" then response.write " class=red"%>>未处理<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?types=1'<%if cstr(types)="1" then response.write " class=red"%>>有问题<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?types=5'<%if cstr(types)="5" then response.write " class=red"%>>已处理<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?jk_mod=all'<%if jk_mod="all" then response.write " class=red"%>>所有<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='admin_shop_emoney_order.asp'><%response.write joekoe_cms.web_unit&"支付"&tit_fir%></a></td>
  </tr>
  </table>
</td></tr>
<tr><td colspan=2 align=center>
  <table border=0 cellspacing=0 cellpadding=2>
  <form action='?' method=get>
  <input type=hidden name=jk_mod value='search'>
  <tr>
  <td>搜索（<%response.write tit_fir%>） 关键字：</td>
  <td><input type=text name=keyword value='<%response.write trim(request.querystring("keyword"))%>' size=15 maxlength=20></td>
  <td><select name=sea_type size=1>
  <option value='ordernum'>按订单号</option>
  <option value='username'>按注册用户</option>
  <option value='nname'>按真实姓名</option>
  </select></td>
  <td><select name=sea_term size=1><option value='all'>满足所有条件</option><option value='only'>满足一个条件</option></select></td>
  <td><input type=submit value='搜索'></td>
  </tr>
  </form>
  </table>
</td></tr>
</table>
<%
call admin_table(1)

if action="handle" then call joekoe_chk_handle()

select case action
case "view"
  call joekoe_chk_view()
case else
  call joekoe_chk_main()
end select

call admin_ender(1)

sub joekoe_chk_handle()
  dim sel_type,seltype,sel_id,hdim,hnum,hid,hi,htype,hintegral
  htype=1
  sel_type=trim(request.form("sel_type"))
  select case sel_type
  case "删除"
    seltype="delete"
  case else
    sel_type=""
    seltype=""
  end select
  if joekoe_cms.post_chk()=false or seltype="" then
    exit sub
  end if
  hintegral=mp_integral()
  sel_id=trim(request.form("sel_id"))
  sel_id=replace(sel_id," ","")
  hdim=split(sel_id,",")
  hnum=ubound(hdim)
  select case seltype
  case "delete"
    for hi=0 to hnum
      hid=hdim(hi)
      if isnumeric(hid) then
        call joekoe_cms.exec("delete from shop_oorders where oid="&hid,0)
        call joekoe_cms.exec("delete from "&data_name&" where id="&hid,0)
      end if
    next
  end select
  erase hdim
  action=""
  call admin_event(sel_type&" "&(hnum+1)&"条（"&tit_fir&"）记录",0,0)
  response.write vbcrlf&"<script language=javascript>alert(""已成功（"&sel_type&"）操作了"&(hnum+1)&"条记录！"");</script>"
end sub

sub joekoe_chk_view()
  dim isuser,username,carry_price,ordernum,dis_remark,ntypes,accept_u,msgs,msg_topic,msg_word
  sql="select top 1 * from "&data_name&" where id="&id
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    rs.close
    call admin_msg(tit_fir&"（ID："&ordernum&"）不存在！","?",1)
    exit sub
  end if
  isuser=rs("isuser")
  username=rs("username")
  carry_price=rs("carry_price")
  ordernum=rs("ordernum")
  call admin_td("浏览"&tit_fir&"（"&ordernum&"）")
  if chk() then
    accept_u=rs("username")
    rs.close
    ntypes=trim(request.form("types"))
    if cstr(ntypes)<>"1" and cstr(ntypes)<>"5" then ntypes=0
    dis_remark=code_admin("dis_remark",1,250)
    sql="update "&data_name&" set types="&ntypes&",dis_tim='"&joekoe_cms.now_time&"',dis_remark='"&dis_remark&"' where id="&id
    call joekoe_cms.exec(sql,0)
    if isuser=true then
      msg_topic=code_admin("msg_topic",1,0)
      msg_word=code_admin("msg_word",1,250)
      if trim(request.form("messages"))="yes" and len(msg_topic)>1 and len(msg_word)>1 then
        sql="insert into user_mail(send_u,accept_u,topic,word,tim,types,isread) " & _
	    "values('"&login_username&"','"&accept_u&"','"&msg_topic&"','"&msg_word&"','"&joekoe_cms.now_time&"',1,0)"
	call joekoe_cms.exec(sql,0)
	msgs="\n\n已给会员（"&accept_u&"）发送了一封站内短信！"
      end if
    end if
    call admin_msg("成功处理了订单（"&ordernum&"，ID："&id&"）！"&msgs,"?types="&types&"&jk_mod="&jk_mod,1)
    exit sub
  end if
  call form_first()
%>
<tr>
<td>运送方式：</td>
<td><%response.write rs("carry")%>&nbsp;（<%
  if int(carry_price)>0 then
    response.write "加"&carry_price&web_dim(45)
  else
    response.write "免费"
  end if
%>）</td>
</tr>
<tr>
<td>订单总金额：</td>
<td><font class=red><%response.write fm_price(rs("prices"),1)%></font>&nbsp;<%response.write web_dim(45)%></td>
</tr>
<tr>
<td>付款方式：</td>
<td><%
  if rs("ispayment") then
    response.write "<font class=blue><b>"&rs("payment")&"</b></font>&nbsp;状态："
    if rs("ispay") then
      response.write "<font class=red>已支付</font>，支付时间：<font class=red2>"&rs("pay_tim")&"</font>"
    else
      response.write "未支付"
    end if
  else
    response.write rs("payment")
  end if
%></td>
</tr>
<tr>
<td>收货人姓名：</td>
<td><%
  response.write rs("nname")
  if rs("isuser") then
    response.write "　会员："&format_user_view(rs("username"),1,0)
  end if
%></td>
</tr>
<tr>
<td>收货人地址：</td>
<td><%response.write rs("address")%></td>
</tr>
<tr>
<td>邮政编码：</td>
<td><%response.write rs("code")%></td>
</tr>
<tr>
<td>联系电话：</td>
<td><%response.write rs("phone")%></td>
</tr>
<tr>
<td>电子信箱：</td>
<td><%response.write rs("email")%></td>
</tr>
<tr>
<td>备注信息：</td>
<td>
  <table border=0 width='100%' class=tf>
  <tr><td class=bw><%response.write joekoe_cms.code_html(rs("remark"),2,0)%></td></tr>
  </table>
</td>
</tr>
<form action='?action=view&jk_mod=<%response.write jk_mod%>&id=<%response.write id%>' method=post>
<input type=hidden name=chk value='yes'>
<tr>
<td>订单类型：</td>
<td><select name=types>
<option value='0'<%if cstr(types)="0" then response.write " selected"%>>未处理订单</option>
<option value='1'<%if cstr(types)="1" then response.write " selected"%>>有问题订单</option>
<option value='5'<%if cstr(types)="5" then response.write " selected"%>>已处理订单</option>
</select>&nbsp;&nbsp;上次处理时间：<%response.write rs("dis_tim")%></td>
</tr>
<tr>
<td valign=top><br>处理信息：<br><=250</td>
<td>
<table border=0><tr>
<td><textarea name=dis_remark rows=3 cols=65><%response.write joekoe_cms.code_word(rs("dis_remark"))%></textarea></td>
<td width=5></td>
<td valign=bottom><%call textarea_resize("dis_remark")%></td>
</tr></table>
</td>
</tr>
<%if isuser=true then%>
<tr class=tr1>
<td>发送短信：</td>
<td><input type=checkbox name=messages value='yes'>&nbsp;选上为处理订单时发送一封站内短信给该会员，在下面填写短信内容</td>
</tr>
<tr class=tr1>
<td>短信标题：</td>
<td><input type=text name=msg_topic value='系统：<%response.write tit_fir&ordernum%>' size=40 maxlength=20><%response.write redx%>不能超过20个字</td>
</tr>
<tr class=tr1>
<td valign=top><br>短信内容：<br><=250</td>
<td><textarea name=msg_word cols=50 rows=5></textarea></td>
</tr>
<%end if%>
<tr class=tr1><td colspan=2 align=center height=30><input type=submit value='处理该订单'>　　　<input type=reset value='重新填写'></td></tr>
</form>
<%
  rs.close
  call joekoe_order_product(id,ordernum)
end sub

sub joekoe_order_product(oid,oordernum)
  dim ssum,nid,nnum,price,price_now,discount,name
  ssum=0
%>
</table>
<table cellspacing=1 cellpadding=4 class=table>
<tr><td colspan=7 align=center>以下是<%response.write tit_fir%>（<font class=red><%response.write oordernum%></font>）的<%response.write web_dim(44)%>清单</td></tr>
<tr height=22 align=center> 
<td width='7%' class=td>序号</td>
<td width='34%' class=td><%response.write web_dim(44)%>名称</td>
<td width='18%' class=td><%response.write web_dim(44)%>编号</td>
<td width='7%' class=td>数量</td>
<td width='13%' class=td>原价（<%response.write web_dim(45)%>）</td>
<td width='8%' class=td>折扣</td>
<td width='13%' class=td>购买（<%response.write web_dim(45)%>）</td>
</tr>
<%
  i=0
  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
%>
<tr align=center>
<td><%response.write i+1%></td>
<td align=left><a href='shop_view.asp?id=<%response.write nid%>' alt='点击浏览<%response.write web_dim(44)%>详细信息' target=_blank><%response.write name%></a></td>
<td align=left><%response.write rs("serial")%></td>
<td><%response.write nnum%></td>
<td align=right><%response.write price%></td>
<td>
<%
        if discount=fm_discount(100) then
          response.write "<font class=gray>"&discount&"</font>"
        else
          response.write "<font class=red2>"&discount&"</font>"
        end if
%>
</td>
<td align=right><font class=blue><%response.write price_now%></font></td>
</tr>
<%
    rs.movenext
    i=i+1
  loop
  rs.close
%>
<tr class=tr1><td colspan=7 height=30 align=right><%response.write tit_fir&"（<font class=red>"&oordernum&"</font>）总的有效金额：<font class=red>"&fm_price(ssum,1)&"</font>&nbsp;"&web_dim(45)%>&nbsp;</td></tr>
<%
end sub

function fm_discount(dvar)
  if dvar>=100 then
    fm_discount="不打折"
    exit function
  end if 
  fm_discount=cstr(dvar/10)&"折"
end function

sub joekoe_chk_main()
  dim n_id,n_ordernum,n_tim
%>
<form name=sel_form action='?jk_mod=<%response.write jk_mod%>&types=<%response.write types%>&action=handle' method=post>
<tr align=center>
<td class=td width='6%'>序号</td>
<td class=td width='23%'>订 单 号</td>
<td class=td width='15%'>收货人</td>
<td class=td width='16%'>订购时间</td>
<td class=td width='12%'>订购金额</td>
<td class=td width='12%'>支付方式</td>
<td class=td width='10%'>支付否</td>
<td class=td width='6%'><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);"></td>
</tr>
<%
  if jk_mod="search" then
    call format_search("ordernum","ordernum,username,nname",2,1)
  else
    if types<>"" then
     sql_add=" where types="&types
     pageurl=pageurl&"types="&types&"&"
    end if
  end if
  sql="select count(id) from "&data_name&sql_add
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" id,ordernum,username,isuser,nname,tim,prices,ispayment,ispay from "&data_name&sql_add&" order by id desc"
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then rs.move (viewpage-1)*nummer
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  for i=1 to nums
    id=rs("id")
    n_ordernum=rs("ordernum")
    n_tim=rs("tim")
%>
<tr align=center>
<td><%response.write (viewpage-1)*nummer+i%></td>
<td align=left><a href='?action=view&types=<%response.write types%>&jk_mod=<%response.write jk_mod%>&id=<%response.write id%>'><%response.write n_ordernum%></a></td>
<td align=left><%
    if rs("isuser") then
      response.write format_user_view(rs("username"),1,0)
    else
      response.write rs("nname")
    end if
%></td>
<td><font alt='<%response.write joekoe_cms.time_type(n_tim,2)%>' class=tims><%response.write joekoe_cms.time_type(n_tim,3)%></td>
<td align=right><%response.write fm_price(rs("prices"),1)%></td>
<td><%
  if rs("ispayment") then
    response.write "在线支付"
  else
    response.write "<font class=gray>其它方式</font>"
  end if
%></td>
<td><%
  if rs("ispay") then
    response.write "<font class=red>已支付</font>"
  else
    response.write "<font class=gray>未支付</font>"
  end if
%></td>
<td><input type=checkbox name=sel_id value='<%response.write id%>'></td>
</tr>
<%
    rs.movenext
  next
  rs.close
%>
<tr class=tr1>
<td colspan=5>
现有<font class=red><%response.write rssum%></font>个<%response.write tit_fir%>，
页次：<font class=red><%response.write viewpage%></font>/<font class=red><%response.write thepages%></font>
分页：<%response.write jk_pagecute(nummer,thepages,viewpage,pageurl,5,"#ff0000")%>
</td>
<td colspan=3 align=center>
执行
<select name=sel_type size=1>
<option value='删除'>删除</option>
</select>
<input type=submit value='操作' onclick="return sel_click(this.form);">
</td>
</tr>
</form>
<%
end sub
'****************************************************
' 咪咪娱乐社区 2006V4.0      Power by www.mimi88.cn
' Email: 556248@qq.com  , master@szvsun.com
' Web: http://www.mimi88.cn
' Copyright (C) 2006 www.mimi88.cn All Rights Reserved.
'****************************************************
%>
