<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
'call checkPrevilege(Session("Name"),"p14")
'''''''''''''''''''''''''''''''''''''''''''''''
dim moduleid,modulename,tablename,listfields,fieldArr
moduleid=Cint(request.QueryString("moduleid"))
set rs=server.createobject("adodb.recordset")
rs.open "select Title,TableName,ListFields from t_module where id="&moduleid,conn,3,1
if not rs.eof then
	modulename=rs(0)
	tablename=rs(1)
end if
rs.close
set rs=nothing
set rs=server.createobject("adodb.recordset")
rs.open "select FName,FTitle from t_fields where ModuleId="&moduleid&" and ShowInList=1",conn,3,1
if not rs.eof then
	fieldArr=rs.getrows()
end if
rs.close
set rs=nothing
dim BeginTime,act,startdate,enddate
BeginTime=Timer
act=request.querystring("act")
const recpage=20
dim i,classid
if not isempty(request("classid")) then
	classid=Clng(request("classid"))
else
	classid=0
end if
startdate=request.QueryString("startdate")
enddate=request.QueryString("enddate")
if(startdate<>"") then
	startdate=cdate(startdate)
end if
if(enddate<>"") then
	enddate=cdate(enddate)
end if
if not isempty(request("page")) then 
currentpage=Clng(request("page"))
else currentpage=1
end if
%>
<html>
<head>
<title><%=modulename%>管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #FFFFFF;
}
-->
</style>
<link href="style/global.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FF0000}
.style2 {color: #CCCCCC}
.style3 {color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
<script language="JavaScript" src="../js/PublicJS.js"></script>
<script language="javascript">
function goto(frm)
{
	var gourl ="?startdate=<%=startdate%>&enddate=<%=enddate%>&classid=<%=classid%>&moduleid=<%=moduleid%>&";
	gourl += "page=" + (frm.page.value);
     var hid=parseInt(frm.hid.value);
	 if(parseInt(frm.page.value)>hid||frm.page.value<=0){
	 alert("错误！请确定你输入的数字在1-"+hid+"之间");
	 return false;
	 }
	window.location.href(gourl);
}</script>
<script language="JavaScript" type="text/JavaScript">
function ConfirmDel()
{
   if(confirm("确认删除？并且不能恢复！确定要删除此信息吗？"))
     return true;
   else
     return false;
	 
}
</script>
</head>

<body>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<table width="100%">
<tr bgcolor="#EEEEEE">
    <td height="22" colspan="11">
    <form name="form2" method="get" action="?">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="24" align="center">
 			关键字：
 			  <input type="text" name="key" id="key">
 			  起始日期：
<input name="startdate" type="text" id="startdate" value="<%if(startdate<>"") then response.Write(startdate) else response.Write(date()) end if%>" size="12" onClick="OpenWindowAndSetValue('Inc/SelectDate.asp',280,120,window,this);this.focus();">
      结束日期：
      <input name="enddate" type="text" id="enddate" value="<%if(enddate<>"") then response.Write(enddate) else response.Write(date()) end if%>" size="12" onClick="OpenWindowAndSetValue('Inc/SelectDate.asp',280,120,window,this);this.focus();">
      <input type="hidden" name="moduleid" value="<%=moduleid%>" />
      <input type="submit" name="button" id="button" value="搜 索"></td>
    </tr>
  </table>
</form>
    </td>
  </tr>
</table>
<h2 style="margin:0px; padding:0px; line-height:25px; text-align:left; font-size:12px; font-weight:bold;"><%=modulename%>管理-(表<%=tablename%>)</h2>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#999999">
  <tr bgcolor="#EEEEEE">
  	<td align="center"><strong>标题</strong></td>
    <%
		if isarray(fieldArr) then
			for i=0 to ubound(fieldArr,2)
				listfields=listfields&","&fieldArr(0,i)
				response.Write("<td><div align=""center""><strong>"&fieldArr(1,i)&"</strong></div></td>")
			next
		end if
		%>
    <td align="center">日期</td>
    <td height="25"><div align="center">修改</div></td>
    <td><div align="center">删除</div></td>
  </tr>
  <!-- 开始按行循环----------------------->
  <%
  		dim sql,countSql
		countSql="select count(*) AS co from "&tablename&" where 1=1"
		if(classid>0) then
			countSql=countSql&" and classid="&classid
		end if
		if(startdate<>"" and enddate<>"") then
			countSql=countSql&" and DATEDIFF(d, '"&startdate&"',PubDate)>=0 and DATEDIFF(d, '"&enddate&"', PubDate)<=0"
		end if
		'response.Write(countsql)
		set rs=server.createobject("adodb.recordset")
		rs.open countSql,conn,3,1
		allrec=rs(0)
		totalpage=int((allrec+recpage-1)/recpage)
		rs.close
		set rs=nothing
		set rs=server.createobject("adodb.recordset")
		sql="select top "&recpage&" id,Title,PubDate,SaveDir"&listfields&" from "&tablename&" where id <=(select min(id) from (select top "&(recpage*(currentpage-1)+1)&" id from "&tablename&" where 1=1"
		if(classid>0) then
			sql=sql&" and classid="&classid
		end if
		if(startdate<>"" and enddate<>"") then
			sql=sql&" and DATEDIFF(d, '"&startdate&"',PubDate)>=0 and DATEDIFF(d, '"&enddate&"', PubDate)<=0"
		end if
		sql=sql&" order by id desc) as t)"
		if(classid>0) then
			sql=sql&" and classid="&classid
		end if
		if(startdate<>"" and enddate<>"") then
			sql=sql&" and DATEDIFF(d, '"&startdate&"',PubDate)>=0 and DATEDIFF(d, '"&enddate&"', PubDate)<=0"
		end if
		sql=sql&" order by id desc "
		rs.open sql,conn,3,1		
		do while not rs.eof		
	%>
  <tr>
  	<td bgcolor="#FFFFFF"#FFFFFF""><div align=""center""><a href="<%=rs("SaveDir")%>" target="_blank">&nbsp;<%=left(rs("Title"),20)%></a></div></td>
    <%
		if isarray(fieldArr) then
			for i=0 to ubound(fieldArr,2)
				if(fieldArr(0,i)="Title") then
					response.Write("")
				else
					response.Write("<td bgcolor=""#FFFFFF""><div align=""center"">"&rs(fieldArr(0,i))&"</div></td>")
				end if
			next
		end if
		%>
    <td align="center" bgcolor="#FFFFFF"><%=year(rs("PubDate"))&"-"&month(rs("PubDate"))&"-"&day(rs("PubDate"))%></td>
    <td height="25" bgcolor="#FFFFFF"><div align="center"><a href="content_mod.asp?id=<%=rs("id")%>&moduleid=<%=moduleid%>">修改</a></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="content_del.asp?id=<%=rs("id")%>&moduleid=<%=moduleid%>" onClick="return ConfirmDel()">删除</a></div></td>
  </tr>  
  <%
			rs.movenext
			i=i+1
	  loop
	 ' end sub
	  rs.close
	  set rs=nothing
  %>
  <!--按行循环结束------------------------>
</table>
<div align="center"><form name="form1" method="post" action="" style="margin:0 0 0 0">
          <%
					n=currentpage+1
					p=currentpage-1
					if p>0then
					response.write("["&"<a href='?moduleid="&moduleid&"&act="&act&"&page="&cstr(p)&"'>上一页</a>]&nbsp;&nbsp;&nbsp;")
					else response.write("上一页&nbsp;&nbsp;&nbsp;")
					end if 
					if (n-1)*recpage>=allrec then 
					response.write("下一页" )
					else
					response.Write("["&"<a href='?moduleid="&moduleid&"&act="&act&"&page="&cstr(n)&"'>下一页</a>]")
					end if
					response.write("&nbsp;共"&allrec&"条&nbsp;")
					response.Write("&nbsp;共"&totalpage&"页&nbsp;")
					response.Write("&nbsp;第"&currentpage&"页&nbsp;")
					%>
          <input type="hidden" name="hid" value="<%=totalpage%>">
&nbsp;&nbsp;跳至
          <input name="page" type="text" size="5" onChange="goto(this.form)" style="border:1px solid #000000;height:18px ">
          页
          <input type="button" name="Button22" value="Go->" style="font-size:12px ;border:1px solid #000000;height:18px ">
</form></div>
</body>
</html>
<%
call connclose()
%>
<%=CStr(FormatNumber((Timer-BeginTime)*1000,2))& "毫秒"%>