<!--#include file="user_top.asp"-->
<!--#include file="inc/class_blog.asp"-->
<script language="javascript" src="inc/function.js"></script>
</head>
<body style="background:#fff">
<%
dim rs,sql,blog,iCount,sGuide
dim id,cmd,action
Dim groupName,tsql
cmd=trim(request("cmd"))
action=trim(request("action"))
id=oblog.filt_badstr(trim(Request("id")))
if cmd="" then
	cmd=0
else
	cmd=clng(cmd)
end If
Set rs =oblog.execute ("SELECT g_name FROM oblog_groups WHERE groupid = " & oblog.l_uGroupId)
groupName = rs (0)
rs.close
G_P_FileName="user_pmmanage.asp?cmd=" & cmd & "&page="

tsql="or groups like '"&oblog.l_uGroupId&",%' or groups like '%,"&oblog.l_uGroupId&"' or groups like '%,"&oblog.l_uGroupId&",%' or groups ='"&oblog.l_uGroupId&"'"

select case action
	case "add"
	call add()
	case "saveadd"
	call saveadd()
	case "del"
	call del()
	case else	
	call main()
end select
set rs=nothing
set blog=nothing
%>
	</div>

  </div>
</div>

</body>
</html>
<%
sub main()
%>
<ul id="user_page_top">
		<li id="p7"><a href="#" onclick="chk_idAll(myform,1)">全部选择</a></li>
		<li id="p8"><a href="#" onclick="chk_idAll(myform,0)">全部取消</a></li>
		<li id="p4"><a href="#" onclick="if (chk_idBatch(myform,'删除选中的短信吗?')==true) { document.myform.submit();}">删除短信</a></li>
		<li>&nbsp;&nbsp;&nbsp;&nbsp;</li>
		<li id="p1"><a href="user_pmmanage.asp">收件箱</a></li>
		<li id="p1"><a href="user_pmmanage.asp?cmd=1">发件箱</a></li>
		<li id="p1"><a href="javascript:openScript('user_pm.asp?action=send',450,400)">发送短信</a></li>
		<li><%'=lAll&"/"&freen%></li>
</ul>
<%
	dim ssql,iCount,i,lPage,lAll,lPages,iPage,freen
	ssql="id,sender,incept,topic,addtime,isguest,isreaded,issys"
	select case cmd
		case 0
			sql="select "&ssql&" from oblog_pm where incept='"&oblog.l_uname&"' and delr=0 "&tsql&" order by issys desc,id desc"
			sGuide=sGuide & "收件箱"
		case 1
			sql="select "&ssql&" from oblog_pm where sender='"&oblog.l_uname&"' and dels=0 order by id desc"
			sGuide=sGuide & "发件箱"
		case else
	end select
	Set rs=Server.CreateObject("Adodb.RecordSet")
	'response.Write(sql)
	rs.Open sql,Conn,1,1
	iCount=rs.RecordCount
  '分页处理
  lAll=INT(rs.recordcount)
    If lAll=0 Then    	
    	rs.Close
    	Set rs=Nothing
    	%>
    	<div id="user_page_content">
		   <div id="content_li">
		   	<ul class="content_li_conten">
		   		<li class="t1"></li>
		   		<li class="t3">&nbsp;</li>
		   	</ul>
		   	<ul class="content_li_conten">
		   		<li class="t1"></li>
		   		<li class="t3"><%=sGuide & " 没有相关纪录" %></li></ul>
		  	</div>
		  </div>
		  <script>parent.show_title("<%=sGuide%>");</script>
    	<%
    	Exit Sub
    End If
    i=0
    iPage=12
	'分页
	If Request("page") = "" Or Request("page") ="0" then
		lPage = 1
	Else
		lPage = Int(Request("page"))
	End If
	
	'设置缓存大小 = 每页需显示的记录数目
	rs.CacheSize = iPage
	rs.PageSize = iPage
	rs.movefirst		
	lPages = rs.PageCount
	If lPage>lPages Then lPage=lPages
	rs.AbsolutePage = lPage
	i=0

	freen=oblog.l_Group(27,0)-lAll
%>
	
	<div id="showpage">	
	  	
	  <%=MakeMiniPageBar(lAll,iPage,lPage,G_P_FileName)%>
	</div>
<style type="text/css">
<!--
.content_li_top .t2 {padding:0 0 0 7px;width:102px;}
.content_li_top .t3 {padding:0 0 0 14px;}
.content_li_top .t4 {width:100px;margin:0 15px 0 -20px;}
.content_li_conten .t11 {width:90px!important;text-align:left!important;}
.content_li_conten .t2 {width:100px!important;}
.content_li_conten .t4 {width:130px;text-align:left!important;}
-->
</style>
	<div id="user_page_content">
		<ul class="content_li_top">
			<li class="t1">选中</li>
			<li class="t11">状态</li>
			<li class="t3">标题</li>
			<li class="t2">收件人</li>
			<li class="t2">发件人</li>
			<li class="t2">操作</li>
		</ul>
			<ul class="list_top">
  		 <div id="content_li">
			<form name="myform" method="Post" action="user_pmmanage.asp?action=del&cmd=<%=cmd%>" onSubmit="return confirm('确定要执行选定的操作吗？');">
	<%do while not rs.eof
		i = i + 1%>
	<ul class="content_li_conten" id="u<%=rs("id")%>">
	<li class="t1"><input name='id' type='checkbox' id="c<%=cstr(rs("id"))%>" value='<%=cstr(rs("id"))%>'<%If rs("issys")= 1 Then%>disabled<%End if%> /></li>
	<li class="t11"><%
	If rs("issys")= 1 Then 
		response.write "<font color=red style=font-weight:600>系统通知</font>"
	Else 
		response.write OB_IIF2(rs("isreaded"),"已读","<font color=red>未读</font>")
	End if	
	%></li>
	<li class="t3" onclick="chk_iddiv('<%=rs("id")%>')"><a href="javascript:openScript('user_pm.asp?action=read<%=cmd%>&id=<%=rs("id")%>',450,380)"><%=oblog.filt_html(rs("topic"))%></a><span style="font-family:Century Gothic,verdana,tahoma,Arial,Helvetica,sans-serif;font-size:10px;">(<%=OB_IIF(rs("addtime"),"-")%>)</span></li>
	<li class="t2"><%
	If rs("incept")="0" Then 
		response.Write "<span style=""color:#090;font-weight:600;"">" &groupName& "</span>"
	Else 
		response.Write oblog.filt_html(rs("incept"))
	End if%></li>
	<li class="t2"><%
	If rs("issys")= 1 Then 
		Response.Write "<font color=red style=font-weight:600>" &rs("sender") &"</font>"
	Else 
		Response.Write oblog.filt_html(rs("sender"))
	End If
	%></li>
	<li class="t2">
	<%If rs("issys")= 1 Then %>
		<s>删除</s>
	<%Else%>
		<a href = "user_pmmanage.asp?action=del&id=<%=rs("id")%>" onclick="return confirm('确定要删除吗？');">删除</a>
	<%End if%>
	</li>
	</ul>
<%
	if i>=iPage then exit do
	rs.movenext
loop
%>
	</form>
	</div>
	<script>parent.show_title("<%=sGuide%>");</script>
  <%
	rs.Close
	if iCount>oblog.l_Group(27,0) then
			'oblog.execute("update oblog_pm set delr=1 where id not in (select top "&oblog.l_gPmMax&" id from  oblog_pm where incept='"&oblog.l_uname&"' order by id desc ) and incept='"&oblog.l_uname&"'")
		oblog.execute("delete from oblog_pm where delr=1 and dels=1")
		Response.Write"<script language=JavaScript>alert(""您的信箱已满，请及时清理！"");</script>"
	end if
	set rs=Nothing
end sub


sub del()
	if id="" then
		oblog.adderrstr( "错误：请指定要删除的对象！")
		oblog.showusererr
		exit sub
	end if
	if instr(id,",")>0 then
		dim n,i
		id=FilterIDs(id)
		n=split(id,",")
		for i=0 to ubound(n)
			delone(n(i))
		next
	else
		delone(id)
	end if
	set rs=nothing
	oblog.showok "删除短消息成功！",""
end sub

sub delone(id)
	id=clng(id)
	select case cmd
		case 0
		sql="update oblog_pm set delr=1 where id=" & clng(id)&" and incept='"&oblog.l_uname&"'"
		case 1
		sql="update oblog_pm set dels=1 where id=" & clng(id)&" and sender='"&oblog.l_uname&"'"
	end select	
	oblog.execute(sql)
end sub
%>