<!--#include virtual="/show/adminhead.asp"-->
<!--#include file="adminleft.asp"-->

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><%=webname%>-商品分类</title>
<%
call logquanxian("c1",1)
%>
<DIV>

<SCRIPT language=javascript>
function ShowDialog(url, width, height, optValidate) {
	var arr = showModalDialog(url, window, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no");
	}
</SCRIPT>
<script language="javascript">
function fenleierji(con){
	if(document.getElementById(con).style.display == "none"){
		document.getElementById(con).style.display = "";
	}
	else{
		document.getElementById(con).style.display = "none";
	}	
}
</script>


<%
act=request.QueryString("act")
cact=request.QueryString("cact")
page=request.QueryString("page")
uid=request.QueryString("uid")
link="adminfenlei.asp?ct="



if cact="tihuan" then
call lognamecode()
con=request.form("con")
tocon=request.form("tocon")

if con="" then call PopErr("获取参数错误")
if trim(tocon)="" then tocon="*"

sql="select aykafenleiname from aykafenlei where aykafenleiname like '%"&trim(request.QueryString("con"))&"%'" 
rs.open sql,conn,1,3
if not(rs.eof) then
	do while not rs.eof
	rs("aykafenleiname")=replace(trim(rs("aykafenleiname")),trim(con),trim(tocon))
	rs.update
	rs.movenext
	loop
end if
rs.close

sql="select aykafenleishuoming from aykafenlei where aykafenleishuoming like '%"&trim(request.QueryString("con"))&"%'" 
rs.open sql,conn,1,3
if not(rs.eof) then
	do while not rs.eof
	rs("aykafenleishuoming")=replace(trim(rs("aykafenleishuoming")),trim(con),trim(tocon))
	rs.update
	rs.movenext
	loop
end if
rs.close

call logadd(request.Cookies("aynameid"),"管理-分类字符替换成功"&id,0,0)
response.Redirect("adminfenlei.asp?page="&page&"")

end if







%>




<DIV id=main1200> 
<%call webleft()%>
<DIV id=main_right>
<DIV id=main_right_content>
<STYLE>.apply_style {
	POSITION: absolute
}
.right_title A {
	LINE-HEIGHT: 27px; WIDTH: 126px; DISPLAY: inline-block; BACKGROUND: url(<%=ossurl%>images/bg22.gif) no-repeat; HEIGHT: 27px
}
.right_title A.current {
	BACKGROUND: url(<%=ossurl%>images/main_right_title_bg.gif) no-repeat; COLOR: #fff; FONT-WEIGHT: bold
}
.table_style_1 TD {
	HEIGHT: 38px
}
.table_style_home_info TD {
	PADDING-BOTTOM: 0px; PADDING-LEFT: 10px; PADDING-RIGHT: 0px; HEIGHT: 30px; PADDING-TOP: 0px
}
</STYLE>
<%

if act<>"" then

	if act="del" then
	call lognamecode()
	page=request.QueryString("page")
	id=request.QueryString("id")
	uid=request.QueryString("uid")
	if id="" then call PopErr("参数获取失败")
	
	sql="select * from aykafenlei where ayshangjiid="&clng(id)&"" 
	rs.open sql,conn,1,3
		if not(rs.bof and rs.eof) then
		rs.close
		call PopErr("请先将该分类下的二级分类删除")
    	else
		rs.close
		set delfenlei=server.CreateObject("adodb.recordset")
		sql="select * from aykafenlei where aykafenleiid="&clng(id)&""
		delfenlei.open sql,conn,1,3
			if delfenlei.bof and delfenlei.eof then
			delfenlei.close
			call PopErr("参数获取失败")
			else
			delfenlei.delete
			delfenlei.close
			call logadd(request.Cookies("aynameid"),"管理-分类删除成功"&id,0,0)
			response.Redirect("adminfenlei.asp?page="&page&"&uid="&uid)
			end if
		end if
	end if
	
	
	shangname=request.QueryString("cat2")
	
	
	if act="xj" then
	page=request.QueryString("page")
	id=request.QueryString("id")

	sql="select * from aykafenlei where aykafenleiid="&clng(id)&"" 
	rs.open sql,conn,1,3
	rs("issjsuo")=1
	rs("aykafenleikg")=1
	rs.update
	rs.close
	call logadd(request.Cookies("aynameid"),"管理-分类锁定设置成功"&id,0,0)
	response.Redirect("adminfenlei.asp?page="&page&"&cact=cha&shangname="&shangname&"")
	end if
	
	
	if act="sj" then
	page=request.QueryString("page")
	id=request.QueryString("id")
	

	sql="select * from aykafenlei where aykafenleiid="&clng(id)&"" 
	rs.open sql,conn,1,3
	rs("issjsuo")=0
	rs("aykafenleikg")=0
	rs.update
	rs.close
	call logadd(request.Cookies("aynameid"),"管理-分类解锁设置成功"&id,0,0)
	response.Redirect("adminfenlei.asp?page="&page&"&cact=cha&shangname="&shangname&"")
	end if
	
	
	
end if




sql2=""
if cact="cha" then
link="adminfenlei.asp?cact=cha"

shangname=request("shangname")

if shangname<>"" then
sql2=sql2&" and aykafenleiname like '%"&shangname&"%'"
end if
end if

if uid<>"" then
sql2=sql2&" and aykanamesuoyou="&uid&""
end if





sql="select aykafenleiid,aykafenleiname,ayshangjiid,aykanamesuoyou,aykafenleikg from aykafenlei where ayshangjiid=0 "&sql2&" order by aykafenleiid desc" 
rs.open sql,conn,1,1
	
%>
<DIV class=right_titleadmin>&nbsp;&nbsp;商品分类</DIV>
<DIV class=main>
<table width="0" border="0">
  <tr>
    <td>
<form action="?cact=cha" method="post" name="chaxun" id="chaxun">
&nbsp;商品名称：
<input name="shangname" type="text" id="shangname" value="<%if shangname<>"" then response.Write shangname%>" maxlength="25">
<input type="submit" name="Submit" value=" 查 询 ">
<br><br>
</form>
    </td>
    <td>
<form action="?cact=tihuan" method="post" name="chaxun" id="chaxun">
&nbsp;将：
<input name="con" type="text" id="con" value="" size="14">替换为<input name="tocon" type="text" id="tocon" value="*" size="14">
<input type="submit" name="Submit" value=" 替 换 ">
<br><br>
</form>
    </td>
  </tr>
</table>



<DIV class=main>
    <table width="99%" border="0" cellpadding="0" cellspacing="0" class="table_style_a1">
      <tr>
        <th align="center" class="border_right border_bottom" style="font-weight: bold" >分类名称</td>
        <th align="center" class="border_right border_bottom" style="font-weight: bold">所属会员</td>
        <th align="center" class="border_right border_bottom" style="font-weight: bold">姓名        
        <th align="center" class="border_right border_bottom" style="font-weight: bold">商户ID
        <th align="center" class="border_bottom" style="font-weight: bold">分类管理</td>      </tr>
      <%
nouid=""
rs.pagesize=50 
pagecount=rs.pagecount 
if request("page")="" then 
page=1
else
page=int(request("page")) 
end if
if page<=0 then page=1 
if request("page")="" then page=1
if not(rs.bof and rs.eof) then
rs.absolutepage=page
zongshu=rs.RecordCount
do while not rs.eof%>

	  <tr onmouseover=this.bgColor='#D2FFFF' onmouseout=this.bgColor='#ffffff'>
        <td align="left" class="border_right border_bottom">
          &nbsp;<span style="font-weight: bold"><%=trim(rs("aykafenleiname"))%>
		  </span></td>
        <td align="center" class="border_right border_bottom"><a target="_blank" href="adminuseredit.asp?id=<%=rs("aykanamesuoyou")%>"><%=rs("aykanamesuoyou")%></a></td>
        
        <%
		set rsn=server.CreateObject("adodb.recordset")
		sqln="select aynameid,ayusername,aytrueuser from ayname where aynameid="&rs("aykanamesuoyou")&""
		rsn.open sqln,conn,1,1
		if not(rsn.eof) then
		%>
        <td align="center" class="border_right border_bottom"><%=trim(rsn("aytrueuser"))%></td>
        <td align="center" class="border_right border_bottom"><a href="adminuseredit.asp?id=<%=rs("aykanamesuoyou")%>&page=<%=page%>" target="_blank"><%=rsn("ayusername")%></a></td>
        <%
		else
		nouid=nouid&rs("aykanamesuoyou")&","
		%>
        <td align="center" class="border_right border_bottom">-</td>
        <td align="center" class="border_right border_bottom">-</td>
		
		<%end if
		rsn.close
		%>		
          
        
        <td align="center" class="border_bottom">
        
		<%if cint(rs("aykafenleikg"))=0 then%>
		<a href="?act=xj&id=<%=rs("aykafenleiid")%>&cat2=<%=shangname%>&page=<%=page%>" title="点击下架">上架中</a> 
		<%elseif cint(rs("aykafenleikg"))=1 then%>
		<a href="?act=sj&id=<%=rs("aykafenleiid")%>&cat2=<%=shangname%>&page=<%=page%>" title="点击上架"><font color=red>下架中</font></a>
		<%end if%>
        		
		<a href="adminfenleiedit.asp?id=<%=rs("aykafenleiid")%>">编辑</a>  
		<a href="?act=del&id=<%=rs("aykafenleiid")%>&page=<%=page%>&uid=<%=uid%>"  onclick="javascript:return confirm('您确定要删除吗？');"><img src="<%=ossurl%>images/ico_del.gif" alt="删除分类" border="0"></a></td>
      </tr>


     <%
	set rserji=server.CreateObject("adodb.recordset")
	sql="select * from aykafenlei where ayshangjiid="&rs("aykafenleiid")&" order by aykafenleisx asc" 
	rserji.open sql,conn,1,1
	do while not rserji.eof
	%>


	  <tr onmouseover=this.bgColor='#D2FFFF' onmouseout=this.bgColor='#ffffff'>
        <td align="left" class="border_right border_bottom">
 		&nbsp;&nbsp;&nbsp;┕<%=trim(rserji("aykafenleiname"))%>		  </td>
        <td align="center" class="border_right border_bottom"><%=rserji("aykanamesuoyou")%></td>
        
        <%
		set rsn=server.CreateObject("adodb.recordset")
		sqln="select aynameid,ayusername,aytrueuser from ayname where aynameid="&rserji("aykanamesuoyou")&""
		rsn.open sqln,conn,1,1
		if not(rsn.eof) then
		%>
        
        <td align="center" class="border_right border_bottom"><%=trim(rsn("aytrueuser"))%></td>
        <td align="center" class="border_right border_bottom"><a href="adminuseredit.asp?id=<%=rserji("aykanamesuoyou")%>&page=<%=page%>" target="_blank"><%=rsn("ayusername")%></a></td>
        <%else
		nouid=nouid&rs("aykanamesuoyou")&","
		%>
        <td align="center" class="border_right border_bottom">-</td>
        <td align="center" class="border_right border_bottom">-</td>
		<%end if
		rsn.close
		%>			 
        <td align="center" class="border_bottom">
        
		<%if cint(rserji("aykafenleikg"))=0 then%>
		<a href="?act=xj&id=<%=rserji("aykafenleiid")%>&cat2=<%=shangname%>&page=<%=page%>" title="点击下架">上架中</a> 
		<%elseif cint(rserji("aykafenleikg"))=1 then%>
		<a href="?act=sj&id=<%=rserji("aykafenleiid")%>&cat2=<%=shangname%>&page=<%=page%>" title="点击上架"><font color=red>下架中</font></a>
		<%end if%>
        	
        <a onClick="javascript:fenleierji('<%=88&clng(rserji("aykafenleiid"))%>');" style="cursor:hand"></a> 
		<a href="adminfenleiedit.asp?id=<%=rserji("aykafenleiid")%>">编辑</a> 
		<a href="?act=del&id=<%=rserji("aykafenleiid")%>&page=<%=page%>"  onclick="javascript:return confirm('您确定要删除吗？');"><img src="<%=ossurl%>images/ico_del.gif" alt="删除分类" border="0"></a></td>
      </tr>

	
	<%rserji.movenext
	loop
	rserji.close%> 
	
	
	  	  <%n=n+1
  		rs.movenext  '指针向下移动
  		if n>=rs.pagesize then exit do  
  		loop
		end if
	    rs.close%>
	  
	
      <tr>
        <td colspan="5">&nbsp;
          <%if pagecount=0 then   
response.write("首页 ")
elseif page=1 then       
response.write("首页 ")
else%>
          <a href="<%=link%>&page=1&shangname=<%=shangname%>">首页</a>
          <%end if

if pagecount=0 then   
response.write("上页&nbsp;")
elseif page=1 then       
response.write("上页&nbsp;")
else%>
          <a href="<%=link%>&page=<%=page-1%>&shangname=<%=shangname%>">上页</a>&nbsp;
          <%end if

if pagecount>20 then
if page<=10 then 
aa=1
bb=20
aabu=""
bbbu=" … "
elseif page>=11 then 
aa=page-9
bb=page+10
aabu=" …"
bbbu=" … "
	if bb>=pagecount then 
	aa=pagecount-20
	bb=pagecount
	aabu=" … "
	bbbu=""
	end if
end if
response.Write aabu
for aa=aa to bb
if page=aa then
response.Write("<a href="&link&"&page="&aa&"&shangname="&shangname&"><strong>"&aa&"</strong></a>&nbsp;")
else
response.Write("<a href="&link&"&page="&aa&"&shangname="&shangname&">"&aa&"</a>&nbsp;")
end if
next
response.Write bbbu

else

for i=1 to pagecount
if page=i then
response.Write("<a href="&link&"&page="&i&"&shangname="&shangname&"><strong>"&i&"</a></strong>&nbsp;")
else
response.Write("<a href="&link&"&page="&i&"&shangname="&shangname&">"&i&"</a>&nbsp;")
end if
next

end if

if pagecount=0 then 
response.write("下页&nbsp;")
elseif page=pagecount then 
response.write("下页&nbsp;")
else%>
          <a href="<%=link%>&page=<%=page+1%>&shangname=<%=shangname%>">下页</a>
          <%end if%>
          <%if pagecount=0 then  '总页数为0 显示空
response.write("尾页 ") 
elseif page=pagecount then 
response.write("尾页 ")
else%>
          <a href="<%=link%>&page=<%=pagecount %>&shangname=<%=shangname%>">尾页</a>
          <%end if

if pagecount<>0 then 
response.Write page&"/"&pagecount
end if
response.Write "&nbsp;共"&zongshu&"条"

response.Write "&nbsp;"
'response.Write nouid
%></td>
      </tr>
    </table>

  </DIV>


</DIV></DIV>
<DIV class=clear></DIV></DIV>
</DIV>
<SCRIPT>
$(function(){
$('.left_title').each(function(){
   $(this).click(function(){
	   var index=$('.left_title').index(this);
	   if($(this).next().hasClass('hide_m')){
		   $(this).next().removeClass('hide_m');
           $(this).next().show();		 
		   $(this).find('img').attr('src','<%=ossurl%>images/expansion.gif');
		   $.cookie('m_index_'+index,'',{expires:0});
	   } else {
	       $(this).next().hide();
		   $(this).next().addClass('hide_m');
		   $(this).find('img').attr('src','<%=ossurl%>images/shrank.gif');		   
		   $.cookie('m_index_'+index,'none',{expires:365});
	   }
   })
})

$('.left_title').each(function(){
	var index=$('.left_title').index(this);
    $(this).next().css('display',$.cookie('m_index_'+index) ? $.cookie('m_index_'+index) : '');
	if($.cookie('m_index_'+index)){
	    $(this).next().addClass('hide_m');
	}
	$(this).find('img').attr('src',$.cookie('m_index_'+index) ? '<%=ossurl%>images/shrank.gif' : '<%=ossurl%>images/expansion.gif');
})
})

</SCRIPT>


<!--#include virtual="/show/footadmin.asp"-->

