<!-- #include file="include/admin_onlogin.asp" -->
<%

dim tim,nid,card_max_num
card_max_num=1000
index_url="notes"
call admin_master(0,0)
call admin_header(0,0)
%>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a href='?'><%response.write tit%></a></td>
  <td width=10></td>
  <td><a href='?jk_mod=emoney'<%if jk_mod="emoney" then response.write " class=red"%>>购买<%response.write joekoe_cms.web_unit&tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?jk_mod=prepay'<%if jk_mod="prepay" then response.write " class=red"%>>充值服务<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?jk_mod=card'<%if jk_mod="card" then response.write " class=red"%>>会员卡管理</a></td>
  </tr>
  </table>
</td></tr>
</table>
<%
call admin_table(1)

select case jk_mod
case "prepay"
  data_name="notes_prepay"
  if action="handle" then
    call joekoe_go_handle()
  end if
  call joekoe_chk_prepay()
case "card"
  call admin_td("会员卡管理")
%>
<tr align=center valign=top>
<td>
  <table border=0>
  <tr><td><%response.write img_admin("","")%>&nbsp;<a href='?jk_mod=<%response.write jk_mod%>'>会员卡列表</a></td></tr>
  <tr><td><%response.write img_admin("","")%>&nbsp;<a href='?jk_mod=<%response.write jk_mod%>&action=add'<%if action="add" then response.write " class=red"%>>添加会员卡</a></td></tr>
  <tr><td><%response.write img_admin("","")%>&nbsp;<a href='?jk_mod=<%response.write jk_mod%>&action=rnd'<%if action="rnd" then response.write " class=red"%>>批量生成会员卡</a></td></tr>
  <tr><td><%response.write img_admin("","")%>&nbsp;<a href='?jk_mod=<%response.write jk_mod%>&action=lock'<%if action="lock" then response.write " class=red"%>>批量锁定会员卡</a></td></tr>
  </table>
</td>
<td>
  <table cellspacing=1 cellpadding=3 class=table0>
<%
  select case action
  case "delete"
    call joekoe_chk_card_delete()
  case "lock"
    call joekoe_chk_card_lock()
  case "edit"
    call joekoe_chk_card_edit()
  case "add"
    call joekoe_chk_card_add()
  case "rnd"
    call joekoe_chk_card_rnd()
  case else
    call joekoe_chk_card()
  end select
%>
  </table>
</td>
</tr>
<%
case "emoney"
  call joekoe_chk_emoney()
case else
  call joekoe_chk_main()
end select

call admin_ender(1)

sub joekoe_chk_prepay()
  dim str_types,str_username,username2,num_order,str_tim
%>
<form name=sel_form action='?jk_mod=<%response.write jk_mod%>&action=handle' method=post>
<tr align=center>
<td class=td width='6%'>序号</td>
<td class=td width='8%'>类型</td>
<td class=td width='10%'>购买总价</td>
<td class=td width='16%'>充值用户 </td>
<td class=td width='10%'>充值时间</td>
<td class=td width='15%'>充值名称</td>
<td class=td width='10%'>购买单价</td>
<td class=td width='8%'>数量</td>
<td class=td width='12%'>购买时间</td>
<td class=td width='5%'><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);"></td>
</tr>
<%
  sql="select count(id) from notes_prepay"
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from notes_prepay order by id desc"
  call joekoe_cms.exec(sql,-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
    str_types="购买"
    if rs("types")=1 then str_types="<font class=red alt='购买者："&rs("username")&"'>赠送</font>"
    str_username=format_user_view(rs("username2"),1,18)
    num_order=rs("num_order")
    str_tim=rs("tim")
    response.write vbcrlf&"<tr class=bg_td align=center>" & _
         vbcrlf&"<td class=tims>"&(viewpage-1)*nummer+i&"</td>" & _
         vbcrlf&"<td>"&str_types&"</td>" & _
         vbcrlf&"<td align=right><font class=red2>"&rs("total")&"</font> "&joekoe_cms.web_unit&"</td>" & _
         vbcrlf&"<td>"&str_username&"</td>" & _
         vbcrlf&"<td align=right><font class=blue><b>"&(num_order*rs("num_month"))&"</b></font> 个月</td>" & _
         vbcrlf&"<td>"&rs("explain")&"</td>" & _
         vbcrlf&"<td align=right><font class=red2>"&rs("price")&"</font> "&joekoe_cms.web_unit&"</td>" & _
         vbcrlf&"<td>"&num_order&"</td>" & _
         vbcrlf&"<td><font class=tims alt='"&str_tim&"'>"&joekoe_cms.time_type(str_tim,4)&"</font></td>" & _
         vbcrlf&"<td><input type=checkbox name=sel_id value='"&rs("id")&"'></td>" & _
         vbcrlf&"</tr>"
    rs.movenext
  next
  rs.close
%>
  <tr>
  <td colspan=7>
现有<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

function card_rand_pass(rnum)
  dim var_pass,var_len,temp1,ri,rand_num
  var_pass="abcdefghijklmnopqrstuvwxyz0123456789"
  var_len=len(var_pass)
  temp1=""
  for ri=1 to rnum
    randomize
    rand_num=int((var_len-1+1)*rnd)+1
    temp1=temp1&mid(var_pass,rand_num,1)
  next
  card_rand_pass=temp1
end function

function card_format_var(vlen,vvar)
  dim fi,temp1
  temp1=""
  for fi=1 to vlen
    temp1=temp1&vvar
  next
  card_format_var=temp1
end function

sub joekoe_chk_card_delete()
  dim sel_ids,sdim,snum
  sel_ids=trim(request.form("sel_id"))
  sel_ids=replace(sel_ids," ","")
  sdim=split(sel_ids,",")
  snum=ubound(sdim)
  for i=0 to snum
    if isnumeric(sdim(i)) then
      call joekoe_cms.exec("delete from cards where c_id="&sdim(i),0)
    end if
  next
  erase sdim
  call admin_msg("已成功删除 "&snum&" 条会员卡信息！","?jk_mod="&jk_mod,1)
end sub

sub joekoe_chk_card_lock()
  call admin_td("批量锁定会员卡")
  if chk() then
    dim c_name_start,c_name_end,c_hidden
    c_name_start=code_admin("c_name_start",1,20)
    c_name_end=code_admin("c_name_end",1,20)
    select case trim(request.form("c_hidden"))
    case "no"
      c_hidden=0
    case "yes"
      c_hidden=1
    case else
      c_hidden=2
    end select
    if c_name_start="" or c_name_end="" then
      call admin_error("开头卡号 和 结束卡号 不能为空！")
      exit sub
    end if
    sql="update cards set c_hidden="&c_hidden&" where c_name>'"&c_name_start&"' and c_name<'"&c_name_end&"'"
    call joekoe_cms.exec(sql,0)
    call admin_msg("批量锁定会员卡（"&c_name_start&" ~ "&c_name_end&"）！","?jk_mod="&jk_mod,0)
    exit sub
  end if
  call form_first()
%>
<form name=add_frm action='?jk_mod=<%response.write jk_mod%>&action=lock' method=post>
<input type=hidden name=chk value='yes'>
<tr>
<td width='20%'>开头卡号：</td>
<td width='80%'><input type=text name=c_name_start value='' size=30 maxlength=20><%response.write redx%></td>
</tr>
<tr>
<td>结束卡号：</td>
<td><input type=text name=c_name_end value='' size=30 maxlength=20><%response.write redx%></td>
</tr>
<tr>
<td>操作状态：</td>
<td><input type=radio name=c_hidden value='no'>&nbsp;未使用&nbsp;
<input type=radio name=c_hidden value='yes'>&nbsp;已使用&nbsp;
<input type=radio name=c_hidden value='lock' checked>&nbsp;锁定</td>
</tr>
<tr><td></td><td height=40><input type=submit value='批量锁定会员卡'></td></tr>
</form>
<%
end sub

sub joekoe_chk_card_edit()
  dim c_name,c_pass,c_emoney,c_hidden
  call admin_td("修改会员卡")
  sql="select top 1 * from cards where c_id="&id
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,3
  if rs.eof then
    call admin_msg("会员卡ID（"&id&"）不存在！","?jk_mod="&jk_mod,1)
    rs.close
  end if
  if chk() then
    c_name=code_admin("c_name",1,10)
    c_pass=code_admin("c_pass",1,10)
    c_emoney=code_admin("c_emoney",1,10)
    if not int_true(c_emoney) then c_emoney=0
    select case trim(request.form("c_hidden"))
    case "no"
      c_hidden=0
    case "yes"
      c_hidden=1
    case else
      c_hidden=2
    end select
    if c_name="" or c_pass="" then
      call admin_error("会员卡的 卡号和密码 不能为空！")
      exit sub
    end if
    if int(c_emoney)<1 then
      call admin_error("会员卡的 充值数量 必须为大于等于1的整数！")
      exit sub
    end if
    rs("c_name")=c_name
    rs("c_pass")=c_pass
    rs("c_emoney")=c_emoney
    rs("c_hidden")=c_hidden
    rs.update
    rs.close
    call admin_msg("成功修改一条 会员卡 信息！","?jk_mod="&jk_mod,0)
    exit sub
  end if
  call form_first()
  c_hidden=rs("c_hidden")
%>
<form name=add_frm action='?jk_mod=<%response.write jk_mod%>&action=edit&id=<%response.write id%>' method=post>
<input type=hidden name=chk value='yes'>
<tr>
<td width='20%'>会员卡号：</td>
<td width='80%'><input type=text name=c_name value='<%response.write rs("c_name")%>' size=30 maxlength=20><%response.write redx%></td>
</tr>
<tr>
<td>卡号密码：</td>
<td><input type=text name=c_pass value='<%response.write rs("c_pass")%>' size=30 maxlength=20><%response.write redx%></td>
</tr>
<tr>
<td>充值数量：</td>
<td><input type=text name=c_emoney value='<%response.write rs("c_emoney")%>' size=10 maxlength=10>&nbsp;<%response.write joekoe_cms.web_unit&redx%></td>
</tr>
<tr>
<td>当前状态：</td>
<td><input type=radio name=c_hidden value='no'<%if int(c_hidden)=0 then response.write " checked"%>>&nbsp;未使用&nbsp;
<input type=radio name=c_hidden value='yes'<%if int(c_hidden)=1 then response.write " checked"%>>&nbsp;已使用&nbsp;
<input type=radio name=c_hidden value='lock'<%if int(c_hidden)=2 then response.write " checked"%>>&nbsp;锁定</td>
</tr>
<%
  rs.close
  call submit_edit()
end sub

sub joekoe_chk_card_add()
  dim c_name,c_pass,c_emoney,c_hidden
  call admin_td("添加会员卡")
  if chk() then
    c_name=code_admin("c_name",1,10)
    c_pass=code_admin("c_pass",1,10)
    c_emoney=code_admin("c_emoney",1,10)
    if not int_true(c_emoney) then c_emoney=0
    c_hidden=0
    if trim(request.form("c_hidden"))="yes" then c_hidden=1
    if c_name="" or c_pass="" then
      call admin_error("会员卡的 卡号和密码 不能为空！")
      exit sub
    end if
    if int(c_emoney)<1 then
      call admin_error("会员卡的 充值数量 必须为大于等于1的整数！")
      exit sub
    end if
    sql="select * from cards"
    call joekoe_cms.exec("",-1)
    rs.open sql,conn,1,3
    rs.addnew
    rs("c_name")=c_name
    rs("c_pass")=c_pass
    rs("c_emoney")=c_emoney
    rs("c_hidden")=c_hidden
    rs.update
    rs.close
    call admin_msg("成功添加一条 会员卡 信息！","?jk_mod="&jk_mod,0)
    exit sub
  end if
  call form_first()
%>
<form name=add_frm action='?jk_mod=<%response.write jk_mod%>&action=add' method=post>
<input type=hidden name=chk value='yes'>
<tr>
<td width='20%'>会员卡号：</td>
<td width='80%'><input type=text name=c_name value='' size=30 maxlength=20><%response.write redx%></td>
</tr>
<tr>
<td>卡号密码：</td>
<td><input type=text name=c_pass value='' size=30 maxlength=20><%response.write redx%></td>
</tr>
<tr>
<td>充值数量：</td>
<td><input type=text name=c_emoney value='' size=10 maxlength=10>&nbsp;<%response.write joekoe_cms.web_unit&redx%></td>
</tr>
<tr>
<td>当前状态：</td>
<td><input type=radio name=c_hidden value='no' checked>&nbsp;未使用&nbsp;
<input type=radio name=c_hidden value='yes'>&nbsp;已使用&nbsp;
<input type=radio name=c_hidden value='lock'>&nbsp;锁定</td>
</tr>
</tr>
<%
  call submit_add()
end sub

sub joekoe_chk_card_rnd()
  call admin_td("批量生成会员卡")
  dim c_num,c_name_start,c_name_len,c_name_head,c_pass_len,c_emoney,c_name,c_pass,tmp1
  if chk() then
    c_num=trim(request.form("c_num"))
    if not int_true(c_num) then c_num=0
    c_name_start=trim(request.form("c_name_start"))
    if not int_true(c_name_start) then c_name_start=1
    if int(c_name_start)<1 then c_name_start=1
    c_name_len=trim(request.form("c_name_len"))
    if not int_true(c_name_len) then c_name_len=0
    c_name_head=code_admin("c_name_head",1,10)
    c_pass_len=trim(request.form("c_pass_len"))
    if not int_true(c_pass_len) then c_pass_len=1
    if int(c_pass_len)<1 then c_pass_len=1
    c_emoney=trim(request.form("c_emoney"))
    if not int_true(c_emoney) then c_emoney=1
    if int(c_emoney)<1 then c_emoney=1
    'if c_name_head="" then
    '  call admin_error("您输入的 卡号头系数 不能为空！")
    '  exit sub
    'end if
    if int(c_num)<1 or int(c_num)>int(card_max_num) then
      call admin_error("您输入的 增加数量 小于1或大于"&card_max_num&"！")
      exit sub
    end if
    sql="select count(c_id) from cards where left(c_name,"&(len(c_name_head)+1)&")='"&c_name_head&"0' and len(c_name)="&c_name_len
    set rs=joekoe_cms.exec(sql,1)
    if rs(0)>0 then
      rs.close
      call admin_error("您输入的 卡号头系数（"&c_name_head&"）及卡号长度（"&c_name_len&"） 可能会引起卡号重复！")
      exit sub
    end if
    rs.close
    for i=c_name_start to (int(c_num)+int(c_name_start)-1)
      tmp1=card_format_var((c_name_len-len(c_name_head)-len(i)),"0")
      c_name=c_name_head&tmp1&i
      c_pass=card_rand_pass(c_pass_len)
      sql="insert into cards (c_name,c_pass,c_emoney,c_hidden) " & _
	  "values ('"&c_name&"','"&c_pass&"',"&c_emoney&",0)"
      call joekoe_cms.exec(sql,0)
    next
    call admin_msg("已成功生成"&c_num&"个会员卡号！","?jk_mod="&jk_mod,0)
    exit sub
  end if
  call form_first()
%>
<form name=add_frm action='?jk_mod=<%response.write jk_mod%>&action=rnd' method=post>
<input type=hidden name=chk value='yes'>
<tr>
<td width='20%'>增加数量：</td>
<td width='80%'><input type=text name=c_num value='1' size=10> 个，一次最多增加<font class=red><%response.write card_max_num%></font>个</td>
</tr>
<tr>
<td>开始系数：</td>
<td><input type=text name=c_name_start value='1' size=10> 一般为1或上次生成数量+1</td>
</tr>
<tr>
<td>卡号长度：</td>
<td><select name=c_name_len sizs=1>
<option>6</option>
<option>8</option>
<option>10</option>
<option>12</option>
<option selected>15</option>
<option>18</option>
<option>20</option>
</select> 位</td>
</tr>
<tr>
<td>卡号头系数：</td>
<td><input type=text name=c_name_head value='C' alt='长度不能超过10' size=10 maxlength=10> 例：<font class=red>C</font>000000000023</td>
</tr>
<tr>
<td>密码长度：</td>
<td><select name=c_pass_len sizs=1>
<option>5</option>
<option>8</option>
<option selected>10</option>
<option>20</option>
</select> 位</td>
</tr>
<tr>
<td>充值货币数：</td>
<td><select name=c_emoney size=1>
<option>5</option>
<option>10</option>
<option>20</option>
<option>50</option>
<option>100</option>
</select> <%response.write joekoe_cms.web_unit%></td>
</tr>
<tr><td></td><td height=40><input type=submit value='批量生成会员卡'></td></tr>
</form>
<%
end sub

sub joekoe_chk_card()
  dim c_hidden
%>
  <form name=sel_form action='?jk_mod=<%response.write jk_mod%>&action=delete' method=post>
  <tr align=center>
  <td class=td width='7%'>序号</td>
  <td class=td width='30%'>卡号</td>
  <td class=td width='30%'>密码</td>
  <td class=td width='12%'><%response.write joekoe_cms.web_unit%></td>
  <td class=td width='16%'>相关属性</td>
  <td class=td width='5%'><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);"></td>
  </tr>
<%
  sql="select count(c_id) from cards"
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from cards order by c_id desc"
  call joekoe_cms.exec(sql,-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("c_id")
    c_hidden=rs("c_hidden")
%>
  <tr align=center>
  <td class=tims><%response.write (viewpage-1)*nummer+i%></td>
  <td><%response.write rs("c_name")%></td>
  <td><%response.write rs("c_pass")%></td>
  <td class=red2><%response.write rs("c_emoney")%>&nbsp;</td>
  <td><%
    response.write pro_edit("?jk_mod="&jk_mod&"&action=edit&id="&id,"编辑该会员卡")&"&nbsp;"
    select case int(c_hidden)
    case 0
      response.write "<font class=gray>未使用</font>"
    case 1
      response.write "<font class=red>已使用</font>"
    case else
      response.write "<font class=blue>锁定</font>"
    end select
%></td>
  <td><input type=checkbox name=sel_id value='<%response.write id%>'></td>
  </tr>
<%
    rs.movenext
  next
  rs.close
%>
  <tr class=tr1>
  <td colspan=3>
现有<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

sub joekoe_chk_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 joekoe_cms.exec("delete from notes_emoney where e_id="&hid,0)
    next
    call admin_msg("已成功删除了"&(hnum+1)&"条"&tit_fir,pageurl,1)
  case "clear"
    call joekoe_cms.exec("delete from notes_emoney where e_ispay=0 and datediff("&s_d&"d"&s_d&",e_tim,"&s_tim&")>7",0)
    call admin_msg("已成功清理未支付"&tit_fir,pageurl,1)
    exit sub
  end select
  call admin_td("购买"&joekoe_cms.web_unit&tit_fir)
  sql="select sum(e_amount) from notes_emoney where e_ispay=1"
  set rs=joekoe_cms.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 joekoe_cms.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='16%'>购买时间</td>
  <td class=td width='11%'>支付否</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=" where e_ispay=1"
    pageurl=pageurl&"action="&action&"&"
  case "nopay"
    sql_add=" where e_ispay=0"
    pageurl=pageurl&"action="&action&"&"
  end select
  sql="select count(e_id) from notes_emoney "&sql_add
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from notes_emoney "&sql_add&" order by e_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
    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 (viewpage-1)*nummer+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=gray>元</font></td>
  <td><%response.write rs("e_emoney")%>&nbsp;<font class=gray><%response.write joekoe_cms.web_unit%></font></td>
  <td class=tims><%
  if e_ispay then
    response.write "<font class=red alt='支付时间："&joekoe_cms.time_type(e_ptim,2)&"<br><font class=gray>购买时间："&joekoe_cms.time_type(tim,2)&"</font>'>"&joekoe_cms.time_type(e_ptim,3)&"</font>"
  else
    response.write "<font alt='购买时间："&joekoe_cms.time_type(tim,2)&"'>"&joekoe_cms.time_type(tim,3)&"</font>"
  end if
%></td>
  <td><%
  if e_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 nid%>'></td>
  </tr>
<%
    rs.movenext
  next
  rs.close
%>
  <tr>
  <td colspan=6>
现有<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=2 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>
  </table>
</td>
</tr>
<%
end sub

sub joekoe_chk_main()
  dim sum_pay,data_type,clear_msg
  call admin_td(tit)
  sql="select sum(e_amount) from notes_emoney where e_ispay=1"
  set rs=joekoe_cms.exec(sql,1)
  sum_pay=rs(0)
  rs.close
  if not isnumeric(sum_pay) then sum_pay=0
%>
<tr>
<td width='20%'>购买<%response.write joekoe_cms.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='?jk_mod=emoney&action=ispay'>已支付购买</a></td>
  <td width=5></td>
  <td><%response.write img_admin("","")%>&nbsp;<a href='?jk_mod=emoney&action=nopay'>未支付购买</a></td>
  </tr>
  </table>
</td>
</tr>
<%
  if joekoe_cms.chk() then
    data_type=trim(request.form("data_type"))
    select case data_type
    case "all"
      sql="delete from notes"
    clear_msg="所有"
    case "week"
      sql="delete from notes where datediff("&s_d&"d"&s_d&",tim,"&s_tim&")>7"
      clear_msg="一周前"
    case else	'"month"
      sql="delete from notes where datediff("&s_d&"d"&s_d&",tim,"&s_tim&")>30"
    clear_msg="一个月前"
    end select
    call joekoe_cms.exec(sql,0)
    call admin_msg("已成功清理了"&clear_msg&"的消费数据！",pageurl,1)
    exit sub
  end if
  call form_first()
%>
<tr>
<td>消费数据清理：</td>
<td>
  <table border=0>
  <tr>
  <td>对网站内部模块的虚拟货币（<%response.write joekoe_cms.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);"></td>
</form>
</tr>
<%
end sub
%>
