<!--#INCLUDE FILE="conn.asp" -->
<!--#INCLUDE FILE="Class_Checkuser.asp" -->
<!--#INCLUDE FILE="Class_Top.asp" -->
<!--#INCLUDE FILE="inc/char.asp" -->
<%
locat="学校通讯录"
Dim totalPages,currentPage
Dim rs,sql
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",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="Card" Then
				Call top(2,1)
				Call cardstyle()
			Else
				style="List"
				Call top(2,1)
				Call liststyle()
			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=Class_Mate.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 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=0 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=0 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>
	<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><input type=button onClick="openScript('Class_Modify.asp',800,600)" value=修改资料 class=button  title=修改我的个人资料>&nbsp;
     <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='Class_Mail.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='Class_Mate.asp?ClassID="&ClsID&"&Style=List&Page="&currentpage&"'"" type=button value=列表 class=button title=切换到列表样式>"
	Else
		Response.Write "<input onClick=""location.href='Class_Mate.asp?ClassID="&ClsID&"&Style=Card&Page="&currentpage&"'"" type=button value=卡片 class=button  title=切换到卡片样式>"
	End if
	Response.Write "&nbsp;<input type=button onclick=""location.href='Class_Mate.asp?ClassID="&ClsID&"&Action=Download'"" value=下载 class=button  title=""下载本校成员通讯录"">&nbsp;<input type=button onclick=""openScript('Class_Mate.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=""Class_Userinfo.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(5)<>"" Then%><a target=_blank href="Class_Userinfo.asp?Name=<%=rs(1)%>&Action=showdetail"><img src="<%=rs(5)%>" 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;转到第<select name=""page"" style=""width:35px"" onChange=""location.href='?ClassID="&ClsID&"&Style="&style&"&page='+this.options[selectedIndex].value"">"
             dim ii
             ii=1
             do while ii<=totalpages
             if ii=currentPage then
             response.write("<option selected value="&ii&">"&ii&"</option>")
             else
             response.write("<option value="&ii&">"&ii&"</option>")
             end if
             ii=ii+1
             loop
Response.Write "</select>页</td>"&_
	"</tr></table>"


End Sub
Sub download()

Dim OutStr
Dim Name,Sql
Dim RecNum,i,Rs

	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 bgcolor="&LightTBColor&">"&_
	"<tr><td align=center height=35><font size=5 face=楷体_GB2312 color=#000000><strong>"&htmlencode(ClassName)&"通讯录</strong></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="&LightTBColor&"><th>姓名</th><th>电话</th><th>手机</th><th>QQ</th><th>Email</th><th width=""27%"">工作单位</th></tr>"

	Set Rs = Server.CreateObject("ADODB.Recordset")
	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=0 and J.classid="&ClsID&" order by S.realname"
	Rs.open sql,Conn,1,1
	RecNum=Rs.Recordcount
	for i=1 to RecNum
		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
	next
	Rs.close:set rs=nothing

	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 Export()

	Dim OutStr
	Dim sql,rs
	Dim ThisRecord
	Dim Format
	Dim i,j,RecNum

	Format=Request("Format")
	Set Rs = Server.CreateObject("ADODB.Recordset")

	Select Case Format
	Case 0
		'outlook express
		OutStr="姓名,用户名,QQ号码,电子邮件地址,个人主页,住宅电话,移动电话,工作单位"
		sql = "Select S.realname,S.userid,S.oicq,S.email,S.homepage,S.telephone,S.mobilephone,S.workshop from student S inner join joinclass J on S.userid=J.userid where J.classid="&ClsID&" and J.isauditing=0 order by S.realname"
		Rs.open sql,Conn,1,1
		RecNum=Rs.Recordcount
		for j=1 to RecNum
			ThisRecord=""
			for i=0 to 7
				ThisRecord=ThisRecord&rs(i)&","
			next 
			ThisRecord=left(ThisRecord,len(ThisRecord)-1)
			OutStr=OutStr&vbcrlf&ThisRecord
			rs.movenext
		next
		
	Case 1

		'foxmail
		OutStr="姓名,用户名,性别,生日,QQ号码,电子邮件地址,个人主页,家庭电话,手机,工作单位,邮政编码,通讯地址"
		sql="Select  S.realname,S.userid,S.sex,S.birthday,S.oicq,S.email,S.homepage,S.telephone,S.mobilephone,S.workshop,S.zipcode,S.address from student S inner join joinclass J on S.userid=J.userid where J.classid="&ClsID&" and J.isauditing=0 order by S.realname"
		Rs.open sql,Conn,1,1
		RecNum=Rs.Recordcount
		for j=1 to RecNum
			ThisRecord=""
			for i=0 to 11
				If i=2 Then
					If rs(2)=1 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
		next

	Case 2
		'WinPIM
		OutStr="姓名,用户名,性别,生日,QQ号码,电子邮件地址,个人主页,家庭电话,手机,工作单位,邮政编码,通讯地址"
		sql="Select  S.realname,S.userid,S.sex,S.birthday,S.oicq,S.email,S.homepage,S.telephone,S.mobilephone,S.workshop,S.zipcode,S.address from student S inner join joinclass J on S.userid=J.userid where J.classid="&ClsID&" and J.isauditing=0 order by S.realname"
		Rs.open sql,Conn,1,1
		RecNum=Rs.Recordcount
		for j=1 to RecNum
			ThisRecord=""
			for i=0 to 11
				If i=2 Then
					If rs(2)=1 Then ThisRecord=ThisRecord&"女," Else ThisRecord=ThisRecord&"男,"
				Else
					ThisRecord=ThisRecord&rs(i)&","
				End If
			next 
			ThisRecord=ThisRecord&"0"
			OutStr=OutStr&vbcrlf&ThisRecord
			rs.movenext
		next

	End Select
	Rs.close: Set rs=Nothing

	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
if Request("Action")<>"SelFormat" then Call footer()

%>


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




