<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../HSK_Cls/HSK.MemberCls.asp"-->
<!--#include file="../HSK_Cls/HSK.Label.CommonCls.asp"-->
<%
Dim KSCls
Set KSCls = New User_Promotion
KSCls.HSK_Run()
Set KSCls = Nothing

Class User_Promotion
        Private KS,KSUser
		Private CurrentPage,totalPut,TotalPages,SQL
		Private RS,MaxPerPage
		Private TempStr,SqlStr,Action,ComeUrl
		Private Sub Class_Initialize()
			MaxPerPage =50
		  Set KS=New PublicCls
		  Set KSUser = New UserCls
		End Sub
        Private Sub Class_Terminate()
		 Set KS=Nothing
		 Set KSUser=Nothing
		End Sub
		%>
		<!--#include file="../HSK_Cls/UserFunction.asp"-->
		<%
		Public Sub loadMain()	
		IF Cbool(KSUser.UserLoginChecked)=false Then
		  Response.Write "<script>top.location.href='Login';</script>"
		  Exit Sub
		End If
		Action=KS.G("action")
		ComeUrl=Cstr(Request.ServerVariables("HTTP_REFERER"))
		If ComeUrl="" Then ComeUrl="login"
		Call KSUser.Head()
		If KS.S("page") <> "" Then
		   CurrentPage = CInt(KS.S("page"))
		Else
		   CurrentPage = 1
		End If
		%>
		<div class="tabs">						  
			<ul>
				<li class="select"><a href="?">查看下线用户</a></li>
			    <li><a href="/index.asp?do=reg&Uid=<%=KSUser.UserName%>" target="_blank">为下线开户</a></li>
				<li><a href="user_logpoint.asp">查看发布点明细</a></li>
				<li><a href="user_logmoney.asp">查看资金明细</a></li>
				<li><a href="user_message.asp?action=inbox">查看站内信箱</a></li>
			</ul>
		</div>
		<%
		Select Case Action
		Case "ShowDetail" : ShowDetail : Call KSUser.InnerLocation("用户详细资料")
		Case Else : Call KSUser.InnerLocation("查看下线用户")
		End Select
		
		If Action<>"ShowDetail" Then
		 	 SqlStr="Select UserID,UserName,GroupID,LastLoginTime,Money,KS_FaBuTaskCount,KS_JieShouTaskCount From KS_User Where AllianceUser='" & KSUser.UserName &"' order by UserID desc"
			 Set RS=Server.createobject("adodb.recordset")
			 RS.open SqlStr,conn,1,1
		
			 If RS.EOF And RS.BOF Then
					 Response.Write "<table width=98% border=0 align=center cellpadding=3 cellspacing=1 class=border><tr class='tdbg'><td align=center height=25 colspan=9 valign=top>共找到 <font color=#ff6600>0</font> 个用户</td></tr></table>"
					 RS.Close
					 Set RS=Nothing
					 Exit Sub
			 Else
					totalPut = RS.RecordCount
					If CurrentPage < 1 Then
						CurrentPage = 1
					End If
		
					If (CurrentPage - 1) * MaxPerPage > totalPut Then
						If (totalPut Mod MaxPerPage) = 0 Then
							CurrentPage = totalPut \ MaxPerPage
						Else
							CurrentPage = totalPut \ MaxPerPage + 1
						End If
					End If
		
					If CurrentPage = 1 Then
						Call ShowContent
					Else
						If (CurrentPage - 1) * MaxPerPage < totalPut Then
							RS.Move (CurrentPage - 1) * MaxPerPage
							Call ShowContent
						Else
							CurrentPage = 1
							Call ShowContent
						End If
					End If
			End If
			RS.Close
			Set RS=Nothing
		End If
		End Sub
						 
		Sub ShowContent()
		Dim CountPoint,TotalCountPoint
		CountPoint = 0: TotalCountPoint = 0
		%>
		  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="border">
			  <tr class=title>
					<td width="16%" align="center" height="22">用户名</td>
					<td width="13%" align="center">所属用户组</td>
					<td width="11%" align="center">发任务数量</td>
					<td width="11%" align="center">接任务数量</td>
					<td width="15%" align="center" style="color:#F00">我推广应得奖励</td>
					<td width="20%" align="center">最后登录时间</td>
					<td width="" align="center">操作</td>
				  </tr>
				<% Dim I
				Do While Not rs.eof
				%>
				  <tr height="23" class=tdbg id='u<%=rs("UserID")%>' onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
					<td class='splittd' align="center"><a href="?Action=ShowDetail&UserID=<%=rs("UserID")%>"><%=rs("UserName")%></a></td>
					<td class='splittd' align="center"><font color=blue><%=KS.GetUserGroupName(rs("GroupID"))%></font></td>
					<td class='splittd' align="center"><%=rs("KS_FaBuTaskCount")%> 条</td>
					<td class='splittd' align="center"><%=rs("KS_JieShouTaskCount")%> 条</td>
					<td class='splittd' align="center" style="color:#F00"><%
					CountPoint = Conn.Execute("SELECT SUM(Point) FROM KS_LogPoint WHERE (UserName = '" & KSUser.UserName & "') AND (InOrOutFlag = 1) AND ([User] = '" & rs("UserName") & "') AND (Descript LIKE '%推荐会员:%任务数量%')")(0)
					If Not KS.IsNul(CountPoint) Then
						KS.Echo CountPoint
					Else
						CountPoint = 0
						KS.Echo "0"
					End If
					TotalCountPoint = TotalCountPoint + CountPoint
					%> 个发布点</td>
					<td class='splittd' align="center"><%=rs("LastLoginTime")%></td>
					<td class='splittd' align="center"><a href="?Action=ShowDetail&UserID=<%=rs("UserID")%>">详细</a>&nbsp; <a href="User_Message.asp?action=new&Touser=<%=rs("UserName")%>">发站内信</a></td>
				  </tr>
			<%
			I = I + 1
			RS.MoveNext
			If I >= MaxPerPage Then Exit Do
			
			loop
			%>
        <tr>
        	<td colspan="7" height="15"></td>
        </tr>
		<tr valign=middle class='list' onMouseOver="this.className='listmouseover'" onMouseOut="this.className='list'">
        	<td colspan="3" align="right">本页我推广应得奖励发布点共计：<%=TotalCountPoint%> 点</td>
			<td colspan="3" align="right">
			<%
			 Call KS.ShowPage(totalput, MaxPerPage, "", CurrentPage,false,true)
			%>
		</td>
        <td align="left"> 共有<%=totalPut%>个用户</td>
		</tr>
		</table>
		<%
		End Sub
		
		Sub ShowDetail()	'详细资料
			dim rsUser,sqlUser,sSex,ChargeType,GroupID,UserID
			UserID=KS.ChkClng(KS.S("UserID"))
			GroupID=KS.ChkClng(KS.S("GroupID"))
			if UserID=0 then Response.Write("<script>alert('提交参数有误，请与管理员联系！');history.back();</script>")
			sqlUser="select * from KS_User where AllianceUser='" & KSUser.UserName & "' And UserID=" & UserID
			Set rsUser=Server.CreateObject("ADODB.RECORDSET")
			rsUser.Open sqlUser,conn,1,1
			if rsUser.bof and rsUser.eof then
				Response.Write "<br><li>找不到指定的用户！</li>"
				rsUser.close:set rsUser=Nothing
				exit sub
			end if
			If GroupID=0 Then GroupID=rsUser("GroupID")
			ChargeType=rsUser("ChargeType")
		%>

		<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
			<TR class="sort">
			  <TD height="22" colspan="4" align="center"><span style="margin-top:10px;text-align:center;font-weight:bold">用户详细资料</span></TD>
		  </TR>
			<TR class="tdbg"> 
				<TD height="25" align="left" colspan="4">
				&nbsp; &nbsp; &nbsp;<strong>用户名称：</strong><%=rsUser("UserName")%>&nbsp;&nbsp;<strong>注册时间：</strong><%=rsUser("RegDate")%>&nbsp;&nbsp;<strong>可用资金：</strong><%=Round(rsUser("money"),2)%>元&nbsp;&nbsp;<strong>可用发布点：</strong><%=Round(rsUser("point"),2)%>点&nbsp;&nbsp;<strong>总积分：</strong><%=rsUser("KS_TotalScore")%>分
				</TD>
			</TR>
			<TR class="tdbg"> 
				<TD height="25" align="left" colspan="4">
				&nbsp; &nbsp; &nbsp;<strong>该用户推广的下线用户有：<%=Conn.Execute("Select Count(UserID) From KS_User Where AllianceUser='" & rsUser("UserName") & "'")(0)%> 个</strong>
				</TD>
			</TR>
			<tr class="tdbg">
			  <td colspan="4">
			  <%
			            
					Dim Template:Template=LFCls.GetSingleFieldValue("Select Template From KS_UserForm Where ID=" & KS.U_G(GroupID,"formid"))
						   Dim FieldsList:FieldsList=LFCls.GetSingleFieldValue("Select FormField From KS_UserForm Where ID=" & KS.U_G(GroupID,"formid"))
						   Dim RS:Set RS=Server.CreateObject("ADODB.RECORDSET")
						   RS.Open "Select FieldID,FieldType,FieldName,DefaultValue,Width,Options from KS_Field Where ChannelID=101 Order By OrderID",conn,1,1
						   Dim SQL,K,N,InputStr,O_Arr,O_Len,F_V,O_Value,O_Text,BRStr
						   If Not RS.EOf Then SQL=RS.GetRows(-1):RS.Close():Set RS=Nothing
						   For K=0 TO Ubound(SQL,2)
							 If KS.FoundInArr(FieldsList,SQL(0,k),",") Then
							  InputStr=""
							  If lcase(SQL(2,K))="province&city" Then
								 InputStr=rsUser("Province") & "" &  rsUser("City") & ""
							  Else
							  InputStr=rsUser(SQL(2,K))
							  If InputStr="" OR IsNull(InputStr) Then InputStr=" "
							 End If
							  Template=Replace(Template,"[@NoDisplay(" & SQL(2,K) & ")]","")
							  Template=Replace(Template,"[@" & SQL(2,K) & "]",InputStr)

							End If
						   Next
							Template=Replace(Template,"{@NoDisplay}"," style='display:none'")
							Response.Write Template
			  
			  %>			  </td>
			</tr>
			

			<TR class="tdbg"> 
			  <TD height="30" colspan="4" align="center"><input name='backbutton' id='backbutton' type='button' onclick='history.back();' value=' 返 回 ' class='button'></TD>
			</TR>
	    </TABLE>
		<br><br>
		<%
			rsUser.close:set rsUser=Nothing
	  End Sub
		

End Class
%>