<!--#INCLUDE FILE="conn.asp" -->
<!--#INCLUDE FILE="Class_Checkuser.asp" -->
<!--#INCLUDE FILE="Class_Top.asp" -->
<%
Dim Locat

Select Case Request("action")
Case "Birthday"
	Locat="学校生日榜"
Case "VisitCount"
	Locat="学校访问统计"
Case "ViewLog"
	Locat="查看学校管理日志"	
End Select

if membername="" Then
  	ErrMsg=ErrMsg+"<br>"+"<li>您还没有<a href=Class_Login.asp><font color=red>登录或注册校友录</font></a>。"
	Call top(1,1)
	Call Error("Information",ErrMsg)
	
Else
	Dim ClsID,Degree,ClassName
	ClsID=Request("ClassID")
	joinstatus=chkjoinclass(ClsID)
	if joinstatus<>"" Then
		Call top(1,1)
		Call Error("Exclamation",ErrMsg)
	Else
		Call top(2,1)
		Select Case Request("action")
		Case "Birthday"
			Call birthdaylist()
		Case "VisitCount"
			Call visitclass()
		Case "ViewLog"
			Call ManageLog()
		End Select
	End if
End if


Sub birthdaylist()

	Dim rs,sql
	Dim NextBir
	Dim BirMonth,BirDay
	Dim nbinterval
	Set rs = Server.CreateObject("ADODB.Recordset")
	sql="select S.userid,S.realname,S.birthday,S.wish from student S inner join joinclass J "&_
		"on S.userid=J.userid where J.isauditing=0 and J.classid="&ClsID&" order by S.birthday"
	rs.open sql,conn,1,1%>
	<!--#INCLUDE FILE="inc/popwish.inc" -->
	<br><br><TABLE width=85% border=0 align=center>
	<TR>
		<TD><IMG SRC=images/birthday.gif WIDTH=134 HEIGHT=31></TD>
	</TR>
	</TABLE>
	<table border=0 cellpadding=5 cellspacing=1 width=85% Class=TableBorder align=center>
	<TR><Th width=18% align=center nowrap>姓&nbsp;&nbsp;名</Th>
	<Th width=18% align=center nowrap>出生日期</Th>
	<Th width=10% align=center nowrap>星座</Th>
	<Th width=15% align=center nowrap>距离生日天数</Th>
	<Th align=center nowrap>生日愿望</Th></TR>

	<%do until Rs.eof
		BirMonth=Month(Rs(2))
		BirDay=Day(Rs(2))

		NextBir =DateSerial(Year(Date),BirMonth,BirDay)
		if NextBir<date() Then NextBir =DateAdd("yyyy",1,NextBir)

		nbinterval=DateDiff("d",Date(),NextBir)
		Response.write "<TR Class=LightTableBody><TD align=middle>"
		if membername=Rs(0) Then
			Response.write "<a href=javascript:openScript('Class_Modify.asp?Action=MakeWish',400,300) title=修改生日愿望><FONT color=blue>"&Rs(1)&"</FONT></a>"
		Else
			Response.write Rs(1)
		End if
		Response.write "</TD><TD align=middle>"&Rs(2)&"</TD><TD align=middle>"&constellation(rs(2),false)&"</TD><TD align=middle nowrap>"

		if nbinterval=0 Then
			Response.write "<img src=images/cake.gif alt=祝"&Rs(1)&""&DateDiff("yyyy",Rs(2),date)&"岁生日快乐！>"
		ElseIf BirMonth=Month(Date) and BirDay>day(date) Then 
			Response.write "<a title=""本月过生日""><font color=brown>"&nbinterval&"</font></a>"
		Else
			Response.write nbinterval
		End if
		Response.write "</TD><td>"

		if Rs(3)<>"" Then
			if len(rs(3))>20 then showish=left(rs(3),20)&"..." else showish=rs(3)
			showish=server.htmlencode(showish)
			response.write "<a style=""cursor:default"" onmouseover=""popwish('"&htmlencode(Rs(3))&"')"" onmouseout=""kill()""><img src=images/wish.gif height=16 align=absmiddle hspace=2>"&showish&"</a>"
		End if
		
		Response.write "</td></TR>"
		Rs.movenext
	loop%>
	
	</td></tr></table><BR><BR>

	<%Rs.Close
	Set Rs=Nothing

End Sub



Sub VisitClass()

	Dim rs,sql
	Set rs = Server.CreateObject("ADODB.Recordset")
	sql="Select S.realname,J.visitcount,J.lastvisit,J.jointime from student S inner join joinclass J "&_
	"on S.userid=J.userid where J.isauditing=0 and J.classid="&ClsID&" order by J.visitcount desc"
	rs.open sql,Conn,1,1
	%>
	<br><br>
	<table border="0" cellpadding="5" cellspacing="1" width="75%"   Class=TableBorder align="center">
	  <TR>
		<Th width="38%" align=center nowrap>姓&nbsp;&nbsp;名</Th>
		<Th width="22%" align=center nowrap>加入日期</Th>
		<Th width="22%" align=center nowrap>访问本校次数</Th>
		<Th width="40%" align=center nowrap>最近访问时间</Th>
	 </TR>
	<%
	do until Rs.eof
		response.write "<TR Class=LightTableBody>"&_
		"<TD align=middle>"&Rs(0)&"</TD><TD align=middle nowrap>"&datevalue(Rs(3))&"</TD>"&_
		"<TD align=middle>"&Rs(1)&"</TD><TD nowrap>&nbsp;"&Rs(2)&"</TD></TR>"	
		Rs.movenext
	loop

	Rs.Close
	Set Rs=Nothing
	%>
	</table><BR><BR>
	<%
End Sub


Sub ManageLog()

	Dim sql,rs
	sql="Select L.content,L.mgrdate,S.realname from log L inner join student S on S.userid=L.userid where L.classid="&ClsID&" order by L.mgrdate desc"
	Set rs = Server.CreateObject("ADODB.Recordset")
	Rs.open sql,Conn,1,1
	%>
	<br><br>
	<table border="0" cellpadding="5" cellspacing="1" width="700"   Class=TableBorder align="center">
		  <TR Class=DarkTableBody>
			  <Td width="100%" valign="middle" align="center" colspan=4><B>学校管理日志</B></Td>
		 </TR>
	  <TR>
		<Th width="10%" nowrap>管理者</Th>
		<Th width="60%" nowrap>管理内容</Th>
		<Th width="20%" nowrap>日期</Th>
		<Th width="20%" nowrap>时间</Th>
	 </TR>
	<%
	if rs.eof and rs.bof then


else
	do until Rs.eof
		response.write "<TR Class=LightTableBody>"&_
		"<TD align=middle nowrap>"&Rs(2)&"</TD><TD>"&htmlencode(Rs(0))&"</TD>"&_
		"<TD align=middle nowrap>"&formatdatetime(Rs(1),vbShortDate)&"</TD>"&_
		"<TD align=middle nowrap>"&formatdatetime(Rs(1),vbLongTime)&"</TD></TR>"
		Rs.movenext
	loop
end if

	Rs.Close
	Set Rs=Nothing
	%>
	</table><BR>
	<%
End Sub
%>
<%Call footer%>

<!--#INCLUDE FILE="inc/constellation.asp" -->
