<!--#include file=../conn.asp-->
<!-- #include file="inc/const.asp" -->
<%Head()
	dim admin_flag
	admin_flag=",19,"
	if not master or instr(","&session("flag")&",",admin_flag)=0 then
		Errmsg=ErrMsg + "<BR><li>本页面为管理员专用，请<a href=../"&LoginUrl&" target=_top>登录</a>后进入。<br><li>您没有管理本页面的权限。"
		Call Ms_error()
	End If
		Main(1)
		Select Case Request("action")
		Case "search"''读取数据列表
		call search()
		Case "Toset"''执行操作
		call Toset()
		Case "view"''查看聚会
		call view()
		Case "view_j"''响应会员列表
		call view_j()
		Case "Tojoin"''响应会员管理
		call Tojoin()
		Case Else
		call sIndex()''搜索表单
		End Select
		Main(0)
		Footer()

sub main(Str)
if Str=1 then%>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
  <tr> 
    <th height="23" colspan="8" class="tableHeaderText">网友聚会管理中心</th>
  </tr>
  <tr> 
    <td width="18%" height="25" align="center" class="forumrow">注意事项</td>
    <td width="77%" height="25" class="forumrow" colspan="7">
	<li>删除聚会此操作是不可逆的；</li>
	<li>可进行审核、删除操作；</li>
	<li>点击聚会名称进入查看聚会；</li>
	<li>点击相应类别进入查看该类所有聚会。</li>
	</td>
  </tr>
  <tr> 
    <td height="29" align="center" class="forumRowHighlight">快捷方式</td>
	<td width="77%" height="29" class="forumRowHighlight" colspan="7"><a href="klatch.asp">管理首页</a> 
      | <a href="?action=search&t=1">所有聚会</a> 
      | <a href="?action=search&t=2">最新100</a> | <a href="?action=search&t=3">人气100</a> 
      | <a href="?action=search&t=4">未审聚会</a> | <a href="?action=search&t=5">已经结束</a> | <a href="?action=search&t=6">已审核</a></td>
  </tr>
  <%
	Else
%>
</table>
<p></p>
<%end if
end sub

sub sIndex()''搜索%>
<form action="?action=search" method=post>
<input type=hidden name="t" value="7"> 
<tr>
<th align=left colspan=8 height=23>高级聚会查询</th>
</tr>
<tr>
<td width=20% class=forumrow>注意事项</td>
<td width=80% class=forumrow colspan=7>在记录很多的情况下搜索条件越多查询越慢，请尽量减少查询条件</td>
</tr>
<tr>
<td width=20% class=forumrow>会员姓名</td>
<td width=80% class=forumrow colspan=7><input name="username" type="text" size="20">&nbsp;<input type=checkbox name="like" value="1" checked>
      完整匹配</td>
</tr>
<tr>
<td width=20% class=forumrow>聚会名称</td>
<td width=80% class=forumrow colspan=7><input name="title" type="text" size="30">
</td>
</tr>
<tr>
<td width=20% class=forumrow>聚会类别</td>
<td width=80% class=forumrow colspan=7>
<select name="Typeid">
<option value=""></option>
      <option value="1">周末闲聊</option>
	  <option value="2">酒吧畅饮</option>
	  <option value="3">郊外远足</option>
	  <option value="4">游戏切磋</option>
	  <option value="5">逛街看戏</option>
	  <option value="6">白领聚会</option>
    </select></td>
</tr>
<tr>
<td width=20% class=forumrow>所在城市</td>
<td width=80% class=forumrow colspan=7><input name="City" type="text" size="20">
</td>
</tr>
<tr>
<td width=100% class=forumrow align=center colspan=8><input name="submit" type=submit value="   搜  索   "></td>
</tr>
</form>
<%
end sub


sub search()''列出所有聚会数据
strFileName="klatch.asp?action="&Request("action") & "&t="&request("t")&"&typeid="&request("typeid")&"&city="&request("City")&""
call tumppages()
dim sql
sql = " Kid,Username,Title,Typeid,Enddate,City,Checked,Joinnum,hits "%>
<tr>
<th colspan=8 align=left height=23>搜索结果</th>
</tr>
<FORM METHOD=POST ACTION="?action=Toset">
<tr align=center height=23>
<td class=forumRowHighlight width="18%"><B>发起人</B></td>
<td class=forumRowHighlight width="28%"><B>聚会名称</B></td>
<td class=forumRowHighlight width="10%"><B>类别</B></td>
<td class=forumRowHighlight width="14%"><B>结束时间</B></td>
<td class=forumRowHighlight width="8%"><B>城市</B></td>
<td class=forumRowHighlight width="6%"><B>状态</B></td>
<td class=forumRowHighlight width="5%"><B>人气</B></td>
<td class=forumRowHighlight><B>操作</B></td>
</tr>
<%dim sqlstr
set rs=server.createobject("adodb.recordset")
Select Case Request("t")
	Case 1
		Sql = "SELECT " & sql & " from Ms_klatch ORDER BY KID DESC"
	Case 2
		Sql = "SELECT top 100 " & sql & " from Ms_klatch ORDER BY KID DESC"
	case 3
		Sql = "SELECT top 100 " & sql & " from Ms_klatch ORDER BY hits DESC"
	case 4
		Sql = "SELECT " & sql & " from Ms_klatch where Checked=0 ORDER BY KID DESC"
	case 5
		If IsSqlDataBase=1 Then
		sql="select " & sql & " from Ms_klatch where datediff(day,"&SqlNowString&",Enddate)<1 order by KID desc"
		else
		sql="select " & sql & " from Ms_klatch where datediff('d',"&SqlNowString&",Enddate)<1 order by KID desc"
		end if
	case 6
		Sql = "SELECT " & sql & " from Ms_klatch where Checked=1 ORDER BY KID DESC"
	case 8
		Sql = "SELECT " & sql & " from Ms_klatch where typeid="&request("Typeid")&" ORDER BY KID DESC"	
	case 7''搜索开始
	sqlstr=""''搜索开始
		if request("username")<>"" then
			if request("like")=1 then
			sqlstr=" username='"&request("username")&"' "
			else
			sqlstr=" username like '%"&request("username")&"%' "
			end if
		end if
	if request("Typeid")<>"" then
			if sqlstr<>"" then
			sqlstr=sqlstr & " and Typeid="&request("Typeid")&" "
			else
			sqlstr=" Typeid="&request("Typeid")&" "
			end if
		end if
	if request("title")<>"" then
			if sqlstr<>"" then
			sqlstr=sqlstr & " and title like '%"&request("title")&"%' "
			else
			sqlstr=" title like '%"&request("title")&"%' "
			end if
		end if
	if request("City")<>"" then
			if sqlstr<>"" then
			sqlstr=sqlstr & " and City ='"&request("City")&"' "
			else
			sqlstr=" City ='"&request("City")&"' "
			end if
		end if	
		if sqlstr<>"" then
		Sql = "SELECT " & sql & " FROM Ms_klatch WHERE " & Sqlstr & " ORDER BY kID DESC"
		else
		Response.Write "<tr><td colspan=8 class=forumrow>搜索条件不能都为空。</td></tr>"
		Response.End
		end if			
	case else
		Response.Write "<tr><td colspan=8 class=forumrow>错误的参数。</td></tr>"
		Response.End
	End Select
	rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
call rspages()
do while not rs.eof and page_count<Cint(MaxPerPage)%>
<tr align=center height=23>
<td class=forumrow width="12%"><a href="admin_user.asp?action=modify&username=<%=rs(1)%>"><%=rs(1)%></a></td>
<td class=forumrow width="28%" align="left"><a href=?action=view&id=<%=rs(0)%> title="聚会信息"><%=rs(2)%></a> <font color="#666666">[<a href=?action=view_j&id=<%=rs(0)%> title="参加会员列表"><%=rs(7)%></a>]</font></td>
<td class=forumrow width="10%"><%if rs(3)=1 then
	response.write("<a href=?action=search&t=8&typeid=1>周末闲聊</a>")
	elseif rs(3)=2 then
	response.write("<a href=?action=search&t=8&typeid=2>酒吧畅饮</a>")
	elseif rs(3)=3 then
	response.write("<a href=?action=search&t=8&typeid=3>郊外远足</a>")
	elseif rs(3)=4 then
	response.write("<a href=?action=search&t=8&typeid=4>游戏切磋</a>")
	elseif rs(3)=5 then
	response.write("<a href=?action=search&t=8&typeid=5>逛街看戏</a>")
	elseif rs(3)=6 then
	response.write("<a href=?action=search&t=8&typeid=6>白领聚会</a>")
	else
	response.write("<a href=?action=search&t=8&typeid=7><font color=red>网站活动</font></a>")
	end if%></td>
<td class=forumrow width="14%"><%=rs(4)%></td>
<td class=forumrow width="8%"><%=rs(5)%></td>
<td class=forumrow width="6%">
<%if rs(6)=0 then
response.Write("<font color=red>未审</font>")
else
response.Write("<font color=green>已审</font>")
end if%></td>
<td class=forumrow width="5%"><%=rs(8)%></td>
<td class=forumrow><input type="checkbox" name="id" value="<%=rs(0)%>"></td>
</tr>
<%page_count=page_count+1
  rs.movenext
  loop
  else
  response.Write("<tr><td colspan=8 class=forumrow>暂时数据。</td></tr>")
  end if
  if totalrec>0 then%>
<tr align="center"> 
      <td height="24" colspan="8" class=forumrow><%
		  	call showpage(strFileName)
		  %></td>
    </tr>
<%end if%>
<tr align="center"> 
      <td height="24" colspan="8" class=forumrow align="right"><input type="radio" name="paction" value="1">删除记录
	  <input type="radio" name="paction" value="2">审核操作
	  <select name="chkset">
	  <option value=""></option>
	  <option value=1>选定审核</option>
	  <option value=2>全部审核</option>
	  <option value=3>选定撤消</option>
	  <option value=4>全部撤消</option>
	  </select>
	  全部选定<input type=checkbox value="on" name="chkall" onclick="CheckAll(this.form)"></td>
    </tr>
	<tr align="center"> 
      <td height="24" colspan="8" class=forumRowHighlight><input type=submit name=submit value="执行操作"  onclick="{if(confirm('确定执行操作吗?')){return true;}return false;}"></td>
    </tr>
</form>
<%end sub

sub Toset()''执行操作
dim delid,fixid,Maxnum
response.write "<tr><th colspan=8 height=23 align=left>执行结果</th></tr>"
	if request("paction")="" then
		response.write "<tr><td colspan=8 class=forumrow>请指定相关参数。</td></tr>"
		founderr=true
	end if
	delid=replace(request.form("id"),"'","")
	delid=replace(delid,";","")
	delid=replace(delid,"--","")
	delid=replace(delid,")","")
	fixid=replace(delid,",","")
	fixid=Trim(replace(fixid," ",""))
if not founderr then
		if request("paction")=1 then''删除操作
				Conn.Execute("delete from Ms_klatch where Kid in ("&delid&")")
				Conn.Execute("delete from Ms_kljoin where Kid in ("&delid&")")''删除加入的用户
				response.write "<tr><td colspan=8 class=forumrow>删除聚会成功。</td></tr>"
		elseif request("paction")=2 then''审核操作
			if Cint(request("chkset"))=1 then
			Conn.Execute("update Ms_klatch set Checked=1 where Kid in ("&delid&")")''审核聚会记录
		response.write "<tr><td colspan=8 class=forumrow>选定审核聚会成功。</td></tr>"
			elseif Cint(request("chkset"))=2 then
			Conn.Execute("update Ms_klatch set Checked=1 where Checked=0")''审核聚会记录
		response.write "<tr><td colspan=8 class=forumrow>全部审核聚会成功。</td></tr>"
			elseif Cint(request("chkset"))=3 then
			Conn.Execute("update Ms_klatch set Checked=0 where Kid in ("&delid&")")''撤消聚会记录
		response.write "<tr><td colspan=8 class=forumrow>选定撤消聚会成功。</td></tr>"
			elseif Cint(request("chkset"))=4 then
			Conn.Execute("update Ms_klatch set Checked=0 where Checked=1")''撤消聚会记录
		response.write "<tr><td colspan=8 class=forumrow>全部撤消聚会成功。</td></tr>"
			end if
		else
		response.write "<tr><td colspan=8 class=forumrow>错误的参数。</td></tr>"
		end if
end if
end sub

sub view_j()''查看参加会员列表
strFileName="klatch.asp?action="&request("view_j")&"&id="&Request("Pid") & ""
call tumppages()
dim sql
sql = " ID,Username,Jointime,Checked "
%>
<tr>
<th colspan=8 align=left height=23>参加会员列表</th>
</tr>
<FORM METHOD=POST ACTION="?action=Tojoin">
<tr align="center"> 
      <td width="17%" height="27" class=forumRowHighlight>会员名称</td>
      <td width="18%" class=forumRowHighlight>参加时间</td>
      <td width="10%" class=forumRowHighlight>状态</td>
      <td class=forumRowHighlight colspan="4">操作</td>
    </tr>
	<%set rs=server.createobject("adodb.recordset")
  sql="select " & sql & " from Ms_kljoin where KID="&request("id")&""
rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
call rspages()
do while not rs.eof and page_count<Cint(MaxPerPage)%>
<tr align=center height=23>
  <td class=forumrow width="17%"><a href="admin_user.asp?action=modify&username=<%=rs(1)%>"><%=rs(1)%></a></td>
  <td class=forumrow width="16%"><%=rs(2)%></td>
  <td class=forumrow width="10%"><%if rs(3)=0 then
	response.Write("<font color=#999999>未审核</font>")
	elseif rs(3)=1 then
	response.Write("<font color=red>已审核</font>")
	end if%></td>
  <td class=forumrow colspan="4"><input type="checkbox" name="id" value="<%=rs(0)%>"></td>
</tr>
<%page_count=page_count+1
  rs.movenext
  loop
  end if
  if totalrec>0 then%>
  <tr align="center"> 
      <td height="24" colspan="8" class=forumrow> <%
		  	call showpage(strFileName)
		  %></td>
    </tr>
<%end if%>
<tr align="center"> 
      <td height="24" colspan="8" class=forumrow align=right><input type="radio" name="jaction" value=1>删除记录
	  <input type="radio" name="jaction" value="2">审核操作
	  <select name="chkset">
	  <option value=""></option>
	  <option value=1>选定审核</option>
	  <option value=2>全部审核</option>
	  <option value=3>选定撤消</option>
	  <option value=4>全部撤消</option>　
	  </select>
	  <input type="hidden" name="Kid" value="<%=request("id")%>">
全部选定<input type=checkbox value="on" name="chkall" onclick="CheckAll(this.form)"></td>
    </tr>
	<tr align="center"> 
      <td height="24" colspan="8" class=forumRowHighlight><input type=submit name=submit value="执行操作"  onclick="{if(confirm('确定执行操作吗?')){return true;}return false;}"></td>
    </tr>
</form>
<%end sub

sub Tojoin()''加入操作
dim delid,fixid,Maxnum
response.write "<tr><th colspan=8 height=23 align=left>执行结果</th></tr>"
	if request("jaction")="" then
		response.write "<tr><td colspan=8 class=forumrow>请指定相关参数。</td></tr>"
		founderr=true
	end if
	delid=replace(request.form("id"),"'","")
	delid=replace(delid,";","")
	delid=replace(delid,"--","")
	delid=replace(delid,")","")
	fixid=replace(delid,",","")
	fixid=Trim(replace(fixid," ",""))
if not founderr then
		if request("jaction")=1 then''删除操作
				Maxnum=ubound(split(delid,","))
				Conn.Execute("delete from Ms_kljoin where ID in ("&delid&")")''删除加入的用户
				conn.execute("Update Ms_klatch set Joinnum=Joinnum-"&(Maxnum+1)&" where Kid="&request("id")&"")
				response.write "<tr><td colspan=8 class=forumrow>删除参加会员成功。</td></tr>"
		elseif request("jaction")=2 then''审核操作
			if Cint(request("chkset"))=1 then
			Conn.Execute("update Ms_kljoin set Checked=1 where ID in ("&delid&")")''审核响应聚会记录
		response.write "<tr><td colspan=8 class=forumrow>选定审核响应聚会成功。</td></tr>"
			elseif Cint(request("chkset"))=2 then
			Conn.Execute("update Ms_kljoin set Checked=1 where Checked=0")''审核响应聚会记录
		response.write "<tr><td colspan=8 class=forumrow>全部审核响应聚会成功。</td></tr>"
			elseif Cint(request("chkset"))=3 then
			Conn.Execute("update Ms_kljoin set Checked=0 where ID in ("&delid&")")''撤消响应聚会记录
		response.write "<tr><td colspan=8 class=forumrow>选定撤消响应聚会成功。</td></tr>"
			elseif Cint(request("chkset"))=4 then
			Conn.Execute("update Ms_kljoin set Checked=0 where Checked=1")''撤消响应聚会记录
		response.write "<tr><td colspan=8 class=forumrow>全部撤消响应聚会成功。</td></tr>"
			end if
		else
		response.write "<tr><td colspan=8 class=forumrow>错误的参数。</td></tr>"
		end if
end if
end sub

sub view()''查看聚会
sql="select * from [Ms_klatch] where Kid="&request("id")&""
		set rs=conn.execute(Sql)
		if not (rs.eof and rs.bof) then
%><tr><th colspan=8 height=23 align=center><%=rs("Username")%> 的聚会</th></tr>
  <TR> 
    <TD  class=forumrow>聚会名称：</TD>
                            <TD colspan=7 class=forumrow><%=rs("title")%></TD>
                          </TR>
                          <TR> 
                            <TD  class=forumrow>聚会类别：</TD>
                            <TD colspan=7 class=forumrow><%
	  Select Case rs("Typeid")
	Case 1
	response.Write("周末闲聊")
	Case 2
	response.Write("酒吧畅饮")
	Case 3
	response.Write("郊外远足")
	Case 4
	response.Write("游戏切磋")
	Case 5
	response.Write("逛街看戏")
	Case 6
	response.Write("白领聚会")
	Case 7
	response.Write("网站活动")
	End Select%></TD>
                          </TR>
                          <TR> 
                            <TD class=forumrow>开始时间：</TD>
                            <TD colspan=7 class=forumrow><%=rs("Stardate")%></TD>
                          </TR>
                          <TR> 
                            <TD  class=forumrow>结束时间：</TD>
                            <TD colspan=7 class=forumrow><%=rs("Enddate")%></TD>
                          </TR>
                          <TR> 
                            <TD  class=forumrow>所在城市：</TD>
                            <TD colspan=7 class=forumrow><%=rs("State")%>－<%=rs("City")%></TD>
                          </TR>
                          <TR> 
                            <TD  class=forumrow>聚会地点：</TD>
                            <TD colspan=7 class=forumrow><%=rs("Address")%></TD>
                          </TR>
                          <TR> 
                            <TD  class=forumrow>聚会性别：</TD>
                            <TD colspan=7 class=forumrow><%if rs("Klatchsex")=1 then
							response.Write("先生")
							elseif rs("Klatchsex")=0 then
							response.Write("小姐")
							else
							response.write("不限")
							end if
							%></TD>
                          </TR>
                          <TR> 
                            <TD  class=forumrow>聚会年龄：</TD>
                            <TD colspan=7 class=forumrow><%=rs("Minage")%>－<%=rs("Maxage")%>岁</TD>
                          </TR>
                          <TR> 
                            <TD  class=forumrow>接头暗号：</TD>
                            <TD colspan=7 class=forumrow><%=rs("Klanhao")%></TD>
                          </TR>
                          <TR> 
                            <TD  class=forumrow>邀请人数：</TD>
                            <TD colspan=7 class=forumrow><%if rs("quota")=0 then
							response.Write("不限")
							else
							response.Write(rs("quota"))
							end if%></TD>
                          </TR>
                          <TR> 
                            <TD class=forumrow>费用预算：</TD>
                            <TD colspan=7 class=forumrow><%=rs("Money")%> 元/人</TD>
                          </TR>
                          <TR> 
                            <TD class=forumrow>联系方式：</TD>
                            <TD colspan=7 class=forumrow>电话：<%=split(rs("Touch"),"|")(0)%><br>
                              手机：<%=split(rs("Touch"),"|")(1)%><br>
                              邮件：<%=split(rs("Touch"),"|")(2)%> </TD>
                          </TR>
                          <TR> 
                            <TD class=forumrow>聚会内容：</TD>
                            <TD colspan=7 class=forumrow><%=rs("Content")%></TD>
                          </TR>
                          <TR> 
                            <TD  class=forumrow>注意事项：</TD>
                            <TD colspan=7 class=forumrow><%=rs("Notice")%></TD>
                          </TR>
                          <TR> 
                            <TD  class=forumrow>交通线路：</TD>
                            <TD colspan=7 class=forumrow><%=rs("Takebus")%></TD>
                          </TR>
                          <TR> 
                            <TD class=forumrow>报名说明：</TD>
                            <TD colspan=7 class=forumrow><%=rs("Joinsay")%></TD>
                          </TR>
<%end if
rs.close
end sub%>