<!--#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 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>广告管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<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>
<link href="/js/jquery-ui-1.8.10/css/ui-lightness/jquery-ui-1.8.10.custom.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../js/PublicJS.js"></script>
<script type="text/javascript" src="/js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.10/js/jquery-ui-1.8.10.custom.min.js"></script>
<script type="text/javascript" src="/js/jquery.validate/jquery.validate.min.js"></script>
<script language="javascript">
function goto(frm)
{
	var gourl ="ad_manage.asp?startdate=<%=startdate%>&enddate=<%=enddate%>&classid=<%=classid%>&act=<%=act%>&";
	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);
}

function ConfirmDel()
{
   if(confirm("确认删除？并且不能恢复！确定要删除此信息吗？"))
     return true;
   else
     return false;
	 
}
function PreView(id){
	$('#dialog-preview'+id).dialog({
			height: 500,
			width: 350,
			modal: true
																 });
}
</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%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#999999">
  <tr bgcolor="#FF9900">
    <td height="22" colspan="11" bgcolor="#FF9900"><div align="center"><span class="style3">◆ 广告管理 ◆</span></div></td>
  </tr>
  <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">频道：
      <select name="classid">
      <option value="0">不限</option>
  		<%
				set rs=server.CreateObject("adodb.recordset")
				sql="select id,title from catalogs where parentid=0 order by id asc"
				rs.open sql,conn,3,1
				if not rs.eof then
					first=rs.GetRows()
				else
					response.Write("<option>点击右边＋号选择栏目</option>")
				end if
				rs.close
				set rs=nothing
				dim ssl
				ssl=""
				if(isarray(first)) then
					for i=0 to ubound(first,2)
						if(first(0,i)=classid) then
							ssl=" selected"
						else
							ssl=""
						end if
						response.Write("<option value="&first(0,i)&ssl&">├"&first(1,i)&"</option>"&Chr(10))	    	
					next	
				end if
			%> 	     
 </select>
 			超始日期：
        <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="submit" name="button" id="button" value="搜 索"></td>
    </tr>
  </table>
</form>
    </td>
  </tr>
  <tr bgcolor="#EEEEEE">
    <td width="5%" height="22"><div align="center">id</div></td>
    <td width="5%"><div align="center">过期</div></td>
    <td width="19%"><div align="center">广告名称</div></td>
    <td width="11%"><div align="center">广告类型</div></td>
    <td width="12%"><div align="center">预览</div></td>
    <td width="9%"><div align="center">宽*高</div></td>
    <td width="7%"><div align="center">点击</div></td>
    <td width="10%"><div align="center">代码</div></td>
    <td width="10%"><div align="center">日期</div></td>
    <td width="6%"><div align="center">修改</div></td>
    <td width="6%"><div align="center">删除</div></td>
  </tr>
  <!-- 开始按行循环----------------------->
  <%
  		dim sql,countSql
		countSql="select count(*) AS co from ad where 1=1"
		if(classid>0) then
			countSql=countSql&" and catalogId="&classid
		end if
		if(startdate<>"" and enddate<>"") then
			countSql=countSql&" and DATEDIFF(d, '"&startdate&"',moditime)>=0 and DATEDIFF(d, '"&enddate&"', moditime)<=0"
		end if
		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&" * from ad where id <=(select min(id) from (select top "&(recpage*(currentpage-1)+1)&" id from ad where 1=1"
			if(classid>0) then
				sql=sql&" and catalogId="&classid
			end if
			if(startdate<>"" and enddate<>"") then
				sql=sql&" and DATEDIFF(d, '"&startdate&"',moditime)>=0 and DATEDIFF(d, '"&enddate&"', moditime)<=0"
			end if
			sql=sql&" order by id desc) as t)"
			if(classid>0) then
				sql=sql&" and catalogId="&classid
			end if
			if(startdate<>"" and enddate<>"") then
				sql=sql&" and DATEDIFF(d, '"&startdate&"',moditime)>=0 and DATEDIFF(d, '"&enddate&"', moditime)<=0"
			end if
			sql=sql&" order by id desc "
		rs.open sql,conn,3,1		
		do while not rs.eof
		
	%>
  <tr>
    <td height="20" bgcolor="#FFFFFF"><div align="center"><%=rs("id")%></div></td>
    <td bgcolor="#FFFFFF">
    <div id="dialog-preview<%=rs("id")%>" style="display:none;" title="广告预览"><script src="/aa/js_<%=rs("id")%>.js"></script></div>
	<div align="center">
	<%
		expireTime=rs("expiretime")
		if(datediff("d",expireTime,date)>0) then
			response.Write("<font color=""red"">是</font>")
		else
			response.write("否")
		end if
	%>
 
	</div></td>
    <td bgcolor="#FFFFFF"><div align="center"><%=rs("title")%></div></td>
    <td bgcolor="#FFFFFF"><div align="center">
	<%
		if(rs("adType")=0) then
			response.Write("文字")
		elseif(rs("adType")=1) then
			response.Write("图片")
		elseif(rs("adType")=2) then
			response.Write("Flash")
		end if
	%></div></td>
    <td bgcolor="#FFFFFF"><div align="center">
    <a href="javascript:PreView(<%=rs("id")%>)"><strong>预览</strong></a></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><%=rs("imgW")%>*<%=rs("imgH")%></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><%=rs("hits")%><br><a href="ad_detail.asp?id=<%=rs("id")%>">明细</a><br>
<a href="ad_reset.asp?id=<%=rs("id")%>" onClick="return confirm('确认执行此操作吗？')">清零</a></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="ad_gencode.asp?id=<%=rs("id")%>">获取代码</a>=&gt;</div></td>
    <td bgcolor="#FFFFFF"><div align="center"><%=rs("moditime")%></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="ad_mod.asp?id=<%=rs("id")%>&catalogid=<%=rs("catalogId")%>">修改</a></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="dele.asp?id=<%=rs("id")%>&table=ad" onClick="return ConfirmDel()">删除</a></div></td>
  </tr>
  
  <%
    rs.movenext
	  i=i+1
	  loop
	 ' end sub
	  rs.close
	  set rs=nothing
  %>
  <tr>
    <td height="22" colspan="11" bgcolor="#FFFFFF"><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='ad_manage.asp?startdate="&startdate&"&enddate="&enddate&"&classid="&classid&"&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='ad_manage.asp?startdate="&startdate&"&enddate="&enddate&"&classid="&classid&"&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></td>
  </tr>
  <!--按行循环结束------------------------>
</table>
</body>
</html>
<%
call connclose()
%>
<%=CStr(FormatNumber((Timer-BeginTime)*1000,2))& "毫秒"%>