<%
    data_path="../../" 'ACC连接数据库路径，对SQL无效
 	numid="no"
	dir="no"
  %>
  <!--#include file="../../conn/conn.asp"-->
<!--#include file="../../inc/filesystem.asp"-->
 <!--#include file="../../inc/safe.asp"-->
 <!--#include file="../rolecheck.asp"-->


 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<LINK href="../css/style.css" rel=stylesheet type=text/css>
 <title></title>
 <style type="text/css">
<!--
.STYLE1 {
	color: #0099CC;
	font-weight: bold;
}
.STYLE3 {color: #CC4A44}
.STYLE4 {color: #CE4942}
.STYLE5 {
	color: #0033FF;
	font-weight: bold;
}
-->
 </style>
  <script language="javascript">
 function gook()
 {
 var i=confirm("你确定要删除吗？");
 if(i)
 {
 return true ;
 }
 else
 {
 return false;
 }
 }
 function isdeal()
 {
  var i=confirm("注意：此操作在一个月内只能进行一次并且必须(请确保本月竞价已经结束，审核工作已经结束才执行此操作！)------竞价成功(通过审核)的记录将保存到历史记录中，请注意竞价失败的记录将被删除，当前竞价数据将全部被清空,以备下次竞价使用！");
 if(i)
 {
 return true ;
 }
 else
 {
 return false;
 }
 }
 </script> <script language="javascript">
 function isshen()
 {
 var i=confirm("请先确定该竞价者已经支付费用！该操作只在进行竞价处理操作执行前是可逆的，一旦通过审核，将在竞价处理操作执行后被删除！");
 if(i)
 {
 return true ;
 }
 else
 {
 return false;
 }
 }
 </script>
  </head>
  <%
  '--删除记录----------------------------------------
  action=Replace_Text(request("action"))
  delid=Replace_Text(request("delid"))
  ratedeal=Replace_Text(request("ratedeal"))
  if action<>"" and delid<>"" then 
  conn.execute "delete from Websen_temp_price where id="&delid
   end if
   
   '--竞价处理-----------------------------------------------
  if ratedeal<>"" then
    '当前的竞价是否关闭
	set rsc=server.CreateObject("adodb.recordset")
	sqlc="select * from Websen_config_price"
	rsc.open sqlc,conn,1,1
	if not rsc.eof then 
	if rsc("isopen")=1 then 
	  response.Write("<script>alert('对不起!当前正在竞价阶段，无效的处理操作!');history.back(-1);</script>")
	  response.End()
	 else
	  '处理每个关键字已审核的(已付费)前三名的公司竞价信息从表Websen_temp_price到表Websen_history_price中
	 '(每个关键字的竞价只保留前三个按金额排)--------------------------------------
	 
	 set rso=server.CreateObject("adodb.recordset")
	 sqlo="select distinct(keywords)  from Websen_temp_price  "
	 rso.open sqlo,conn,1,1
	 if not rso.eof then
 	 do while not rso.eof 
 	 set rso1=server.CreateObject("adodb.recordset")
	 sqlo1="select top 3 * from Websen_temp_price where keywords='"&rso("keywords")&"' and  ispay=1 order by price desc "
	 rso1.open sqlo1,conn,1,1
	 if not rso1.eof then
	 i=1
	 do while not rso1.eof 
	 '取出前三条存入历史表中-----------------------------------
	 set rsto=server.CreateObject("adodb.recordset")
	 sqlto="select * from Websen_history_price"
	 rsto.open sqlto,conn,1,3
	 rsto.addnew 
	 rsto("keywords")=rso1("keywords")
	 rsto("gsid")=rso1("gsid")
	 rsto("price")=rso1("price")
	 rsto("addtime")=rso1("addtime")
	 rsto("begintime")=DateAdd("m", 1, now())
	 rsto.update
	 rsto.close
	 '----------------------------------------------------------
	 if i=3 then exit do
	 i=i+1
  	 rso1.movenext
	 loop
	 end if 
 	 rso.movenext
	 loop
	 end if
 	 
	 '---------------------------------------
 
	If Database_type=1 Then
     conn.execute "TRUNCATE table Websen_temp_price "
	 else
	 conn.execute "delete from Websen_temp_price"
	 end if
	 response.Write("<script >alert('操作完成！竞价成功的记录已经存储到历史记录中!');location.href='current.asp';</script>")
	 response.End()
 
	 end if
     end if
  end if
  '------------------------------------------------
  %>
  <body>
<table cellpadding="1" cellspacing="1" border="0" width="100%" class="tableBorder" align="center">
    <tr align="center">
      <th height="25" align="center"><span class="tableHeaderText"><strong>当前竞价数据管理</strong></span> </th>
    </tr>
	<tr><td align="left">&nbsp;<font  color="red">◆</font><a href="current.asp">所有记录</a>&nbsp;&nbsp;&nbsp;
 	操作提示：<font color="red">本系统针对每个关键字的竞价最多只保留前三名的成功记录！第三名以后的将全部删除！</font>
	</td></tr><form name="chu"   method="post" action="" onSubmit="return isdeal();"><tr><td height="30">
      &nbsp;&nbsp;<input type="submit" style="color:red"  name="ratedeal" value="      竞 价 处 理       "                 />
	</td></tr></form> 	
</table>
   <table cellpadding="0"   bordercolor="#EBF1FA" cellspacing="0" border="1" width="98%"  align="center">
     <tr ><td   >
  <table cellpadding="0"   bordercolor="#EBF1FA" cellspacing="0" border="0" width="100%"  align="center">
      <tr><td colspan="7" align="center" height="1" bgcolor="#D1D1D1"></td></tr>
         <tr height="25" bgcolor="#C6CFE7" style="color:#000000"><td width="28%"  >&nbsp;<a href="current.asp"><font color="red">竞价的关键词</font></a></td>
         <td width="32%"  >竞价公司</td>
         <td width="9%"  ><a href="current.asp?order_key=1"><font color="red">竞价金额</font></a></td>
         <td width="16%"  ><a href="current.asp?order_key=2"><font color="red">竞价时间</font></a></td>
         <td width="5%"><a href="current.asp?order_key=3"><font color="red">性质</font></a></td>
		 <td width="5%"> 状态</td>
         <td width="5%">操作</td>
         </tr>
		 <tr><td colspan="7" height="1"  bgcolor="#006699"></td></tr>

	 <%
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from Websen_temp_price  order by keywords "
	if Replace_Text(request("order_key"))<>"" then
     if Replace_Text(request("order_key"))="1" then
	 	sql="select * from Websen_temp_price order by price desc "
 	 elseif  Replace_Text(request("order_key"))="2"  then
 		sql="select * from Websen_temp_price order by addtime  desc"
	  elseif  Replace_Text(request("order_key"))="3"  then
 		sql="select * from Websen_temp_price where ishigh=1"
		else
	 	sql="select * from Websen_temp_price order by keywords "
	end if
   	end if
 	rs.open sql,conn,1,1
	msg_per_page=20'定义每页显示记录条数
	
	if not rs.eof then 
			
	%>
	<!--#include file="../../inc/headpage.asp"-->
	<%
	j=1
 
do while not rs.eof and rowcount > 0 
%>
	 <tr <%if j mod 2=0 then response.Write("bgcolor=#F7F7F7   onMouseOut=""this.style.backgroundColor='#F7F7F7'"" onMouseOver=""this.style.backgroundColor='#D7E3F3'""") else response.Write("bgcolor=#ffffff  onMouseOut=""this.style.backgroundColor='#ffffff'"" onMouseOver=""this.style.backgroundColor='#D7E3F3'""") end if%>  height="25"><td   >
&nbsp;<a href="keyword.asp?keyname=<%=rs("keywords")%>&keyid=<%=rs("id")%>"><%=rs("keywords")%></a>  </td> <td>
<%
set rsg=server.CreateObject("adodb.recordset")
sqlg="select  * from Websen_corporation  where id="&rs("gsid")
rsg.open sqlg,conn,1,1 
if not rsg.eof then 
%>
<a href="../vipgrade/edit.asp?id=<%=rsg("id")%>"><%=rsg("qymc")%></a>
<%
else
response.Write("不详")
end if
rsg.close
 %></td>

 <td><font color="red"><%=rs("price")%></font>&nbsp;<font color="#666666">元</font></td><td><font color="#666666"><%=rs("addtime")%></font></td> <td><%
 if rs("ishigh")=1 then 
 response.Write("<font color=red>一口价</font>") 
 end if
 %></td> <td>
 <%
		if rs("ispay")=1 then 
		%>
		<a href="checkkey.asp?keyid=<%=rs("id")%>&action=0" onClick="return isshen();"><font color="red">已审核</font></a>
		<%
		else
		%>
	 	<a href="checkkey.asp?keyid=<%=rs("id")%>&action=1" onClick="return isshen();">未审核</a>
 		<%
		end if
 	%>
  </td> <td><a href="current.asp?action=del&delid=<%=rs("id")%>" onClick="return gook();">删除</a></td>  </tr>
  <%
    j=j+1
 	rowcount=rowcount-1
	rs.movenext
 	loop
 	%>
	<tr><td colspan="7" align="center" ><%=listPages("current.asp?order_key="&Replace_Text(request("order_key"))&"")%></td></tr>
  <%
	rs.close
	end if
  %>
  
</table>
	 
	 
	 
	 </td>     </tr>
</table>
  
   
  
  
  
   
</body>
</html>
