<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="admin.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/function.asp"-->
<%if session("utype")<>1 then
response.Write("<script>alert('非法操作！你己被记录！');location.href='./';</script>")
response.End()
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>商家设置 - <%=cf_name%></title>
<link href="images/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="images/us.js"></script>
</head>

<body>
<!--#include file="top.asp"-->
<div class="con bian">
   <div class="bd_l"><!--#include file="left.asp"--></div>
   <div class="bd_r">
      <div class="title">商家管理</div>
	  <%
'//添加
if request("action")=1 then
if request("title")="" or request("classid")="" then response.Redirect"cw_shop.asp?add=1"
if request("pic")<>"" then
ispic=1
else
ispic=0
end if
set rs=server.CreateObject("adodb.recordset")
sql="select * from cw_shop where userid="&session("userid")
rs.open sql,conn,1,3
if not rs.eof then
   response.Write("<script>alert('请误重复提交！');history.back();</script>")
   response.End()
else
rs.addnew
rs("title")=request("title")
rs("classid")=request("classid")
rs("userid")=session("userid")
rs("email")=request("email")
rs("fax")=request("fax")
rs("website")=request("website")
rs("address")=request("address")
rs("service")=request("service")
rs("content")=replace(request("content"),chr(13),"<br />")
rs("pic")=request("pic")
rs("tel")=request("tel")
rs("ispass")=shop_pass
rs("ispic")=ispic
rs.update
id=rs("sid")
rs.close
end if
set rs=nothing
call cw_jf("+",2)
'生成
if shop_pass=1 then call c_show(id,2,"1",0,"cw_shop")
response.Write("<div class='msg'><h1 class='msg_t'>恭喜您，商家资料提交成功！</h1></div>")  
response.Write("<script>var url='cw_shop.asp'; setTimeout('location.href=(url)',2000)</script>")
response.End()
end if
'//修改
if request("action")=2 then
if request("title")="" or request("classid")="" then response.Redirect"cw_shop.asp"
if request("pic")<>"" then
ispic=1
else
ispic=0
end if
set rs=server.CreateObject("adodb.recordset")
sql="select * from cw_shop where id="&request("id")&""
rs.open sql,conn,1,3
pic=rs("pic")
rs("title")=request("title")
rs("classid")=request("classid")
rs("email")=request("email")
rs("fax")=request("fax")
rs("website")=request("website")
rs("address")=request("address")
rs("service")=request("service")
rs("content")=replace(request("content"),chr(13),"<br />")
rs("pic")=request("pic")
rs("tel")=request("tel")
rs("ispass")=shop_pass
rs("ispic")=ispic
rs.update
rs.close
set rs=nothing
if Request("pic")<>pic then Cw_del(cf_root&pic)
if shop_pass=1 then call c_show(request("id"),2,"1",0,"cw_shop")
response.Write("<div class='msg'><h1 class='msg_t'>恭喜您，商家资料修改成功！</h1></div>")  
response.Write("<script>var url='cw_shop.asp'; setTimeout('location.href=(url)',2000)</script>")
response.End()
end if
'//判断用户是否为商家，非则跳至申请
if request("add")="" then
set rr=server.CreateObject("adodb.recordset")
rq="select * from cw_shop where userid="&session("userid")
rr.open rq,conn,1,1
if rr.recordcount=0 then
  response.Redirect"cw_shop.asp?add=1"
  response.End()
end if
%>
<table width="99%" border="0">
<form method="post" name="form1" action="cw_shop.asp" onsubmit="return check_shop(this)">
  
  <tr>
    <td width="100" height="20" align="right">公司名称：</td>
    <td><input name="title" type="text" id="title" value="<%=rr("title")%>" size="60" maxlength="100" /></td>
  </tr>
  <tr>
    <td height="20" align="right">所属行业：</td>
    <td><select name="classid" id="classid">
      <%
	set rf=server.CreateObject("adodb.recordset")
	rfq="select * from cw_shop_class where followid=0 order by ordnum asc,id asc"
	rf.open rfq,conn,1,1
	if not rf.eof then
	do while not rf.eof 
	set rs=server.CreateObject("adodb.recordset")
	rsq="select * from cw_shop_class where followid="&rf("id")&" order by ordnum asc,id asc"
	rs.open rsq,conn,1,1
		if rs.recordcount>0 then
	%>
      <optgroup label="<%=rf("title")%>" style="color:#FF0000"></optgroup>
      <%
	else
	%>
      <option value="<%=rf("id")%>" <%if rr("classid")=rf("id") then%>selected="selected"<%end if%>>&nbsp;&nbsp;<%=rf("title")%></option>
      <%
	end if
	if not rs.eof then
	do while not rs.eof
	set rq=server.CreateObject("adodb.recordset")
	rqq="select * from cw_shop_class where followid="&rs("id")&" order by ordnum asc,id asc"
	rq.open rqq,conn,1,1	
	if rq.recordcount>0 then
	%>
      <optgroup label="<%=rs("title")%>" style="color:#FF0000"></optgroup>
      <%else%>
      <option value="<%=rs("id")%>" <%if rr("classid")=rs("id") then%>selected="selected"<%end if%>>&nbsp;&nbsp;<%=rs("title")%></option>
      <%
	end if
	if not rq.eof then
	do while not rq.eof
	%>
      <option value="<%=rq("id")%>" <%if rr("classid")=rq("id") then%>selected="selected"<%end if%>>&nbsp;&nbsp;&nbsp;&nbsp;<%=rq("title")%></option>
      <%
		rq.movenext
		loop
		end if
		rq.close
		set rq=nothing	
	rs.movenext
	loop
	end if
	rs.close
	set rs=nothing
	  rf.movenext
	  loop
	  end if
	  rf.close
	  set rf=nothing
	  %>
    </select></td>
  </tr>  
  
  <tr>
    <td height="20" align="right">公司邮箱：</td>
    <td><input name="email" type="text" id="email" value="<%=rr("email")%>" maxlength="30" /></td>
  </tr>
  <tr>
    <td height="20" align="right">公司电话：</td>
    <td><input name="tel" type="text" id="tel" value="<%=rr("tel")%>" maxlength="13" /></td>
  </tr>
  <tr>
    <td height="20" align="right">公司传真：</td>
    <td><input name="fax" type="text" id="fax" value="<%=rr("fax")%>" maxlength="20" /></td>
  </tr>
  <tr>
    <td height="20" align="right">公司网站：</td>
    <td><input name="website" type="text" id="website" value="<%=rr("website")%>" maxlength="100" /></td>
  </tr>
  <tr>
    <td height="20" align="right">公司地址：</td>
    <td><input name="address" type="text" id="address" value="<%=rr("address")%>" size="60" maxlength="100" /></td>
  </tr>
  <tr>
    <td height="20" align="right">主营业务：</td>
    <td><input name="service" type="text" id="service" value="<%=rr("service")%>" size="60" /></td>
  </tr>
  <tr>
    <td height="20" align="right">商家LOGO：</td>
    <td><input type="text" name="pic" id="pic" value="<%=rr("pic")%>" readonly="" size="40"  /><iframe src="../inc/upload.asp?lei=5&pid=pic&fid=fm&rid=shop" frameborder="0" width="400" height="25" scrolling="No" id="fm" style="display:none"></iframe> <input type="button" onclick="document.getElementById('pic').style.display='none';document.getElementById('fm').style.display='inline';document.getElementById('s1').style.display='none'" id="s1" style="cursor:pointer; cursor:pointer" value="上传图片"> *建议尺寸640*480像素</td>
  </tr>
  
  <tr>
    <td height="20" align="right">公司简介：</td>
    <td><textarea name="content" cols="80" rows="15" id="content" ><%=replace(rr("content"),"<br />",chr(13))%></textarea></td>
  </tr>
  <tr>
    <td height="20" align="right">&nbsp;</td>
    <td><input type="submit" name="Submit3" value="修改商家资料" class="btn" />
      <input name="id" type="hidden" id="id" value="<%=rr("id")%>" />
      <input name="action" type="hidden" id="action" value="2" /></td>
  </tr>
  </form>
</table>
  <%
  rr.close
  set rr=nothing
  end if
  if request("add")=1 then
  %>
  <table width="99%" border="0">
<form method="post" name="fm" id="fm" action="cw_shop.asp" onsubmit="return check_shop(this)">
  
  <tr>
    <td height="20" align="right">&nbsp;</td>
    <td><h3>申请商家/企业认证</h3></td>
  </tr>
  <tr>
    <td width="100" height="20" align="right">公司名称：</td>
    <td><input name="title" type="text" id="title" size="50" maxlength="100" />
      *请正确填写后期不能修改</td>
  </tr>
  <tr>
    <td height="20" align="right">所属行业：</td>
    <td><select name="classid" id="classid">
      <%
	set rf=server.CreateObject("adodb.recordset")
	rfq="select * from cw_shop_class where followid=0 order by ordnum asc,id asc"
	rf.open rfq,conn,1,1
	if not rf.eof then
	do while not rf.eof 
	set rs=server.CreateObject("adodb.recordset")
	rsq="select * from cw_shop_class where followid="&rf("id")&" order by ordnum asc,id asc"
	rs.open rsq,conn,1,1
		if rs.recordcount>0 then
	%>
      <optgroup label="<%=rf("title")%>" style="color:#FF0000"></optgroup>
      <%
	else
	%>
      <option value="<%=rf("id")%>">&nbsp;&nbsp;<%=rf("title")%></option>
      <%
	end if
	if not rs.eof then
	do while not rs.eof
	set rq=server.CreateObject("adodb.recordset")
	rqq="select * from cw_shop_class where followid="&rs("id")&" order by ordnum asc,id asc"
	rq.open rqq,conn,1,1	
	if rq.recordcount>0 then
	%>
      <optgroup label="<%=rs("title")%>" style="color:#FF0000"></optgroup>
      <%else%>
      <option value="<%=rs("id")%>">&nbsp;&nbsp;<%=rs("title")%></option>
      <%
	end if
	if not rq.eof then
	do while not rq.eof
	%>
      <option value="<%=rq("id")%>">&nbsp;&nbsp;&nbsp;&nbsp;<%=rq("title")%></option>
      <%
		rq.movenext
		loop
		end if
		rq.close
		set rq=nothing	
	rs.movenext
	loop
	end if
	rs.close
	set rs=nothing
	  rf.movenext
	  loop
	  end if
	  rf.close
	  set rf=nothing
	  %>
    </select></td>
  </tr>  
  
  <tr>
    <td height="20" align="right">公司邮箱：</td>
    <td><input name="email" type="text" id="email" maxlength="30" /></td>
  </tr>
  <tr>
    <td height="20" align="right">公司电话：</td>
    <td><input name="tel" type="text" id="tel" maxlength="13" /></td>
  </tr>
  <tr>
    <td height="20" align="right">公司传真：</td>
    <td><input name="fax" type="text" id="fax" maxlength="20" /></td>
  </tr>
  <tr>
    <td height="20" align="right">公司网站：</td>
    <td><input name="website" type="text" id="website" maxlength="100" /></td>
  </tr>
  <tr>
    <td height="20" align="right">公司地址：</td>
    <td><input name="address" type="text" id="address" size="50" maxlength="100" /></td>
  </tr>
  <tr>
    <td height="20" align="right">主营业务：</td>
    <td><input name="service" type="text" id="service" size="50" /></td>
  </tr>
  <tr>
    <td height="20" align="right">商家LOGO：</td>
    <td><input type="text" name="pic" id="pic" value="" readonly="" size="40" style="display:none" /><iframe src="../inc/upload.asp?lei=5&pid=pic&fid=fm" frameborder="0" width="400" height="25" scrolling="No" id="fm"></iframe>
      *建议尺寸640*480像素</td>
  </tr>
  <tr>
    <td height="20" align="right">公司简介：</td>
    <td><textarea name="content" cols="80" rows="15" id="content" ></textarea></td>
  </tr>
  <tr>
    <td height="20" align="right">&nbsp;</td>
    <td><input type="submit" name="Submit3" value="提交商家审核" class="btn" />
      <input name="action" type="hidden" id="action" value="1" /></td>
  </tr>
  </form>
</table>
<%end if%>  
   </div>
   <div class="clear"></div>
</div>
<div class="line"></div>
<!--#include file="foot.asp"-->
<%
call closes()
%>
</body>
</html>
