<!--#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>
<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 广告管理</div>
    <div class="opers">
		<a href="index.asp" class="btn<%If request("Action")="" Then echo " btn_primary" %>">广告列表</a>
		<a href="?Action=add" class="btn<%If request("Action")="add" Then echo " btn_primary" %>">添加广告</a>
		<a href="http://www.fycms.com/sys/ad.asp" class="btn">常用广告代码 </a>
    </div>
   <% If Not fycms.fycms_QXYZ(0,"ad","") Then   Call fycms.Alert("对不起，你没有操作权限！","") 
	Dim sql, sqlCount,Sqls,intPageSize, strPageInfo,arrinfo, i,pages,intPageNow,strLocalUrl,Action,Aname,AID
	Dim Title,adfile,adwidth,adheight,adurl,Content,UnlockTime,StartTime,EndTime,isset
	Action=Request("Action")
	Dim ShowErr
		IF Request.QueryString("Action") = "del" Then
		Dim ID:ID = Request("ID")
			IF ID = "" Then
				Call fycms.ActErr("请指定要删除的广告","","1")
 				Response.end
			End IF
 			Sql="delete from ads_fy where ID=" &  ChkNumeric(ID) & ""
 		Conn.Execute sql:Set Conn=nothing
			Call fycms.ActErr("操作成功","Sys_fy/ad/Index.asp","")
 	  End IF
	  
	  Select Case Action
	  		Case "edit","add"
				call edit()
			Case "AddSave","EditSave"
				Call Saves()
			Case Else
				call main()
		end select
		sub main()
	 Dim ACT_TypeDiY,TypeDiY,Manage
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
	intPageNow = request.QueryString("page")
	intPageSize =20
	sql = "SELECT ID,isset,Title,adfile,adwidth,adheight,adurl,Content,UnlockTime,StartTime,EndTime,addtime " & _
		" FROM [ads_fy]" & _
		" ORDER BY [ID] DESC"
	sqlCount = "SELECT Count([ID])" & _
			" FROM [ads_fy]"
		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
	 %> <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>选中</th>
	  <th>广告类型</th>
	  <th>广告名称</th>
	  <th>调用代码</th>
	  <th>管理操作</th>
	  </tr>
    </thead>
     <%
		Dim bgColor
		If IsArray(arrinfo) Then
			For i = 0 to UBound(arrinfo, 2)
			bgColor="#FFFFFF"
			if i mod 2=0 then bgColor="#DFEFFF"
	%>
    <tr>
      <td >
	 <%= arrinfo(0,i) %> </td>
      <td >
	  <%
	  Select Case  arrinfo(1,i)
		Case "1"
			echo "文字广告"
		Case "2"
			echo "图片广告"
		Case "3"
			echo "Flash广告"
		Case "4"
			echo "Flash广告"
	  
	  
	  End Select %></td>
      <td ><%= arrinfo(2,i) %></td>
      <td  onClick=show("daima<%= arrinfo(0,i) %>")>查看</td>
      <td colspan="2" align="center">
	  <a href="?Action=edit&id=<%= arrinfo(0,i) %>">修改</a>┆
	  <a href="?Action=del&ID=<%= arrinfo(0,i) %>" onClick="return confirm('确认删除此自定义属性吗?')">删除</a>	  </td>
    </tr>


<tr id="daima<%= arrinfo(0,i) %>" style="display:none;"><td colspan="6" align="center">
	<input type="text" class="Ainput" size="80" value="<script language='javascript' src='{fy:dir}Plus/ad/index.asp?ID=<%= arrinfo(0,i) %>'></script>"> 
	请将此段代码加到要显示广告的位置，该位置将显示该项广告内容
</td></tr>	

	<% 
	Next
	End If
	%>
   
    </table>
    <div class="pagelist">
    	<%= strPageInfo%>
   </div>


     <% end sub
Sub edit() 
	If Action ="edit" Then 
		Dim Rs,ID,A
		id = ChkNumeric(Request.QueryString("id"))
		Set Rs=fycms.actexe("select * from ads_fy Where id="&id&"")
		If rs.eof Then
			Call fycms.alert("未知错误","")
		Else
			Title=Rs("Title")
			isset=Rs("isset")
			adfile=Rs("adfile")
			adwidth=Rs("adwidth")
			adheight=Rs("adheight")
			adurl=Rs("adurl")
			Content=Rs("Content")
			If Content <> "" Then Content=Server.HTMLEncode(Content)

			UnlockTime=Rs("UnlockTime")
			StartTime=Rs("StartTime")
			EndTime=Rs("EndTime")
			Id=Rs("Id")
		End If
		A="EditSave"
	Else
		A="AddSave"	
		isset=1
		UnlockTime=1
	End If 
%>
 

  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
<form name="form1" method="post" action="?action=<%= A %>&ID=<%= ID %>">
	<tr>
      <td colspan="2" align="center" class="bg_tr">添加/修改广告</td>
    </tr>	
	
	<tr>
      <td width="18%" align="right"   ><strong>广告名称：</strong></td>
      <td width="82%"  class="tl"><input name="title" type="text" id="title" class="Ainput" value="<%=title%>" size="35" /> 
  	  </td>
    </tr>
 
	   



   <tr>
      <td align="right"  ><strong>广告类型：</strong></td>
      <td  class="tl">
	 <label for="issets1"><input onClick=issets(1) type="radio" <%If isset="1" Then echo "checked"%>   value="1" name="isset"  id="issets1">&nbsp;文字广告&nbsp;</label>
	 <label for="issets2"><input onClick=issets(2) type="radio" <%If isset="2" Then echo "checked"%>      value="2" name="isset"  id="issets2">&nbsp;图片广告&nbsp;</label>
	 <label for="issets3"><input onClick=issets(3) type="radio" <%If isset="3" Then echo "checked"%>      value="3" name="isset"  id="issets3">&nbsp;Flash广告&nbsp;</label>
	 <label for="issets4"><input onClick=issets(4) type="radio" <%If isset="4" Then echo "checked"%>      value="4" name="isset"  id="issets4">&nbsp;广告代码&nbsp;</label>
		</td>
    </tr>	
  
	<tr id="issetsyle1"
	style="DISPLAY: none"
	>
      <td align="right" ><strong>广告文件：</strong></td>
      <td class="tl"><input name="adfile"  id="adfile" type="text" class="Ainput"  value="<%=adfile%>" size="50" />
	  	  宽：
	    <input name="adwidth" type="text" class="Ainput"   size="5" onKeyUp="value=value.replace(/[^\d]/g,'');"  value="<%=adwidth%>"> 
	    高：
	    <input name="adheight" type="text" class="Ainput"  size="5" onKeyUp="value=value.replace(/[^\d]/g,'');" value="<%=adheight%>">	  
 
  <input id="PicUrls" class="btn btn_primary" onClick="javascript:tdialog(999,'<%=fycms.actsys&fycms.adminurl%>/include/Upload_Admin.asp?A=add&instr=0&ModeID=999&instrname=adfile');" name="button" type="button"   value="点击上传图片">
 
 
 </td>
    </tr>



	<tr id="issetsyle2"
	style="DISPLAY: none"
	>
      <td align="right"  ><strong>网址：</strong></td>
      <td class="tl"><input name="adurl" type="text" class="Ainput"  value="<%=adurl%>" size="35" /></td>
    </tr>

 
   
 
   	<tr id="issetsyle3" 	style="DISPLAY: none"
>
      <td align="right"  ><strong>广告代码：</strong></td>
      <td class="tl"><textarea name="content" id="content" cols="90" rows="20"><%=content%></textarea>
	   </td>
    </tr>
     



   
		   <tr>
      <td height="25"  ><strong>启用时间限制：</strong></td>
      <td height="25"  class="tl">
	  <input    onClick=time(0)    <%If UnlockTime="0" Then echo "checked"%>  id="UnlockTime1" type="radio" name="UnlockTime" value="0">
        <label for="UnlockTime1">启用</label>
      <input    onClick=time(1) <%If UnlockTime="1" Then echo "checked"%>     id="UnlockTime2"  type="radio" name="UnlockTime" value="1"> 
     <label for="UnlockTime2">不启用</label></td>
    </tr>
	
	


	
	    <tr  id="times1"	>
      <td height="25" align="right"><strong>开始时间：</strong></td>
      <td height="25" class="tl"><input  class="Ainput"  size=30 name="StartTime" type="text" id="StartTime" value="<%=StartTime%>"  onClick="WdatePicker();" />
	   </td>
    </tr>

	
	    <tr id="times2"  >
      <td height="25" align="right"><strong>结束时间：</strong></td>
      <td height="25" class="tl"><input  class="Ainput"   size=30  name="EndTime" type="text" id="EndTime" value="<%=EndTime%>"  onClick="WdatePicker();"/>
	   </td>
    </tr>

 
    <tr>
      <td colspan="2" align="center" class="tl">
        <input type=button class="btn btn_primary" onclick=CheckForm() name=Submit value="  保存  " />
&nbsp;&nbsp;
<input class="btn btn_primary" type="reset" name="Submit2" value="  重置  ">
     </td>
    </tr></form>
  </table>
  
<%end sub 


sub saves()
		dim Rs,RsSql
 		 ID=ChkNumeric(fycms.S("ID"))
		 StartTime= fycms.S("StartTime")
		 EndTime= fycms.S("EndTime")
		 If IsDate(StartTime)=false Then StartTime=now
		 If IsDate(EndTime)=false Then EndTime=now
 				
 
		 IF fycms.S("title") = "" Then
			Call fycms.Alert("请输入广告名称!",""):Exit Sub
		 End if
		If Action="AddSave" Then 
			 
			 Set Rs = Server.CreateObject("adodb.recordset")
			  RsSql = "select * from ads_fy"
			  Rs.Open RsSql, Conn, 1, 3
			  Rs.AddNew
		 	  Rs("isset") = ChkNumeric(fycms.S("isset"))
		 	  Rs("Title") = fycms.S("Title")
		 	  Rs("adfile") = fycms.S("adfile")
		 	  Rs("adwidth") = ChkNumeric(fycms.S("adwidth"))
		 	  Rs("adheight") = ChkNumeric(fycms.S("adheight"))
		 	  Rs("adurl") = fycms.S("adurl")
		 	  Rs("UnlockTime") = ChkNumeric(fycms.S("UnlockTime"))
		 	  Rs("StartTime") = StartTime
		 	  Rs("EndTime") = EndTime
		 	  Rs("addtime") = now
		 	  Rs("Content") = fycms.S("Content")
			  Rs.Update
			  Rs.Close:Set Rs = Nothing			
			Call fycms.ActErr("操作成功","Sys_fy/ad/Index.asp","")
 		Else
			 Set Rs = Server.CreateObject("adodb.recordset")
			  RsSql = "select * from ads_fy Where ID="&ID
			  Rs.Open RsSql, Conn, 1, 3
		 	  Rs("isset") = ChkNumeric(fycms.S("isset"))
		 	  Rs("Title") = fycms.S("Title")
		 	  Rs("adfile") = fycms.S("adfile")
		 	  Rs("adwidth") = ChkNumeric(fycms.S("adwidth"))
		 	  Rs("adheight") = ChkNumeric(fycms.S("adheight"))
		 	  Rs("adurl") = fycms.S("adurl")
		 	  Rs("UnlockTime") = ChkNumeric(fycms.S("UnlockTime"))
		 	  Rs("StartTime") = StartTime
		 	  Rs("EndTime") = EndTime
		 	  Rs("Content") = fycms.S("Content")
			  Rs.Update
			  Rs.Close:Set Rs = Nothing			
			Call fycms.ActErr("操作成功","Sys_fy/ad/Index.asp","")
 		End If 
end sub
CloseConn %>
<script language = "JavaScript">
 function time(n){
	if (n == 0){
		times1.style.display='';
		times2.style.display='';
	}
	else{
		times1.style.display='none';
		times2.style.display='none';
	}
} 
 
function issets(n){
	if (n == "1"){
		issetsyle1.style.display='none';
		issetsyle2.style.display='';
		issetsyle3.style.display='none';
	}

	else if (n == "2"){
		issetsyle1.style.display='';
		issetsyle2.style.display='';
		issetsyle3.style.display='none';
	}

	else if (n == "3"){
		issetsyle1.style.display='';
		issetsyle2.style.display='none';
		issetsyle3.style.display='none';
	}
	else if (n == "4"){
		issetsyle1.style.display='none';
		issetsyle2.style.display='none';
		issetsyle3.style.display='';
 	}

	else{
		issetsyle1.style.display='';
		issetsyle2.style.display='';
		issetsyle3.style.display='';
	}
} 
 function CheckForm()
{ var form=document.form1;
   if (form.title.value=='')
    { alert("请输入广告名称!");   
	  form.title.focus();    
	   return false;
    }
	 
			
		form.Submit.value="正在提交数据,请稍等...";
		form.Submit.disabled=true;	
		form.Submit2.disabled=true;	
	    form.submit();
        return true;
}

function show(id)
{
	if(document.all(id).style.display=='none')
{
	document.all(id).style.display='block';
}
else
{
	document.all(id).style.display='none';
}
}

</script>
<script language="javascript">issets(<%=isset%>);</script>
<script language="javascript">time("<%=UnlockTime%>");</script>
</div>
</body>
</html>
