<!--#INCLUDE FILE="setup.asp" -->
<!--#INCLUDE FILE="checkuser.asp" -->
<!--#INCLUDE FILE="theme.asp" -->
<!--#INCLUDE FILE="include/char.asp" -->
<%
locat="班级通讯录"
Dim totalPages,currentPage
Dim rs,sql
if membername="" Then
  	ErrMsg=ErrMsg+"<br>"+"<li>您还没有<a href=login.asp>登录</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",joinstatus)
	Else
		if Request("Action")="Download" Then
			Call download()
		ElseIf Request("Action")="Export" Then
			Call export()
		ElseIf Request("Action")="SelFormat" Then
			act="导出班级地址簿"
			Call pagehead()
			Call selformat()
		Else
			style=Request("style")
			if style="List" Then
				Call top(2,1)
				Call liststyle()
			Else
				style="Card"
				Call top(2,1)
				Call cardstyle()
			End if
		End if
	End if
End if


Sub SelFormat()

%>
<SCRIPT LANGUAGE="javascript">
function DoHelpChange() 
{
	var v = document.all['typeselect'].value;
	if (v == '0') {
		document.all['help1'].style.display='';
		document.all['help2'].style.display='none';
		document.all['help3'].style.display='none';
	} else if (v == '1') {
		document.all['help1'].style.display='none';
		document.all['help2'].style.display='';
		document.all['help3'].style.display='none';
	} else if (v == '2') {
		document.all['help1'].style.display='none';
		document.all['help2'].style.display='none';
		document.all['help3'].style.display='';
	}
}
</script>
<table width=100% height=100% bgcolor=<%=BodyColor%>><tr><td valign=top>
<form action=ClassMate.asp?ClassID=<%=ClsID%> method=post>
<input type=hidden name=Action value=Export>
<table border=0 Class=TableBorder cellspacing=1 cellpadding=5><tr><th>成员地址簿导出</th></tr>
<tr Class=LightTableBody><td>成员地址簿导出功能,可以将班级所有同学的详细联系方式导入到您最喜爱的个人信息管理工具中(OutLook, Foxmail, WinPim),使你更加方便的与同学,好友交流.</td></tr>
<tr Class=DarkTableBody><td>&nbsp;&nbsp;请选择地址薄导出格式:&nbsp;
	<SELECT ID="typeselect" NAME="format" ONCHANGE="DoHelpChange();">
		<OPTION VALUE="0">Outlook Express (中文版) 
		<OPTION VALUE="1">Foxmail 
		<OPTION VALUE="2">友情强档 WinPIM
	</SELECT>
</td></tr>
<tr Class=LightTableBody><td>提示: 在点击"立即导出地址簿"按钮, 在弹出的对话框中点击"保存",然后选择路径, 地址簿文件"AddressBook.csv"将会保存至您的电脑中, 比如"C:\AddressBook.csv".</td></tr>

		<tr Class=LightTableBody><td height=160>			<DIV ID="help1">
				将成员地址簿导入Outlook Express的操作步骤:<BR>
					1. 在Outlook Express中选择菜单: 文件 -> 导入 -> 其他通讯薄<BR>
					2. 选择"文本文件(以逗号分隔)", 点击"导入"按钮<BR>
					3. 点击浏览, 选择您刚才保存的文件名, 比如: C:\AddressBook.csv, 点击"下一步"按钮<BR>
					4. 选择字段, 推荐全部选择, 然后按"完成"<BR>
					5. OutLook 将自行完成导入功能, 如果导入过程中出现对话框提示, 很有可能是用户信息不完备,或格式错误,或重复信息, 推荐"是", "保留"<BR>
					6. 导入完成后, OutLook会提示"成功导入", 点击"确定"即可!<BR>
			</DIV>
			<DIV ID="help2" STYLE="display: none">
				将成员地址簿导入Foxmail 的操作步骤:<BR>
					1. 在 Foxmail 中选择菜单: 地址薄 -> 工具 -> 导入 -> CSV文件(*.csv)<BR>
					2. 点击浏览, 选择您刚才保存的文件名, 比如: C:\AddressBook.csv, 点击"下一步"按钮<BR>
					3. 选择字段, 推荐点击"全选", 然后按"完成"<BR>
					4. Foxmail 将自行完成导入功能, 如果导入过程中出现对话框提示, 很有可能是用户信息不完备,或格式错误,或重复信息, 推荐"是", "保留"<BR>
					5. 导入完成后, Foxmail会提示"成功导入", 点击"确定"即可!<BR>
			</DIV>
			<DIV ID="help3" STYLE="display: none">
				将成员地址簿导入"友情强档WinPim" 的操作步骤:<BR>
					1. 在 友情强档 中选择菜单: 文件 -> 导入 -> CSV(逗号分隔文本文件)<BR>
					2. 点击浏览, 选择您刚才保存的文件名, 比如: C:\AddressBook.csv, 点击"下一步"按钮<BR>
					3. 选择要保存的字段, 推荐点击"全选", 然后按"完成"<BR>	
					4. WinPim 将自行完成导入功能, 如果导入过程中出现对话框提示, 很有可能是用户信息不完备,或格式错误,或重复信息, 推荐"是", "保留"<BR>
					5. 导入完成后, WinPim会提示"成功导入", 点击"确定"即可!<BR>
			</DIV>
</td></tr>
<tr Class=DarkTableBody><td align=center><input type=submit value='立即导出地址簿' class=button>
</td></tr></table>
</form>
</td></tr></table>
<%End Sub


Sub Export()

	Dim OutStr
	Dim sql,rs
	Dim ThisRecord
	Dim format

	format=Request("format")

	Select Case format
	Case 0
		'outlook express
		OutStr="姓名,昵称,电子邮件地址,住宅所在街道,住宅所在地的邮政编码,住宅电话,移动电话,个人网页,公司"

		sql="Select S.realname,S.userid,S.email,S.address,S.zipcode,S.telephone,S.mobilephone,S.homepage,S.workshop from student S inner join joinclass J on S.userid=J.userid where J.isauditing=False and J.classid="&ClsID&" order by S.realname"
		Set rs=Conn.Execute(sql)

		do until rs.eof
		ThisRecord=""
		for i=0 to 8
			ThisRecord=ThisRecord&rs(i)&","
		next 
		ThisRecord=left(ThisRecord,len(ThisRecord)-1)
		OutStr=OutStr&vbcrlf&ThisRecord
		rs.movenext
		loop
		
		Set rs=Nothing

	Case 1

		'foxmail
		OutStr="姓名,电子邮件地址,手机,OICQ,个人主页,性别,生日,家庭所在地邮政编码,家庭所在街道,家庭电话1,公司"
		sql="Select  S.realname,S.email,S.mobilephone,S.oicq,S.homepage,S.sex,S.birthday,S.zipcode,S.address,S.telephone,S.workshop from student S inner join joinclass J on S.userid=J.userid where J.isauditing=False and J.classid="&ClsID&" order by S.realname"
		Set rs=Conn.Execute(sql)

		do until rs.eof
		ThisRecord=""
		for i=0 to 10
			if i=5 Then
				if rs(5)=True Then ThisRecord=ThisRecord&"女" Else ThisRecord=ThisRecord&"男"
			Else
				ThisRecord=ThisRecord&rs(i)&","
			End if
		next 
		ThisRecord=left(ThisRecord,len(ThisRecord)-1)
		OutStr=OutStr&vbcrlf&ThisRecord
		rs.movenext
		loop

		Set rs=Nothing

	Case 2
		'WinPIM
		OutStr="姓名,昵称,移动电话,ICQ,电子邮件,个人主页,家庭所在地的邮政编码,家庭地址,家庭电话,单位名称,性别,生日,Messenger,生日农历标志"
		sql="Select S.realname,S.userid,S.mobilephone,S.oicq,S.email,S.homepage,S.zipcode,S.address,S.telephone,S.workshop,S.sex,S.birthday,S.msn from student S inner join joinclass J on S.userid=J.userid where J.isauditing=False and J.classid="&ClsID&" order by S.realname"
		Set rs=Conn.Execute(sql)

		do until rs.eof
		ThisRecord=""
		for i=0 to 12
			if i=10 Then
				if rs(10)=True Then ThisRecord=ThisRecord&"女" Else ThisRecord=ThisRecord&"男"
			Else
				ThisRecord=ThisRecord&rs(i)&","
			End if
		next 
		ThisRecord=ThisRecord&"0"
		OutStr=OutStr&vbcrlf&ThisRecord
		rs.movenext
		loop

		Set rs=Nothing


	End Select


	Response.Buffer = True 
	Response.Clear 
	 
	Response.AddHeader "Content-Disposition", "attachment; filename=AddressBook.csv"
	Response.AddHeader "Content-Length", strlength(OutStr)
	Response.CharSet = "UTF-8" 
	Response.ContentType = "application/octet-stream" 
	Response.Write OutStr
	Response.Flush 
	response.End

End Sub



Sub download()

Dim OutStr

	OutStr="<html><head>"&_
	"<style type=text/css>"&_
	".A {font-size: 9pt; text-decoration: none}"&_
	"td,th {font-size: 9pt}"&_
	"a:hover {color: #FF0000; text-decoration: underline}"&_
	"a:active {color: #990000; text-decoration: none}"&_
	"a:link {color: #000000; text-decoration: none}"&_
	"A:visited{COLOR: #000000; text-decoration: none}"&_
	"</style>"&_
	"<title>"&ClassName&"通讯录</title>"&_
	"<body bgcolor=#FFFFFF text=#000000>"&_
	"<table width=700 cellspacing=0 cellpadding=0 align=center>"&_
	"<tr><td align=center height=35><font size=6 face=华文行楷 color=#779933>"&htmlencode(ClassName)&"通讯录</font></td>"&_
	"</tr></table>"&_
	"<TABLE border=0 width=700 bgcolor="&TableBorderColor&" cellspacing=1 cellpadding=0 align=center>"&_
	"<tr><td>"&_
	"<TABLE border=0 width=100% bgcolor=#ffffff cellspacing=1 cellpadding=5 align=center>"&_
	"<tr bgcolor="&TableBorderColor&"><th>姓名</th><th>电话</th><th>手机</th><th>QQ</th><th>Email</th><th width=""27%"">工作单位</th></tr>"
	 
	sql="Select S.realname,S.userid,S.email,S.oicq,S.telephone,S.mobilephone,S.workshop from student S inner join joinclass J on S.userid=J.userid where J.isauditing=False and J.classid="&ClsID&" order by S.realname"

	Set rs=Conn.Execute(sql)

	do until rs.eof

		name=rs(0)
		if len(name)=2 Then name=left(name,1)&"&nbsp;&nbsp;"&right(name,1)

		OutStr=OutStr&"<tr bgcolor="&LightTBColor&"><td>&nbsp;&nbsp;"&name&"</a></td>"&_
		"<td>"&rs(4)&"</td>"&_
		"<td>"&rs(5)&"</td>"&_
		"<td><a href=http://search.tencent.com/cgi-bin/friend/user_show_info?ln="&rs(3)&" target=_blank title=查看"&name&"的OICQ状态>"&rs(3)&"</a></td>"&_
		"<td><a href=mailto:"&rs(2)&" title=给"&name&"发邮件>"&rs(2)&"</a></td>"&_
		"<td>"&htmlencode(rs(6))&"</td>"&_
		"</tr>"

		rs.movenext
	loop
	OutStr=OutStr&"</table></td></tr></table>"

	Response.Buffer = True 
	Response.Clear 
	 
	Response.AddHeader "Content-Disposition", "attachment; filename=classmate.htm"
	Response.AddHeader "Content-Length", strlength(OutStr)+425
	Response.CharSet = "UTF-8" 
	Response.ContentType = "application/octet-stream" 
	Response.Write OutStr
	Response.Flush 

End Sub


Sub opnbar()

	if style="List" Then
		sql="Select S.realname,S.userid,S.email,S.oicq,S.telephone,S.mobilephone,S.workshop from student S inner join joinclass J on S.userid=J.userid where J.isauditing=False and J.classid="&ClsID&" order by S.realname"
	Else
		sql = "Select S.realname,S.userid,S.email,S.homepage,S.oicq,S.imageid,S.telephone,S.mobilephone,S.workshop,J.degree from student S inner join joinclass J on S.userid=J.userid where J.classid="&ClsID&" and J.isauditing=False order by S.realname"
	End if
	Set rs = server.CreateObject("ADODB.Recordset")
	rs.open sql,Conn,1,1
	rs.pagesize=20
	totalpages=rs.pagecount
	currentPage=Request("page")
	if currentpage="" Then currentpage=1
	if not isnumeric(currentpage) Then
		currentpage=1
	ElseIf Cint(currentpage)>totalpages Then
		currentpage=totalpages
	End if
	currentpage=Cint(currentpage)
	if not (rs.eof and rs.bof) then 
		rs.absolutepage=currentpage
	end if
	%>
	<br><br>
	<TABLE border=0 cellspacing=0 cellpadding=0 align=center width=100%>
	<TR><TD align=left>
			<IMG SRC="IMAGES/classmate.gif" WIDTH="114" HEIGHT="38" BORDER=0 ALT=""></td>
		<td align=right valign=bottom><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT><input onClick=document.all.WebBrowser.ExecWB(6,1) type=button value=打印 class=button title=打印本页>&nbsp;
	<%response.write "<input onClick=""location.href='ClassMail.asp?ClassID="&ClsID&"&Action=ClassMail'"" type=button value=邮件 class=button title=班级邮件群发"
	if IntVar(5)=0 Then Response.Write " disabled"
	response.write ">&nbsp;"
	if style="Card" Then
		Response.Write "<input onClick=""location.href='ClassMate.asp?ClassID="&ClsID&"&Style=List&Page="&currentpage&"'"" type=button value=列表 class=button title=切换到列表样式>"
	Else
		Response.Write "<input onClick=""location.href='ClassMate.asp?ClassID="&ClsID&"&Style=Card&Page="&currentpage&"'"" type=button value=卡片 class=button  title=切换到卡片样式>"
	End if
	Response.Write "&nbsp;<input type=button onclick=""location.href='ClassMate.asp?ClassID="&ClsID&"&Action=Download'"" value=下载 class=button  title=""下载本班成员通讯录"">&nbsp;<input type=button onclick=""openScript('ClassMate.asp?ClassID="&ClsID&"&Action=SelFormat',500,350)"" value=导出 class=button  title=将班级成员通讯地址导入到您的个人信息管理工具中></td></tr></table>"

End Sub


Sub ListStyle()

	
	dim i
	Call opnbar()
	Response.Write "<TABLE border=0 width=""100%"" Class=TableBorder cellspacing=1 cellpadding=5>"&_
	"<tr><th>姓名</th><th>电话</th><th>手机</th><th>QQ</th><th>Email</th><th width=""27%"">工作单位</th></tr>"

	if totalpages<>0 then
	for i=1 to 20
	name=htmlencode(rs(0))
	if len(name)=2 Then
		name=left(name,1)&"&nbsp;&nbsp;"&right(name,1)
	End if

	Response.Write "<tr Class=LightTableBody><td>&nbsp;&nbsp;<a target=_blank href=""Profile.asp?Name="&rs(1)&"&Action=showdetail"" title=""查看"&name&"的详细个人资料"">"&name&"</a></td>"&_
		"<td>"&rs(4)&"</td>"&_
		"<td>"&rs(5)&"</td>"&_
		"<td><a href=""http://search.tencent.com/cgi-bin/friend/user_show_info?ln="&rs(3)&""" target=_blank title=""查看"&name&"的OICQ状态"">"&rs(3)&"</a></td>"&_
		"<td><a href=""mailto:"&rs(2)&""" title=""给"&name&"发邮件"">"&rs(2)&"</a></td>"&_
		"<td>"&htmlencode(rs(6))&"</td>"&_
		"</tr>"

	rs.movenext
	if currentpage=totalpages then
		if rs.eof then exit for
	end if
	next
	end if

	rs.close
	Set rs=Nothing
	Call pagelink()

End Sub


Sub CardStyle()

	dim i
	Call opnbar()
	if totalpages<>0 then
	Response.Write "<TABLE border=0 width=""100%"">"
	for i=1 to 20

	if i mod 2=1 Then Response.Write "<TR>"
	Response.Write "<TD align=center width=""25%"" height=""150"">"

	name=rs(0)
	if len(name)=2 Then
		name=left(name,1)&"&nbsp;&nbsp;"&right(name,1)
	End if

	face=rs(5)
	if isnull(face) Then face=""

	if rs(9)>6 Then
		namestyle="color:white;filter:glow(color=#FF7777,strength=1)"
	ElseIf rs(9)>1 Then
		namestyle="color:white;filter:glow(color=#33dd33,strength=1)"
	Else
		namestyle="color:white;filter:glow(color=#7777ff,strength=1)"
	End if
	namestyle=namestyle&";FONT-SIZE:12pt"


	%>
	<STYLE type=text/css>
	.cardfont{FONT-SIZE:11px;COLOR:#666699;FONT-FAMILY:"Arial","宋体";TEXT-DECORATION:none}
	</style>

	<table align=center border=0><tr><td align=center>
	<TABLE border=0 width=320 cellspacing=0 cellpadding=0 align=left>
	<TR>
	<TD colspan=2 class=DarkTableBody>
	<TABLE width=100% cellspacing=3 cellpadding=5 border=0>
	<TR>
	<TD bgcolor=eeeeff height=180  background="images/cardback.gif">
	<table border="0" width="90%" height="96" align=center cellspacing=0 cellpadding=0>
	  <tr>
		<td width="25%" rowspan="2" height="80"><%if rs("imageid")<>0 Then%><a target=_blank href="Profile.asp?Name=<%=rs(1)%>&Action=showdetail"><img src="face/image<%=rs("imageid")%>.gif" align=right class=trans border=0 alt="点击查看<%=name%>的详细个人资料"></a><%End if%></td>
		<td width="75%" colspan=2 height="35" align=right class=cardfont><%=htmlencode(ClassName)%></td>
	  </tr>
	  <tr>
		<td width=50% height="40" align=right><table  border=0 style="<%=namestyle%>"><tr><td><span style="FONT-SIZE: 11pt"><%=name%></span></td></tr></table></td><td width=60 class=cardfont>&nbsp;&nbsp;
		<%if rs(9)>1 Then Response.Write grade(rs(9),False)%>
		</td>
	  </tr>
	</table>
	<table border="0" width="90%" align=center cellspacing=0 cellpadding=0>
	  <tr height=18>
		<td class=cardfont width=40%>电话:<%=rs(6)%></td>
		<td class=cardfont>手机:<%=rs(7)%></td>
	  </tr>
	  <tr height=18>
		<td class=cardfont>QQ:<%if rs(4)<>"" Then%>
	<a class=green href='http://search.tencent.com/cgi-bin/friend/user_show_info?ln=<%=rs(4)%>' target=_blank title='查看<%=name%>的OICQ状态'><%=rs(4)%></a>
	<%End if%></td>
		<td class=cardfont>Email:<%if rs(2)<>"" Then%><a href="mailto:<%=rs(2)%>" title="给<%=name%>发邮件"><%=rs(2)%></a><%End if%></td>
	  </tr>
	  <tr height=18>
		<td width="100%" colspan="2" class=cardfont>我的主页:<%if rs(3)<>"" Then%><a  href="<%=rs(3)%>"
		target="_blank" title='访问<%=name%>的个人主页'><%=htmlencode(rs(3))%></a><%End if%></td>
	  </tr>
	  <tr height=18>
		<td width="100%" colspan="2" class=cardfont>工作单位:<%=htmlencode(rs(8))%></td>
	  </tr>
	</table>

	</TD>
	</TR>
	</TABLE>
	</TD>
	</TR>
	<TR><TD width=10></TD><TD width=290 bgcolor=#9999aa height=5><spacer type=block width=1></TD></TR>
	</TABLE>
	<TABLE border=0 width=5 cellspacing=0 cellpadding=0 align=left>
	<TR><TD height=8></TD></TR>
	<TR><TD height=183 bgcolor=#9999aa><br></TD></TR>
	</TABLE>
	</td></tr></table>
	<BR>
	<%
	rs.movenext
	if currentpage=totalpages then
		if rs.eof then 
			response.write "</tr>"
			exit for 
		end if 
	end if 

	if i mod 2=0 Then Response.Write "</TR>"
	next
	end if
	rs.close:Set rs=Nothing
	%>
	</td><tr></table>


	<%
	Call PageLink()

End Sub


Sub PageLink()
	%>
	<table width=100% align="center">
	<tr><td align=left valign=center>
	<% 
	if currentpage=0 Then currentpage=1
	if not  (currentpage=1 or totalpages=0) Then
		Response.Write "　<a href=?ClassID="&ClsID&"&Style="&style&"&Page="&currentpage-1&"&OrderBy="&order&"><img src=images/left.gif border=0 hspace=2>上一页</a>"
	End if
			
	if not (currentpage=totalpages or totalpages=0) Then
		Response.Write "　<a href=?ClassID="&ClsID&"&Style="&style&"&Page="&currentpage+1&"&OrderBy="&order&"><img src=images/right.gif border=0 hspace=2>下一页</a>"
	End if

	Response.Write "</td><td align=right valign=center>页次:"&currentpage&"/"&totalpages&_
	"&nbsp;&nbsp;&nbsp;去第&nbsp;<input type=text name=targetPage size=2 style=""height:16px;width:20px;"">&nbsp;页</td>"&_
	"<td width=15 align=right style=""cursor:hand""onclick=""location.href='ClassMate.asp?ClassID="&ClsID&"&Style="&style&"&Page='+targetPage.value"">"&_
	"<img src=images/btngo.gif width=13 height=15>"&_
	"</td></tr></table>"


End Sub

if Request("Action")<>"SelFormat" then Call footer()

%>


<!--#INCLUDE FILE="include/grade.asp" -->




