<!--#include file="inc/inc_sys.asp"-->
<!--#include file="../inc/class_blog.asp"-->
<%
dim rs, sql
dim UserID,cmd,Keyword,sField
dim str
keyword=trim(request("keyword"))
if keyword<>"" then
	keyword=oblog.filt_badstr(keyword)
end if
sField=trim(request("Field"))
cmd=trim(request("cmd"))
Action=trim(request("Action"))
UserID=trim(Request("UserID"))


if cmd="" then
	cmd=0
else
	cmd=Clng(cmd)
end if

G_P_FileName="m_team.asp?cmd=" & cmd
if sField<>"" then
	G_P_FileName=G_P_FileName&"&Field="&sField
end if
if keyword<>"" then 
	G_P_FileName=G_P_FileName&"&keyword="&keyword 
	cmd=10
End If

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>oBlog--<%=P_QQ_NAME%>管理</title>
<link rel="stylesheet" href="images/style.css" type="text/css" />
<script src="images/menu.js" type="text/javascript"></script>
</head>
<body>
<div id="main_body">
	<ul class="main_top">
		<li class="main_top_left left"><%=P_QQ_NAME%>管理</li>
		<li class="main_top_right right"> </li>
	</ul>
	<div class="main_content_rightbg">
		<div class="main_content_leftbg">
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" Class="border" id="table1">
  <form name="form1" action="m_team.asp" method="get">
    <tr class="tdbg">
      <td width="100" height="30"><strong>快速查找<%=P_QQ_NAME%>：</strong></td>
      <td width="687" height="30">
		<select size=1 name="cmd" onChange="javascript:submit()">
          <option value=>请选择查询条件</option>
		  <option value="0">等待认证的<%=P_QQ_NAME%></option>
          <option value="1">被锁住的<%=P_QQ_NAME%></option>
          <option value="2">最后注册的50个<%=P_QQ_NAME%></option>
          <option value="3">积分最高TOP10</option>
          <option value="4">积分最低的10个<%=P_QQ_NAME%></option>

        </select>
        &nbsp;&nbsp;&nbsp;&nbsp;<a href="m_team.asp"><%=P_QQ_NAME%>管理首页</a></td>
    </tr>
  </form>
  <form name="form2" method="post" action="m_team.asp">
  <tr class="tdbg">
    <td width="120"><strong><%=P_QQ_NAME%>高级查询：</strong></td>
    <td >
      <select name="Field" id="Field">
      <option value="teamid" selected><%=P_QQ_NAME%>ID</option>
	  <option value="teamname" selected><%=P_QQ_NAME%>名</option>
      <option value="UserID" ><%=P_QQ_MASTERNAME%>ID</option>
	  <option value="username" ><%=P_QQ_MASTERNAME%>名</option>

      </select>
      <input name="Keyword" type="text" id="Keyword" size="20" maxlength="30">
      <input type="submit" name="Submit2" value=" 查 询 ">
      <input name="cmd" type="hidden" id="cmd" value="10">
	  若为空，则查询所有<%=P_QQ_NAME%></td>
  </tr>
</form>
</table>
		</div>
	</div>
	<ul class="main_end">
		<li class="main_end_left left"></li>
		<li class="main_end_right right"></li>
	</ul>
</div>
<%
Dim s1,actionStr,teamid
s1=Request("s1")
teamid=Request("teamid")
If teamid<>"" Then teamid=Int(teamid)
Select Case LCase(Action)
	Case "modifystate"
			Select Case s1
				Case "1"
					actionStr="通过审核"
					Call TeamScore(teamid)
					oblog.Execute("Update oblog_team Set istate=3 Where teamid=" & teamid)
				Case "2"
					actionStr="锁定"
					oblog.Execute("Update oblog_team Set istate=2 Where teamid=" & teamid)
				Case "4"
					actionStr="解除锁定"
					oblog.Execute("Update oblog_team Set istate=3 Where teamid=" & teamid)
				Case "3"
					actionStr="删除"
'					oblog.Execute("Update oblog_team Set istate=0 Where teamid=" & teamid)
					oblog.Execute("DELETE FROM oblog_team Where teamid=" & teamid)
			End Select
			oblog.showok "群组" & actionStr & "成功",""
	Case "best"
		call best()
	Case "delteam"
		call delteam()
	Case else
		call main()
end Select
if FoundErr=true then
	call WriteErrMsg()
end If

Sub TeamScore(teamid)
	Dim rs
	Set rs = oblog.Execute ("SELECT createrid FROM oblog_team WHERE teamid = " &teamid)
	oblog.GiveScore "" ,oblog.CacheScores(12),rs(0)
	rs.close
	Set rs=Nothing
End Sub

sub main()
	
	sGuide=""
	select case cmd
		case 0
			sql="select top 500 * from oblog_team Where istate=1 order by teamid desc"
			sGuide=sGuide & "等待管理认证的" & P_QQ_NAME
		case 1
			sql="select top 500 * from oblog_team Where istate=2 order by teamid desc"
			sGuide=sGuide & "所有被锁住的" & P_QQ_NAME
		case 2
			sql="select top 500 * from oblog_team Where istate>0 order by teamid desc"
			sGuide=sGuide & "最后注册的500个" & P_QQ_NAME
		case 3
			sql="select top 500 * from oblog_team Where istate=3 order by teamscore desc"
			sGuide=sGuide & "积分最高的前500个" & P_QQ_NAME
		case 4
			sql="select top 500 * from oblog_team Where istate=3 order by teamscore"
			sGuide=sGuide & "积分最少的10个" & P_QQ_NAME
		case 10
			if Keyword="" then
				sql="select top 500 * from oblog_team order by teamid Desc"
				sGuide=sGuide & "所有" & P_QQ_NAME
			else
				select case LCase(sField)
				case "userid"
					if IsNumeric(Keyword)=false then
						FoundErr=true
						ErrMsg=ErrMsg & "<br><li>"&P_QQ_MASTERNAME&"ID必须是整数！</li>"
					else
						sql="select * from oblog_team where managerid=" & Clng(Keyword)
						sGuide=sGuide & P_QQ_MASTERNAME & "ID等于<font color=red> " & Clng(Keyword) & " </font>的" & P_QQ_NAME
					end if
				case "username"
					sql="select * from oblog_team where managername like '%" & Keyword & "%'"
					sGuide=sGuide & P_QQ_MASTERNAME &"用户名中含有“ <font color=red>" & Keyword & "</font> ”的" & P_QQ_NAME					
				case "teamname"
					sql="select * from oblog_team where t_name like '%" & Keyword & "%'"
					sGuide=sGuide & P_QQ_NAME &"名称中含有“ <font color=red>" & Keyword & "</font> ”的" & P_QQ_NAME	
				case "teamid"
					sql="select * from oblog_team where teamid=" & Clng(Keyword)
					sGuide=sGuide & P_QQ_NAME &"ID等于“ <font color=red>" & Keyword & "</font> ”的" & P_QQ_NAME	
				end select
			end if
		case else
			FoundErr=true
			ErrMsg=ErrMsg & "<br><li>错误的参数！</li>"
	end select
	If sGuide="" Then sGuide="群组管理"
	if FoundErr=true then exit sub
	if not IsObject(conn) then link_database
	Set rs=Server.CreateObject("Adodb.RecordSet")
	'response.write sql
	rs.Open sql,Conn,1,1
	%>
	<div id="main_body">
	<ul class="main_top">
		<li class="main_top_left left"><%=sGuide%></li>
		<li class="main_top_right right"> </li>
	</ul>
	<div class="main_content_rightbg">
		<div class="main_content_leftbg">
			<%
	Call oblog.MakePageBar(rs,"个" & P_QQ_NAME)
	%>
	 </table>
		</div>
	</div>
	<%
	rs.Close
	set rs=Nothing
end sub

sub showContent()
   	dim i
    i=0
%>
<style type="text/css">
<!--
.border tr td {padding:3px 0!important;}
-->
</style>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border" id="table3">
          <tr class="title">
            <td width="44" align="center"><strong>ID</strong></td>
            <td width="90" align="center"><strong><%=P_QQ_NAME%>LOGO</strong></td>
            <td width="160" align="center"><strong><%=P_QQ_NAME%>名 <%=P_QQ_MASTERNAME%> 申请时间</strong></td>
            <td width="60" align="center"><strong>会员数</strong></td>
            <td width="50" align="center"><strong>主贴</strong></td>
            <td width="50" align="center"><strong>回复</strong></td>
            <td align="center"><strong>申请说明</strong></td>
            <td  width="80" align="center" ><strong>操作</strong></td>
          </tr>
          <%
          Dim icoUrl                  	
          do while not rs.EOF 
          	icoUrl=rs("t_ico")
          	If LCase(Left(icoUrl,7))<>"http://" Then icoUrl="../" & icoUrl
          	%>
          <tr class="tdbg">
            <td style="font-family:Century Gothic,verdana,tahoma,Arial,Helvetica,sans-serif;font-size:10px;font-weight:600;" align="center"><%=rs("teamid")%></td>
            <td align="center"><a href="<%=icoUrl%>" target="_blank" title="点击查看该图"><img src="<%=icoUrl%>" align="absmiddle" style="width:80px;height:60px;border:0;"></a></td>
            <td><span style="display:block;padding:0 0 0 8px!important;"><a href="../group.asp?gid=<%=rs("teamid")%>" target="_blank"><%=rs("t_name")%></a></span><span style="display:block;padding:0 0 0 8px!important;color:#217dbd;">组长：<a href="../go.asp?userid=<%=rs("managerid")%>" target="_blank"><%=rs("managername")%></a></span><span style="display:block;color:#999;font-family:tahoma,Arial,Helvetica,sans-serif;font-size:10px;padding:0 0 0 8px!important;"><%=rs("createtime")%></span></td>
            <td align="center" style="font-weight:600;color:#217dbd;">
			<%=rs("icount0")%>人
            </td>
        	<td align="center" style="font-weight:600;color:#f00;">
            <%=rs("icount1")%>
			</td>
        	<td align="center" style="font-weight:600;color:#090;">
            <%=rs("icount2")%>
			</td>
            <td valign="top">
			<span style="padding:6px;"><%=oblog.Filt_html(OB_IIF(rs("intro"),""))%></span>
			</td>	 
            <td  align="center">
            <%select case cint(rs("istate"))
            	case 1
            		str="<span style=""color:#f60;font-weight:600;"">待审</span>"
            	case 2
            		str="<span style=""color:#f00;font-weight:600;"">锁定</span>"
            	case 3
            		str="<span style=""color:#090;font-weight:600;"">正常</span>"
            end select
            response.write str
            %>
			
            <%select case cint(rs("istate"))
            	case 1%>
            	<a href="m_team.asp?action=modifystate&s1=1&teamid=<%=rs("teamid")%>" onClick="return confirm('确定要批准通过此<%=P_QQ_NAME%>吗？');">通过</a>
            	<%case 2%>
            	<a href="m_team.asp?action=modifystate&s1=4&teamid=<%=rs("teamid")%>" onClick="return confirm('确定要解锁此<%=P_QQ_NAME%>吗？');">解锁</a>
            	<%case 3%>
            	<a href="m_team.asp?action=modifystate&s1=2&teamid=<%=rs("teamid")%>" onClick="return confirm('确定要锁定此<%=P_QQ_NAME%>吗？');">锁定</a>
            <%end select%>
<span style="display:block;color:#694659;width:54px;text-align:right;"><a href="m_team.asp?action=modifystate&s1=3&teamid=<%=rs("teamid")%>" onClick="return confirm('确定要删除此<%=P_QQ_NAME%>吗？');">删除</a></span>
            </td>
          </tr>
          <%
	i=i+1
	if i>=G_P_PerMax then exit do
	rs.movenext
	
Loop
response.write "</table>"
end sub
%>

	<ul class="main_end">
		<li class="main_end_left left"></li>
		<li class="main_end_right right"></li>
	</ul>
</div>
</body>
</html>