<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../KS_Cls/Kesion.CommonCls.asp"-->
<!--#include file="../KS_Cls/Kesion.Label.BaseFunCls.asp"-->
<!--#include file="../KS_Cls/Kesion.AdministratorCls.asp"-->
<!--#include file="../KS_Cls/Kesion.UpFileCls.asp"-->
<!--#include file="Include/Session.asp"-->
<%

Dim KSCls
Set KSCls = New Admin_EnterPrise
KSCls.Kesion()
Set KSCls = Nothing

Class Admin_EnterPrise
        Private KS,Param,KSCls,subjectID
		Private Action,i,strClass,RS,SQL,maxperpage,CurrentPage,totalPut,TotalPageNum
        Private Sub Class_Initialize()
		  Set KS=New PublicCls
		  Set KSCls=New ManageCls
		End Sub
        Private Sub Class_Terminate()
		 Call CloseConn()
		 Set KS=Nothing
		End Sub

		Public Sub Kesion()
		 With Response
		   	 If Not KS.ReturnPowerResult(0, "M530001") Then          '检查是权限
					 Call KS.ReturnErr(1, "")
					 .End
			 End If
			  .Write "<html>"
			  .Write"<head>"
			  .Write"<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"
			  .Write"<link href=""Include/Admin_Style.CSS"" rel=""stylesheet"" type=""text/css"">"
			  .Write "<script src=""../Inc/common.js"" language=""JavaScript""></script>"
			  .Write "<script src=""../Inc/jquery.js"" language=""JavaScript""></script>"
			  .Write "<script src='../inc/box.js'></script>"
			  .Write"</head>"
			  .Write"<body leftmargin=""0"" topmargin=""0"" marginwidth=""0"" marginheight=""0"">"
			  If KS.G("action")<>"ShowUser" Then
			  .Write "<ul id='menu_top'>"
			  .Write "<li class='parent' onclick=""window.parent.frames['BottomFrame'].location.href='KS.Split.asp?OpStr='+escape('团购系统 >> <font color=red>添加团购主题</font>')+'&ButtonSymbol=GOSave';location.href='?action=Add';""><span class=child onmouseover=""this.parentNode.className='parent_border'"" onMouseOut=""this.parentNode.className='parent'""><img src='images/ico/a.gif' border='0' align='absmiddle'>添加团购</span></li>"
			  .Write "<li class='parent' onclick=""location.href='KS.GroupBuyInt.asp';""><span class=child onmouseover=""this.parentNode.className='parent_border'"" onMouseOut=""this.parentNode.className='parent'""><img src='images/ico/move.gif' border='0' align='absmiddle'>兴趣活动分类管理</span></li>"
			  .Write "<li style='margin-left:30px;margin-top:10px'><strong>查看方式:</strong><a href=""KS.GroupBuy.asp"">所有团购</a> <a href=""KS.GroupBuy.asp?flag=1"">进行中的团购</a>  <a href=""KS.GroupBuy.asp?flag=2"">已结束的团购</a> <a href=""KS.GroupBuy.asp?flag=3"">已锁定的团购</a></li>"
              End If
			  .Write "</ul>"
		End With
		
		
		maxperpage = 30 '###每页显示数
		If Not IsNumeric(Request("page")) And Len(Request("page")) <> 0 Then
			Response.Write ("错误的系统参数!请输入整数")
			Response.End
		End If
		If Not IsEmpty(Request("page")) And Len(Request("page")) <> 0 Then
			CurrentPage = CInt(Request("page"))
		Else
			CurrentPage = 1
		End If
		If CInt(CurrentPage) = 0 Then CurrentPage = 1
		SubjectID=KS.ChkCLng(KS.S("SubjectID"))
		Param=" where SubjectID=" & SubjectId
		If KS.G("KeyWord")<>"" Then
		  If KS.G("condition")=1 Then
		   Param= Param & " and RealName like '%" & KS.G("KeyWord") & "%'"
		  ElseiF KS.G("condition")=2 Then
		   Param= Param & " and Mobile like '%" & KS.G("KeyWord") & "%'"
		  Else
		   Param= Param & " and Interest like '%" & KS.G("KeyWord") & "%'"
		  End If
		End If
		If KS.S("Flag")<>"" Then 
		  If KS.G("Flag")="1" Then Param=Param & " and status=1"
		  If KS.G("Flag")="2" Then Param=Param & " and status=0"
		End If

		totalPut = Conn.Execute("Select Count(id) From KS_GroupBuyBM " & Param)(0)
		TotalPageNum = CInt(totalPut / maxperpage)  '得到总页数
		If TotalPageNum < totalPut / maxperpage Then TotalPageNum = TotalPageNum + 1
		If CurrentPage < 1 Then CurrentPage = 1
		If CurrentPage > TotalPageNum Then CurrentPage = TotalPageNum
		Select Case KS.G("action")
		 Case "ShowUser" Call ShowUser()
		 Case "Add","Edit" Call RealNameManage()
		 Case "EditSave" Call DoSave()
		 Case "Del"  Call BMDel()
		 Case "lock"  Call BMLock()
		 Case "unlock"  Call BMUnLock()
		 Case Else
		  Call showmain
		End Select
End Sub

Private Sub showmain()
%>


<div style="height:45px;line-height:45px;font-size:14px;text-align:center;font-weight:Bold">
团购主题:<%=LFCls.GetSingleFieldValue("Select Subject From KS_GroupBuy Where ID=" & SubjectID)%>，已报名：<font color=blue><%=LFCls.GetSingleFieldValue("Select Count(ID) From KS_GroupBuyBM Where subjectID=" & SubjectID)%></font>人，已审核：<font color=red><%=LFCls.GetSingleFieldValue("Select Count(ID) From KS_GroupBuyBM Where status=1 and subjectID=" & SubjectID)%></font>人。
</div>

<table width="100%" border="0" align="center" cellspacing="0" cellpadding="0">
 <tr>
   <td>查看方式：<a href="?subjectid=<%=subjectid%>&flag=1"><font color=#999999>已审核</font></a> - <a href="?subjectid=<%=subjectid%>&flag=2"><font color=#999999>未审核</font></a></td>
   <td style="font-size:14px;text-align:right;font-weight:Bold;padding-right:20px"><img src="images/qs.gif" align="absmiddle">
<a href="#" onclick="javascript:window.parent.frames['BottomFrame'].location.href='KS.Split.asp?OpStr='+escape('团购系统 >> <font color=red>添加报名</font>')+'&ButtonSymbol=GOSave';location.href='KS.GroupBuyBM.asp?action=Add&subjectid=<%=SubjectID%>'">添加报名</a></td>
 </tr>
</table>
<script>
  function note(id){ 
   onscrolls=false;
   new KesionPopup().PopupCenterIframe("查看用户报名信息","?Action=ShowUser&id="+id,200,180,'auto')
 }
</script>

<table width="100%" border="0" align="center" cellspacing="0" cellpadding="0">
<tr height="25" align="center" class='sort'>
	<td width='5%' nowrap>选择</th>
	<td nowrap>姓名</th>
	<td nowrap>用户名</th>
	<td nowrap>手机</th>
	<td nowrap>状态</th>
	<td nowrap>操作</th>
	<td width='5%' nowrap>选择</th>
	<td nowrap>姓名</th>
	<td nowrap>用户名</th>
	<td nowrap>手机</th>
	<td nowrap>状态</th>
	<td nowrap>操作</th>
</tr>
<%
	Set Rs = Server.CreateObject("ADODB.Recordset")
	SQL = "select ID,RealName,Mobile,Status,AcceptSms,UserName from KS_GroupBuyBM " & Param & " order by id desc"
	If DataBaseType = 1 Then
		If CurrentPage > 100 Then
			Rs.Open SQL, Conn, 1, 1
		Else
			Set Rs = Conn.Execute(SQL)
		End If
	Else
		Rs.Open SQL, Conn, 1, 1
	End If
	If Rs.bof And Rs.EOF Then
		Response.Write "<tr><td height=""25"" align=center bgcolor=""#ffffff"" colspan=10>该主题下还没有任何报名！</td></tr>"
	Else
		If TotalPageNum > 1 then Rs.Move (CurrentPage - 1) * maxperpage
		Dim i,n,k
		Dim SQLs:SQLs=RS.GetRows(-1)
		RS.Close:Set RS=Nothing
%>
<form name=selform method=post action=?action=Del>
<%
    n=0
	For I=0 To Ubound(SQLs,2)
		
%>
<tr height="25" class='list' onMouseOver="this.className='listmouseover'" onMouseOut="this.className='list'">
    <%For K=1 To 2%>
	<td align="center" class="splittd"><input type=checkbox name=ID value='<%=SQLs(0,n)%>'>
	
	</td>
	<td class="splittd"><%=n+1%>、<a href="#" onclick="note('<%=SQLs(0,n)%>');"><%=SQLs(1,n)%></a></td>
	<td class="splittd" align="center">&nbsp;<%=SQLs(5,n)%>&nbsp;</td>
	<td class="splittd">&nbsp;<%=SQLs(2,n)%>&nbsp;</td>
	<td align="center" class="splittd">
	<%if SQLs(3,n)=1 then%>
	  <a href="?Action=lock&id=<%=SQLs(0,n)%>&SubjectID=<%=SubjectID%>"><font color=blue>已审</font></a>
	<%else%>
	  <a href="?Action=unlock&id=<%=SQLs(0,n)%>&SubjectID=<%=SubjectID%>"><font color=red>未审</font></a>
	<%end if%>
	   
	 </td>

	<td align="center" class="splittd"><a href="?action=Edit&ID=<%=SQLs(0,n)%>&SubjectID=<%=SubjectID%>"  onclick="window.parent.frames['BottomFrame'].location.href='KS.Split.asp?OpStr='+escape('团购系统 >> <font color=red>修改报名信息</font>')+'&ButtonSymbol=GOSave';">改</a> <a href="?Action=Del&ID=<%=SQLs(0,n)%>&SubjectID=<%=SubjectID%>" onclick="return(confirm('确定删除该报名吗？'));">删</a> 
	</td>
  <%
   n=n+1
   If N>Ubound(SQLs,2) Then Exit For
  Next
  %>
</tr>
<%
      If N>Ubound(SQLs,2) Then Exit For
 Next
End If
%>
<tr>
	<td class='list' onMouseOver="this.className='listmouseover'" onMouseOut="this.className='list'" height='25' colspan=11>
	&nbsp;&nbsp;<input id="chkAll" onClick="CheckAll(this.form)" type="checkbox" value="checkbox"  name="chkAll">全选
	<input class=Button type="submit" name="Submit2" value=" 删除选中的报名 " onclick="{if(confirm('此操作不可逆，确定要删除选中的记录吗?')){this.document.selform.submit();return true;}return false;}">
	
		<input type="button" class="button" value="打印本页" onclick='window.print()'>
	<input type="button" class="button" value="取消返回" onclick="history.back()">

	</td>
</tr>
</form>
<tr>
	<td  colspan=17 align=right>
	<%
	 Call KSCLS.ShowPage(totalPut, MaxPerPage, "KS.GroupBuyBM.asp", True, "个", CurrentPage, KS.QueryParam("page"))
	%></td>
</tr>
</table>
<div>
<form action="KS.GroupBuyBM.asp" name="myform" method="get">
   <input type="hidden" value="<%=SubjectID%>" name="subjectid">
   <div style="border:1px dashed #cccccc;margin:3px;padding:4px">
      &nbsp;<strong>快速搜索=></strong>
	 &nbsp;关键字:<input type="text" class='textbox' name="keyword">&nbsp;条件:
	 <select name="condition">
	  <option value=1>按姓名</option>
	  <option value=2>按手机</option>
	  <option value=3>按兴趣</option>
	 </select>
	  &nbsp;<input type="submit" value="开始搜索" class="button" name="s1">
    </div>
</form>
</div>
<%
End Sub

Sub RealNameManage()
Dim RealName,AddDate,Mobile,Acceptsms,Interest,Status,Subjectid,username
Dim ID:ID=KS.ChkClng(KS.G("ID"))
Dim RS
If KS.G("Action")="Edit" Then
    Set RS=server.createobject("adodb.recordset")
	RS.Open "Select * From KS_GroupBuyBM Where ID=" & ID,conn,1,1
	 If RS.Eof And RS.Bof Then
	  RS.Close:Set RS=Nothing
	  Response.Write "<script>alert('参数传递出错！');history.back();</script>"
	  Response.End
	 Else
	   RealName=RS("RealName")
	   Mobile=RS("Mobile")
	   Acceptsms=RS("Acceptsms")
	   Subjectid=RS("Subjectid")
	   Interest=RS("Interest")
	   username=rs("username")
	   Status=RS("Status")
	 End If
	RS.Close:Set RS=Nothing
Else
  AddDate=Now
  Status=1
  Subjectid=KS.ChkClng(KS.G("Subjectid"))
 End If
%>
<script>
function CheckForm()
{
	if ($('#RealName').val()=='')
	{
	 alert('请输入姓名!');
	 $("#RealName").focus();
	 return false;
	}
	if ($('#Mobile').val()=='')
	{
	 alert('请输入联系电话!');
	 $("#Mobile").focus();
	 return false;
	}
document.myform.submit();
}
</script>
<div style="height:45px;line-height:45px;font-size:14px;text-align:center;font-weight:Bold">
团购主题:<%=LFCls.GetSingleFieldValue("Select Subject From KS_GroupBuy Where ID=" & SubjectID)%>
</div>

<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" class="ctable">
 <form name="myform" action="?action=EditSave" method="post">
   <input type="hidden" value="<%=ID%>" name="id">
   <input type="hidden" value="<%=SubjectID%>" name="Subjectid">
   <input type="hidden" value="<%=request.servervariables("http_referer")%>" name="comeurl">
          <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='160' height='30' align='right' class='clefttitle'><strong>会员名称：</strong></td>
           <td height='30' colspan="2">&nbsp;<input type='text' name='username' id='username' value='<%=username%>' size="40"> 可选</td>
          </tr> 
          <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='160' height='30' align='right' class='clefttitle'><strong>联系人：</strong></td>
           <td height='30' colspan="2">&nbsp;<input type='text' name='RealName' id='RealName' value='<%=RealName%>' size="40"> <font color=red>*</font></td>
          </tr> 
		   <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='160' height='30' align='right' class='clefttitle'><strong>联系电话：</strong></td>
           <td height='30' colspan="2">&nbsp;<input type='text' name='Mobile' id='Mobile' value="<%=Mobile%>" size="40"/><font color=red>*</font>
			 </div></td>
          </tr>  
		   <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='160' height='30' align='right' class='clefttitle'><strong>接收手机短信通知：</strong></td>
           <td height='30' colspan="2">&nbsp;<input type='Checkbox' name='Acceptsms' value="1"<%if acceptsms="1" then response.write " checked"%>/>是</td>
	      </tr>  
		  
         
		   <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='160' height='30' align='right' class='clefttitle'><strong>其他感兴趣的活动：</strong></td>
            <td width="431">
			 <%
			  Set RS=Conn.Execute("Select Item From KS_GroupBuyInt Where SubjectID=0 Or SubjectID=" & SubjectID & " Order By OrderID asc,id desc")
			  Do While Not RS.Eof
				  If Instr(Interest,RS(0))<>0 Then
				   Response.Write " <input type='checkbox' name='Interest' checked value='" & RS(0) & "'>" & RS(0)
				  Else
				   Response.Write " <input type='checkbox' name='Interest' value='" & RS(0) & "'>" & RS(0)
				  End If
			  RS.MoveNext
			  Loop
			  RS.Close:Set RS=Nothing
			 %>
			</td>
          </tr>  
		   

		  <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='160' height='30' align='right' class='clefttitle'><strong>状态：</strong></td>
           <td height='30' colspan="2">&nbsp;
		    <input type="radio" name="Status" value="0"<%if Status=0 then response.write " checked"%>>
		    未审
			<input type="radio" name="Status" value="1"<%if Status=1 then response.write " checked"%>> 
			已审		   </td>
          </tr>  
		  </table>
		 
 
<%
End Sub

Sub DoSave()

	   Dim Subjectid:Subjectid=KS.ChkClng(KS.G("Subjectid"))
	   If Subjectid=0 Then
			 Response.Write "<script>alert('对不起,您没有选择团购主题！');history.back();</script>"
			 Exit Sub
	   End If
       Dim ID:ID=KS.ChkClng(KS.G("id"))
	   Dim RealName:RealName=KS.LoseHtml(KS.G("RealName"))
	   Dim Mobile:Mobile=KS.LoseHtml(KS.G("Mobile"))
	   Dim Interest:Interest=Replace(KS.LoseHtml(KS.G("Interest"))," ","")
	   Dim AcceptSms:AcceptSms=KS.ChkClng(KS.G("AcceptSms"))
	   Dim Status:Status=KS.ChkClng(KS.G("Status"))
       Dim username:username=KS.G("username")
		
	   If RealName="" Then Response.Write "<script>alert('联系人必须输入');history.back();</script>":response.end
            If Not Conn.Execute("Select * From KS_GroupBuyBM Where SubjectID=" & SubjectID & " And RealName='" & RealName & "' And Mobile='" & Mobile & "' And ID<>" & ID).Eof Then
			 Call KS.AlertHistory("对不起,该用户已报名过!",-1)
			 Exit SUb
			End If


            Dim RS: Set RS=Server.CreateObject("Adodb.RecordSet")
			  RS.Open "Select * From KS_GroupBuyBM Where ID=" & ID,Conn,1,3
			  If RS.Eof And RS.Bof Then
			     RS.AddNEW
			  End If
			     RS("username")=username
			     RS("SubjectID")=SubjectID
			     RS("RealName")=RealName
				 RS("Mobile")=Mobile
				 RS("AcceptSms")=AcceptSms
				 RS("Interest")=Interest
				 RS("Status")=Status
		 		 RS.Update
			     RS.Close
				 Set RS=Nothing
				 
				 If ID=0 Then
				  Response.Write "<script>if (confirm('报名添加成功,继续添加吗?')){location.href='?action=Add&Subjectid=" & SubjectId& "';}else{parent.frames['BottomFrame'].location.href='KS.Split.asp?ButtonSymbol=Disabled&OpStr=" & Server.URLEncode("团购系统 >> <font color=red>报名管理</font>") & "';location.href='KS.GroupBuyBM.asp?subjectid=" & subjectid & "';}</script>"
				 Else
				 
				  Response.Write "<script>alert('报名修改成功！');parent.frames['BottomFrame'].location.href='KS.Split.asp?ButtonSymbol=Disabled&OpStr=" & Server.URLEncode("团购系统 >> <font color=red>报名管理</font>") & "';location.href='"& KS.G("ComeUrl") & "';</script>"
				 End If

EnD Sub

'删除
Sub BMDel()
 Dim ID:ID=KS.G("ID")
 Dim UserName,DefaultTemplateID
 If ID="" Then Response.Write "<script>alert('对不起，您没有选择!');history.back();</script>":response.end
 Conn.execute("Delete From KS_GroupBuyBM Where id In("& id & ")")
 Response.Write "<script>alert('删除成功！');location.href='" & Request.servervariables("http_referer") & "';</script>"
End Sub


'锁定
Sub BMLock()
 Dim ID:ID=KS.G("ID")
 If ID="" Then Response.Write "<script>alert('对不起，您没有选择!');history.back();</script>":response.end
 Conn.execute("Update KS_GroupBuyBM Set Status=0 Where id In("& id & ")")
 Response.Write "<script>location.href='" & Request.servervariables("http_referer") & "';</script>"
End Sub
'解锁
Sub BMUnLock()
 Dim ID:ID=KS.G("ID")
 If ID="" Then Response.Write "<script>alert('对不起，您没有选择!');history.back();</script>":response.end
 Conn.execute("Update KS_GroupBuyBM Set Status=1 Where id In("& id & ")")
 Response.Write "<script>location.href='" & Request.servervariables("http_referer") & "';</script>"
End Sub

Sub ShowUser()
 Response.Write "<style>" & vbcrlf
 Response.Write ".l{margin-left:10px;margin-top:20px;}"
 response.write ".l li{height:20px}"
 response.write "</style>"
 Dim ID:ID=KS.ChkClng(KS.G("ID"))
 Dim RS:Set RS=Server.CreateObject("ADODB.RECORDSET")
 RS.Open "Select top 1 RealName,Mobile,AcceptSms,Interest,UserName From KS_GroupBuyBM Where ID=" & ID,conn,1,1
   Response.Write "<div class='l'>"
   If RS.Eof And RS.Bof Then
     Response.Write "对不起，参数出错！"
   Else
	 Do While Not RS.Eof
	   Response.Write "<li><strong>会员名称:</strong><font color=#ff6600>" & RS(4) & "</font></li>"
	   if not ks.isnul(rs(4)) then
	   Response.Write "<li><strong>会员级别:</strong><font color=green>" & KS.U_G(KS.ChkClng(conn.execute("select top 1 groupid from ks_user where username='" & RS(4) &"'")(0)),"groupname") & "</font></li>"
	   end if
	   Response.Write "<li><strong>联 系 人:</strong><font color=blue>" & RS(0) & "</font></li>"
	   Response.Write "<li><strong>联系方式:</strong>" & RS(1) & "</li>"
	   Response.Write "<li><strong>是否接收短信服务:</strong>"
	   if rs(2)="1" then response.write "是" else response.write "否"
	   Response.Write "</li>"
	   Response.Write "<li><strong>其他感兴趣的活动:</strong>" & RS(3) & "</li>"
	   RS.MoveNext
	 Loop
   End If
	   Response.Write "</div>"
 RS.Close:Set RS=Nothing
End Sub

End Class
%> 
