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

<%
dim g
dim g_n
dim id
dim u
dim s 
dim p_s
dim ids

id=int(request("id"))
rs.open"select sort_property,sort_up,sort_name from jins_goods_sort where sort_id="&id&" ",conn,1,3
if rs.eof then
   MySys.Error.info = "不存在此商品分类"
   MySys.Error.location = "back"
   MySys.Error.err()
End If

g=rs("sort_property")

if request("action")="delete" then
'On Error Resume Next
	
	set s = MySys.temp.search
	
	s.sort_ids=""
	s.Sort_search "jins_goods_sort",id ,""
	ids=s.sort_ids
	if ids="" then ids=","
	ids=right(ids,len(ids)-1)
	
	'response.end

	if g<>"" then 
		g=split(g,",")
		
		c=""
		n=int(request("n"))
		for i=0 to ubound(g)
		if i<>n then c=c+","+g(i)
		next
		if c<>"" then c=right(c,len(c)-1)
		'rs.BeginTrans
		rs("sort_property")=c
		rs.update
		u=rs("sort_up")
		rs.close
		
		'/////////////////////////
		dim ids_d
		p_s=s.ListSortProperty("goods",u)
		p_s=ubound(split(p_s,","))
		n=p_s+n+1 '生成自定义属性位置
		
		set rs=server.createobject("ADODB.Recordset")
		rs.open "select goods_property from jins_goods_list where sort_id in ("&ids&") ",conn,1,3
		'rs_t.BeginTrans
		do while not rs.eof 
			g=rs("goods_property")
			if g<>"" then 
				g=split(g,",")
				c=""
				'n=int(request("n"))
				for i=0 to ubound(g)
				if i<>n then c=c+","+g(i)
				next	
				if c<>"" then c=right(c,len(c)-1)
				rs("goods_property")=c
				rs.update
			end if
			rs.movenext
		loop
		
		rs.close
	end if
	'/////////////////////////
	set s = nothing

	MySys.Error.info = "删除成功！"
	MySys.Error.location = "back"
	MySys.Error.suc()
end if

if request("action")="edit" then

	if g<>"" then 
		g=split(g,",")
	
		c=""
		if rs("sort_property")<>"" then
			for i=0 to ubound(g)
				cc=""
				for ii=0 to 2
				cc=cc+"|"&request("p_"&i&"_"&ii)
				next
				cc=right(cc,len(cc)-1)
				c=c+","+cc
			next
			rs("sort_property")=right(c,len(c)-1)
			rs.update
		end if
		rs.close
	end if
	
	MySys.Error.info = "编辑成功！"
	MySys.Error.location = "back"
	MySys.Error.suc()
end if

if request("action")="add" then

	set s = MySys.temp.search
	
	s.sort_ids=""
	s.Sort_search "jins_goods_sort",id ,""
	ids=s.sort_ids
	if ids="" then ids=","
	ids=right(ids,len(ids)-1)

	c=""
	cc=""
	
	for ii=0 to 2
	   cc=cc+"|"&request("p_"&ii)
	next
	cc=right(cc,len(cc)-1)

	if rs("sort_property")<>"" then rs("sort_property")=rs("sort_property")&","&cc else rs("sort_property")=cc
	rs.update
	rs.close
	'/////////////////////////////////////////////////////////////////////////
	p_s=s.ListSortProperty("goods",id)
	p_s=ubound(split(p_s,","))
	n=p_s-1 '生成自定义属性插入位置
	'response.write n
	'response.end
	
	rs.open "select goods_property from jins_goods_list where sort_id in ("&ids&") ",conn,1,3
	'rs_t.BeginTrans
	dim m
	dim s_i
	dim n_g
	
	do while not rs.eof 
		c=""
		m=0
		s_i=""
	    n_g=-1
		g=rs("goods_property")
		
		if g<>"" then 
			g=split(g,",")
			n_g=ubound(g)
		end if
		
		if n_g>n then m=n_g else m=n
		
		for i=0 to m
			if n_g<i then s_i="" else s_i=g(i) 
			if i=n then 
				c=c&","&s_i&","
			else
				c=c&","&s_i
			end if
		next	
		
		if c<>"" then c=right(c,len(c)-1)
		rs("goods_property")=c
		rs.update
		rs.movenext
	loop
	
	rs.close
	
	set s=nothing


	MySys.Error.info = "添加成功！"
	MySys.Error.location = "back"
	MySys.Error.suc()
end if

%>
<body topmargin="10" leftmargin="10" rightmargin="10" bottommargin="10" marginwidth="10" marginheight="10">
<form name=admin_goods_sort_property method=post action='admin_goods_sort_property_edit.asp?action=edit&id=<%=id%>'>
<div valign=top>
<table cellpadding="0" cellspacing="0"  width="100%" align=center style='border:0px solid #ebebeb' >
	<tr>
		<td  colspan="8" width="100%" align=left><br>·分类路径: 根目录 
		  <%
		  MySys.GuideSort "jins_goods_sort",rs("sort_up") ,"admin_goods_sort_property_edit.asp" 
		  response.write replace(MySys.guide_sort,"$$","")
		  %>
		  > <a href=admin_goods_sort_property_edit.asp?id=<%=id%> > <%=rs("sort_name")%></a><br><br>
		</td>
	</tr>
	<tr>
	<td  valign=top align=center>
	<table cellpadding="3" cellspacing="3" width="100%" height="30" align=center style='border:1px solid #ebebeb' >
			<tr>
				<td  width="15%" align=left valign=center>属性名</td>
				<td  width="10%" align=left valign=center>可选类型</td>
				<td  width="45%" align=left valign=center>备选值(用 & 隔开)</td>
				<td  width="5%" align=left valign=center>删除</td>
			</tr>
			
			<tr>
			    <td height='1' colspan="8" width='100%' background='images/dot03.gif'></td>
			</tr>
			<%
			if rs("sort_property")<>"" then
			if g<>"" then g=split(g,",")
			for i=0 to ubound(g)
			g(i)=split(g(i),"|")
			%>
			<tr id=cat_<%=i%>>
				<td  width="15%" align=left valign=center><input name=p_<%=i%>_0 value='<%=g(i)(0)%>' type=text size=25></td>
				<td  width="10%" align=left valign=center>
				<select name=p_<%=i%>_1 >
				<option value=0 <%if g(i)(1)="0" then response.write "selected"%> >文本全匹配</option>
				<option value=1 <%if g(i)(1)="1" then response.write "selected"%> >单选</option>
				<option value=2 <%if g(i)(1)="2" then response.write "selected"%> >多选</option>
				<option value=3 <%if g(i)(1)="3" then response.write "selected"%> >文本</option>
				<option value=4 <%if g(i)(1)="4" then response.write "selected"%> >数值范围</option>
				<option value=5 <%if g(i)(1)="5" then response.write "selected"%> >日期</option>
			    </select>
				</td>
				<td  width="45%" align=left valign=center><input name=p_<%=i%>_2 value='<%if ubound(g(i))>1 then %><%=g(i)(2)%><%end if%>' type=text size=70></td>
				<td  width="5%" align=left valign=center><a title='点击删除此项！' href='admin_goods_sort_property_edit.asp?action=delete&id=<%=id%>&n=<%=i%>'><img border='0' src='Images/delete.gif' align='bottom' alt='点击删除此项！'></a></td>
			</tr>
			<tr>
			    <td height='1' colspan="8" width='100%' background='images/dot03.gif'></td>
			</tr>
			<%
			next
			end if
			%>
	<tr>
	<td colspan="8" height="20" align="center">
	<input type=submit value='提 交'>
	<input type=reset value='重置' >
	</td>
	</tr>
		
	</table>
</td>
</tr>
	
</table>
</div>
</form>

<form name=admin_goods_sort_property_add method=post action='admin_goods_sort_property_edit.asp?action=add&id=<%=id%>'>
<div valign=top>
<table cellpadding="0" cellspacing="0"  width="100%"  align=center style='border:0px solid #ebebeb' >
	<tr>
	<td  valign=top align=center>
	<table cellpadding="3" cellspacing="3" width="100%" height="30" align=center style='border:1px solid #ebebeb' >
			<tr>
				<td  width="15%" align=left valign=center>属性名</td>
				<td  width="10%" align=left valign=center>可选类型</td>
				<td  width="45%" align=left valign=center>备选值(用 & 隔开)</td>
				<td  width="5%" align=left valign=center></td>
			</tr>
			
			<tr>
			    <td height='1' colspan="8" width='100%' background='images/dot03.gif'></td>
			</tr>
			<tr >
				<td  width="15%" align=left valign=center><input name=p_0  type=text size=25></td>
				<td  width="10%" align=left valign=center>
				<select name=p_1 >
				<option value=0 >文本全匹配</option>
				<option value=1 >单选</option>
				<option value=2 >多选</option>
				<option value=3 >文本</option>
				<option value=4 >数值范围</option>
				<option value=5 >日期</option>
			    </select>
				</td>
				<td  width="45%" align=left valign=center><input name=p_2  type=text size=70></td>
				<td  width="5%" align=left valign=center></td>
			</tr>
			<tr>
			    <td height='1' colspan="8" width='100%' background='images/dot03.gif'></td>
			</tr>
	<tr>
	<td colspan="8" height="20" align="center">
	<input type=submit value='添 加'>
	<input type=reset value='重置' >
	</td>
	</tr>
		
	</table>
</td>
</tr>
<tr>
	<td  colspan="8" width="100%" align=left><br><br>
	·注意：<br>
	·自定义属性的名称一般情况下请用中文。<br>
	·修改自定义属性的时候请保证属性的值类型与原来的不冲突。<br>
	·添加自定义属性：此类所包含的所有的子类和子类的子类中的商品都将增加此属性。所以请保证您添加的属性是所有子类的公共属性！<br>
	·删除自定义属性：此类所包含的所有的子类和子类的子类中的商品都将删除此属性。请慎重！<br>
	</td>
</tr>

</table>
</div>
</form>
</body>
<!--#include file="admin_end.asp" -->