<!--#include file="../Include/Char.jsp" -->
<!--#include file="../Include/Conn.jsp" -->
<!--#include file="../include/Const.jsp"-->
<!--#include file="../include/function.jsp"-->
<%

   if Request.Cookies("UserID") = "" THEN
     Response.Redirect("Login.jsp")
	 Response.End()
   end if

 ID = Request.cookies("UserID")

if CheckStr(Request("update"))="OK"  then
     
  m_linkman = CheckStr(Request("linkman"))
  if m_linkman = "" then
   call msgbox("对不起，联系人不能为空",1)
	  response.end()
  '  SQL="UPDATE CityCard_League SET linkman ='"& m_linkman &"' WHERE CompanyID="&ID 
  '  Conn.Execute SQL
  end if
  
  m_address = CheckStr(Request("address"))
  if m_address = ""  then
  call msgbox("对不起，商家地址不能为空",1)
	  response.end()
  '  SQL="UPDATE CityCard_League SET address ='"& m_address &"' WHERE CompanyID="&ID 
   ' Conn.Execute SQL
  end if
 
 UploadImage = Request.Cookies("UploadImage") 
 'if UploadImage <> "" then
   ' SQL="UPDATE CityCard_League SET logo ='"& UploadImage &"' WHERE CompanyID="&ID 
  '  Conn.Execute SQL
' end if
    
  m_tel = CheckStr(Request("tel"))
  m_email = CheckStr(Request("email"))
  m_website = CheckStr(Request("website"))
  m_post = CheckStr(Request("post"))
  m_traffic = CheckStr(Request("traffic"))
  m_content = CheckStr(Request("content"))
  
     m_TypeID = Request.Form("TypeID")
   if instr(m_TypeID,":") <> 0 then
     m_CityTypeID = mid(m_TypeID,1,instr(m_TypeID,":")-1)
     m_AreaTypeID = mid(m_TypeID,instr(m_TypeID,":")+1)
   else
	 m_CityTypeID = 0
	 m_AreaTypeID = 0
   end if
   on error resume next
   m_BusinessHours = checkStr(Trim(Request.Form("txtBusinessHours")))
   m_BusinessHours2 = checkStr(Trim(Request.Form("txtBusinessHours2")))
   m_YouhuiTime = (Trim(Request.Form("txtYouhuiTime")))
   m_YouhuiTime2 = (Trim(Request.Form("txtYouhuiTime2")))
   m_Other = checkStr(Trim(Request.Form("txtOther")))
   m_Tbtj = checkStr(Trim(Request.Form("txtTbtj")))
   m_TradeType = checkStr(Trim(Request.Form("selTrade")))
   m_Consume = checkStr(Trim(Request.Form("txtConsume")))
   if m_Consume = "" then m_Consume = 0 
   m_StarGrade = checkStr(Trim(Request.form("selStarGrade")))
   m_Car = checkStr(Trim(Request.Form("txtCar")))
   m_PayClass = checkStr(Trim(Request.Form("txtPayClass")))
   if uploadimage<>"" then
	  SQL="UPDATE CityCard_League SET logo ='"& UploadImage &"',address ='"& m_address &"',linkman ='"& m_linkman &"',tel ='"& m_tel &"',email = '"& m_email &"',website = '"& m_website &"' , post = '"& m_post &"',traffic = '"& m_traffic &"'"
	  else
  SQL="UPDATE CityCard_League SET address ='"& m_address &"',linkman ='"& m_linkman &"',tel ='"& m_tel &"',email = '"& m_email &"',website = '"& m_website &"' , post = '"& m_post &"',traffic = '"& m_traffic &"'"
  end if
  sql=sql&",content = '"& m_content &"',startbusinesstime= '"&m_BusinessHours&"',endbusinesstime= '"&m_BusinessHours2&"',starttime= '"&m_YouhuiTime&"',endtime= '"&m_YouhuiTime2&"',businesstimecontent= '"&m_Other&"',tbtj= '"&m_tbtj&"',hangyeid= "&m_TradeType&",Consume= "&m_Consume&",cabaretgrade= "&m_StarGrade&",Car='"&m_car&"',PayClass='"&m_PayClass&"',stateid="&m_CityTypeID&",cityid="&m_AreaTypeID
  sql=sql&" WHERE CompanyID="& ID  
  Conn.Execute SQL
  'response.write sql
  'response.end
  '开始重新生成静态网页
  Dim mTemplatePath,mTemplateAllPath
  Dim mNewsContent,mAllPath,mFileName,mPathDir
  dim temnum(3)
  temnum(0)="index.html"
  temnum(1)="about.html"
  temnum(2)="contact.html"
 ' On Error Resume Next
     league_id=ID
     mSql = "Select * from citycard_league where companyid="&league_id    
	 Set rs_html=Conn.Execute (mSQL)
	if rs_html("template_id")<>"0" then
	 mTitle=rs_html("name")
     m_temID = rs_html("Template_id")
	' response.write m_temID
	' response.end
      dim n
    for n=0 to 2
    'Create Html
	       mTemplatePath=temnum(n)

	       Set fso = CreateObject("Scripting.FileSystemObject")
           mTemplateAllPath = Server.MapPath("../jubao/Template/"&m_temID&"/"&mTemplatePath)
	      If fso.FileExists(mTemplateAllPath) then
	       Set objStream = fso.OpenTextFile(mTemplateAllPath)
	      Else
	       Call Msgbox("对不起，该模板文件 "&mTemplatePath&" 找不到，\n暂无法生成静态网页!","Index.jsp")
	      End if
		    mNewsContent=""
			'相关数据转化
				m_SQL = "SELECT F_Value FROM T_AreaType WHERE F_ID = "&rs_html("cityid")
				Set rst = conn.Execute(m_SQL)
				if Not rst.Eof then
				mcity=rst(0)
				end if
				rst.close
			  if rs_html("startbusinesstime")=rs_html("endbusinesstime") then
	          mbusinesstime="24小时营业"
              else
	          mbusinesstime=rs_html("startbusinesstime")&"至"&rs_html("endbusinesstime")
              end if
			  select case rs_html("grade")
			  case "1"
			  m_gradeimage="icon_common.gif"
			  case "2"
			  m_gradeimage="icon_copper.gif"
			  case "3"
			  m_gradeimage="icon_general.gif"
			  case "4"
			  m_gradeimage="icon_golden.gif"			 
			  end select
			  dim anid
			  anid=split(rs_html("iscard"),",")
			  if anid(0)="1" then
			  m_cardcontent=rs_html("agio")
			  else
			  m_cardcontent="非聚宝卡加盟商"
			  end if
			  
			  if anid(1)="1" then
			  m_telcontent="平台开发中..."
			  else
			  m_telcontent="非短信加盟商"
			  end if
			  if rs_html("email")<>"" then
			  m_email=rs_html("email")
			  else
			  m_email="  "
			  end if
			  if rs_html("linkman")<>"" then
			  m_linkman=rs_html("linkman")
			  else
			  m_linkman="  "
			  end if
   			  if rs_html("tbtj")<>"" then
			  m_tbtj=rs_html("tbtj")
			  else
			  m_tbtj="  "
			  end if
			  '----------------------------------------------------------------------
			  
	        Do While not objStream.AtEndOfStream
 	        mNewsContent = mNewsContent & objStream.ReadLine
	        mNewsContent = replace(mNewsContent,"[league_id]",rs_html("companyid"))
	        mNewsContent = replace(mNewsContent,"[league_name]",rs_html("name"))		
	    	mNewsContent = replace(mNewsContent,"[league_content]",m_content)
			mNewsContent = replace(mNewsContent,"[league_address]",rs_html("address"))
			mNewsContent = replace(mNewsContent,"[league_traffic]",rs_html("traffic"))
			mNewsContent = replace(mNewsContent,"[league_address]",rs_html("address"))
			mNewsContent = replace(mNewsContent,"[league_city]",mcity)
			mNewsContent = replace(mNewsContent,"[league_tel]",rs_html("tel"))
			mNewsContent = replace(mNewsContent,"[league_consume]",rs_html("consume"))
			mNewsContent = replace(mNewsContent,"[league_car]",rs_html("car"))
			mNewsContent = replace(mNewsContent,"[league_businesstime]",mbusinesstime)
			mNewsContent = replace(mNewsContent,"[league_tbtj]",m_tbtj)
			mNewsContent = replace(mNewsContent,"[league_website]",rs_html("website"))
			mNewsContent = replace(mNewsContent,"[league_PayClass]",rs_html("payclass"))
			mNewsContent = replace(mNewsContent,"[league_hits]",rs_html("hits"))
			mNewsContent = replace(mNewsContent,"[league_grade_gif]",m_gradeimage)
			mNewsContent = replace(mNewsContent,"[league_agiocontent]",rs_html("agiocontent"))
			mNewsContent = replace(mNewsContent,"[league_grade_card]",m_cardcontent)
			mNewsContent = replace(mNewsContent,"[league_grade_tel]",m_telcontent)
			mNewsContent = replace(mNewsContent,"[league_tel]",rs_html("tel"))			
			mNewsContent = replace(mNewsContent,"[league_mail]",m_email)
			mNewsContent = replace(mNewsContent,"[league_linkman]",m_linkman)
	          '  mNewsContent = replace(mNewsContent,"[league_Consume]",rs_html("Consume"))
	  
	       Loop
	         objStream.Close
    'Create BigFolder
	         folderPath = Server.MapPath("../jubao")
             mPathDir = folderPath & "\" & league_id
	         If Not fso.FolderExists(mPathDir) Then
	         Set f = fso.CreateFolder(mPathDir)
	         Set f=nothing
	         end if

	      mFileName=temnum(n)      '生成后的文件名
	      mPathDir = folderPath & "\"&league_id
	      Set objHtml = fso.CreateTextFile(mPathDir+"\"+mFileName)
	      objHtml.WriteLine mNewsContent
	      objHtml.close
	      set fso=nothing
		
		next
			'

		  
		 rs_html.close
		 set rs_html=nothing	
 
    end if 
  '错误
	
 'Response.Cookies("UploadImage") = ""
 ' response.end
  Response.Redirect("Index.jsp")
  Response.End()

end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=site_info(0)%>-商家管理系统</title>
<link href="../Include/Style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
</head>

<body onLoad="MM_preloadImages('images/xf_link1b.gif','images/xf_link2b.gif','images/xf_link3b.gif','images/xf_link4b.gif','images/xf_link5b.gif','images/ly_b_2b.gif','images/ly_b_4b.gif','images/ly_b_1b.gif','images/ly_b_3b.gif','images/ly_b_5b.gif')">
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td width="170" height="500" valign="top" bgcolor="f5f5f5">
      <!--#include file="Left.jsp" -->
    </td>
    <td width="10" valign="top"></td>
    <td width="600" valign="top">
      <table width="600" border="1" cellpadding="0" cellspacing="5" bordercolor="e2e2e2" bgcolor="f5f5f5">
        <tr> 
          <td height="25" background="images/about_bj.gif" class="p4">&nbsp;<b>·资料修改　　　　　<% response.write "<font color=ff0000>"&messagebox&"</font>"%></b></td>
        </tr>
      </table>
      <table width="600" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td height="5"></td>
        </tr>
        <tr> 
          <td height="1" background="images/line.gif" ></td>
        </tr>
      </table>
<%
      ID = Request.Cookies("UserID")
      SET rs=server.createobject("adodb.recordset")
      SQL="SELECT * FROM  CityCard_League WHERE CompanyID ="&ID
      rs.Open SQL,conn,1,1 

 if Not rs.Eof then
   m_UserName = rs("username")
   m_Password = rs("password")
   m_CompanyName = rs("name")
   m_PayClass = rs("payclass")
   m_Operation = rs("operation")
   m_Grade = rs("grade")
   m_CityTypeID = rs("stateid")
   m_AreaTypeID = rs("cityid")
   m_TradeType = rs("hangyeid")
   m_Traffic = rs("traffic")
   m_Tbtj = rs("Tbtj")
   m_Linkman = rs("linkman")
   m_BusinessHours = rs("startbusinesstime")
   m_BusinessHours2 = rs("endbusinesstime")
   m_YouhuiTime = rs("starttime")
   m_YouhuiTime2 = rs("endtime")
   m_Other = rs("businesstimecontent")
   m_Consume = rs("Consume")
  
   
   m_Tel = rs("tel")
   m_StarGradeTypeID = rs("cabaretgrade")
   m_Address = rs("address")
   m_WebSite = rs("website")
   m_Car = rs("car")
   m_Commend = rs("tuijian")
   m_Agio = rs("agio")
   m_AgioContent = rs("agiocontent")
   m_Image = rs("logo")
   m_Image1 = rs("logo1")
   m_Image2 = rs("logo2")
   m_Image3 = rs("logo3")
   m_Image4 = rs("logo4")
  ' m_Image5 = rs("logo5")

   m_Intro = rs("content")
 End if


%>
     
      <table width="89%" height="37" border="0" align="center" cellpadding="4" cellspacing="2" bgcolor="#FFFFFF">
        <tr> 
          <td colspan="2"> <b> 
            <%
		    Response.write "商家:"&rs("name")
		  %>
            </b></td>
        </tr>
        <form name="form1" method="post" action="?update=OK">
          <tr bgcolor="f5f5f5"> 
            <td width="16%" height="15" align="right">联 系 人：</td>
            <td><input name="linkman" type="text" id="linkman" value="<%=rs("linkman")%>" size="10"> 
              <font color="#FF0000">*若为空将不改</font></td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td height="15" align="right">商家地址：</td>
            <td><input name="address" type="text" id="address" value="<%=rs("address")%>" size="45"> 
              <font color="#FF0000">*若为空将不改</font></td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td width="16%" height="19" align="right">商家类型：</td>
            <td width="88%"> <select name="selBigCategory" onChange="TypeChange(this);" >
                <%
             m_SQL="Select F_ID,F_Value From T_CityType order by F_ID"
			 Set rs2 = conn.Execute(m_SQL)
			 mBigArray = rs2.GetRows()
			 for i=0 to ubound(mBigArray,2)
			   m_SQL2="Select * From T_AreaType Where F_CityTypeID="&mBigArray(0,i)&" order by F_Grade"
			   Set rs2 = conn.Execute(m_SQL2)
			   strSmallCategory = mBigArray(0,i)&"-"
			   Do While not rs2.Eof 
   			     strSmallCategory = strSmallCategory & rs2("F_ID")&"+"&rs2("F_Value")+"-"
				 rs2.Movenext
			   Loop
			   if m_CityTypeID = mBigArray(0,i) then
			      Response.write "<option selected value="&strSmallCategory&">"&mBigArray(1,i)&"</option>"
			   else
			      Response.write "<option value="&strSmallCategory&">"&mBigArray(1,i)&"</option>"
               end if
			 next'for
          %>
              </select> <script language="javascript">                               
function TypeChange(theSelect)
{
var sTemp,sString,i,sBigTypeID;
sValue=theSelect.value;
sSubTypeArray=sValue.split("-");
sBigTypeID = sSubTypeArray[0];
sString="<select name='TypeID'>";
for(i=1;i<sSubTypeArray.length-1;i++)
{
 sTemp=sSubTypeArray[i].split("+");
 if (sTemp[0]==<%=m_AreaTypeID%>)
 sString+="<option selected value='"+sBigTypeID+":"+sTemp[0]+"'>"+sTemp[1]+"</option>";
 else
 sString+="<option value='"+sBigTypeID+":"+sTemp[0]+"'>"+sTemp[1]+"</option>";
}
 sString+="<option value='"+sBigTypeID+":0'>全　部</option>";
sString+="</Select>"
form1.TypeID.outerHTML=sString;
}
</script> <select name="TypeID" >
              </select> <script language="javascript">TypeChange(form1.selBigCategory);</script> 
            </td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td height="15" align="right">商家图片：</td>
            <td><iframe src="UploadImage.jsp" name="upfile" width="100%" height="22" align="default" frameborder="0" scrolling="no"></iframe></td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td width="16%" height="2" align="right">所属地区：</td>
            <td width="88%"> <select name="selTrade">
                <%
			   m_SQL = "SELECT F_ID,F_Value FROM T_TradeType ORDER BY F_ID "
			   Set rs2 = conn.Execute(m_SQL)
			   Do While Not rs2.Eof
			      if (m_TradeType) = (rs2("F_ID")) then
     				Response.write "<option value=" + cstr(rs2("F_ID"))
           			Response.write " selected"
       				Response.write ">" + rs2("F_Value")
                  Else
                    Response.write "<option value='" & rs2("F_ID") &"'>"& rs2("F_Value") &"</option>"
                  End if
				 rs2.MoveNext
			   Loop
			   rs2.Close
			   set rs2=nothing
			   %>
              </select></td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td height="15" align="right">折　　扣：</td>
            <td><%=rs("agio")%></td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td width="16%" height="19" align="right">付款方式：</td>
            <td width="88%"> <input name="txtPayClass" type="text" value="<%=m_PayClass%>" size="21" maxlength="20"></td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td width="16%" height="17" align="right">停 车 位：</td>
            <td width="88%"> <input name="txtCar" type="text" value="<%=m_car%>" size="36" maxlength="80"></td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td width="16%" height="9" align="right">最低消费：</td>
            <td> <input name="txtConsume" type="text" value="<%=m_consume%>" size="36" maxlength="80">
              例：100RMB</td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td width="16%" height="8" align="right">特别推荐：</td>
            <td> <input name="txtTbtj" type="text" value="<%=m_Tbtj%>" size="50" > 
            </td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td width="16%" height="8" align="right">营业时间：</td>
            <td width="88%">自 
              <input name="txtBusinessHours" type="text" value="<%=m_BusinessHours%>" size="8" maxlength="80">
              至 
              <input name="txtBusinessHours2" type="text" value="<%=m_BusinessHours2%>"  size="8" maxlength="80">
              例 16至21</td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td width="16%" height="17" align="right">补充说明：</td>
            <td width="88%"> <input name="txtOther" type="text" value="<%=m_other%>" size="36" maxlength="80"></td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td width="16%" height="8" align="right">优惠期限：</td>
            <td width="88%">自 
              <input name="txtYouhuiTime" type="text" value="<%=m_YouhuiTime%>" size="8" maxlength="80">
              至 
              <input name="txtYouhuiTime2" type="text" value="<%=m_YouhuiTime2%>" size="8" maxlength="80">
              例 2006-3-35至2005-8-25</td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td width="16%" height="8" align="right">酒店星级：</td>
            <td width="88%"> <select name="selStarGrade">
                <%
			   m_SQL = "SELECT F_ID,F_Value FROM Tour_StarGradeType ORDER BY F_ID DESC"
			   Set rs2 = conn.Execute(m_SQL)
			   Do While Not rs2.Eof
			     if Trim(m_StarGradeTypeID) = Trim(rs2("F_ID")) then
     				Response.write "<option value=" + cstr(rs2("F_ID"))
           			Response.write " selected"
       				Response.write ">" + rs2("F_Value")
                  Else
                    Response.write "<option value='" & rs2("F_ID") &"'>"& rs2("F_Value") &"</option>"
                  End if
				 rs2.MoveNext
			   Loop
			   rs2.Close
			   set rs2=nothing
			   %>
              </select>
              非酒店不需输入</td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td height="15" align="right">电　　话：</td>
            <td><input name="tel" type="text" id="tel" value="<%=rs("tel")%>"></td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td height="15" align="right">电子邮件：</td>
            <td><input name="email" type="text" id="email" value="<%=rs("email")%>"></td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td height="15" align="right">网　　址：</td>
            <td><input name="website" type="text" id="website" value="<%=rs("website")%>"></td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td height="15" align="right">邮　　编：</td>
            <td><input name="post" type="text" id="post" value="<%=rs("post")%>" size="8" maxlength="6"></td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td height="15" align="right">交通指向：</td>
            <td><input name="traffic" type="text" id="traffic" value="<%=rs("traffic")%>" size="35"></td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td height="15" colspan="2" valign="top">&nbsp;&nbsp;&nbsp;公司简介： </td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td height="15" colspan="2" align="center" valign="top"> 
              <textarea name="content" cols="55" rows="10" id="content" style="display:none"><%=rs("content")%></textarea> 
              <IFRAME ID="LatticeEditDocument" SRC="../Editor/eWebEditor.jsp?id=content&style=standard" FRAMEBORDER="0" SCROLLING="no" WIDTH="600" HEIGHT="350"></IFRAME> 
            </td>
          </tr>
          <tr bgcolor="f5f5f5"> 
            <td height="15" valign="top">&nbsp;</td>
            <td><input type="submit" name="Submit" value="修　改"> <input type="reset" name="Submit2" value="重　来"></td>
          </tr>
        </form>
      </table> </td>
  </tr>
</table>

</body>
</html>
