<!-- #include file="include/AMH_onlogin.asp" -->
<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V2.0》，简称“AsaiMHV2”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

dim tim,nid,nsnum,nsdim
nsnum=-1
Index_Url="notes"
call AMH_master(0,0)
Call AMH_Header(1)
%>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a href='?'>消费管理</a></td>
  <td width=10></td>
  <td><a href='?AsaiMHMod=emoneynote'<%if AsaiMHMod="emoneynote" then Response.Write " class=red"%>><%Response.Write tit%></a></td>
  <td width=10></td>
  <td><a href='?AsaiMHMod=emoney'<%if AsaiMHMod="emoney" then Response.Write " class=red"%>>购买<%Response.Write Cls.web_unit&tit_fir%></a></td>
  </tr>
  </table>
</td></tr>
</table>
<%
call AMH_table(1)
select case AsaiMHMod
case "emoney"
  call AsaiMHChk_Emoney()
case "emoneynote"
  call AsaiMHChk_EmoneyNote()
case else
  call AsaiMHChk_Main()
end select
Call AMH_Ender(tit)
sub AsaiMHChk_EmoneyNote()
call emoney_note_load()
  dim nsort,iid,tim,sel_id,hdim,hnum,hid,hi,htype
  select case action
  case "handle"
    sel_id=trim(request.form("sel_id"))
    sel_id=replace(sel_id," ","")
    hdim=split(sel_id,",")
    hnum=ubound(hdim)
    for hi=0 to hnum
      hid=hdim(hi)
      if isnumeric(hid) then call Cls.exec("delete from AsaiMHNotes where iid="&hid,0)
    next
    call AMH_msg("已成功删除了"&(hnum+1)&"条"&tit_fir,pageurl,1)
	    exit sub
  end select
%>
<form name=sel_form action='?AsaiMHMod=<%Response.Write AsaiMHMod%>&action=handle' method=post>
<tr align=center>
<td width='5%' class=td>序号</td>
<td width='10%' class=td>消费类型</td>
<td width='15%' class=td>消费代码</td>
<td width='10%' class=td>数量</td>
<td width='20%' class=td>消费用户</td>
<td width='25%' class=td>消费时间</td>
<td width='15%' class=td>浏览</td>
<td class=td width='10%'><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);"></td>
</tr>
<%
	Dim obj_page
	Set obj_page=new Cls_PageCute
	obj_page.pageurl=pageurl		
	obj_page.nummer=nummer					
	obj_page.page_t=1									
	obj_page.page_p=5									
	obj_page.page_unit="条"
	obj_page.page_tit=tit_fir
	obj_page.v_id="id"
	Call obj_page.p_init("*","AsaiMHNotes",sql_add,"id desc")
	SQL = obj_page.sql_count
	Set rs=Cls.Exec(SQL,1)
	obj_page.rssum=rs(0)
	Rs.Close
	Call obj_page.p_main("*","AsaiMHNotes",sql_add,"id desc")
	For i=1 To obj_page.page_num
    nsort=rs("nsort")
    iid=rs("iid")
    tim=rs("tim")
%>
<tr  align=center>
<td class=tims><%Response.Write i+obj_page.page_now%></td>
<td><%Response.Write note_nsort(nsort)%></td>
<td class=Gys><%Response.Write nsort%></td>
<td align=right><font class=red2><b><%Response.Write rs("emoney")%></b></font>&nbsp;<%Response.Write Cls.web_unit%></td>
<td><%Response.Write format_user_view(rs("username"),1,18)%></font></td>
<td><font title='<%Response.Write Cls.time_type(tim,2)%>' class=tims><%Response.Write Cls.time_type(tim,1)%></font></td>
<td><a href='<%Response.Write Cls.Web_Dir%><%Response.Write nsort%>/View.asp?id=<%Response.Write iid%>' target=_blank title='栏目ID：<%Response.Write iid%>'>浏览</a></td>
<td><input type=checkbox name=sel_id value='<%Response.Write iid%>'></td>
</tr>
<%
    rs.movenext
  next
  rs.close
%>
<tr class=tr1>
<td colspan=6>
  <table border=0>
  <tr class=tr1>
  <td></td>
  <td><%Response.Write obj_page.page_var%></td>
  <td width=3></td>
  <td>分页：</td>
  <td><%Response.Write obj_page.page_cute%></td>
  </tr>
  </table>
</td>
<td colspan=2 align=center>
  <select name=sel_type size=1>
  <option value='删除'>删除</option>
  </select>
  <input type=submit value='操作' onclick="return sel_click(this.form);" class=btn>
</td>
</tr>
</form>
</table>
</td>
</tr>
<%
end sub
sub emoney_note_load()
  sql="select ChannelDir,ChannelTit from AsaiMHChannel where ChannelDir<>'' order by ChannelIDs"
  set rs=Cls.exec(sql,1)
  if not rs.eof then
    nsdim=rs.getrows()
    nsnum=ubound(nsdim,2)
  End If
  rs.close
End Sub
function note_nsort(nvar)
  dim ni,temp1
  temp1="未知"
  for ni=0 to nsnum
    if nsdim(0,ni)=nvar then
      temp1=nsdim(1,ni)
      exit for
    End If
  next
  note_nsort=temp1
End Function
sub AsaiMHChk_Emoney()
  dim sum_pay,e_ispay,e_ptim,sel_id,hdim,hnum,hid,hi,htype
  select case action
  case "handle"
    sel_id=trim(request.form("sel_id"))
    sel_id=replace(sel_id," ","")
    hdim=split(sel_id,",")
    hnum=ubound(hdim)
    for hi=0 to hnum
      hid=hdim(hi)
      if isnumeric(hid) then call Cls.exec("delete from AsaiMHNotesEmoney where e_id="&hid,0)
    next
    call AMH_msg("已成功删除了"&(hnum+1)&"条"&tit_fir,pageurl,1)
  case "clear"
    call Cls.exec("delete from AsaiMHNotesEmoney where e_ispay=0 and datediff("&s_d&",e_tim,"&s_tim&")>1",0)
    call AMH_msg("已成功清理未支付"&tit_fir,pageurl,1)
    exit sub
  end select
  call AMH_td("购买"&Cls.web_unit&tit_fir)
  sql="select sum(e_amount) from AsaiMHNotesEmoney where e_ispay=1"
  set rs=Cls.exec(sql,1)
  sum_pay=rs(0)
  rs.close
  if not isnumeric(sum_pay) then sum_pay=0
%>
<tr align=center valign=top>
<td>
  <table border=0 cellspacing=2 cellpadding=2>
  <tr><td height=5></td></tr>
  <tr><td><%Response.Write img_admin("","")%>&nbsp;<a href='<%Response.Write pageurl%>'<%if action="" then Response.Write " class=red2"%>>购买<%Response.Write Cls.web_unit&tit_fir%></a></td></tr>
  <tr><td height=5></td></tr>
  <tr><td><%Response.Write img_admin("","")%>&nbsp;<a href='<%Response.Write pageurl%>action=ispay'<%if action="ispay" then Response.Write " class=red2"%>>已支付购买</a></td></tr>
  <tr><td><%Response.Write img_admin("","")%>&nbsp;<a href='<%Response.Write pageurl%>action=nopay'<%if action="nopay" then Response.Write " class=red2"%>>未支付购买</a></td></tr>
  <tr><td height=5></td></tr>
  <tr><td><%Response.Write img_admin("s_emoney","")%>&nbsp;支付额：<font class=red><%Response.Write sum_pay%></font> 元</td></tr>
  <tr><td height=5></td></tr>
  <tr><td><%Response.Write img_admin("s_imp","")%>&nbsp;<a href='<%Response.Write pageurl%>action=clear' alt='注意：清理<font class=red>一天前</font>的未支付<%Response.Write tit_fir%>' onclick="javascript:return click_return('清理一天前的未支付<%Response.Write tit_fir%>',0);">清理未支付<%Response.Write tit_fir%></a></td></tr>
  </table>
</td>
<td>
  <table cellspacing=1 cellpadding=2 class=table0>
  <form name=sel_form action='<%Response.Write pageurl%>action=handle' method=post>
  <tr align=center>
  <td class=td width='7%'>序号</td>
  <td class=td width='25%'>购买订单号</td>
  <td class=td width='16%'>购买用户</td>
  <td class=td width='10%'>金额</td>
  <td class=td width='10%'>购买数</td>
  <td class=td width='14%'>购买时间</td>
  <td class=td width='13%'>支付否</td>
  <td class=td width='5%'><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);"></td>
  </tr>
<%
  select case action
  case "ispay"
    sql_add=" e_ispay=1"
    pageurl=pageurl&"action="&action&"&"
  case "nopay"
    sql_add=" e_ispay=0"
    pageurl=pageurl&"action="&action&"&"
  end select
  dim obj_page
  set obj_page=new Cls_PageCute
  obj_page.pageurl=pageurl			
  obj_page.nummer=nummer						
  obj_page.page_t=1									
  obj_page.page_p=5									
  obj_page.page_unit="条"
  obj_page.page_tit=tit_fir
  obj_page.v_id="e_id"
  Call obj_page.p_init("*","AsaiMHNotesEmoney",sql_add,"e_id desc")
  sql=obj_page.sql_count
  set rs=Cls.exec(sql,1)
  obj_page.rssum=rs(0)
  rs.close
  call obj_page.p_main("*","AsaiMHNotesEmoney",sql_add,"e_id desc")
  for i=1 to obj_page.page_num
    nid=rs("e_id")
    tim=rs("e_tim")
    e_ispay=rs("e_ispay")
    e_ptim=rs("e_ptim")
%>
  <tr align=center>
  <td class=tims><%Response.Write obj_page.page_now+i%></td>
  <td<%if e_ispay then Response.Write " class=blue"%>><%Response.Write rs("e_ordernum")%></td>
  <td><%Response.Write format_user_view(rs("e_username"),1,0)%></td>
  <td><%Response.Write rs("e_amount")%>&nbsp;<font class=Gys>元</font></td>
  <td><%Response.Write rs("e_emoney")%>&nbsp;<font class=Gys><%Response.Write Cls.web_unit%></font></td>
  <td class=tims><%
  if e_ispay then
    Response.Write "<font class=red alt='支付时间："&Cls.time_type(e_ptim,2)&"<br /><font class=Gys>购买时间："&Cls.time_type(tim,2)&"</font>'>"&Cls.time_type(e_ptim,3)&"</font>"
  else
    Response.Write "<font alt='购买时间："&Cls.time_type(tim,2)&"'>"&Cls.time_type(tim,3)&"</font>"
  end if
%></td>
  <td><%
  if e_ispay then
    Response.Write "<font class=red>已支付</font>"
  else
    Response.Write "<font class=Gys>未支付</font>"
  end if
%></td>
  <td><input type=checkbox name=sel_id value='<%Response.Write nid%>'></td>
  </tr>
<%
    rs.movenext
  next
  rs.close
%>
<tr class=tr1>
<td colspan=6>
  <table border=0>
  <tr class=tr1>
  <td></td>
  <td><%Response.Write obj_page.page_var%></td>
  <td width=3></td>
  <td>分页：</td>
  <td><%Response.Write obj_page.page_cute%></td>
  </tr>
  </table>
</td>
<td colspan=2 align=center>
  <select name=sel_type size=1>
  <option value='删除'>删除</option>
  </select>
  <input type=submit value='操作' onclick="return sel_click(this.form);" class=btn>
</td>
</tr>
</form>
</table>
</td>
</tr>
<%
end sub
sub AsaiMHChk_Main()
  dim sum_pay,data_type,clear_msg
  call AMH_td(tit)
  sql="select sum(e_amount) from AsaiMHNotesEmoney where e_ispay=1"
  set rs=Cls.exec(sql,1)
  sum_pay=rs(0)
  rs.close
  if not isnumeric(sum_pay) then sum_pay=0
%>
<tr>
<td width='20%'>购买<%Response.Write Cls.web_unit%>相关属性：</td>
<td width='80%'>
  <table border=0>
  <tr>
  <td><%Response.Write img_admin("s_emoney","")%>&nbsp;总支付金额：<font class=red><%Response.Write sum_pay%></font>&nbsp;元</td>
  <td width=5></td>
  <td><%Response.Write img_admin("","")%>&nbsp;<a href='?AsaiMHMod=emoney&action=ispay'>已支付购买</a></td>
  <td width=5></td>
  <td><%Response.Write img_admin("","")%>&nbsp;<a href='?AsaiMHMod=emoney&action=nopay'>未支付购买</a></td>
  </tr>
  </table>
</td>
</tr>
<%
  if Cls.chk() then
    data_type=trim(request.form("data_type"))
    select case data_type
    case "all"
      sql="delete from AsaiMHNotes"
    clear_msg="所有"
    case "week"
      sql="delete from AsaiMHNotes where datediff("&s_d&",tim,"&s_tim&")>7"
      clear_msg="一周前"
    case else	'"month"
      sql="delete from AsaiMHNotes where datediff("&s_d&",tim,"&s_tim&")>30"
    clear_msg="一个月前"
    end select
    call Cls.exec(sql,0)
    call AMH_msg("已成功清理了"&clear_msg&"的消费数据！",pageurl,1)
    exit sub
  end if
  call form_first()
%>
<tr>
<td>消费数据清理：</td>
<td>
  <table border=0>
  <tr>
  <td>对网站内部模块的虚拟货币（<%Response.Write Cls.web_unit%>）消费数据，如文章、下载、影视、图片等栏目所消耗的消费数据。</td>
  </tr>
  </table>
</td>
</tr>
<tr>
<form name=data_frm action='<%Response.Write pageurl%>' method=post>
<input type=hidden name=chk value='yes'>
<td class=htd>注意：<br />清除后将不能再恢复</td>
<td>
  <table border=0>
  <tr><td><input type=radio name=data_type value='month' checked>&nbsp;清除一个月前的数据</td></tr>
  <tr><td><input type=radio name=data_type value='week'>&nbsp;清除一周前的数据</td></tr>
  <tr><td><input type=radio name=data_type value='all'>&nbsp;清除所有的消费数据</td></tr>
  </table>
</td>
</tr>
<tr>
<td></td>
<td><input type=submit value='执行清除操作' onclick="javascript:return click_return('执行清除操作',0);" class=btn></td>
</form>
</tr>
<%
end sub
%>
