<!--#include file=conn.asp-->
<!-- #include file="inc/const.asp" -->
<!--#include file=bank_data.asp-->
<!-- #include file="bank/bank_const.asp" -->
<%
'=========================================================
' file: bank_masterwork.asp
' Version:2.1 for Dvbbs7.0
' date: 2004-1-7
' script modified by winriver from yaoyue Version
'=========================================================
' copyright (c) 2004 黄河论坛 all rights reserved.
' web: http://www.paperbridge.net http://www.winriver.org
' email: huanghetv@163.com winriver2002@yahoo.com
'=========================================================
Dvbbs.LoadTemplates("")
If Not IsObject(Conn) Then ConnectionDatabase
dim sql,rs,founderr,i,errmsg
founderr=false

dim disabled,masterwork,content
dim pcount,page,total
if not Dvbbs.FoundUser then
    errmsg=errmsg+errmsg6+"您还没有登录或注册，请先<a href=login.asp>登录</a>或<a href=reg.asp>注册</a>。"
    founderr=true
    Dvbbs.Stats="钱庄错误信息"
    call Dvbbs.Nav()
	call new_head()
    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
	call Dvbbs.ActiveOnline()
	call Dvbbs.Footer()
	response.end
end if
if not isbankmaster then
    founderr=true
    errmsg=errmsg+errmsg6+"看到你迎面向帐房而来，钱庄大楼的帐房阿伯不得不仔细的瞧你两眼，发现你很眼生，对你温和的说：“咦，你好像不是本钱庄的掌柜啊！！！！快点给我溜，不然阿伯我要扫把伺候了！！！”"
    Dvbbs.Stats="钱庄错误信息"
    call Dvbbs.Nav()
	call new_head()
    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
end if
'if Dvbbs.ChkPost=false then
   ' founderr=true
   ' errmsg=errmsg+errmsg6+"我就知道，虽然钱不是万能的，但没有钱却是万万不能，连掌柜都会为了钱非法操作咯。"
'end if
masterwork=request("masterwork")
if masterwork="pfgrepay" then
    Dvbbs.Stats="清理到期的贷款"
    call Dvbbs.Nav()
	call new_head()
    call pfgrepay()
elseif masterwork="bankmsg" then
    Dvbbs.Stats="修改钱庄信息"
    call Dvbbs.Nav()
	call new_head()
    call bankmsg()
elseif masterwork="takesalary" then
    Dvbbs.Stats="领薪水"
    call Dvbbs.Nav()
	call new_head()
    call takesalary()
elseif masterwork="masterins" then
    Dvbbs.Stats="掌柜操作"
    call Dvbbs.Nav()
	call new_head()
    call masterins()
elseif masterwork="delpfg" then
    Dvbbs.Stats="清理到期贷款"
    call Dvbbs.Nav()
	call new_head()
    call delpfg()
elseif masterwork="save_fuwu" then
    Dvbbs.Stats="服务设置"
    call Dvbbs.Nav()
	call new_head()
	if isbankmaster and everybody then
    call save_fuwu()
	else
	errmsg=errmsg+errmsg6+"你没有进行特殊服务设置的权限,请与管理员联系"
	Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
	end if
elseif masterwork="jiangli" then
    Dvbbs.Stats="奖励用户"
    call Dvbbs.Nav()
	call new_head()
	if isbankmaster and everybody then
    call jiangli()
    else
	founderr=true
	errmsg=errmsg+errmsg6+"你没有奖励用户的权限,请与管理员联系"
    end if
elseif masterwork="opentime" then
    Dvbbs.Stats="营业时间"
    call Dvbbs.Nav()
	call new_head()
	if isbankmaster then
    call banktime()
    else
	founderr=true
	errmsg=errmsg+errmsg6+"你没有设置营业时间的权限,请与管理员联系"
    end if
else
    Dvbbs.Stats="帐房"
    call Dvbbs.Nav()
	call new_head()
    call main()
end if
call Dvbbs.ActiveOnline()

if founderr then
    Dvbbs.Stats="钱庄错误信息"
    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
end if
call Dvbbs.Footer()

sub main()
  response.write "<table cellpadding=3 cellspacing=1 align=center class=tableborder1>"&_
    "<tr><th align=center><form action=bank_masterwork.asp?bankid="&bankid&"&masterwork=bankmsg method=post>钱庄基本信息设置</td></tr>"&_
    "<tr><td class=tablebody1 align=left>"
  response.write "钱庄名称：　　<input type=text name=bankname size=10 value="&bankname&" disabled> （注册后只有管理员可改）<br><img src=yaoyue.gif height=5><br>"&_
                 "掌柜名字：　　<input type=text name=bankmaster size=10 value="&bankmaster&" "
                 if everybody then
                     response.write " disabled> （非官方钱庄掌柜可以改，但改后就等于把钱庄送人，你将一无所有，要谨慎）<br><img src=yaoyue.gif height=5><br>"
                 else
                     response.write "> （非官方钱庄掌柜可以改，但改后就等于把钱庄送人，你将一无所有，要谨慎）<br><img src=yaoyue.gif height=5><br>"
                 end if
  response.write "库存的魅力值：<input type=text name=loveliness size=10 value="&loveliness&" disabled> （仅为非官方钱庄掌柜作为参考值，不可直接修改）<br><img src=yaoyue.gif height=5><br>"&_
                 "库存的现金：　<input type=text name=stockpile size=10 value="&stockpile&" disabled> （仅为非官方钱庄掌柜作为参考，不可直接修改）<br><img src=yaoyue.gif height=5><br>"&_
                 "销户手继费：　<input type=text name=log_on size=10 value="&log_on&"> （可以输入从<font color=red><b>0</b></font>到<font color=red><b>10000</b></font>之间的整数）<br><img src=yaoyue.gif height=5><br>"&_
                 "钱庄说明：　　<input type=text name=msg size=16 maxlength=30 value="&msg&"> （钱庄的说明，如欢迎语等，最多<font color=red><b>30</b></font>个字）<br><img src=yaoyue.gif height=5><br>"&_
                 "魅力贷款倍数：<input type=text name=zhml size=10 value="&zhml&"> （客户用魅力贷款时的倍数，填<font color=red><b>1</b></font>至<font color=red><b>10000</b></font>之间的整数，只有库存魅力为<font color=red><b>0</b></font>和<font color=red><b>没有人贷款</b></font>时可修改）<br><img src=yaoyue.gif height=5><br>"
  response.write "　　(<font color=red><b>注意</b></font>：<font color=red>魅力贷款倍数</font>同时也会影响魅力买卖，卖魅力给钱庄的价格为所填数的<font color=red><b>2</b></font>倍，向钱庄购买魅力的价格为所填数的<font color=red><b>4</b></font>倍。)<br>"&_
                 "转帐最低积分：<input type=text name=ep size=10 value="&ep&"> （积分要到达多少才可使用转帐汇款功能，<font color=red><b>0</b></font>至<font color=red><b>10000</b></font>之间的整数）<br><img src=yaoyue.gif height=5><br>"&_
                 "开户最低积分：<input type=text name=integral size=10 value="&integral&"> （开户需要的最低积分，<font color=red><b>0</b></font>至<font color=red><b>10000</b></font>之间的整数）<br><img src=yaoyue.gif height=5><br>"&_
                 "贷款最高次数：<input type=text name=pfgtimes size=10 value="&pfgtimes&"> （设定每个客户最多只能同时贷几笔款，次数到达则必须最少还一笔才能再贷，填<font color=red><b>1</b></font>至<font color=red><b>100</b></font>之间的整数）<br><img src=yaoyue.gif height=5><br>"&_
                 "</td></tr><tr><td align=center class=tablebody2><input type=submit name=s value=修改 onclick=""return confirm('确定修改？');""></td></form></tr></table>"


'营业时间
if isbankmaster then
%><br>
<table cellpadding=3 cellspacing=1 align=center class=tableborder1>
  <tr height=22> 
    <th colspan=4 height=20>营业时间</th>
  </tr>
  <form name="form1" method="post" action="?bankid=<%=bankid%>&masterwork=opentime">
    <tr> 
      <td colspan="4" align=center class=tablebody2><b>注意</b>：如果开始时间和结束时间相等，则表示全天不营业</td>
    </tr>
    <tr> 
      <td align=right class=tablebody2 width=45%>①号柜台：活期存取</td>
      <td align=left colspan=3 class=tablebody1 width=55%>从 <input name=from1 id="from1" value=<%=split(openclosetime(0),"|")(0)%> size="8">
        到 <input name=to1 id="to1" value=<%=split(openclosetime(0),"|")(1)%> size="8"></td>
    </tr>
    <tr> 
      <td align=right class=tablebody2>②号柜台：定期存款</td>
      <td align=left colspan=3 class=tablebody1>从 
        <input name=from2 id="from2" value=<%=split(openclosetime(1),"|")(0)%> size="8">
        到 
        <input name=to2 id="to2" value=<%=split(openclosetime(1),"|")(1)%> size="8"></td>
    </tr>
    <tr> 
      <td align=right class=tablebody2>③号柜台：魅力买卖</td>
      <td align=left colspan=3 class=tablebody1>从 
        <input name=from3 id="from3" value=<%=split(openclosetime(2),"|")(0)%> size="8">
        到 
        <input name=to3 id="to3" value=<%=split(openclosetime(2),"|")(1)%> size="8"></td>
    </tr>
    <tr> 
      <td align=right class=tablebody2>④号柜台：魅力信贷</td>
      <td align=left colspan=3 class=tablebody1>从 
        <input name=from4 id="from4" value=<%=split(openclosetime(3),"|")(0)%> size="8">
        到 
        <input name=to4 id="to4" value=<%=split(openclosetime(3),"|")(1)%> size="8"></td>
    </tr>
    <tr> 
      <td align=right class=tablebody2>⑤号柜台：汇款转账</td>
      <td align=left colspan=3 class=tablebody1>从 
        <input name=from5 id="from5" value=<%=split(openclosetime(4),"|")(0)%> size="8">
        到 
        <input name=to5 id="to5" value=<%=split(openclosetime(4),"|")(1)%> size="8"></td>
    </tr>
    <tr> 
      <td align=center colspan=4 class=tablebody1><input type=submit value=提交 name=submit>
        　 <input type=reset value=重置 name=submit2></td>
    </tr>
  </form>
</table><br>
<%
end if

'服务设置
if isbankmaster and everybody then
call fuwu_setting()
end if

'奖励管理
if isbankmaster and everybody then
%>
<table cellpadding=3 cellspacing=1 align=center class=tableborder1>
<tr height=22><th colspan=4 height=20>奖励管理</th></tr> 
	<tr>      
		<td align=center colspan=4 class=tablebody1 height=10></td>      
	</tr>
<form name="form1" method="post" action="?bankid=<%=bankid%>&masterwork=jiangli">      
<tr>      
<td align=right class=tablebody2>奖励对象：</td>      
<td align=left colspan=3 class=tablebody1>
<%call getgroup()%>
</td></tr>      
<tr>      
<td align=right class=tablebody2>奖励金额：</td>      
<td align=left colspan=3 class=tablebody1><input name=money></td>      
</tr>      
<tr>      
<td align=right class=tablebody2>奖励理由：</td>      
<td align=left colspan=3 class=tablebody1><input name=liyou size="50"></td>      
</tr>      
<tr>      
<td align=center colspan=4 class=tablebody1><input type=submit value=奖励 name=submit></td>      
</tr>      
</form> 
</table><br>
<%
end if


  if everybody then
      response.write "<table cellpadding=3 cellspacing=1 align=center class=tableborder1>"&_
                     "<tr><th align=center><form action=bank_masterwork.asp?bankid="&bankid&"&masterwork=takesalary method=post>官方钱庄掌柜薪水分发处</td></tr>"&_
                     "<tr><td class=tablebody1 align=left>"
                     csql="select salary,times,dateandtime from evbankmasterlog where bankid="&bankid&" and mastername='"&Dvbbs.MemberName&"'"
                     set crs=cjconn.execute (csql)
      response.write "　　你的薪水为每<font color=#ff0000><b>"&s_datecount&"</b></font>天<font color=#ff0000><b>"&salary&"</b></font>"&curr&"，你一共已经领过<font color=#ff0000><b>"&crs(1)&"</b></font>次薪水，一共为<font color=#ff0000><b>"&crs(0)&"</b></font>"&curr&"，最后领取的时间为"&crs(2)&"。<br>　　<b>说明</b>：只有到领钱的时间按钮才会生效。如果掌柜超期没有领钱，例如：本来是10天领一次钱的，每次为2000"&curr&"，掌柜等到第二十二天才领，则领到4000"&curr&"，领钱的次数记为两次，最后领钱的日期记录也自动退两天。<br><br><br>"
                     if datediff("d",datediff("d",crs(2),now()),s_datecount)>0 then
                         disabled=" disabled"
                     else
                         disabled=""
                     end if
                     set crs=nothing
      response.write "　　<input type=text name=salary size=10 value="&salary&" disabled>　<input type=submit name=s value=领取薪水"&disabled&"><br></td></tr></form></table>"
  else
      if stockpile < regbank then
          disabled=" disabled"
      else
          disabled=""
      end if
      response.write "<table cellpadding=3 cellspacing=1 align=center class=tableborder1>"&_
                     "<tr><th align=center>非官方钱庄掌柜取款或扩充处</td></tr>"&_
                     "<tr><td class=tablebody1 align=left valign=middle><br>"&_
                     "<form action=bank_masterwork.asp?bankid="&bankid&"&masterwork=masterins method=post>&nbsp;<input type=text name=apporget size=10>&nbsp;&nbsp;取出魅力&nbsp;<input type=radio name=num value=1>&nbsp;&nbsp;扩充魅力<input type=radio name=num value=2>&nbsp;&nbsp;取出现金&nbsp;<input type=radio name=num value=3"&disabled&">&nbsp;&nbsp;扩充金额&nbsp;<input type=radio name=num value=4>&nbsp;&nbsp;<input type=submit name=s value=操作></form>"&_
                     "<b>说明：</b><br>"&_
                     "1.取出魅力为把钱庄库存的魅力值转成你自己的魅力值。<br>"&_
                     "2.扩充魅力为把你现有的魅力值转成钱庄的库存，用来卖给客户的，魅力金钱，你喜欢哪一个多一些呢？<br>"&_
                     "3.取出现金为把钱庄库存的金钱转为你的现金，只有当库存大于<font color=#ff0000><b>"&regbank&"</b></font>"&curr&"时才能操作。<br>"&_
                     "4.扩充现金为把自己的现金加入钱庄的库存中。<br>"&_
                     "5.想知道钱庄库存的魅力值和金钱有多少，看上的的基本信息。<br>"
      response.write "</td></tr></table>"
  end if
  response.write "<table cellpadding=3 cellspacing=1 align=center class=tableborder1>"&_
                 "<tr><th align=center>其它操作</td></tr>"&_
                 "<tr><td class=tablebody1 align=center valign=middle>"
                 if openeventslog then
                     response.write "<input type=button name=t1 value=查看事件记录 onclick=""window.open('bank_clientevents.asp?bankid="&bankid&"&action=events');"">　"
                 end if
  response.write "<input type=button name=t2 value=客户管理 onclick=""javascrip:window.open('bank_clientevents.asp?bankid="&bankid&"');"">　<input type=submit name=s value=清理到期的贷款 onclick=""javascript:location.href='bank_masterwork.asp?bankid="&bankid&"&masterwork=pfgrepay';""></td></tr></table>"
end sub
'读取到期贷款
sub pfgrepay()
  if not isnumeric(request("page")) or request("page")="" then
      page=1
  else
      page=cint(request("page"))
  end if
  set crs=server.createobject("adodb.recordset")
  csql="select p.pid,p.paymentforgoods,p.p_accrual,p.bydetaincp,p.dateandtime,u.name from paymentforgoods p inner join bankuser u on u.bankuserid=p.bankuserid where u.bankid="&bankid&" and datediff('d',datediff('d',p.dateandtime,'"&now()&"'),"&p_repay&") < 0"
  crs.open csql,cjconn,1,1
  if crs.bof and crs.eof then
      founderr=true
      errmsg=errmsg+errmsg6+"没有任何到期的贷款。"
      exit sub
  end if
%>
<table cellpadding=0 cellspacing=0 border=0 width=98% align=center><tr><td>有些人贷款后就很长时间没来，这些贷款到期后也不会自动清理，就得掌柜动手清理了。</td></tr></table>
<form name=pfg action=bank_masterwork.asp?bankid=<%=bankid%>&masterwork=delpfg method=post>
<table cellpadding=3 cellspacing=1 class=tableborder1 align=center>
<tr valign=middle>
<th height=25 width=60>贷款id</th>
<th width=120>用户名</th>
<th width=120>贷款数</th>
<th width=120>贷款利息</th>
<th width=120>所押魅力值</th>
<th width=*>贷款时间</th>
<th width=40>清理</th>
</tr>
<%
      crs.pagesize = Dvbbs.Forum_setting(11)
      total = crs.recordcount
      pcount = crs.pagecount
      if page < 1 then page = 1
      if page > pcount then page = pcount
      crs.move (page-1)*crs.pagesize
      ii = 0
      do while not crs.eof and ii < crs.pagesize
%>
  <tr> 
    <td align=middle class=tablebody2 width=60><%=crs(0)%></td> 
    <td align=middle class=tablebody1 width=120><%=crs(5)%></td> 
    <td align=middle class=tablebody2  width=120><%=crs(1)%></td> 
    <td align=middle class=tablebody1 width=120><%=crs(2)%></td>
    <td align=middle class=tablebody2  width=120><%=crs(3)%></td> 
    <td align=middle class=tablebody1 width=*><%=crs(4)%></td>
    <td align=middle class=tablebody2  width=40><input type=checkbox name=pid value=<%=crs(0)%>></td>
</tr> 
<%
          ii = ii+1
          crs.movenext
      loop
      response.write "</table>"
      call pagefooter()
      response.write "<br><table cellpadding=0 cellspacing=0 border=0 width=98% align=center><tr><td><input type=submit name=action value=清理>　<input type=button name=t value=返办公室 onclick=""javascript:location.href='bank_masterwork.asp?bankid="&bankid&"';""> 选中所有显示的记录：<input type=checkbox name=chkall value=on onclick=""checkall(this.form)"">　</td></tr></table></form>"
  crs.close
  set crs = nothing
%>
<script language="JavaScript">
<!--
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')       e.checked = form.chkall.checked; 
   }
  }
//-->
</script>
<%
end sub
sub pagefooter()
  response.write  "<table border=0 cellpadding=0 cellspacing=3 width=98% align=center>"&_
                  "<tr><td valign=middle nowrap>"&_
                  "页次：<font color=#ff0000><b>"&page&"</b></font>/<b>"&pcount&"</b>页"&_
			     " 每页<font color=#ff0000><b>"&Dvbbs.Forum_setting(11)&"</b></font>条记录 总共有<font color=#ff0000><b>"&total&"</b></font>条记录</td>"&_
			     "<td valign=middle nowrap><font color=red><div align=right><p>分页： "
			if page > 4 then
			    response.write "<a href=bank_mssterwork.asp?bankid="&bankid&"&masterwork=pfgrepay&page=1>[1]</a>..."
			end if
			if pcount>page+3 then
			    ii=page+3
			else
			    ii=pcount
			end if
			for i=page-3 to ii
			    if not i < 1 then
			        if i=cint(page) then
			            response.write "<font color=#ff000000>["&i&"]</font>"
			        else
			            response.write "<a href=bank_masterwork.asp?bankid="&bankid&"&masterwork=pfgrepay&page="&i&">["&i&"]</a>"
			        end if
			    end if
			next
			if page+3 < pcount then
			    response.write "...<a href=bank_masterwork.asp?bankid="&bankid&"&masterwork=pfgrepay&page="&pcount&">["&pcount&"]</a>"
			end if
			response.write "</p></div></font></td></tr></table>"
end sub

sub bankmsg()
  dim bankmaster,log_on,msg,nzhml,integral,ep,pfgtimes,founduser,notfoundbankuser
  if not isnumeric(request.form("log_on")) or not isnumeric(request.form("zhml")) or not isnumeric(request.form("ep")) or not isnumeric(request.form("integral")) or not isnumeric(request.form("pfgtimes")) then
      founderr=true
      errmsg=errmsg+errmsg6+"销户费、贷款倍数、转帐汇所需的最低积分、开户最低积分和最大贷款次数必须是数字。"
      exit sub
  end if
  if everybody then
      bankmaster=Dvbbs.MemberName
  else
      bankmaster=trim(request.form("bankmaster"))
  end if
  log_on=clng(request.form("log_on"))
  msg=trim(request.form("msg"))
  nzhml=clng(request.form("zhml"))
  integral=clng(request.form("integral"))
  ep=clng(request.form("ep"))
  pfgtimes=clng(request.form("pfgtimes"))
  Dvbbs.FoundUser=false
  foundbankuser=false
  if log_on < 0 or log_on > 10000 then
      founderr=true
      errmsg=errmsg+errmsg6+"销户手续费请输入0到10000之间的整数"
  end if
  if len(msg) > 30 then
      founderr=true
      errmsg=errmsg+errmsg6+"钱庄说明不能大于30个字符"
  end if
  if paymentforgoods > 0 or loveliness > 0 then
      if nzhml <> zhml then
          founderr=true
          errmsg=errmsg+errmsg6+"在钱庄还有贷款或库存魅力值不为0时，不允许修改贷款倍数。"
      end if
  elseif nzhml < 1 or nzhml > 10000 then
      founderr=true
      errmsg=errmsg+errmsg6+"魅力贷款倍数请输入1至10000之间的整数"
  end if
  if ep < 0 or ep > 10000 then
      founderr=true
      errmsg=errmsg+errmsg6+"转帐汇款需要的最低积分请输入0至10000之间的整数"
  end if
  if integral > 10000 or integral < 0 then
      founderr=true
      errmsg=errmsg+errmsg6+"开户最低值请输入0至10000之间的整数"
  end if
  if pfgtimes < 1 or pfgtimes > 100 then
      founderr=true
      errmsg=errmsg+errmsg6+"贷款的最高次数请输入1至100之间的整数"
  end if
  if not everybody then
      if bankmaster <> Dvbbs.MemberName then
          csql="select name from bankuser where bankid="&bankid&" and name='"&bankmaster&"'"
          set crs=cjconn.execute (csql)
          if crs.bof and crs.eof then
              notfoundbankuser=true
          else
              notfoundbankuser=false
          end if
          csql="select username from [dv_user] where username='"&bankmaster&"'"
          set crs=conn.execute (csql)
          if crs.bof and crs.eof then
              founderr=true
              errmsg=errmsg+errmsg6+"没找到你所输入的掌柜用户名，请确认该用户名存在！"
              exit sub
          else
              Dvbbs.FoundUser=true
          end if
          set crs=nothing
          if notfoundbankuser and Dvbbs.FoundUser then
              cjconn.execute ("insert into bankuser (bankid,name,currdeposit,events) values ("&bankid&",'"&bankmaster&"',"&l_trade&",'"&l_trade&"|开户|"&now()&"')")
              conn.execute ("update [dv_user] set userwealth=userwealth-"&l_trade&" where username='"&bankmaster&"'")
              '后句那一刀加
              call HyhSaveCookie(-l_trade,0,0,0,0,0)
          end if
      end if
  end if
  if not founderr then
      cjconn.execute ("update bank set bankmaster='"&bankmaster&"',log_on="&log_on&",msg='"&msg&"',zhml="&nzhml&",ep="&ep&",integral="&integral&",pfgtimes="&pfgtimes&" where bankid="&bankid)
      call yaoyue_banksuc()
  end if
end sub

sub takesalary()
  dim salarydate,datecount,times
  csql="select masterid,dateandtime from evbankmasterlog where bankid="&bankid&" and mastername='"&Dvbbs.MemberName&"'"
  set crs=cjconn.execute (csql)
  if datediff("d",datediff("d",crs(1),now()),s_datecount)>0 then
      founderr=true
      errmsg=errmsg+errmsg6+"非法操作！"
      exit sub
  end if
  if datediff("d",crs(1),now()) mod s_datecount > 0 then
      datecount = datediff("d",crs(1),now()) mod s_datecount
  else
      datecount = 0
  end if
  times = datediff("d",crs(1),now()) \ s_datecount
  salarydate = dateadd("d",-datecount,now())
  cjconn.execute ("update evbankmasterlog set salary=salary+"&salary*times&",times=times+"&times&",dateandtime='"&salarydate&"' where masterid="&crs(0))
  conn.execute ("update [dv_user] set userwealth=userwealth+"&salary*times&" where username='"&Dvbbs.MemberName&"'")
  '后句那一刀加
   call HyhSaveCookie(salary*times,0,0,0,0,0)
  call yaoyue_banksuc()
end sub

sub masterins()
  dim apporget,num,banknum,usernum
  if not isnumeric(request.form("apporget")) then
      founderr=true
      errmsg=errmsg+errmsg6+"请输入数字！"
      exit sub
  end if
  apporget=int(abs(request.form("apporget")))
  num=request.form("num")
  if num = 1 then
      banknum=" loveliness=loveliness-"&apporget&" "
      usernum=" usercp=usercp+"&apporget&" "
      if apporget > loveliness then
          founderr=true
          errmsg=errmsg+errmsg6+"你输入的数值大于钱庄现在库存的魅力值！"
      else 
        '那一刀加
        call  HyhSaveCookie(0,apporget,0,0,0,0)
      end if
  elseif num = 2 then
      banknum=" loveliness=loveliness+"&apporget&" "
      usernum=" usercp=usercp-"&apporget&" "
      if apporget > U_cp then
          founderr=true
          errmsg=errmsg+errmsg6+"你输入的数值大于你现有的魅力值！"
      else 
        '那一刀加
        call  HyhSaveCookie(0,-apporget,0,0,0,0)
      end if
  elseif num = 3 then
      banknum=" stockpile=stockpile-"&apporget&" "
      usernum=" userwealth=userwealth+"&apporget&" "
      if stockpile - apporget < regbank then
          founderr=true
          errmsg=errmsg+errmsg6+"你输入的数字使钱庄库存小于" & regbank&curr & "，请重新输入！"
      end if
  elseif num = 4 then
      banknum=" stockpile=stockpile+"&apporget&" "
      usernum=" userwealth=userwealth-"&apporget&" "
      if apporget > U_Wealth and num = 4 then
          founderr=true
          errmsg=errmsg+errmsg6+"想扩充钱庄的库存也得自己有足够的现金吧？你输入的数大于你的现金咯！"
      else
        '那一刀加
        call  HyhSaveCookie(-apporget,0,0,0,0,0)
      end if
  else
      founderr=true
      errmsg=errmsg+errmsg6+"请选择操作项！"
  end if
  if not founderr then
      cjconn.execute ("update bank set "&banknum&" where bankid="&bankid)
      conn.execute ("update [dv_user] set "&usernum&" where username='"&Dvbbs.MemberName&"'")
      call yaoyue_banksuc()
  end if
end sub

sub delpfg()
  dim pid,detaincp,pfg
  pid=trim(request.form("pid"))
  if pid="" then
      founderr=true
      errmsg=errmsg+errmsg6+"请选要清理的贷款！"
  else
      csql="select bankuserid,paymentforgoods,p_accrual,bydetaincp from paymentforgoods where pid in ("&pid&")"
      set crs=cjconn.execute (csql)
      if crs.bof and crs.eof then
          founderr=true
          errmsg=errmsg+errmsg6+"请选要清理的贷款！"
      else
          do while not crs.eof
              pfg=pfg+crs(1)
              detaincp=detaincp+crs(3)
              cjconn.execute ("update bankuser set paymentforgoods=paymentforgoods-"&crs(1)&",p_accrual=p_accrual-"&crs(2)&",bydetaincp=bydetaincp-"&crs(3)&" where bankuserid="&crs(0))
              crs.movenext
          loop
          cjconn.execute ("update bank set loveliness=loveliness+"&detaincp&",paymentforgoods=paymentforgoods-"&pfg&" where bankid="&bankid)
          cjconn.execute ("delete from paymentforgoods where pid in ("&pid&")")
          call yaoyue_banksuc()
      end if
      set crs=nothing
  end if
end sub


'-----------------------------奖励-------------------------------       
sub jiangli()       
	dim money,liyou,classid,rs2,sql2
	if not Dvbbs.master then
		founderr=true
		errmsg=errmsg+errmsg6+"您没有执行奖励的权限。"      
	else	
		if request.form("money")="" or (not isnumeric(request.form("money"))) then
			founderr=true
			errmsg=errmsg+errmsg6+"奖励金额必须为数字"	  
		elseif request.form("money")<0 then
			founderr=true
			errmsg=errmsg+errmsg6+"奖励金额不能为负数"		
		end if
		if trim(request.form("liyou"))="" then
				founderr=true
				errmsg=errmsg+errmsg6+"请输入奖励理由"	
		end if 
	end if	
	
	if founderr then
	exit sub
	end if	  

		dim classuser  '奖励单个用户
		dim usertitle
		money=clng(request.form("money"))
		liyou=trim(request.form("liyou"))
		if request.form("username") = "" then
			classid=cint(request.form("name"))
			if classid=-2 then
				usertitle="所有在线用户"
				sql="select u.userwealth,u.username,o.username from [dv_user] u inner join [dv_online] o on u.username=o.username"
				call sendmsg(usertitle,money,liyou)
     	    elseif classid=-1 then      
				usertitle="所有管理员、版主和贵宾"
	            sql="select userwealth,username from [dv_user] where usergroupid=1 or usergroupid=2 or usergroupid=3 or usergroupid=8"
				call sendmsg(usertitle,money,liyou)
            elseif classid=0 then      
				usertitle="所有用户"
				sql="select userwealth,username from [dv_user]"      
				call sendmsg(usertitle,money,liyou)
		    else
	            sql="select u.userwealth,u.username,u.usergroupid,g.title,g.usergroupid from [dv_user] u inner join dv_usergroups g on u.usergroupid=g.usergroupid where u.usergroupid="&classid
				set rs=server.createobject("adodb.recordset")      
				rs.open sql,conn,1,3
				do while not rs.eof
				usertitle="所有"&rs("title")
				rs(0)=rs(0)+money
				rs.update
					set rs2=server.createobject("adodb.recordset")
					sql2="select * from [dv_message]"
					rs2.open sql2,conn,1,3
					rs2.addnew
					rs2("sender")=bankname&"总掌柜"
					rs2("incept")=rs(1)
					rs2("title")=bankname&"给"&usertitle&"奖励"&cstr(money)&"元"
					rs2("content")=bankname&"给予"&usertitle&cstr(money)&"元奖励。奖励理由："&liyou
					rs2("flag")=0
					rs2("issend")=1
					rs2.update
					rs2.close
					call update_user_msg(rs(1))
				rs.movenext
				loop
             end if
		else
			
        	classuser=Dvbbs.CheckStr(trim(request.form("username")))
        	set rs=server.createobject("adodb.recordset")      
     		sql="select userwealth,username from [dv_user] where username='"&classuser&"'"      
     		rs.open sql,conn,1,3 
			if rs.bof and rs.eof then
				founderr=true
				errmsg=errmsg+errmsg6+"论坛上没有["&classuser&"]这个用户"
				rs.close
				exit sub
			end if					     
        	rs(0)=rs(0)+money       
        	rs.update      
				set rs2=server.createobject("adodb.recordset")      
				sql2="select * from [dv_message]"      
				rs2.open sql2,conn,1,3      
				rs2.addnew      
				rs2("sender")=bankname&"总掌柜"      
				rs2("incept")=rs(1)      
				rs2("title")=bankname&"给您奖励"+cstr(money)+"元"      
				rs2("content")=bankname&"给予您"+cstr(money)+"元奖励。奖励理由："+liyou  
				rs2("flag")=0      
				rs2("issend")=1      
				rs2.update      
				rs2.close      
				call update_user_msg(rs(1))
end if      
rs.close

if request.form("username")<>"" or usertitle<>"" then
	set rs=server.createobject("adodb.recordset")      
	sql="select * from [dv_bbsnews]"      
	rs.open sql,conn,1,3      
	rs.addnew      
	rs("boardid")=0      
	if request.form("username")="" then
		rs("title")=bankname&"奖励"&usertitle
		content=bankname&"奖励"&usertitle
	else
		classuser=Dvbbs.CheckStr(trim(request.form("username")))
		rs("title")=bankname&"奖励用户 "&classuser
		content=bankname&"奖励用户" &classuser
	end if      
	rs("content")="奖励理由："&liyou
	rs("username")=bankname&"总掌柜"
	rs.update      
	rs.close
	'那一刀改
	'Dvbbs.DelCahe "news0"
end if

if not founderr then
    call yaoyue_banksuc()
end if
end sub 

sub banktime()
dim sql
sql="update bank set opentime='"&checktime(request.form("from1"))&"|"&_
	checktime(request.form("to1"))&"||"&_
	checktime(request.form("from2"))&"|"&_
	checktime(request.form("to2"))&"||"&_
	checktime(request.form("from3"))&"|"&_
	checktime(request.form("to3"))&"||"&_
	checktime(request.form("from4"))&"|"&_
	checktime(request.form("to4"))&"||"&_
	checktime(request.form("from5"))&"|"&_
	checktime(request.form("to5"))&"' where bankid="&bankid
cjconn.execute (sql)
call yaoyue_banksuc()
end sub

function checktime(timevar)
if isnumeric(timevar)=0 or instr(timevar,":")>0 then
Dvbbs.Stats="钱庄错误信息"
founderr=true
errmsg=errmsg+errmsg6+"请输入1到24之间的数字！"
Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
else
if cint(timevar)<=24 and cint(timevar)>=0 then
checktime=timevar
else
Dvbbs.Stats="钱庄错误信息"
founderr=true
errmsg=errmsg+errmsg6+"请输入1到24之间的数字！"
Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
end if
end if

end function

sub fuwu_setting() 
dim cp,ep,power,article,announce,message,delmail,ip,fuwu_setting
sql="select * from bankconfig"
set rs=cjconn.execute(sql)
'rs.open sql,cjconn,3,1
cp=rs("cp") 			'购买魅力的价格
ep=rs("ep")				'购买经验的价格
power=rs("power")			'购买发贴数的价格
article=rs("article")			'购买威望的价格
announce=rs("announce")		'发公告的价格
message=rs("message")		'发短信息的价格
ip=rs("ip")				'查ip的价格
delmail=rs("delmail")			'删除1邮件的环保基金单价
fuwu_setting=split(rs("fuwu_setting"),",")        '是否开通服务设置
rs.close
%>          
	<table border=0 cellspacing=1 cellpadding=3 align=center class=tableborder1 style="width:97%">          
	<tr  height=22><th colspan=3  height=26 >特殊服务设置</th></tr>          
	<form name="form1" method="post" action="?bankid=<%=bankid%>&masterwork=save_fuwu">           
	<tr >          
		<td align=right width="35%" class=tablebody1>每点经验的价格：</td>          
		<td align=left width="35%" class=tablebody1><input name=ep value="<%=ep%>"> 元</td> 
		<td align=left width="30%" class=tablebody1>是否开通该服务 
		<input type=radio name="canep" value=0 <%if cint(fuwu_setting(1))=0 then%>checked<%end if%>>否&nbsp;
		<input type=radio name="canep" value=1 <%if cint(fuwu_setting(1))=1 then%>checked<%end if%>>是&nbsp;
		</td>	        
	</tr>          
	<tr >          
		<td align=right width="35%" class=tablebody1>每点魅力的价格：</td>          
		<td align=left width="35%" class=tablebody1><input name=cp value="<%=cp%>"> 元</td>          
		<td align=left width="30%" class=tablebody1>是否开通该服务 
		<input type=radio name="cancp" value=0 <%if cint(fuwu_setting(0))=0 then%>checked<%end if%>>否&nbsp;
		<input type=radio name="cancp" value=1 <%if cint(fuwu_setting(0))=1 then%>checked<%end if%>>是&nbsp;
		</td>	
	</tr>          
	<tr >         
		<td align=right width="35%" class=tablebody1>每点威望的价格：</td>        
		<td align=left width="35%" class=tablebody1><input name=power value="<%=power%>">  元</td>        
		<td align=left width="30%" class=tablebody1>是否开通该服务 
		<input type=radio name="canpower" value=0 <%if cint(fuwu_setting(2))=0 then%>checked<%end if%>>否&nbsp;
		<input type=radio name="canpower" value=1 <%if cint(fuwu_setting(2))=1 then%>checked<%end if%>>是&nbsp;
		</td>	
	</tr>        
	<tr >          
		<td align=right width="35%" class=tablebody1>每点发贴的价格：</td>          
		<td align=left width="35%" class=tablebody1><input name=article value="<%=article%>">  元</td>
		<td align=left width="30%" class=tablebody1>是否开通该服务 
		<input type=radio name="canarticle" value=0 <%if cint(fuwu_setting(3))=0 then%>checked<%end if%>>否&nbsp;
		<input type=radio name="canarticle" value=1 <%if cint(fuwu_setting(3))=1 then%>checked<%end if%>>是&nbsp;
		</td>	         
	</tr>         
	<tr >        
		<td align=right width="35%" class=tablebody1>发公告的价格：</td>        
		<td align=left width="35%" class=tablebody1><input name=announce value="<%=announce%>"> 元</td>          
		<td align=left width="30%" class=tablebody1>是否开通该服务 
		<input type=radio name="canannounce" value=0 <%if cint(fuwu_setting(4))=0 then%>checked<%end if%>>否&nbsp;
		<input type=radio name="canannounce" value=1 <%if cint(fuwu_setting(4))=1 then%>checked<%end if%>>是&nbsp;
		</td>	
	</tr>          
	<tr >          
		<td align=right width="35%" class=tablebody1>群发短信的价格：</td>          
		<td align=left width="35%" class=tablebody1><input name=message value="<%=message%>"> 元</td>  
		<td align=left width="30%" class=tablebody1>是否开通该服务 
		<input type=radio name="canmessage" value=0 <%if cint(fuwu_setting(5))=0 then%>checked<%end if%>>否&nbsp;
		<input type=radio name="canmessage" value=1 <%if cint(fuwu_setting(5))=1 then%>checked<%end if%>>是&nbsp;
		</td>	        
	</tr>          
	<tr >          
		<td align=right width="35%" class=tablebody1>看ip的价格：</td>          
		<td align=left width="35%" class=tablebody1><input name=ip value="<%=ip%>"> 元</td> 
		<td align=left width="30%" class=tablebody1>是否开通该服务 
		<input type=radio name="canip" value=0 <%if cint(fuwu_setting(6))=0 then%>checked<%end if%>>否&nbsp;
		<input type=radio name="canip" value=1 <%if cint(fuwu_setting(6))=1 then%>checked<%end if%>>是&nbsp;
		</td>	         
	</tr>          
	<tr >          
		<td align=right width="35%" class=tablebody1> 删除<font color=red>1</font>封邮件单价：</td>          
		<td align=left width="35%" class=tablebody1><input name=delmail value="<%=delmail%>"> 元</td>  
		<td align=left width="30%" class=tablebody1>是否开通该服务 
		<input type=radio name="candelmail" value=0 <%if cint(fuwu_setting(7))=0 then%>checked<%end if%>>否&nbsp;
		<input type=radio name="candelmail" value=1 <%if cint(fuwu_setting(7))=1 then%>checked<%end if%>>是&nbsp;
		</td>	         
	</tr>          
	<tr> 	       
		<td align=center colspan=3 class=tablebody2><input type=submit value=修改 name=submit></td>          
	</tr> 
	<input type=hidden value="10" name=menu>         
	</form> 	         
	</table> <br>
	<% 
end sub 

sub save_fuwu()
		if not isbankmaster then
		founderr=true
		errmsg=errmsg+errmsg6+"你没有进入服务中心管理的权限!"
	else
		if request.form("cp")="" or (not isnumeric(request.form("cp"))) then
			founderr=true
			errmsg=errmsg+errmsg6+"魅力价格必须为数字"
		elseif request.form("cp")<0 then
			founderr=true
			errmsg=errmsg+errmsg6+"魅力价格不能为负数"
		end if	 
		if request.form("ep")="" or (not isnumeric(request.form("ep"))) then
			founderr=true
			errmsg=errmsg+errmsg6+"经验价格必须为数字" 
		elseif request.form("ep")<0 then
			founderr=true
			errmsg=errmsg+errmsg6+"经验价格不能为负数"		
		end if	
		if request.form("article")="" or (not isnumeric(request.form("article"))) then
			founderr=true
			errmsg=errmsg+errmsg6+"发贴数价格必须为数字" 
		elseif request.form("article")<0 then
			founderr=true
			errmsg=errmsg+errmsg6+"发贴数价格不能为负数"			
		end if	
		if request.form("power")="" or (not isnumeric(request.form("power"))) then			
			founderr=true
			errmsg=errmsg+errmsg6+"威望价格必须为数字" 	
		elseif request.form("power")<0 then
			founderr=true
			errmsg=errmsg+errmsg6+"威望价格不能为负数"		
		end if
		if request.form("announce")="" or (not isnumeric(request.form("announce"))) then			
			founderr=true
			errmsg=errmsg+errmsg6+"公告价格必须为数字" 	
		elseif request.form("announce")<=0 then
			founderr=true
			errmsg=errmsg+errmsg6+"公告价格不能为负数"		
		end if
		if request.form("message")="" or (not isnumeric(request.form("message"))) then
			founderr=true
			errmsg=errmsg+errmsg6+"群发短信息价格必须为数字"
		elseif request.form("message")<0 then
			founderr=true
			errmsg=errmsg+errmsg6+"群发短信息价格不能为负数"		
		end if
		if request.form("ip")="" or (not isnumeric(request.form("ip"))) then
			founderr=true
			errmsg=errmsg+errmsg6+"查在线会员ip信息价格必须为数字"
		elseif request.form("ip")<0 then
			founderr=true
			errmsg=errmsg+errmsg6+"查在线会员ip信息价格不能为负数"		
		end if
		if request.form("delmail")="" or (not isnumeric(request.form("delmail"))) then
			founderr=true
			errmsg=errmsg+errmsg6+"删除邮件单价必须为数字"
		elseif request.form("delmail")<0 then
			founderr=true
			errmsg=errmsg+errmsg6+"删除邮件单价不能为负数"		
		end if				
	end if	
	if founderr then      
		exit sub
	else
		set rs=server.createobject("adodb.recordset")
		sql="select * from bankconfig"
		rs.open sql,cjconn,1,3
		rs("cp")=request.form("cp")
		rs("ep")=request.form("ep")
		rs("power")=request.form("power")
		rs("article")=request.form("article")
		rs("announce")=request.form("announce")
		rs("message")=request.form("message")
		rs("ip")=request.form("ip")
		rs("delmail")=request.form("delmail")         
		
		'cancp/canep/canpower/canarticle/canannounce/canmessage/canip/candelmail  1-是 0－否
		rs("fuwu_setting")=request.form("cancp") & "," & request.form("canep")& "," & request.form("canpower")& "," & request.form("canarticle")& "," & request.form("canannounce")& "," & request.form("canmessage")& "," & request.form("canip")& "," & request.form("candelmail")
		rs.update
		rs.close
      call yaoyue_banksuc()
	end if	
end sub

sub getgroup()
dim rs,sql
%>
<select name="name">      
    <option value="-2" selected>所有在线用户</option>
    <option value="-1">所有管理员、版主和贵宾</option>
    <option value="0">所有用户(包括管理员、版主和贵宾)</option>
<%
set rs=server.createobject("adodb.recordset")
sql="select usergroupid,title from dv_usergroups"
rs.open sql,conn,1,3
do while not rs.eof
if rs("usergroupid")<5 or rs("usergroupid")>7 then
if rs("usergroupid")=4 then
%>
    <option value="<%=rs("usergroupid")%>">所有<%=rs("title")%>(不包括管理员、版主和贵宾)</option>
<%elseif rs("title")<>"注册用户" then%>
    <option value="<%=rs("usergroupid")%>">所有<%=rs("title")%></option>
<%
end if
end if
rs.movenext
loop
rs.close
set rs=nothing
%>
  </select>  奖励单个会员请填写：<input name=username>
<%
end sub

sub sendmsg(usertitle,money,liyou)
dim rs2,sql2
set rs=server.createobject("adodb.recordset")      
rs.open sql,conn,1,3
do while not rs.eof
rs(0)=rs(0)+money
rs.update
	set rs2=server.createobject("adodb.recordset")
	sql2="select * from [dv_message]"
	rs2.open sql2,conn,1,3
	rs2.addnew
	rs2("sender")=bankname&"总掌柜"
	rs2("incept")=rs(1)
	rs2("title")=bankname&"给"&usertitle&"奖励"&cstr(money)&"元"
	rs2("content")=bankname&"给予"&usertitle&cstr(money)&"元奖励。奖励理由："&liyou
	rs2("flag")=0
	rs2("issend")=1
	rs2.update
	rs2.close
	call update_user_msg(rs(1))
rs.movenext         
loop      
end sub

'更新用户短信通知信息（新短信条数||新短讯ID||发信人名）
Sub UPDATE_User_Msg(username)
	Dim msginfo,i,UP_UserInfo,newmsg
	newmsg=newincept(username)
	If newmsg>0 Then
		msginfo=newincept(username) & "||" & inceptid(1,username) & "||" & inceptid(2,username)
	Else
		msginfo="0||0||null"
	End If
	Dvbbs.execute("UPDATE [Dv_User] Set UserMsg='"&Dvbbs.CheckStr(msginfo)&"' WHERE username='"&Dvbbs.CheckStr(username)&"'")
	If username=Dvbbs.MemberName Then
		Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usermsg").text=msginfo
	Else
		Call Dvbbs.NeedUpdateList(username,1)
	End If
End Sub

'统计留言
Function newincept(iusername)
Dim Rss
Rss=Dvbbs.execute("SELECT Count(id) FROM Dv_Message WHERE flag=0 And issend=1 And DelR=0 And incept='"& iusername &"'")
    newincept=Rss(0)
	Set Rss=nothing
	If isnull(newincept) Then newincept=0
End Function

Function inceptid(stype,iusername)
	dim Rss
	Set Rss=Dvbbs.execute("SELECT top 1 id,sender FROM Dv_Message WHERE flag=0 And issend=1 And DelR=0 And incept='"& iusername &"'")
	If not Rss.eof Then
		If stype=1 Then
			inceptid=Rss(0)
		Else
			inceptid=Rss(1)
		End If
	Else
		If stype=1 Then
			inceptid=0
		Else
			inceptid="null"
		End If
	End If
	Set Rss=nothing
End Function
sub HyhSaveCookie(UserWealth,UserCP,UserEP,UserPower,UserMoney,Usertopic)
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@activetime").text = Now()
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@usermoney").text=DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@usermoney").text+cCur(UserMoney)
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userpost").text=DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userpost").text+Clng(Usertopic)
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text=DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text+cCur(UserWealth)
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userep").text=DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userep").text+Clng(UserEP)
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@usercp").text=DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@usercp").text+Clng(UserCP)
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userpower").text=DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userpower").text+Clng(UserPower)
end sub
%>

<%
'黄河7.0插件自助升级器2004-1-7 18:26:34自动添加
sub new_head()
Dvbbs.Head_var 3,0,"钱庄</a> → "&"<a href=bank_main.asp?bankid="&BankID&">"&bankname,"bank_index.asp"
end sub
%>