<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p22")
'''''''''''''''''''''''''''''''''''''''''''''''
dim currentpage,totalpage,totalnum,recpage,urls,listtitle,act
recpage=20
dim LpId,lpareaid,infotypeid,title
act=request.querystring("act")
if(request.QueryString("page")<>"") then
	currentpage=Clng(request.QueryString("page"))
else
	currentpage=1
end if
if(request.QueryString("LpId")<>"") then
	LpId=Clng(request.QueryString("LpId"))
else
	LpId=0
end if
urls="LpId="&LpId
%>
<html>
<head>
<title>楼盘广告管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #FFFFFF;
}
-->
</style>
<link href="style/global.css" rel="stylesheet" type="text/css">
<script language="javascript">
function goto(frm)
{
	var gourl ="?LpId<%=LpId%>&";
	gourl += "page=" + (frm.page.value);
     var hid=parseInt(frm.hid.value);
	 if(parseInt(frm.page.value)>hid||frm.page.value<=0){
	 alert("错误！请确定你输入的数字在1-"+hid+"之间");
	 return false;
	 }
	window.location.href=gourl;
}

function ConfirmDel()
{
   if(confirm("确认删除？并且不能恢复！确定要删除此信息吗？"))
     return true;
   else
     return false;
	 
}
</script>
<script language="JavaScript" src="../js/PublicJS.js"></script>
<style type="text/css">
<!--
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
.style4 {color: #000000}
-->
</style>
</head>

<body>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#999999">
  <tr>
    <td height="22" bgcolor="#FF9900"><div align="center"><span class="style1">◆ 楼盘问答管理 ◆</span></div></td>
  </tr>
</table>
<%
if(act="do") then
	'批量删除
	dim obj,objArr,flags,do_type
	do_type=request.form("do_type")
	if not isempty(request.Form("obj")) then
		obj=request.Form("obj")
	else
		response.Write("请选择需要操作的记录")
		response.Write("<a href=""#"" onClick=""javascript:history.back();"">返回</a>")
		response.End()
	end if
	objArr=split(obj,",")
		for i=0 to ubound(objArr)	
			if(do_type="del") then
				conn.execute("delete from t_lp_wenda where id="&objArr(i))
			end if				
		next
	
	response.Write("批量执行成功！")		
	response.Redirect(request.ServerVariables("HTTP_REFERER"))
elseif(act="reply") then
	id=Clng(request.QueryString("id"))
	set rs=server.createobject("adodb.recordset")
	rs.open "select * from t_lp_wenda where id="&id,conn,3,1
	if not rs.eof then
%>
<form action="?act=replyok&id=<%=id%>" method="post">
  <table width="960" border="0" cellspacing="1" cellpadding="0" bgcolor="#eeeeee">
    <tr>
      <td width="314" height="25" align="right" bgcolor="#FFFFFF">问题：</td>
      <td width="646" bgcolor="#FFFFFF">&nbsp;<%=rs("Title")%></td>
    </tr>
    <tr>
      <td height="25" align="right" bgcolor="#FFFFFF">回答：</td>
      <td bgcolor="#FFFFFF"><textarea name="Reply" id="Reply" cols="45" rows="5"><%=rs("Reply")%></textarea></td>
    </tr>
    <tr>
      <td height="25" align="right" bgcolor="#FFFFFF">回答者：</td>
      <td bgcolor="#FFFFFF"><input type="text" name="ReplyUser" id="ReplyUser" value="<%=rs("ReplyUser")%>"></td>
    </tr>
    <tr>
      <td height="25" align="right" bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">
      <input type="hidden" name="Title" value="<%=rs("Title")%>">
      <input type="hidden" name="ReplyBy" value="<%=rs("AskBy")%>">
      <input type="hidden" name="Email" value="<%=rs("Email")%>">
      <input type="submit" name="button" id="button" value="提 交"></td>
    </tr>
  </table>
</form>
<%
	end if
	rs.close
	set rs=nothing
elseif(act="replyok") then
	dim ReplyBy
	ReplyBy=request.Form("ReplyBy")
	if(instr(ReplyBy,"Email")>0) then
		Set msg = Server.CreateObject("JMail.Message") 
		msg.silent = true 
		msg.Logging = true 
		msg.Charset = "gb2312" 
		msg.MailServerUserName=MailServerUserName	'登录邮件服务器的用户名 
		msg.MailServerPassword=MailServerPassword  '输入smtp服务器验证密码  （用户Email帐号对应的密码） 
		msg.From = MailAddress    '发件人Email 
		msg.FromName = SiteName   '发件人姓名 	
		msg.AddRecipient request.Form("Email")  '收件人Email 
		msg.Subject = "关于"&request.Form("Title")&"的回复"  '信件主题 
		msg.Body = request.Form("Reply")    '正文 
		msg.Send MailServer        'smtp服务器地址（企业邮局地址） smtp.**.com
		set msg=nothing
	end if
	id=Clng(request.QueryString("id"))
	set rs=server.createobject("adodb.recordset")
	rs.open "select * from t_lp_wenda where id="&id,conn,3,3
	rs("Reply")=request.Form("Reply")
	rs("ReplyUser")=request.Form("ReplyUser")
	rs("ReplyDate")=now()
	rs.update
	rs.close
	set rs=nothing
	response.Write("<p align=""center"">成功答复</p>")
	response.Write("<p align=""center""><a href=""javascript:history.go(-2)"">返回</a></p>")
else
%>
<form method="get">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25"><div align="center">楼盘ID：
        <input name="LpId" type="text" id="LpId" value="<%=LpId%>">
        <input type="submit" name="Submit" value="按楼盘查看==&gt;">
</div></td>
    </tr>
  </table>
</form>
<form action="?act=do" method="post" name="mem" style="margin:0px; padding:0px;">
  <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
      <td width="9%" bgcolor="#F5F5F5" class="style1"><div align="center" class="style4"></div></td>
      <td width="17%" height="22" bgcolor="#F5F5F5"><div align="center">姓名</div></td>
      <td width="16%" bgcolor="#F5F5F5" class="style4"><div align="center" class="style4">手机</div></td>
      <td width="21%" bgcolor="#F5F5F5" class="style4"><div align="center">邮箱</div></td>
      <td width="21%" align="center" bgcolor="#F5F5F5" class="style4">提问楼盘</td>
      <td width="16%" bgcolor="#F5F5F5" class="style4"><div align="center">回复方式</div></td>
    </tr>
    <%
		dim csql,qsql
		csql="select count(*) AS co from t_lp_wenda where 1=1"
		if(LpId>0) then
			csql=csql&" and LpId="&LpId
		end if		
		qsql="select top "&recpage&" id,LpId, LpTitle, Title, UserName, Sex, Email, Mobile, Reply, AskDate, AskBy, ReplyDate, ReplyUser  from t_lp_wenda where id <=(select min(id) from (select top "&(recpage*(currentpage-1)+1)&" id from t_lp_wenda where 1=1"
		if(LpId>0) then
			qsql=qsql&" and LpId="&LpId
		end if
		
		qsql=qsql&" order by id desc) as t)"
		if(LpId>0) then
			qsql=qsql&" and LpId="&LpId
		end if		
		qsql=qsql&" order by id desc "			
		''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	  allrec=conn.execute(csql)(0)
	  totalpage=Cint((allrec-1+recpage)/recpage)
	  set rs=server.createobject("adodb.recordset")
		rs.open qsql,conn,3,1
		if not rs.eof then
			listArr=rs.getrows()
		end if
		rs.close
		set rs=nothing
		dim rby
	  if(isarray(listArr)) then
	  	for j=0 to ubound(listArr,2)
				rby=listArr(10,j)
				if(rby<>"") then
					rby=replace(rby,"Email","邮件")
					rby=replace(rby,"Mobile","手机")
				end if
	  %>
    <tr>
      <td bgcolor="#FFFFFF"><div align="center">
          <input type="checkbox" name="obj" value="<%=listArr(0,j)%>" />
      </div></td>
      <td height="20" bgcolor="#FFFFFF"><div align="center"><%=listArr(4,j)%><%=listArr(5,j)%></div></td>
      <td bgcolor="#FFFFFF"><div align="center"><%=listArr(7,j)%></div></td>
      <td bgcolor="#FFFFFF"><div align="center"><%=listArr(6,j)%></div></td>
      <td align="center" bgcolor="#FFFFFF"><a href="../newhouse/show/<%=listArr(1,j)%>.htm" target="_blank"><%=listArr(2,j)%></a></td>
      <td bgcolor="#FFFFFF"><div align="center"><%=rby%></div></td>
	  </tr>
    <tr>
      <td height="24" colspan="6" bgcolor="#FFFFFF" style="line-height:20px;"><a href="../newhouse/show/<%=listArr(1,j)%>.htm" target="_blank">问：</a><a href="../newhouse/show/<%=listArr(1,j)%>.htm" target="_blank"><%=listArr(3,j)%>[<%=listArr(9,j)%>]</a>
      <a href="?act=reply&id=<%=listArr(0,j)%>" style="color:#F00;"><strong>[答复]</strong></a>
      </td>
    </tr>
    <tr>
      <td height="24" colspan="6" bgcolor="#FFFFFF"  style="line-height:20px;">
			
      答：<a href="../newhouse/show/<%=listArr(1,j)%>.htm" target="_blank"><%=listArr(8,j)%>[<%=listArr(11,j)%>] <%=listArr(12,j)%></a></td>
    </tr>
    <%
	    next
	  else
	  	response.Write("<tr><td colspan=""5"">暂时没有记录</td></tr>")
	  end if
	  set carr=nothing
	  %>
  </table>
  <div align="center">
  <input class=Button type="button" name="chksel" value="反选" onClick="ContraSel(this.form)">
  &nbsp;
  <select name="do_type" id="do_type">
    <option value="del">批量删除</option>	
  </select>
  &nbsp;
  <input class=Button type="submit" name="Submit2" value="执行所选 的操作" onClick="return confirm('您确定执行该操作吗?')">
</div>
</form>
<div align="center">
  <form name="form1" method="post" action="" style="margin:0 0 0 0">
    <%n=currentpage+1
p=currentpage-1
if p>0then
response.write("["&"<a href='?"&urls&"&page="&cstr(p)&"'>上一页</a>]&nbsp;&nbsp;&nbsp;")
else response.write("上一页&nbsp;&nbsp;&nbsp;")
end if 
if (n-1)*recpage>=allrec then 
response.write("下一页" )
else
response.Write("["&"<a href='?"&urls&"&page="&cstr(n)&"'>下一页</a>]")
end if
response.write("&nbsp;共"&allrec&"条&nbsp;")
response.Write("&nbsp;共"&totalpage&"页&nbsp;")
response.Write("&nbsp;第"&currentpage&"页&nbsp;")
%>
    <input type="hidden" name="hid" value="<%=totalpage%>">
    &nbsp;&nbsp;跳至
    <input name="page" type="text" size="5" onChange="goto(this.form)" style="border:1px solid #000000;height:18px ">
    页
    <input type="button" name="Button22" value="Go->" style="font-size:12px ;border:1px solid #000000;height:18px ">
  </form>
</div>
<script type="text/javascript">
function ContraSel(form) {
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if (e.name =='obj')
		e.checked=!e.checked;
	}
}
</script>
<%
end if
%>
</body>
</html>
<%
call connclose()
%>
