<!--#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" -->
<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">
<style type="text/css">
<!--
.style1 {color: #FF0000}
.style2 {color: #CCCCCC}
.style3 {color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
<script language="javascript">
function check(obj){
	if(obj.Title.value==""){
		alert("趋势数不能为空!");
		obj.Title.focus();
		obj.Title.select();
		return false;
	}
	if(obj.f_date.value==""){
		alert("日期不能为空!");
		obj.f_date.focus();
		obj.f_date.select();
		return false;
	}
	return true;
}
function goto(frm)
{
	var gof_date ="?";
	gof_date += "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(gof_date);
}
function ConfirmDel()
{
   if(confirm("确认删除？，并且不能恢复！确定要删除此信息吗？"))
     return true;
   else
     return false;
	 
}
</script>
</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>
<%
dim act
act=trim(request.QueryString("act"))
if isempty(act) or act="" then
	call lp_sale_stat_List
elseif(act="add") then
	call lp_sale_stat_Add
elseif(act="addok") then
	call lp_sale_stat_AddOk
elseif(act="mod") then
	call lp_sale_stat_Mod
elseif(act="modok") then
	call lp_sale_stat_ModOk
elseif(act="genxml") then
	call lp_sale_stat_GenXml(0)
	call lp_sale_stat_GenXml(1)
end if
%>
<%
sub lp_sale_stat_GenXml(infotype)
	dim xmls,xmla,tn,unit,utitle,minv,maxv
	if(infotype=0) then
		unit="元"
		utitle="成交价格"
		minv=3000
		maxv=8000
	else
		unit="套"
		utitle="成交套数"
		minv=1000
		maxv=3000
	end if
	set rs=server.createobject("adodb.recordset")
	rs.open "select top 6 id,f_num,f_date from t_lp_salestat where InfoType="&infotype&" order by id desc",conn,3,1
	if not rs.eof then
		xmla=rs.getrows()
	end if
	rs.close
	set rs=nothing
	xmls=xmls&"<chart showFCMenuItem='0' lineThickness='2' showValues='0' anchorRadius='4' divLineAlpha='20' divLineColor='CC3300' divLineIsDashed='1' showAlternateHGridColor='1' alternateHGridAlpha='5' alternateHGridColor='CC3300' shadowAlpha='40' labelStep='0' numvdivlines='25' showAlternateVGridColor='1' chartsshowShadow='1' chartRightMargin='21' chartTopMargin='15' chartLeftMargin='0' chartBottomMargin='3' bgColor='FFFFFF' canvasBorderThickness='1' showBorder='0' legendBorderAlpha='0' bgAngle='360' showlegend='1' borderColor='DEF3F3' toolTipBorderColor='cccc99' canvasPadding='0' toolTipBgColor='ffffcc' legendShadow='0' baseFontSize='12' canvasBorderAlpha='20' outCnvbaseFontSize='10' outCnvbaseFontColor='000000' numberScaleValue='1,10000,1,1,1000' formatNumberScale='1' palette='2' numberScaleUnit='"&unit&",, ,万"&unit&",千万"&unit&"' lineColor='AFD8F8' yAxisMinValue='"&minv&"' yAxisMaxValue='"&maxv&"'>"&chr(10)
			xmls=xmls&"<categories>"&chr(10)
	if isarray(xmla) then
		tn=ubound(xmla,2)
		for i=0 to tn
				xmls=xmls&"<category label='"&xmla(2,tn-i)&"'  />"&chr(10)
		next
		xmls=xmls&"</categories>"&chr(10)		
			xmls=xmls&"<dataset  seriesName='"&utitle&"' color='0033CC' anchorBorderColor='0033CC'  >"&chr(10)
		for i=0 to tn
			xmls=xmls&"<set  value='"&xmla(1,tn-i)&"' toolText='"&xmla(1,tn-i)&unit&"'  />"&chr(10)			
		next	
		xmls=xmls&"	</dataset>"&chr(10)
			
		xmls=xmls&"	<styles>"&chr(10)
		xmls=xmls&"		<definition>"&chr(10)
		xmls=xmls&"			<style name='CaptionFont' type='font' size='12'  />"&chr(10)
		xmls=xmls&"			<style name='myLegendFont' type='font' size='11'  />"&chr(10)
		xmls=xmls&"		</definition>"&chr(10)
		xmls=xmls&"		<application>"&chr(10)
		xmls=xmls&"			<apply toObject='CAPTION' styles='CaptionFont'  />"&chr(10)
		xmls=xmls&"			<apply toObject='SUBCAPTION' styles='CaptionFont'  />"&chr(10)
		xmls=xmls&"			<apply toObject='Legend' styles='myLegendFont'  />"&chr(10)
		xmls=xmls&"		</application>"&chr(10)
		xmls=xmls&"	</styles>"&chr(10)
		xmls=xmls&"	</chart>"&chr(10)
	end if
	call SaveTextFile(server.MapPath("/news/data"&infotype&".xml"),xmls)  
	response.Write("成功生成XML数据~!")
	response.Write("<br><a href=lp_sale_stat.asp>返回</a>")
end sub
Sub lp_sale_stat_Add
%>
<FORM method="POST" name="form1" action="?act=addok" style="margin:0 0 0 0;" onSubmit="return check(this)">
  <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#FF9900">
  <TD height="24" colspan="2"><div align="center" class="style3">添加楼盘趋势数字</div></TD>
  </TR>
<TR bgcolor="#F5F5F5">
  <TD align="right">类别：</TD>
  <TD><input name="InfoType" type="radio" id="radio" value="0" checked>
价格
  <input name="InfoType" type="radio" id="radio2" value="1">
成交数</TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD width="46%"><div align="right">数字：</div></TD>
  <TD width="54%"><input name="f_num" type="text" id="f_num" size="35"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD width="46%"><div align="right">日期：</div></TD>
  <TD width="54%"><input name="f_date" type="text" id="f_date" value="<%=month(date())%>/<%=day(date())%>" size="35"></TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD align=right>&nbsp;	  </TD>
    <TD align=right><div align="left"> 
        <input type=submit name=b1 value="提 交">&nbsp;&nbsp;
        <input type=reset name=b2 value="重 填">       
    </div></TD>
</TR>
</TABLE>
</FORM>
<%
end Sub
Sub lp_sale_stat_AddOk
	dim title,f_date,InfoType
	InfoType=Cint(request.Form("InfoType"))
	f_num=replace(request.Form("f_num"),"'","")
	f_date=replace(request.Form("f_date"),"'","")
	set rs=server.createobject("adodb.recordset")
	rs.open "select top 1 * from t_lp_salestat where 1=0",conn,3,3
	rs.addnew
	rs("f_num")=f_num		
	rs("f_date")=f_date	
	rs("InfoType")=InfoType
	rs.update	
	response.Write("添加楼盘趋势成功~!")
	response.Write("<br><a href=lp_sale_stat.asp>返回</a>")
	rs.close
	set rs=nothing
end Sub
Sub lp_sale_stat_ModOk
	dim id,title,f_date,InfoType
	InfoType=Clng(request.Form("InfoType"))
	id=Clng(request.QueryString("id"))
	f_num=replace(request.Form("f_num"),"'","")
	f_date=replace(request.Form("f_date"),"'","")
	set rs=server.createobject("adodb.recordset")
	rs.open "select top 1 * from t_lp_salestat where id="&id,conn,3,3
	if not rs.eof then		
		rs("f_num")=f_num		
		rs("f_date")=f_date	
		rs("InfoType")=InfoType
		rs.update	
		response.Write("修改楼盘趋势成功~!")
		response.Write("<br><a href=""lp_sale_stat.asp"">返回</a>")
	end if
	rs.close
	set rs=nothing
end Sub
Sub lp_sale_stat_Mod
	dim id,rs
	id=Clng(request.QueryString("id"))
	set rs=conn.execute("select * from t_lp_salestat where id="&id)
	if not rs.eof then
%>
<FORM method="POST" name="form1" action="?act=modok&id=<%=id%>" style="margin:0 0 0 0;" onSubmit="return check(this)">
  <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#FF9900">
  <TD height="24" colspan="2"><div align="center" class="style3">修改楼盘趋势数字</div></TD>
  </TR>
  <TR bgcolor="#F5F5F5">
  <TD align=right>类别：</TD>
    <TD align=left><input name="InfoType" type="radio" id="radio" value="0" <%if(rs("InfoType")=0) then response.Write("checked") end if%>>
      价格
        <input name="InfoType" type="radio" id="radio2" value="1" <%if(rs("InfoType")=1) then response.Write("checked") end if%>>
成交数</TD>
  </TR>
<TR bgcolor="#F5F5F5">
  <TD width="46%"><div align="right">数字：</div></TD>
  <TD width="54%"><input name="f_num" type="text" id="f_num" size="35" value="<%=rs("f_num")%>"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD width="46%"><div align="right">日 期：</div></TD>
  <TD width="54%"><input name="f_date" type="text" id="f_date" size="35" value="<%=rs("f_date")%>"></TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD align=right>&nbsp;	  </TD>
    <TD align=right><div align="left"> 
        <input type=submit name=b1 value="提 交">&nbsp;&nbsp;
        <input type=reset name=b2 value="重 填">       
    </div></TD>
</TR>
</TABLE>
</FORM>
<%
	end if
	rs.close
	set rs=nothing
end Sub
Sub lp_sale_stat_List
	dim BeginTime,i,currentpage,allrec,totalpage,n,p
	BeginTime=Timer
	const recpage=20
	if not isempty(request("page")) and request("page")<>"" then 
		currentpage=Clng(request("page"))
	else
		currentpage=1
	end if
%>
<div style="text-align:center; line-height:28px;"><a href="?act=add">添加楼盘趋势数字--&gt;</a></div>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#999999">
  <tr bgcolor="#FF9900">
    <td height="22" colspan="8"><div align="center"><span class="style3">◆ 管理楼盘趋势 ◆</span> <a href="?act=genxml">生成统计报表</a></div></td>
  </tr>
  <tr bgcolor="#EEEEEE">
    <td width="6%" height="22"><div align="center">id</div></td>
    <td width="19%" align="center">类别</td>
    <td width="21%"><div align="center">趋势数</div></td>
    <td width="29%"><div align="center">日期</div></td>    
    <td width="12%"><div align="center">修改</div></td>
    <td width="13%"><div align="center">删除</div></td>
  </tr>
  <%
  		set rs=server.createobject("adodb.recordset")
  		rs.open "select count(*) AS co from t_lp_salestat",conn,3,1
		allrec=rs(0)
		totalpage=int((allrec+recpage-1)/recpage)
		rs.close
		set rs=nothing
		set rs=server.createobject("adodb.recordset")
		if(currentpage=1) then
			sql="select top "&recpage&" id,f_num,f_date,infotype from t_lp_salestat order by id desc"
		else
			sql="select top "&recpage&" id,f_num,f_date,infotype from t_lp_salestat where id not in (select top "&(recpage*(currentpage-1))&" id from t_lp_salestat order by id desc) order by id desc "
		end if
		rs.open sql,conn,3,1		
		do while not rs.eof		
	%>
  <tr>
    <td height="20" bgcolor="#FFFFFF"><div align="center"><%=rs(0)%></div></td>
    <td align="center" bgcolor="#FFFFFF"><%if(rs(3)=0) then response.Write("价格") else response.Write("成交") end if%></td>    
    <td bgcolor="#FFFFFF"><div align="center"><%=rs(1)%></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="<%=rs(2)%>" target="_blank"><%=rs(2)%></a></div></td>    
    <td bgcolor="#FFFFFF"><div align="center"><a href="?act=mod&id=<%=rs(0)%>">修改</a></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="dele.asp?id=<%=rs(0)%>&table=t_lp_salestat" onClick="return ConfirmDel()">删除</a></div></td>
  </tr>
  
  <%
    		rs.movenext
	  		i=i+1
	   		if i>=recpage then 
				exit do
	  		end if
	  loop
	  rs.close
	  set rs=nothing
  %>
  <tr>
    <td height="22" colspan="8" bgcolor="#FFFFFF">
	<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='?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='?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></td>
  </tr>
</table>
<%=CStr(FormatNumber((Timer-BeginTime)*1000,2))& "毫秒"%>
<%end Sub%>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="40"><div align="center"></div></td>
  </tr>
</table>
</body>
</html>
<%
call connclose()
%>