<%@ Language=VBScript%>
<%
Response.Buffer=false
Response.Expires=0
%>
<!-- #include file="../dsn.asp" -->
<!-- #include file="../links.asp" -->
<%
if session("adminusername")="" then
		session("xhy")=1
		Response.Redirect linkwarn
end if
showok=Request.QueryString ("showok")
id=Request.QueryString("id")
pid=Request.QueryString("pid")
ppid=Request.QueryString("ppid")
pageno=Request.QueryString("pageno")
mode=Request.QueryString ("mode")
htmlname=linkadmin&"?ppid="&ppid&"&pid="&pid
if id="" then
		id=0
	else
		id=cint(id)
end if
if pid="" then
		pid=0
	else	
		pid=cint(pid)	
	
end if
if ppid="" then
		ppid=0
	else
		ppid=int(ppid)
end if	
if pid=19 or pid=39 or pid=40 or pid=41 or pid=59 then			
		addhtml=linkadmin&"?ppid="&ppid&"&pid="&pid&"&showok=1"
	else	
		addhtml=linkadminedit&"?ppid="&ppid&"&pid="&pid
end if		
picadmin=linkadmin2&"?ppid="&ppid&"&pid="&pid
yzhtml=linkadmin&"?pid="&pid&"&ppid="&ppid
xyhtml=linkxy&"?pid="&pid&"&ppid="&ppid
autohtml=linkautolist&"?ppid="&ppid&"&pid="&pid
autopichtml=linkautopiclist&"?ppid="&ppid&"&pid="&pid

plflag=Request.QueryString ("plflag")
pl1=Request.QueryString ("pl")
if pl1="" or pl1=1 then pl1=1
if pl1=1 then 
		pl1=9
	else
		pl1=1
end if 
if plflag="" then plflag="pl"
if pid=20 or pid=63 or pid=64 or pid=65 then both=1
if pid=23 or pid=27 or pid=31 or pid=35 or pid=53 or pid=54 or pid=55 then Response.Redirect xyhtml
if pid=29 then Response.Redirect linkengageadmin&"?pid="&pid&"&ppid="&ppid
if pid=30 then Response.Redirect linkengageuser&"?ppid="&ppid&"&pid="&pid
if pid=34 then Response.Redirect linkorderadmin&"?pid="&pid&"&ppid="&ppid
if pid=36 then Response.Redirect linkcountadmin&"?pid="&pid&"&ppid="&ppid
if pid=37 then Response.Redirect linkcontactadmin&"?pid="&pid&"&ppid="&ppid
if pid=25 then Response.Redirect "service_contact_admin.asp?pid="&pid&"&ppid="&ppid
if pid=38 then Response.Redirect linkcountlist
if pid=56 then Response.Redirect "user_list.asp?pid="&pid&"&ppid="&ppid
if pid=60 then Response.Redirect "user_list_web.asp?pid="&pid&"&ppid="&ppid
if pid=57 then%>
	<script language="javascript">
		var str
		str="../forum.asp?" ;
		window.open(str,"bbswin","")		
	</script>
<%
Response.End
end if
'if pid=42 then
set cn=Server.CreateObject("ADODB.Connection")
cn.Open mycnstr
set rs=server.CreateObject("ADODB.Recordset")
set rs1=server.CreateObject("ADODB.Recordset")
set rs2=server.CreateObject("ADODB.Recordset")
if ppid<>0 then
		sqltext="select title from scool where id="&ppid
		rs1.Open sqltext,cn,1,1
		if not rs1.EOF then
				scoolname=rs1("title")
		end if
		rs1.Close 
end if
if pid<>0 then
		sqltext="select title,picflag from classes where id="&pid
		rs1.Open sqltext,cn,1,1
		if not rs1.EOF then
				classesname=rs1("title")
				classpic=rs1("picflag")
		end if
		rs1.Close 
end if
htmltitle="基本数据管理"
txtname="名称"
tabname="danwei"
if id<>0 then
	sqltext="select * from "+tabname+" where id="&id
	rs.Open sqltext,cn,1,1
	if not rs.EOF then
		titletxt=trim(rs("title"))
		pl=rs("pl")
		enable=rs("enable")
		creatdate=rs("creatdate")
		httpadd=trim(rs("httpadd"))
		picflag=rs("picflag")
		picname=trim(rs("picname"))
		fileflag=rs("fileflag")
		yhj=trim(rs("yhj"))
		thj=trim(rs("thj"))
		tel=trim(rs("tel"))
		name2=trim(rs("name2"))
		address=trim(rs("add"))
		webflag=rs("pbflag")
		if pid=16 then
			picflag=rs("picflag2")
			picname=rs("picname2")
		end if	
	end if
	rs.Close 
else
	enable=1	
end if
if Request.ServerVariables("REQUEST_METHOD")="POST" and mode<>"888" then
		if not isempty(request("sel")) then
     		idlist=request("sel")
     		if instr(idlist,",")>0 then
				dim idarr
				idArr=split(idlist)
				for i = 0 to ubound(idarr)
	       			delid=clng(idarr(i))
	       			call setupdate(delid,mode)
				next
			else
				delid=clng(idlist)
				call setupdate(delid,mode)
			end if	
		end if
		delid=0
		Response.Redirect htmlname
end if
  sub setupdate(id,mm)
    if mm="999" then
		sqltext3="delete from "+tabname+" where id="&id
		cn.Execute sqltext3   
		sqltext3="delete from cdanwei where pid="&id&" and ppid="&pid&" and pppid="&ppid
		cn.Execute sqltext3   
	elseif  mm="777" then
		sqltext3="update "+tabname+" set enable=1 where id="&id
		cn.Execute sqltext3
	elseif  mm="666" then
		sqltext3="update "+tabname+" set enable=0 where id="&id
		cn.Execute sqltext3
	elseif  mm="555" then
		sqltext3="update "+tabname+" set tjflag=1 where id="&id
		cn.Execute sqltext3
	elseif  mm="444" then
		sqltext3="update "+tabname+" set tjflag=0 where id="&id
		cn.Execute sqltext3			
	end if	
  end sub  
if Request.ServerVariables("REQUEST_METHOD")="POST" and mode="888" then
		pl=trim(Request.Form("pl"))
		titletxt=trim(Request.Form("title"))
		if pid=31 then
				yhj=trim(Request.Form ("yhj"))
				thj=trim(Request.Form ("thj"))
				if yhj="" or not isnumeric(yhj) then yhj="400"
				if thj="" or not isnumeric(thj) then thj="300"
		end if
		if pl="" or not isnumeric(pl) then 
				sqltext3="select max(pl) as maxpl from "+tabname+" where pid="&pid&" and ppid="&ppid
				rs2.Open sqltext3,cn,1,1
				if not rs2.EOF then
						pl=rs2("maxpl")+1
				end if
				rs2.Close 
			else
				pl=cint(pl)
		end if
		if pl="" or not isnumeric(pl) then pl=1
		sqltext3="select * from "+tabname+" where title='"+titletxt+"' and pid="&pid&" and ppid="&ppid&" and id<>"&id	
		rs2.Open sqltext3,cn,1,1
		if not rs2.EOF then
				err=1
				errtxt="错误：条目“"&titletxt&"”已存在，请换名重试！"
				titletxt=""
		end if
		if err<>1 and id=0 then					
				sqltext2="select * from "+tabname
				rs1.Open sqltext2,cn,1,2
				rs1.AddNew
				rs1("pid")=pid
				rs1("ppid")=ppid
				rs1.Update
				id=rs1("id")
				rs1.Close
		end if
		if err<>1 and id<>0 then
				sqltext2="select * from "+tabname+" where id="&id
				rs1.Open sqltext2,cn,1,2
				if Request.Form ("showflag")="1" then
					rs1("enable")=1
				else
					rs1("enable")=0
				end if
				rs1("pl")=pl
				rs1("httpadd")=checkstring(trim(Request.Form ("httpadd")))
				rs1("title")=titletxt
				rs1("creatdate")=now()
				rs1("fileflag")=cint(Request.Form ("fileflag"))
				rs1("pbflag")=cint(Request.Form ("webflag"))
				if pid=31 then
					rs1("yhj")=yhj
					rs1("thj")=thj
				end if
				rs1("tel")=tel
				rs1.Update
				id=rs1("id")
				rs1.Close
		end if
		if err<>1 then Response.Redirect htmlname
end if  
tjtxt="推荐"	
notjtxt="不推荐"
%>
<html>
<head>
<title><%=htmltitle%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {font-size: 12px; color: #000000; font-family: 宋体}
td {font-size: 12px; color: #000000; font-family: 宋体;line-height:130%}
.t1 {font:12px 宋体;color=000000} 
.t2 {font:12px 宋体;color:ffffff} 
.t3 {font:12px 宋体;color:336699} 
.t4 {font:12px 宋体;color:ff0000} 
.t5 {font:12px 宋体;color:ff6600} 


.bt1 {font:14px 宋体;color=000000} 
.bt2 {font:12px 宋体;color:ffffff} 
.bt3 {font:14px 宋体;color:336699} 
.bt4 {font:14px 宋体;color:ff0000} 
.bt5 {font:14px 宋体;color:0000ff}
.bt10 {font:14px 宋体;color:0000ff}

.td1 {font-size:12px;background-color:#3388bb;color:#ffffff}
.td2 {font-size:12px;background-color:#ffffff;color:#000000;}

A:link {color: #000077}
A:visited {color: #000077}
A:hover {color: #ff0000}

A.r1:link {text-decoration:none;color:#304556;}
A.r1:visited {text-decoration:none;color:#304556;}
A.r1:hover {text-decoration:underline;color:ff6600;}

A.r2:link {text-decoration:none;color:#ffffff;}
A.r2:visited {text-decoration:none;color:#ffffff;}
A.r2:hover {text-decoration:underline;color:cccc00;}

-->
</style>
</head>
<body topmargin=5>
<table width="100%" align=center>
	<tr>
	<td valign="top" align="left" width="100%">
		<table width="100%" height="20" border="0">
			<tr>
			<td style="font-size:12px;"></td>
			<td><font class="t5">当前位置： <%Response.Write (scoolname)%>→  <%Response.Write (classesname)%>(列表)</font>
			</td>
			<td align="right">
			</td>
			</tr>
			</table>
			</td>
			</tr>
			</table>
       <table width="100%" border="0" cellspacing="1" cellpadding="1" style="font-size:14.5px;line-height:100%" valign=top>
        <tr><td height=280 valign=top>		
		<table width="100%" height="20" border="0">
			<form action="<%=htmlname%>" method=post name="listform">
			<tr>
		<%
			if pl1=1 or pid=67 then
					sqltext1="select * from "+tabname+" where pid="&pid&" and ppid="&ppid&" order by "+plflag
				else
					sqltext1="select * from "+tabname+" where pid="&pid&" and ppid="&ppid&" order by "+plflag+" desc"
			end if
		'Response.Write sqltext1
		rs1.Open sqltext1,cn,1,1
		listcs=20
		rs1.PageSize=listcs
		if pageno="" then 
			pageno=1
		else
			pageno=cint(pageno)	
		end if	
		if rs1.PageCount>0 then rs1.AbsolutePage=pageno%>
				<td class=t1 align="left">
			<a href="Javascript:window.location.reload()">[刷新列表]</a>
			<a href="<%=addhtml%>&id=0">[增加]</a>
			<a href="javascript:delrows()">[删除]</a>
			<a href="javascript:shows()">[显示]</a>
			<a href="javascript:noshows()">[不显示]</a>
			<%if ppid=9 then%>
			<a href="javascript:tj()">[<%=tjtxt%>]</a>
			<a href="javascript:notj()">[<%=notjtxt%>]</a>				
			<%end if%>
			<%if pid=19 then%>	
				<a href="<%=xyhtml%>">[企业荣誉序言]</a>
			<%end if%>	
		</td>
		<td align="right">
		<%if rs1.PageCount>1 then%>
			[第<b><font color=ff6600><%=pageno%></font></b>页, 共<b><font color=ff6600><%=rs1.PageCount%></font></b>页<b><font color=ff6600><%=rs1.RecordCount%></font></b>条记录		              	
			<%if pageno>1 then%>
				<a class=r href="<%=htmlname%>&pageno=1">首页</a>              
				<a class=r href="<%=htmlname%>&pageno=<%=pageno-1%>">上页</a>              
			<%end if              
			if pageno<rs1.PageCount then%>              
				<a class=r href="<%=htmlname%>&pageno=<%=pageno+1%>">下页</a>              
				<a class=r href="<%=htmlname%>&pageno=<%=rs1.PageCount%>">末页</a>              
			<%end if%>              
		<%end if              
		%>              
		</td></tr>
		</table>
		<table width="100%" border="0" cellspacing="1" cellpadding="1" style="font-size:14.5px;line-height:100%">
			<tr bgcolor="666699" style="color:#ffffff" align="center">
				<td class=bt2>&nbsp;</td>
				<td class=bt2 width=50><a href="<%=htmlname%>&plflag=pl&pl=<%=pl1%>"><font color="#ffffff">序号</a></td>
			    <td class=bt2><a href="<%=htmlname%>&plflag=enable&pl=<%=pl1%>"><font color="#ffffff">是否显示</a></td>
			    <%if ppid=9 then%>
						<td class=bt2><a href="<%=htmlname%>&plflag=tjflag&pl=<%=pl1%>"><font color="#ffffff">是否推荐</a></td>		
				<%end if%>		
				<td class=bt2><a href="<%=htmlname%>&plflag=title&pl=<%=pl1%>"><font color="#ffffff"><%=txtname%></a></td>
				<%if pid<>59 and pid<>67 then%>
				<%if pid=19 or pid=40 or pid=41 or ppid=9 or pid=32 or pid=22 then%>
						<td class=bt2><font color="#ffffff">小图</td>
						<td class=bt2><font color="#ffffff">大图</td>
						<%if ppid=9 then%>
								<td class=bt2><font color="#ffffff">规格列表</td>
						<%end if%>		
					<%else%>
						<%if pid<>21 and pid<>67 and pid<>39 and both<>1 then%>
								<td class=bt2><a href="<%=htmlname%>&plflag=pl&pl=<%=pl1%>"><font color="#ffffff">排版模式</a></td>
						<%end if%>		
						<td class=bt2><font color="#ffffff">图文</td>
				<%end if%>		
				<%end if%>
				<%if both=1 then%><td></td><%end if%>
				<%if pid=67 then%>
				<td class=bt2><font color="#ffffff">电话</td>
				<td class=bt2><font color="#ffffff">地址</td>
				<%end if%>
			</tr>
		<%
		i=0
		do while not rs1.EOF and i<listcs 
			if (i mod 2)=1 then
				Response.Write("<tr bgcolor=fefefe>")
			else
				Response.Write("<tr bgcolor=efefef>")
			end if	
			sqltext="select count(*) from cdanwei where pppid="&ppid&" and ppid="&pid&" and pid="&rs1("id")
		    rs.Open sqltext,cn,1,1
		    sm=rs(0)
		    rs.Close  
		%>
		<td width="20" align="center">
		<%if rs1("id")<>4 then%>
				<input type="checkbox" name="sel" value="<%=(rs1("id"))%>">
		<%end if%>
		</td>
		<td width="50" align="center"><%=rs1("pl")%></td>
		<td width="70" align="center">
			<%if rs1("enable")=1 then 
				Response.Write "显示"
		    else
				Response.Write "<font color=red>不显示</font>"
			end if%>
		</td>
		<%if ppid=9 then%>
		<td width="70" align="center">
			<%if rs1("tjflag")=1 then 
				Response.Write "<font color=red>首页推荐</font>"
			end if%>
		</td>
		<%end if%>
		<td align=left><a href="<%=addhtml%>&id=<%=rs1("id")%>"><%=rs1("title")%></a></td>
		<%if pid<>59 then%>
		<%if pid=19 or pid=40 or pid=41 or ppid=9 or pid=32 or pid=22 then%>
				<td width="120" align="center">
					<a href="Javascript:editfile('<%=rs1("id")%>','0','<%=tabname%>')">小图</a>
						<%if rs1("picflag")="1" then Response.Write("<font color=red style='font-size:12px'>(有)</font>") else Response.Write("<font color=navy style='font-size:12px'>(无)</font>")%>
				</td>
				<td width="120" align="center">
					<a href="Javascript:editfile('<%=rs1("id")%>','4','<%=tabname%>')">大图</a>
						<%if rs1("picflag4")="1" then Response.Write("<font color=red style='font-size:12px'>(有)</font>") else Response.Write("<font color=navy style='font-size:12px'>(无)</font>")%>
				</td>
				<%if ppid=9 then%>
					<td width="120" align="center">
						<a href="<%=picadmin%>&id=<%=rs1("id")%>">规格列表<font color=red>(<%=sm%>)</font>>></a>
					</td>
				<%end if%>	
		<%else%>		
			<%if pid<>21 and pid<>67 and pid<>39 and both<>1 then%>
				<td width="80" align="center"><%if rs1("flag")=0 then Response.Write ("单图模式") else Response.Write ("<font color=red>多图混排</font>") end if%></td>
			<%end if%>
			<%if pid<>39 and pid<>2 and both<>1 and pid<>67 then%>
				<%if rs1("flag")=1 then%>
					<td width="120" align="center">
						<a href="<%=picadmin%>&id=<%=rs1("id")%>">图文段落<font color=red>(<%=sm%>)</font>>></a>
					</td>
				<%else%>
					<td width="120" align="center">
						<a href="Javascript:editfile('<%=rs1("id")%>','1','<%=tabname%>')">图片</a>
							<%if rs1("picflag1")="1" then Response.Write("<font color=red style='font-size:12px'>(有)</font>") else Response.Write("<font color=navy style='font-size:12px'>(无)</font>")%>
					</td>
				<%end if%>	
			<%elseif both<>1 and pid<>67 then%>
				<td width="120" align="center">
						<a href="Javascript:editfile('<%=rs1("id")%>','0','<%=tabname%>')">图片/FLASH</a>
							<%if rs1("picname")<>"" then Response.Write("<font color=red style='font-size:12px'>(有)</font>") else Response.Write("<font color=navy style='font-size:12px'>(无)</font>")%>
				</td>
			<%elseif both=1 then%>
				<td width="150" align="center">
						>> <a href="<%=picadmin%>&id=<%=rs1("id")%>">销售网点维护</a>
						<%
						xs=0
						sql="select * from cdanwei where pid="&rs1("id")
						rs2.Open sql,cn,1,1
						if not rs2.EOF then xs=rs2.RecordCount
						rs2.Close
						%>
						(<font color=red><%=xs%></font>)
				</td>
				<td width="120"></td>
			<%end if%>
		<%end if%>				
		<%end if%>
		<%if pid=67 then%>
		<td align=left>&nbsp; <%=rs1("tel")%></td>
		<td align=left>&nbsp; <%=rs1("add")%></td>
		<%end if%>
		</tr>
	    <%rs1.MoveNext 
			i=i+1
	    loop%> 
	    </form>
		</table>
		</td></tr></table>
	 <%if showok="1" then%>
		<table width="100%" border="0" cellspacing="1" cellpadding="1">
		  <tr bgcolor="666699" style="color:#ffffff" align="center">
		    <td>
		    </td>
		  </tr>
		</table>
		<table width="100%" border="0" cellspacing="1" cellpadding="1" style="font-size:14.5px;line-height:100%">
		  <tr bgcolor="ffffff" style="color:#ffffff" align="center">
		    <td height=20 align=left><font color=red><b><%=errtxt%></b></font></td>
		  </tr>
		</table>
		<table width="100%" border="0" cellspacing="1" cellpadding="1" style="font-size:14.5px;line-height:100%">
		  <form action="<%=htmlname%>&id=<%=id%>&mode=888&showok=1" method=post name=editform onsubmit="return checkform(editform)">
			<tr><td width=70 align=right>序号：</td><td><input type="text" value="<%=pl%>" name="pl" maxlength=15 size=5>
			     &nbsp;&nbsp;&nbsp;&nbsp;是否显示：<input type="checkbox" value="1" name="showflag" <%if enable=1 then Response.Write "checked"%>>
			     &nbsp;&nbsp;&nbsp;&nbsp;更新时间：<%=creatdate%>
			</td></tr>
		    <tr><td align=right><%=txtname%>：</td><td><input type="text" value="<%=titletxt%>" name="title" maxlength=35 size=30><font color=red>*</font></td></tr>
		    <%if pid=39 or pid=17 then%>
		    <tr><td align=right>窗口尺寸：</td><td>
				<input type="text" value="<%=yhj%>" name="yhj" maxlength=15 size=10>(长)&nbsp;&nbsp;
				<input type="text" value="<%=thj%>" name="thj" maxlength=15 size=10>(宽)&nbsp;
				<font color=red>（可选，不填则默认为500*400）</font>
			</td></tr>
			<%end if%>
			<%if pid=59 then%>
			<tr><td align=right>链接地址：</td><td><input type="text" value="<%=httpadd%>" name="httpadd" maxlength=50 size=35><font color=red>（可选，不填则无链接）</font></td></tr>
			<%end if%>
			<tr><td height=40>&nbsp;</td><td><input type="submit" value="确定提交" name=s1>&nbsp;&nbsp;<input type="button" value="取消返回" name=re1 onClick="window.location.href='<%=htmlname%>'"></td></tr>
		 </form>
		</table>		
	<%end if%>		
	  </td></tr>
	 </table>	
</body>
</html>
<script language="Javascript">

    function checkform(form)
    {
        var flag;
        if(form("title").value==""){alert("<%=txtname%>不能为空！");form.title.focus();return false}else{flag=true}
        return flag;
    }
    function delrows()
    {
        if (confirm('您确认要删除你所选中的项目吗？')==true)
        {        
        document.listform.action="<%=htmlname%>&mode=999";
        document.listform.submit();
        }
    }
    function shows()
    {
		listform.action="<%=htmlname%>&mode=777";
        document.listform.submit();
    }
    function noshows()
    {
        document.listform.action="<%=htmlname%>&mode=666";
        document.listform.submit();
    }
    function tj()
    {
		listform.action="<%=htmlname%>&mode=555";
        document.listform.submit();
    }
    function notj()
    {
        document.listform.action="<%=htmlname%>&mode=444";
        document.listform.submit();
    }    
	function editfile(keyno,pic,tablename)
	{
		var str
		str="file_upload.asp?" ;
		str=str+"keyno="+keyno+"&pic="+pic+"&tablename="+tablename
		window.open(str,"mywin","toolbar=no,location=no,directories=no,status=no,resizable=no,menubar=no,scrollbars=yes,width=550,height=400,left=120,top=70")		
	}
	function submitgate(keyno)
	{
	var str="../gate_detail.asp"
	str=str+"?id="+keyno
	window.open(str, 'gate', 'scrollbars=yes,width=400,height=210');
	}
</script>
<%
function checkstring(str)
	if str<>"" then
		if left(str,1)<>"." then	
			a=instr(str,"http://")
			if a<>1 then
					checkstring="http://"&str
				else
					checkstring=str
			end if
		else
			checkstring=str	
		end if	
	end if
end function
%>