<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<!-- #include file="inc/Session.asp" -->
<!--#include file="../newhouse/inc/function.asp"-->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p22")
'''''''''''''''''''''''''''''''''''''''''''''''
dim currentpage,totalpage,totalnum,recpage,urls,listtitle,act
recpage=20
dim lp_id,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("lp_id")<>"") then
	lp_id=Clng(request.QueryString("lp_id"))
else
	lp_id=0
end if
urls="lp_id="&lp_id
%>
<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;
}
.padleft{ padding-left:10px;}
form{ margin:0px; padding:0px;}
-->
</style>
<link href="style/global.css" rel="stylesheet" type="text/css">
<script language="javascript">
function goto(frm)
{
	var gourl ="?lp_id<%=lp_id%>&";
	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 checkint(elem)
{
  var checkOK = ".0123456789";
  var checkStr = elem.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
		ch = checkStr.charAt(i);
    	for (j = 0;  j < checkOK.length;  j++)
      	if (ch == checkOK.charAt(j))
        break;
    	if (j == checkOK.length)
    	{
      		allValid = false;
      		break;
    	}
  }
  if (!allValid)
  {
    	alert("只能输入数字。");
    	elem.focus();
    	return (false);
  }
  return (true);
}
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="add") then
%>
<form action="?act=doadd&lp_id=<%=lp_id%>" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#999999">
  <tr>
    <td height="25" colspan="2" bgcolor="#F5F5F5"><div align="center"><strong>添加户型图</strong></div></td>
  </tr>
  <tr>
    <td height="32" align="right" bgcolor="#FFFFFF">类型：</td>
    <td bgcolor="#FFFFFF" class="padleft"><table cellspacing="0" cellpadding="0">
      <tr>
        <td width="73"><label>
          <select name="f_shi">
            <option value="1">一室</option>
            <option value="2" selected="selected">二室</option>
            <option value="3">三室</option>
            <option value="4">四室</option>
            <option value="5">五室</option>
            <option value="6">六室</option>
            <option value="7">七室</option>
            <option value="0">其它</option>
          </select>
        </label></td>
        <td width="77" align="right"><select name="f_ting">
          <option value="0">不 限</option>
          <option value="1" selected="selected">一</option>
          <option value="2">二</option>
          <option value="3">三</option>
          <option value="4">四</option>
          <option value="5">五</option>
          <option value="6">六</option>
        </select></td>
        <td width="24" align="left">厅 </td>
        <td width="79" align="right"><select name="f_wei">
          <option value="0">不 限</option>
          <option selected="selected" value="1">一</option>
          <option value="2">二</option>
          <option value="3">三</option>
          <option value="4">四</option>
          <option value="5">五</option>
          <option value="6">六</option>
        </select></td>
        <td width="23" align="left">卫</td>
        <td width="78" align="right"><select name="f_chu">
          <option value="0">不 限</option>
          <option value="1" selected="selected">一</option>
          <option value="2">二</option>
          <option value="3">三</option>
          <option value="4">四</option>
          <option value="5">五</option>
          <option value="6">六</option>
        </select></td>
        <td width="32" align="left">厨</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="32" align="right" bgcolor="#FFFFFF">面积：</td>
    <td bgcolor="#FFFFFF" class="padleft"><input name="f_area" type="text" id="f_area" value="0" size="12" onBlur="checkint(this)" >      
      平方米</td>
  </tr>
  <tr>
    <td width="34%" height="32" bgcolor="#FFFFFF"><div align="right">描述：</div></td>
    <td width="66%" bgcolor="#FFFFFF" class="padleft"><div align="left">
      <input name="f_title" type="text" id="f_title">
    </div></td>
  </tr>
  <tr>
    <td height="32" bgcolor="#FFFFFF"><div align="right">图片：</div></td>
    <td bgcolor="#FFFFFF" class="padleft"><div align="left">
      <input name="f_photo" type="text" id="f_photo" size="50">
      <input type="button" name="Button" value="上传->" onClick="javascript:document.forms[0].f_photo.value=window.showModalDialog('upimg_thumbnail.htm','','dialogHeight:130px;dialogWidth:410px;help:no;status:no;scroll:no')">
    </div></td>
  </tr>
  <tr>
    <td height="32" colspan="2" bgcolor="#FFFFFF"><div align="center">
      <input type="submit" name="Submit" value="提 交">&nbsp;&nbsp;
      <input type="reset" name="Submit3" value="重 写">
    </div></td>
    </tr>
</table>
</form>
<%
elseif(act="doadd") then
	dim f_photo,f_title,f_shi,f_ting,f_wei,f_chu,f_area,lp_title
	set rs=conn.execute("select title from t_lp where id="&lp_id)
	if not rs.eof then
		lp_title=rs(0)
	end if
	rs.close
	set rs=nothing
	f_photo=request.form("f_photo")
	f_title=request.form("f_title")
	f_shi=cint(request.Form("f_shi"))
	f_ting=cint(request.Form("f_ting"))
	f_wei=cint(request.Form("f_wei"))
	f_chu=cint(request.Form("f_chu"))
	f_area=cint(request.Form("f_area"))
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from f_lp_hx",conn,3,3
	rs.addnew
	rs("f_title")=f_title
	rs("lp_title")=lp_title
	rs("f_photo")=f_photo
	rs("f_desc")=""
	rs("lp_id")=lp_id
	rs("f_shi")=f_shi
	rs("f_ting")=f_ting
	rs("f_wei")=f_wei
	rs("f_chu")=f_chu
	rs("f_area")=f_area
	rs("f_isrem")=0
	rs("f_rem_date")=now()
	rs.update
	rs.close
	set rs=nothing
	response.write("<p align=""center"">成功添加户型图!<a href=""?lp_id="&lp_id&""">返回管理</a>&nbsp;<a href=""javascript:history.back();"">继续添加</a></p>")
	'生成htm
	'show_htm=ReadHtml(SiteUrl&"/newhouse/show.asp?id="&lp_id,"gb2312")
	'call SaveTextFile(server.MapPath("/newhouse/show/")&"\"&lp_id&".htm",show_htm)
elseif(act="mod") then	
	id=Clng(request.querystring("id"))
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from f_lp_hx where id="&id,conn,3,1
	if not rs.eof then
%>
<form action="?act=domod&id=<%=id%>&lp_id=<%=lp_id%>" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#999999">
  <tr>
    <td height="22" colspan="2" bgcolor="#F5F5F5"><div align="center"><strong>修改户型图</strong></div></td>
  </tr>
  <tr>
    <td height="32" align="right" bgcolor="#FFFFFF">类型：</td>
    <td bgcolor="#FFFFFF" class="padleft"><table cellspacing="0" cellpadding="0">
      <tr>
        <td width="73"><label>
          <select name="f_shi">
            <option value="1" <%if(rs("f_shi")=1) then response.Write("selected=""selected""") end if%>>一室</option>
            <option value="2" <%if(rs("f_shi")=2) then response.Write("selected=""selected""") end if%>>二室</option>
            <option value="3" <%if(rs("f_shi")=3) then response.Write("selected=""selected""") end if%>>三室</option>
            <option value="4" <%if(rs("f_shi")=4) then response.Write("selected=""selected""") end if%>>四室</option>
            <option value="5" <%if(rs("f_shi")=5) then response.Write("selected=""selected""") end if%>>五室</option>
            <option value="6" <%if(rs("f_shi")=6) then response.Write("selected=""selected""") end if%>>六室</option>
            <option value="7" <%if(rs("f_shi")=7) then response.Write("selected=""selected""") end if%>>七室</option>
            <option value="0" <%if(rs("f_shi")=0) then response.Write("selected=""selected""") end if%>>其它</option>
          </select>
        </label></td>
        <td width="77" align="right"><select name="f_ting">
          <option value="0">不 限</option>
          <option value="1" <%if(rs("f_ting")=1) then response.Write("selected=""selected""") end if%>>一</option>
          <option value="2" <%if(rs("f_ting")=2) then response.Write("selected=""selected""") end if%>>二</option>
          <option value="3" <%if(rs("f_ting")=3) then response.Write("selected=""selected""") end if%>>三</option>
          <option value="4" <%if(rs("f_ting")=4) then response.Write("selected=""selected""") end if%>>四</option>
          <option value="5" <%if(rs("f_ting")=5) then response.Write("selected=""selected""") end if%>>五</option>
          <option value="6" <%if(rs("f_ting")=6) then response.Write("selected=""selected""") end if%>>六</option>
        </select></td>
        <td width="24" align="left">厅 </td>
        <td width="79" align="right"><select name="f_wei">
          <option value="0">不 限</option>
          <option value="1" <%if(rs("f_wei")=1) then response.Write("selected=""selected""") end if%>>一</option>
          <option value="2" <%if(rs("f_wei")=2) then response.Write("selected=""selected""") end if%>>二</option>
          <option value="3" <%if(rs("f_wei")=3) then response.Write("selected=""selected""") end if%>>三</option>
          <option value="4" <%if(rs("f_wei")=4) then response.Write("selected=""selected""") end if%>>四</option>
          <option value="5" <%if(rs("f_wei")=5) then response.Write("selected=""selected""") end if%>>五</option>
          <option value="6" <%if(rs("f_wei")=6) then response.Write("selected=""selected""") end if%>>六</option>
        </select></td>
        <td width="23" align="left">卫</td>
        <td width="78" align="right"><select name="f_chu">
          <option value="0">不 限</option>
          <option value="1" <%if(rs("f_chu")=1) then response.Write("selected=""selected""") end if%>>一</option>
          <option value="2" <%if(rs("f_chu")=2) then response.Write("selected=""selected""") end if%>>二</option>
          <option value="3" <%if(rs("f_chu")=3) then response.Write("selected=""selected""") end if%>>三</option>
          <option value="4" <%if(rs("f_chu")=4) then response.Write("selected=""selected""") end if%>>四</option>
          <option value="5" <%if(rs("f_chu")=5) then response.Write("selected=""selected""") end if%>>五</option>
          <option value="6" <%if(rs("f_chu")=6) then response.Write("selected=""selected""") end if%>>六</option>
        </select></td>
        <td width="32" align="left">厨</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="32" align="right" bgcolor="#FFFFFF">面积：</td>
    <td bgcolor="#FFFFFF" class="padleft"><input name="f_area" type="text" id="f_area" value="<%=rs("f_area")%>"size="12" onBlur="checkint(this)" >      
      平方米</td>
  </tr>
  <tr>
    <td width="33%" height="22" bgcolor="#FFFFFF"><div align="right">描述：</div></td>
    <td width="67%" bgcolor="#FFFFFF" class="padleft"><div align="left">
      <input name="f_title" type="text" id="f_title" value="<%=rs("f_title")%>">
    </div></td>
  </tr>
  <tr>
    <td height="22" bgcolor="#FFFFFF"><div align="right">图片：</div></td>
    <td bgcolor="#FFFFFF" class="padleft"><div align="left">
      <input name="f_photo" type="text" id="f_photo" value="<%=rs("f_photo")%>" size="50">
      <input type="button" name="Button2" value="上传->" onClick="javascript:document.forms[0].f_photo.value=window.showModalDialog('upimg_thumbnail.htm','','dialogHeight:130px;dialogWidth:410px;help:no;status:no;scroll:no')">
    </div></td>
  </tr>
  <tr>
    <td height="22" colspan="2" bgcolor="#FFFFFF"><div align="center">
      <input type="submit" name="Submit" value="提 交">&nbsp;&nbsp;
      <input type="reset" name="Submit3" value="重 写">
    </div></td>
    </tr>
</table>
</form>
<%
	end if
	rs.close
	set rs=nothing
elseif(act="domod") then
	id=Clng(request.querystring("id"))
	
	set rs=conn.execute("select title from t_lp where id="&lp_id)
	if not rs.eof then
		lp_title=rs(0)
	end if
	rs.close
	set rs=nothing
	f_photo=request.form("f_photo")
	f_title=request.form("f_title")
	f_shi=cint(request.Form("f_shi"))
	f_ting=cint(request.Form("f_ting"))
	f_wei=cint(request.Form("f_wei"))
	f_chu=cint(request.Form("f_chu"))
	f_area=cint(request.Form("f_area"))
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from f_lp_hx where id="&id,conn,3,3
	rs("f_title")=f_title
	rs("lp_title")=lp_title
	rs("f_photo")=f_photo
	rs("f_desc")=""
	rs("f_shi")=f_shi
	rs("f_ting")=f_ting
	rs("f_wei")=f_wei
	rs("f_chu")=f_chu
	rs("f_area")=f_area
	rs.update
	rs.close
	set rs=nothing
	response.write("<p align=""center"">成功修改户型图!<a href=""javascript:history.go(-2);"">返回管理</a>&nbsp;<a href=""javascript:history.go(-2);"">继续修改</a></p>")
	'生成htm
	show_htm=ReadHtml(SiteUrl&"/newhouse/show.asp?id="&lp_id,"gb2312")
	call SaveTextFile(server.MapPath("/newhouse/show/")&"\"&lp_id&".htm",show_htm)
elseif(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 f_lp_hx where id="&objArr(i))
			end if				
		next
	
	response.Write("批量执行成功！")		
	response.Redirect(request.ServerVariables("HTTP_REFERER"))
else
%>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#999999">
  <tr>
    <td height="22" bgcolor="#FFFFFF"><div align="center"><a href="?act=add&lp_id=<%=lp_id%>"><strong>添加户型图</strong></a></div></td>
  </tr>
</table>
<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="24%" height="22" bgcolor="#F5F5F5"><div align="center"><strong>图片</strong></div></td>
        <td width="17%" align="center" bgcolor="#F5F5F5"><strong>面积</strong></td>
        <td width="17%" align="center" bgcolor="#F5F5F5"><strong>户型</strong></td>
        <td width="22%" bgcolor="#F5F5F5"><div align="center"><strong>描述</strong></div></td>
        <td width="11%" bgcolor="#F5F5F5" class="style4"><div align="center" class="style4"><strong>修改</strong></div></td>
    </tr>
	  <%
		dim csql,qsql
		csql="select count(*) AS co from f_lp_hx where 1=1"
		if(lp_id>0) then
			csql=csql&" and lp_id="&lp_id
		end if		
		qsql="select top "&recpage&" id,f_title,f_photo,f_desc,f_shi,f_ting,f_wei,f_chu,f_area from f_lp_hx where id <=(select min(id) from (select top "&(recpage*(currentpage-1)+1)&" id from f_lp_hx where 1=1"
		if(lp_id>0) then
			qsql=qsql&" and lp_id="&lp_id
		end if
		
		qsql=qsql&" order by id desc) as t)"
		if(lp_id>0) then
			qsql=qsql&" and lp_id="&lp_id
		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
	  if(isarray(listArr)) then
	  	for j=0 to ubound(listArr,2)
	  %>
      <tr>
        <td bgcolor="#FFFFFF"><div align="center">
          <input type="checkbox" name="obj" value="<%=listArr(0,j)%>" />
        </div></td>
        <td height="70" bgcolor="#FFFFFF"><div align="center"><a href="<%=replace(listArr(2,j),"_v","")%>" target="_blank"><img src="<%=listArr(2,j)%>" width="60" height="60" border="0" /></a></div></td>
        <td align="center" bgcolor="#FFFFFF"><%=listArr(8,j)%>㎡</td>
        <td align="center" bgcolor="#FFFFFF"><%=listArr(4,j)%>室-<%=listArr(5,j)%>厅-<%=listArr(6,j)%>卫-<%=listArr(7,j)%>橱</td>
        <td bgcolor="#FFFFFF"><div align="center"><%=listArr(1,j)%></div></td>
        <td bgcolor="#FFFFFF"><div align="center"><a href="?act=mod&id=<%=listArr(0,j)%>&lp_id=<%=lp_id%>">修改</a></div></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()
%>
