<%'guidedisplay=1%>
<!--#include file="admin_start.asp" -->

<%
dim sort_content
dim sort_style
dim id
dim id_copy

id=request("id")
id_copy=request("id_copy")

if not MySys.check.isInteger(id) then
   MySys.Error.info = "请提交合法的模板id！"
   MySys.Error.location = "back"
   MySys.Error.err()
End If

id=int(id)
id_copy=int(id_copy)

if id_copy>0 then
	rs.open"select * from jins_template_sort where sort_id="&id_copy&" ",conn,1,1
	if rs.eof then
	   Session("FB_EM_1_ACC_id_copy")=""
	   MySys.Error.info = "您要粘贴的模版不存在！"
	   MySys.Error.location = "admin_template_add.asp?id="&id
	   MySys.Error.err()
	End If
	sort_content=rs("sort_content")
	sort_style=rs("sort_style")
	rs.close
end if

rs.open"select * from jins_template_sort where sort_id="&id&" ",conn,1,1
if rs.eof and id<>0 then
   MySys.Error.info = "您请求的上级模板不存在！"
   MySys.Error.location = "back"
   MySys.Error.err()
   sort_customer_grade=""
elseif id<>0 then
   sort_customer_grade=rs("sort_customer_grade")
else
   sort_customer_grade=""
End If

if id>0 then
	MySys.template.get_template_info(id)
else
	MySys.template.template_project_id=""
end if
%>
<body topmargin="30" marginwidth="10" marginheight="10">
<form name=edit_template target=admin_edit_template method=post><input type=hidden name=c value=''><input type=hidden name=c_sql value=''><input type=hidden name=formname value=''><input type=hidden name=inputname value=''></form>
<form name=template_sort action="admin_template_edit_handle.asp?action=add" method=post>
<table cellpadding="3" cellspacing="4" width="90%" height="30" align=center style='border:1px solid #ebebeb' >
	<tr>
		<td width="2%" align=right><img alt='点击弹开编辑框' onclick="opencat(basic_open)" style='CURSOR: hand' src="Images/index_search.gif" width="8" height="16"></td>
		<td  width="98%" align=left>
		<font color="#ebebeb"> | </font>
		<img alt='点击弹开提示信息框' onclick="opencat(help_ads_open)" style='CURSOR: hand' src="Images/icon_info.gif" width="13" height="13" hspace="0" align="absmiddle">			
		<font color="#ebebeb"> | </font>
		模板添加
	    </td>
	</tr>		
	<tr id="help_ads_open" style="display:  ">
		<td colspan="10" align=left>
		<table cellpadding="4" cellspacing="2" width="99%" height="30" align=center style='border:1px dashed #B7B7B7' >
			<tr>
				<td colspan="8" width='100%' style="line-height:150% ">
				·您可以更改用户的类型<br>
				·通过更改登陆ip锁定可以解除用户错误的操作造成的无法登陆！<br>
				·通过重置取回密码问题和答案可以帮助用户在忘记密码和密码提示问题的情况下恢复用户权限！<br>
			</td>
			</tr>
		</table>
		</td>
	</tr>
	
	<tr id="basic_open" >
		<td colspan="10" align=left style='padding-bottom:5px'>
		<table cellpadding="4" cellspacing="2" bgcolor='#f7f7f7' width="99%" height="30" align=center style='border:1px dashed #808080;padding:20px' >
			<tr>
				<td  width="15%" align=right>上级模板路径:</td>
				<td  width="85%" align=left>
				<select name=sort_up onchange='cc();'>
				<%
				set s=MySys.temp.search
				s.sort_list=""
				s.list_Sort "", "jins_template_sort",0,"根目录|"&id
				response.write s.sort_list
				set s=nothing
				%>
				</select>
				<script language="javascript" defer>
				function cc(){
				window.location="admin_template_add.asp?id="+document.template_sort.sort_up.value;
				}
				</script>
				<%if Session("FB_EM_1_ACC_template_copy")<>"" then %>
				<input type=button value='粘贴已复制的模版' onclick='window.location="admin_template_add.asp?id=<%=request("id")%>&id_copy=<%=Session("FB_EM_1_ACC_template_copy")%>"'>
				<%end if%>
				</td>
			</tr>
			<tr>
				<td  width="15%" align=right>模板名称:</td>
				<td  width="85%" align=left>
				  <input name=sort_name value='' size=25 >
				  <% 
				  dim ccc
				  ccc=""
				  if id<>0 then 
					  set rss=conn.execute("select sort_mark,sort_name from jins_template_sort where sort_up=(select sort_id from jins_template_sort where sort_mark='"&rs("sort_mark")&"' and sort_sys=1 )  order by sort_num ")  
					  if not rss.eof then 
						  do while not rss.eof 
						      if conn.execute("select sort_id from jins_template_sort where sort_mark='"&rss("sort_mark")&"' and sort_up="&rs("sort_id")&" ").eof then
							  ccc=ccc&"<option value='"&rss("sort_mark")&"' >"&rss("sort_name")&"</option>"
							  end if
							  rss.movenext
						  loop
						  if ccc<>"" then 
						  %>
						   模版类型：
						  <select name=sort_mark >
						   <%response.write ccc%>
						  </select>
						  <%
						  else
						  %>
						  新增模版类型 >> 模版标识：<input value='<%if rs("sort_up")>0 then response.write rs("sort_mark")&"_" %>' name=sort_mark size=25>
				          <%
                          End If
					  else
						  %>
						  新增模版类型 >> 模版标识：<input value='<%if rs("sort_up")>0 then response.write rs("sort_mark")&"_" %>' name=sort_mark size=25>
				     <%
				      end if
					  set rss=nothing
				 else
				 %>
					  模版类型：模版方案<input value='project' type=hidden name=sort_mark size=25>
				 <%
				  end if
				 %>
				</td>
			</tr>
			<tr>
				<td  width="15%" align=right>加入时间:</td>
				<td  width="85%" align=left>
				<input name=sort_addtime value='<%=now()%>' size=25 >
				模板开关:
				<select name=sort_open >
				<option value=1 selected >打开</option>
				<option value=0  >关闭</option>
				</select>
				 
				</td>
			</tr>
			<%
			sort_folder="template/folders"
			if id>0 then
				sort_folder=conn.execute("select sort_folder from jins_template_sort where sort_id="&id&"  ")(0)
			end if
			%>
			<tr>
				<td  width="15%" align=right >模板文件夹:</td>
				<td  width="85%" align=left>
                <input id="sort_folder" name="sort_folder" size="83" value='<%=sort_folder%>' >
			    </td>
			</tr>
			<tr>
				<td  width="15%" align=right valign=top >访问权限:</td>
				<td  width="85%" align=left >
				<%MySys.EditGrade(sort_customer_grade)%>
			    </td>
			</tr>
			<tr>
				<td  width="15%" align=right valign=top >模板描述:</td>
				<td  width="85%" align=left>
                <textarea id="sort_description" name="sort_description" cols="70" rows="10"></textarea>
			    </td>
			</tr>
		</table><br>
		<%
		'////////////////////////////////////////////////////////////////////////////////////////////////////////
		%>
		<table cellpadding="4" cellspacing="2" bgcolor='#f7f7f7' width="99%" height="30" align=center style='border:1px dashed #808080;padding:20px' >
			<tr>
				<td  width="15%" align=right valign=top>模板源码:</td>
				<td  width="85%" align=left>
                <textarea  wrap="off" id="sort_content" name="sort_content" cols="70" rows="20"><%=sort_content%></textarea>
                <a title='点击进行详细编辑！' href="javascript:openedit_template('template_sort','sort_content','object,private?project=<%=MySys.template.template_project_id%>,public,link','','<%=int(timer)%>','模版源码编辑 > 新增模版 > '+template_sort.sort_name.value);" >
				<img border=0 src="Images/old.gif" width="21" height="20" align="top">
				</a>
				</td>
			</tr>
			<tr>
				<td  width="15%" align=right valign=top>模板样式表:</td>
				<td  width="85%" align=left>
                <textarea wrap="off" id="sort_style" name="sort_style" cols="70" rows="20"><%=sort_style%></textarea>
				</td>
			</tr>
		</table><br>
		</td>
	</tr>

	<tr>
		<td height='1' colspan="9" background='images/dot03.gif'></td>
	</tr>
	
	<tr>
	  <td height='30' colspan="8" width='100%' align=center >
	  <input type=submit value="提交设置！" >
	   <input type=reset value="重置" > 
	   <input onclick='history.back(-1)' type=button value="返回" >	  </td>
	</tr>
</table>		
<SCRIPT language=javascript>
	function opencat(cat)
	{
 	 	if(cat.style.display=="none"){
     	cat.style.display="";
  		} else {
     	cat.style.display="none"; 
  		}
	}</SCRIPT>
</form>
<%
rs.close
%>
<!--#include file="admin_end.asp" -->