<!--#include file="../fy.Function.asp"-->
<!--#include file="../../fy_inc/cls_pageview.asp"-->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>多图管理</title>
<link rel="stylesheet" type="text/css" href="../css/base.css">
<link rel="stylesheet" type="text/css" href="../css/content.css">
<script type="text/javascript" src="../../fy_inc/js/jquery.js"></script>
<script type='text/javascript' src='../../fy_inc/js/lhg/lhgdialog.min.js'></script>
<script type='text/javascript' src='../js/main.js'></script>
</head>
<body><%	Dim sql, sqlCount,Sqls,intPageSize, strPageInfo,arrinfo, i,pages,intPageNow,strLocalUrl,Action,AID
	Dim ModeID,picurl,picinfo,thumbpic,title,FieldName,rs
	Action=Request("Action")
	aid=ChkNumeric(Request("aid"))
	ModeID=ChkNumeric(Request("ModeID"))
	
 	FieldName=rsql(Request("FieldName"))
%>
<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 多图管理</div>
    <div class="opers">
	<a href="?Action=add&ModeID=<%=ModeID%>&FieldName=fycms&aid=<%=aid%>" class="btn<%If Request("Action")="add"  And (FieldName="" Or    FieldName="fycms") Then echo " btn_primary" %>" >添加图片</a>
	<a href="?Action=list&ModeID=<%=ModeID%>&FieldName=fycms&aid=<%=aid%>" class="btn<%If Request("Action")="list" And  (FieldName="" Or    FieldName="fycms")  Then echo " btn_primary" %>">查看图片</a>
	<a href="sys.all.pic.asp?Action=list&ModeID=<%=ModeID%>&FieldName=fycms&aid=<%=aid%>" class="btn">批量添加图片</a>
	
  
	<%	  Set rs=fycms.ACTEXE("Select * from Table_fy  Where ModeID=" & ModeID & " and fycms=1  and FieldType='PicType' and Type_Type=1 order by OrderID desc,ID asc")
 			If Not rs.eof Then 
				Do While Not rs.eof

	%>
	 <a href="?Action=add&ModeID=<%=ModeID%>&FieldName=<%=rs("FieldName")%>&aid=<%=aid%>" class="btn<%If Request("Action")="add" And FieldName=rs("FieldName") Then echo " btn_primary" %>" >添加<%=rs("title")%></a>
	<a href="?Action=list&ModeID=<%=ModeID%>&FieldName=<%=rs("FieldName")%>&aid=<%=aid%>" class="btn<%If Request("Action")="list" And FieldName=rs("FieldName") Then echo " btn_primary" %>">查看<%=rs("title")%></a>
	<%rs.movenext
	Loop
	End if%>

    </div><%  
	If Trim(FieldName)="" Then FieldName="fycms"
	Dim ShowErr
		IF Request.QueryString("Action") = "del" Then
		Dim ID:ID = ChkNumeric(Request("ID"))
			IF ID = "" Then
				Call fycms.ActErr("请指定要删除的id","","1")
 				Response.end
			End IF
 		Set rs=fycms.actexe("Select * from syspic Where id=" & ID & " ")
 		If Not rs.eof  Then
 			Call  fycms.DeleteFile(Rs("picurl"))
			Conn.execute("Delete from syspic  Where id= "&Rs("id"))
 		End If 
 		Call fycms.ActErr("删除成功","fy_Mode/allpic.asp?Action=list&ModeID="&ModeID&"&FieldName="&FieldName&"&aid="&aid&"","")
 	  End IF
	  
	  Select Case Action
	  		Case "edit","add"
				call edit()
			Case "AddSave","EditSave"
				Call Saves()
			Case "px"
				Call px()
			Case Else
				call main()
		end Select
		

	Sub px()
			Dim i,OrderID
			ID = Split(fycms.s("ID"),","):OrderID = Split(fycms.s("OrderID"),",")
			 For I = LBound(ID) To UBound(ID)
 					Conn.execute("Update syspic set OrderID="&OrderID(I)&" where modeid="&modeid&" and  ID = "&ChkNumeric(ID(I))&"")
			Next 
			set conn=Nothing
		  Response.Redirect "?Action=list&ModeID="&ModeID&"&FieldName="&FieldName&"&aid="&aid
	End sub


		sub main()
	 Dim ACT_TypeDiY,TypeDiY,Manage
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
	intPageNow = request.QueryString("page")
	intPageSize =20
	sql = "SELECT [ID], [AID],[title], [picurl], [orderid],[modeid]" & _
		" FROM [syspic] where Fieldname='"&FieldName&"' and aid="&aid&" " & _
		" ORDER BY [ID] DESC"
 	sqlCount = "SELECT Count([ID])" & _
			" FROM [syspic] where Fieldname='"&FieldName&"' and aid="&aid&" "
		Dim clsRecordInfo
		Set clsRecordInfo = New Cls_PageView
			clsRecordInfo.intRecordCount = 2816
			clsRecordInfo.strSqlCount = sqlCount
			clsRecordInfo.strSql = sql
			clsRecordInfo.intPageSize = intPageSize
			clsRecordInfo.intPageNow = intPageNow
			clsRecordInfo.strPageUrl = strLocalUrl
			clsRecordInfo.strPageVar = "page"
		clsRecordInfo.objConn = Conn		
		arrinfo = clsRecordInfo.arrinfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = Nothing
		ModeID=ChkNumeric(Request("ModeID"))

 	 %>


      <form name="Article" method="post"  action="?Action=px&ModeID=<%=ModeID%>&FieldName=fycms&aid=<%=aid%>">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>选中</th>
      <th>ID</th>
      <th>所属文章</th>
      <th>标题</th>
      <th>路径</th>
      <th>排序</th>
      <th>管理操作</th>
	  </tr>
    </thead>
    	 <%
 		If IsArray(arrinfo) Then
			For i = 0 to UBound(arrinfo, 2)
 	%>


     <tr>
      <td>
	  <input type="checkbox" name="ID" value="<%= arrinfo(0,i) %>">	  </td>
      <td><%= arrinfo(0,i) %></td>
      <td><%

	Dim AName,modeid
 	modeid=ChkNumeric(arrinfo(5,i))
	If modeid=0 Then modeid=1
	Set AName=fycms.ACTEXE("Select title from  "&fycms.ACT_C(modeid,2)&"  where ID = "& arrinfo(1,i))
	If Not Aname.eof Then 
		echo "<a target=""_blank"" href="""&fycms.actsys&fycms.act_c(arrinfo(5,i),5)&"?ID="&arrinfo(1,i)&""">"&Aname("title")&"</a>"
	Else
		echo "<font color=red>该文章已被删除</font>"
	End If 
  	  %>
	  </td>
      <td><%= arrinfo(2,i) %></td>
      <td> 
 	  <a href="<%= arrinfo(3,i) %>" target="_blank"><img src="<%= arrinfo(3,i) %>" width="65" /></a>	  
	  </td>
      <td>
	            <input name="OrderID" type="text" class="Ainput" id="OrderID" value="<%=arrinfo(4,i)%>" size="4" maxlength="3">
          <input name="A" type="hidden" id="A" value="N">
		  <input name="ID" type="hidden" id="ID" value="<%=arrinfo(0,i)%>">	

	  
	  </td>
      <td colspan="2" align="center">
	  <a href="?Action=edit&id=<%= arrinfo(0,i) %>&ModeID=<%=ModeID%>&FieldName=<%=FieldName%>&aid=<%=aid%>">修改</a>┆
	  <a href="?Action=del&ID=<%= arrinfo(0,i) %>&ModeID=<%=ModeID%>&FieldName=<%=FieldName%>&aid=<%=aid%>" onClick="return confirm('确认删除此自定义属性吗?')">删除</a>	  </td>
    </tr><% 
	Next
	End If
	%>

   
 <tr>
    <td colspan="8" class="tl"><input type="submit" Class="btn btn_primary" name="Submit" value=" 批量更新排序 "></td>
  </tr>


    </table></form>
    <div class="pagelist">
    <%= strPageInfo%>
   </div>

  <script language="javascript">



function CheckAll(form)  
  {  
 for (var i=0;i<form.elements.length;i++)  
    {  
    var e = Article.elements[i];  
   if (e.name != 'chkall')  
      e.checked = Article.chkall.checked;  
   }  
  }
 
</script>
  <% end sub
Sub edit() 
	If Action ="edit" Then 
		Dim Rs,ID,A
		id = ChkNumeric(Request.QueryString("id"))
		Set Rs=fycms.actexe("select * from syspic Where id="&id&"")
		If rs.eof Then
			Call fycms.alert("未知错误","")
		Else
			picinfo=Rs("picinfo")
			AID=Rs("AID")
			Id=Rs("Id")
			picurl=Rs("picurl")
			picinfo=Rs("picinfo")
			thumbpic=Rs("thumbpic")
			Fieldname=Rs("Fieldname")
			title=Rs("title")
 
			
		End If
		A="EditSave"
	Else
		A="AddSave"	
	End If 
%>


<form name="form1" method="post" action="?action=<%= A %>&ID=<%= ID %>&AID=<%= AID %>&FieldName=<%= Fieldname %>&ModeID=<%= ModeID %>">
    <div class="divtable"> 
        <dl>
            <dt>图片缩略图：</dt>
            <dd>
              <input name="thumbpic" id="thumbpic" type="text" class="Ainput" value="<%= thumbpic %>" size="50">    
			  <input id="PicUrls" class="btn " onClick="javascript:tdialog(<%=ModeID%>,'<%=fycms.actsys&fycms.adminurl%>/include/Upload_Admin.asp?A=add&instr=0&ModeID=<%=ModeID%>&instrname=thumbpic');" name="button" type="button"   value="点击上传图片">
可不传,以大图为准
            </dd>
         </dl>
        
        <dl>
            <dt>图片大图：</dt>
            <dd>
              <input name="picurl" id="picurl" type="text" class="Ainput" value="<%= picurl %>" size="50"> <input id="PicUrls2" class="btn " onClick="javascript:tdialog(<%=ModeID%>,'<%=fycms.actsys&fycms.adminurl%>/include/Upload_Admin.asp?A=add&instr=0&ModeID=<%=ModeID%>&instrname=picurl');" name="button" type="button"   value="点击上传图片"> <span id="Zoom1"></span>
			   	  <a href="<%= picurl %>" target="_blank"><img src="<%= picurl %>" width="65" /></a>	  

            </dd>
         </dl>
      
        <dl>
            <dt>标题：</dt>
            <dd>
              <input name="title" type="text" class="Ainput" value="<%= title %>" size="50"> 
            </dd>
         </dl>

        <dl>
            <dt>描述：</dt>
            <dd>
              <input name="picinfo" type="text" class="Ainput" value="<%= picinfo %>" size="50"> 
            </dd>
         </dl>

			
			<dl>
            <dt class="vhid">提交：</dt>
            <dd>
                <a class="btn btn_primary" href="javascript:void(0);" onclick="CheckForm()">提交</a>
				<input name="Submit2" type="reset" class="btn" value="  重置  ">
            </dd>
         </dl>
        
    </div>
    </form>

 
<%end sub 


sub saves()
		dim Rs,RsSql
		 AID=fycms.S("aid")
		 picinfo=fycms.S("picinfo")
		 thumbpic=fycms.S("thumbpic")
		 title=fycms.S("title")
		 Fieldname=fycms.S("FieldName")
		 picurl=fycms.S("picurl")
		 
		 ID=ChkNumeric(fycms.S("ID"))
		 IF fycms.S("FieldName") = "" Then
			Call fycms.Alert("对应的字段属性为空!",""):Exit Sub
		 End if
		If Action="AddSave" Then 
			 Set Rs = Server.CreateObject("adodb.recordset")
			  RsSql = "select * from syspic"
			  Rs.Open RsSql, Conn, 1, 3
			  Rs.AddNew
		 	  Rs("picinfo") = picinfo
		 	  Rs("AID") = AID
		 	  Rs("modeid") = modeid
		 	  Rs("Fieldname") = Fieldname
		 	  Rs("title") = title
		 	  Rs("picurl") = picurl
		 	  Rs("thumbpic") = thumbpic
			  Rs.Update
			  Rs.Close:Set Rs = Nothing			
			  Call fycms.ActErr("添加成功","fy_Mode/allpic.asp?Action=list&ModeID="&ModeID&"&FieldName="&FieldName&"&aid="&aid&"","")
 		Else
		 
			 Set Rs = Server.CreateObject("adodb.recordset")
			  RsSql = "select * from syspic Where ID="&ID
			  Rs.Open RsSql, Conn, 1, 3
		 	  Rs("picinfo") = picinfo
		 	  Rs("title") = title
		 	  Rs("picurl") = picurl
		 	  Rs("thumbpic") = thumbpic
 			  Rs.Update
			  Rs.Close:Set Rs = Nothing			
			  Call fycms.ActErr("操作成功","fy_Mode/allpic.asp?Action=list&ModeID="&ModeID&"&FieldName="&FieldName&"&aid="&aid&"","")
 		End If 
end sub
CloseConn %>
<script language="javascript">
function CheckForm()
{ var form=document.form1;
	
 
 
	if (form.picurl.value=='')
		{ alert("请上传大图!");   
		  form.picurl.focus();    
		   return false;
		} 
 	    form.submit();
        return true;
	}
	
	
	</script> 









</div>
<script type="text/javascript">
<!--
	function zoom(zid,zimg) {
	var div = document.getElementById(zid);
	div.style.position = 'absolute';
	div.innerHTML = "<img src=" + zimg + " style='padding:1px;border:1px solid #9FD253;background-color:#fff;margin:18px 0px 0px 0px;'>"
}
//-->
</script>
</body>
</html>
