<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="checklogin.asp"-->
<!--#include file="../inc/function.asp"-->
<!--#include file="../getips.asp"-->
<%
dim CatalogId,ParentId,id
id=Clng(request.QueryString("id"))
if(request.QueryString("CatalogId")<>"") then
	cid=Clng(request.QueryString("CatalogId"))	
else
	cid=0
end if
if(request.QueryString("ParentId")<>"") then
	ParentId=Clng(request.QueryString("ParentId"))
else
	pid=2
end if
%>
<!DOCTYPE html PUBliC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>修改信息-<%=SiteName%></title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/js/prototype.js"></script>
<script type="text/javascript" src="/js/effects.js"></script>
<script type="text/javascript" src="/js/validation.js"></script>
<script type="text/javascript" src="/js/areas.js"></script>
<script type="text/javascript" src="/js/catalogs.js"></script>
<LINK media=screen href="/js/dhtmlgoodies_calendar.css" rel=stylesheet></LINK>
<SCRIPT src="/js/dhtmlgoodies_calendar.js" type=text/javascript></SCRIPT>
</head>
<body>
<table width="98%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td style="border-bottom:1px solid #2fc300;"><h2>修改信息</h2></td>
  </tr>
</table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#2fc300">
  <tr>
    <td height="4"></td>
  </tr>
</table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
            <td valign="top">
          <%
        dim act
        act=request.querystring("act")
        if(act="do") then
          call InfoAddOk()
				 	response.write("<div align=""center""><br><h3>成功修改信息</h3></p>")
        else
          call InfoPub()
        end if
        %>    </td>
          </tr>
        </table>
<%
sub InfoAddOk
	dim rs,InfoTypeId,ParentId,CatalogId,DelPass,Title,ExpireDate,ItemsNum,Price,Province,City,ContactMan,Tel,Mobile,QQ,Content,Photo,SavePath,Demons,Address,Area,MIP
	SavePath="/html/"&chan_data(now())&chan_day(now())&"/"&chan_file(now())&"."&FileExt
	InfoTypeId=Cint(request.Form("InfoTypeId"))
	ParentId=Cint(request.form("ParentId"))
	if(isnumeric(request.Form("CatalogId"))) then
		CatalogId=Cint(request.Form("CatalogId"))
	else
		CatalogId=0
	end if
	Province=request.Form("Province")
	if(Province<>"") then
		Province=Cint(Province)
	else
		Province=0
	end if
	City=request.Form("City")
	if(City<>"") then
		City=Cint(City)
	else
		City=0
	end if
	Title=tohtml2(request.Form("Title"))
	if(Title=session("TotCms_LastPost")) then
		response.write("<script>alert('不能重复修改相同的信息!');history.back();</script>")
	elseif(CatalogId=0) then
		response.write("<script>alert('请选择二级分类!');history.back();</script>")
	elseif(City=0) then
		response.write("<script>alert('请选择区县!');history.back();</script>")
	else
		ItemsNum=Cint(request.form("ItemsNum"))
		Price=Csng(request.form("Price"))		
		if(Province>0) then
			set rs=server.CreateObject("adodb.recordset")
			rs.open "select title from t_area where id="&Province,conn,3,1
			if not rs.eof then
				Area=rs(0)
			end if
			rs.close
			set rs=nothing
		end if
		if(City>0) then
			set rs=server.CreateObject("adodb.recordset")
			rs.open "select title from t_area where id="&City,conn,3,1
			if not rs.eof then
				Area=Area&rs(0)
			end if
			rs.close
			set rs=nothing
		end if
		ContactMan=tohtml2(request.Form("ContactMan"))
		Tel=tohtml2(request.Form("Tel"))
		QQ=tohtml2(request.Form("QQ"))
		Content=trim(request.Form("Content"))
		Demons=gotTopic(Content,200)
		Content=tohtml(Content)
		Photo=request.Form("Photo")
		Address=tohtml2(request.Form("Address"))
		MIP=request.ServerVariables("REMOTE_ADDR")&naddress(request.ServerVariables("REMOTE_ADDR"))
		set rs=server.CreateObject("adodb.recordset")
		rs.open "select * from t_info where id="&id,conn,3,3
		rs("InfoTypeId")=InfoTypeId
		rs("ParentId")=ParentId
		rs("CatalogId")=CatalogId	
		rs("Photo")=Photo
		rs("Title")=Title
		rs("Price")=Price
		rs("Province")=Province
		rs("City")=City
		rs("ContactMan")=ContactMan
		rs("QQ")=QQ
		rs("Tel")=Tel	
		rs("Content")=Content
		rs("Demons")=Demons
		rs("PubDate")=now()
		rs("PubIp")=MIP
		rs("Hits")=1
		rs("IsCheck")=0
		rs("IsDel")=0
		rs("IsHot")=0
		rs("IsTop")=0
		rs("DelPass")=""
		rs("SavePath")=SavePath
		rs("Address")=Address
		rs("Area")=Area
		rs("Score")=0
		rs("ScoreEndDate")=now()
		rs.update
		rs.close
		set rs=nothing
	end if
	
end sub
sub InfoPub
	dim rs,userinfo,sql,first
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from t_info where id="&id,conn,3,1
	if not rs.eof then
		InfoTypeId=rs("InfoTypeId")
		ParentId=rs("ParentId")
		CatalogId=rs("CatalogId")	
		Photo=rs("Photo")
		Title=rs("Title")
		Price=rs("Price")
		Province=rs("Province")
		City=rs("City")
		ContactMan=rs("ContactMan")
		QQ=rs("QQ")
		Tel=rs("Tel")	
		Content=rs("Content")
		Demons=rs("Demons")		
		Address=rs("Address")		
	end if
	rs.close
	
	set rs=server.CreateObject("adodb.recordset")
	sql="select id,title from catalogs where parentid="&PlugIn_InfoId&" order by id asc"
	rs.open sql,conn,3,1
	if not rs.eof and not rs.bof then
		first=rs.GetRows()
	else		
	end if
	rs.close
	set rs=nothing
%>
<form id="PostForm" name="PostForm" method="post" action="?act=do&id=<%=id%>">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border">  
  <tr>
    <td class="td_row">&nbsp;</td>
    <td class="td_row">&nbsp;</td>
  </tr>
  <tr>
    <td align="center" bgcolor="#F6F6F6" class="pad_5">服务类型：</td>
    <td class="td_row">
	<select name="InfoTypeId" id="InfoTypeId">
		<option value="1" selected="selected">供</option>
		<option value="2">求</option>
    </select>    </td>
  </tr>
  <tr>
    <td align="center" bgcolor="#F6F6F6" class="pad_5">信息分类：</td>
    <td class="td_row">
		<select name="ParentId" id="ParentId" size="10" onchange="GetCatalogChilds(this.options[this.selectedIndex].value,0,'CatalogId')">
		<%
		dim sel
			if isarray(first) then
			for i=0 to ubound(first,2)
					if(first(0,i)=pid) then
						sel=" selected=""selected"""
					else
						sel=""
					end if
					response.Write("<option value="""&first(0,i)&""""&sel&">"&first(1,i)&"</option>"&Chr(10))    	
			next
		end if
		%>
    </select>		
		<select name="CatalogId" id="CatalogId" size="10">
			<option>请选择二级分类</option>
		</select>
		<script type="text/javascript">
		GetCatalogChilds(<%=ParentId%>,<%=CatalogId%>,'CatalogId');	
		</script></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#F6F6F6" class="pad_5">标题：(<span class="style1">*</span>)</td>
    <td class="td_row"><input name="Title" type="text" class="validate-title" id="Title" title="请输入信息标题" value="<%=Title%>" size="80" maxlength="200" />
    <span id="advice-validate-title-Title" style="display:none; color:#FF0000;">标题5-200个字符</span></td>
  </tr>
  <tr>
    <td width="18%" align="center" bgcolor="#F6F6F6" class="pad_5">价格：(<span class="style1">*</span>)</td>
    <td width="82%" class="td_row"><input name="Price" type="text" id="Price" class="validate-number" value="0" size="8" />0=面议<span id="advice-validate-number-Price" style="display:none; color:#FF0000;">请输入数字</span></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#F6F6F6" class="pad_5">区县：</td>
    <td class="td_row">	
  		<select name="Province" id="Province" onchange="GetChilds(this.options[this.selectedIndex].value,0,'City')">
        <option value="0">选择城市</option>
        <script type="text/javascript">
				document.write(GetFirst(<%=Province%>,''));
        </script>
      </select>
      <select name="City" id="City">
        <option value="0">选择地区</option>
      </select>	
      <script type="text/javascript">
				GetChilds(<%=Province%>,<%=City%>,'City');
      </script>
  	</td>
  </tr>
  <tr>
    <td align="center" bgcolor="#F6F6F6" class="pad_5">联系人：(<span class="style1">*</span>)</td>
    <td class="td_row"><input name="ContactMan" type="text" class="required" id="ContactMan" value="<%=ContactMan%>" />
    <span id="advice-required-ContactMan" style="display:none; color:#FF0000;">联系人不能为空!</span></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#F6F6F6" class="pad_5">电话：(<span class="style1">*</span>)</td>
    <td class="td_row"><input name="Tel" type="text" class="required" value="<%=Tel%>" />
      <span id="advice-required-Tel" style="display:none; color:#FF0000;">电话不能为空!</span></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#F6F6F6" class="pad_5">地址：</td>
    <td class="td_row"><input name="Address" type="text" id="Address" size="32" value="<%=Address%>" /></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#F6F6F6" class="pad_5">QQ：</td>
    <td class="td_row"><input name="QQ" type="text" value="<%=QQ%>" /></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#F6F6F6" class="pad_5">详细说明：</td>
    <td class="td_row"><textarea name="Content" cols="60" rows="5" id="Content" class="validate-content"><%=Content%></textarea><span id="advice-validate-content-Content" style="display:none; color:#FF0000;">详细说明10-2000字!</span></td>
  </tr>
  <tr>
    <td class="td_row">头像：</td>
    <td class="td_row"><p>
      <input name="Photo" type="text" id="Photo" value="<%=Photo%>" size="32" />
      <input type="button" name="Button" value="上传-&gt;" onclick="upImgs()" />
      </p>
      <p>        <img src="/images/nopic.jpg" alt="上传图片" width="160" height="130" id="p_view" /><br />
      提示：系统最大允许上传100K的文件，请确定您的图片处理后小于100K。</p></td>
  </tr>
  <tr>
    <td align="center" class="td_row">&nbsp;</td>
    <td height="50" class="td_row">
      <input type="submit" name="Submit" value="确 定" />
      <input type="reset" name="Submit2" value="取 消" /></td>
  </tr>
</table>
</form>
<script language="javascript">
function upImgs(){
	var ret=window.showModalDialog('upimg.htm','','dialogHeight:140px;dialogWidth:410px;help:no;status:no;scroll:no')+'';
	
	if(ret!='undefined'){
		document.getElementById('Photo').value=ret
		document.getElementById('p_view').src=ret;
	}
}
function formCallback(result, form) {
	window.status = "valiation callback for form '" + form.id + "': result = " + result;
}

var valid = new Validation('PostForm', {immediate : true, onFormValidate : formCallback,useTitles : true});
Validation.addAllThese([
	['validate-content','',{
		minLength:6,
		maxLength : 2000
	}],
	['validate-title','',{
		minLength:5,
		maxLength:200
	}]
]);
</script>
<%
end sub
%>
</body>
</html>
<%
call connclose()
%>
