<% Option Explicit %>
<!--#include file="../../FS_Inc/Const.asp" -->
<!--#include file="../../FS_Inc/Function.asp" -->
<!--#include file="../../FS_InterFace/MF_Function.asp" -->
<!--#include file="../../FS_Inc/Func_Page.asp" -->
<!--#include file="cls_sys.asp" -->
<%
Dim Conn,User_Conn
MF_Default_Conn
MF_Session_TF
if not MF_Check_Pop_TF("SD_List") then Err_Show

MF_User_Conn
Dim Req_List,Arr_Temp,IsContinue,Stract,NewsID,NewsSql,ObjNews,TS_Str_Sql,TS_Get_ID,TS_All_ClassID
Dim ArrID,DelI,p_Temp_RsCid,p_Temp_RsCName,i,p_Temp_RsNewsList
Dim page_size,page_no,page_total,record_all,PageNums,tmp_OrderId,PubType
Dim int_RPP,int_Start,int_showNumberLink_,str_nonLinkColor_,toF_,toP10_,toP1_,toN1_,toN10_,toL_,showMorePageGo_Type_,cPageNo

int_RPP=20 '设置每页显示数目
int_showNumberLink_=8 '数字导航显示数目
showMorePageGo_Type_ = 1 '是下拉菜单还是输入值跳转，当多次调用时只能选1
str_nonLinkColor_="#999999" '非热链接颜色
toF_="<font face=webdings title=""首页"">9</font>"  			'首页 
toP10_=" <font face=webdings title=""上十页"">7</font>"			'上十
toP1_=" <font face=webdings title=""上一页"">3</font>"			'上一
toN1_=" <font face=webdings title=""下一页"">4</font>"			'下一
toN10_=" <font face=webdings title=""下十页"">8</font>"			'下十
toL_="<font face=webdings title=""最后一页"">:</font>"
'Conn.execute("delete from FS_SD_News where ClassID is null")
Dim strShowErr
Stract = Request("act")
If Stract <> "" Then 
	NewsID = Request("id")
	If trim(NewsID)="" or isnull(trim(NewsID))  Then 
		strShowErr = "<li>选择记录</li>"
		Response.Redirect("../Error.asp?ErrCodes="&Server.URLEncode(strShowErr)&"&ErrorUrl=supply/news.asp")
		Response.end
	end if
	If InStr(NewsID,",")>0 Then 
		ArrID = Split(NewsID,",")
	else
		ArrID = Array(NewsID)
	End If 
	For DelI=0 To UBound(ArrID)
		If Stract = "del" Then 
			if not MF_Check_Pop_TF("SD003") then Err_Show
			Conn.execute("delete from FS_SD_news where id=" & CintStr(ArrID(DelI)))
		elseif Stract = "cancelaudit" then
			if not MF_Check_Pop_TF("SD004") then Err_Show
			Conn.execute("update FS_SD_news set ispass=0 where id=" & CintStr(ArrID(DelI)))
		elseif Stract = "audit" then
			if not MF_Check_Pop_TF("SD004") then Err_Show
			Conn.execute("update FS_SD_news set ispass=1 where id=" & CintStr(ArrID(DelI)))
			'------供求信息审核后扣除点数和金币   2006-12-29 by ken
			Dim SDAuditRs,UserIDSTR,MustAuditObj,MustAuditTF,MustPoint,MustMoney
			Set SDAuditRs = Conn.ExeCute("Select UserNumber From Fs_SD_News Where ID =" & CintStr(ArrID(DelI)))
			If Not SDAuditRs.Eof Then
				If SDAuditRs(0) <> "" And Not IsNull(SDAuditRs(0)) Then
					If Cstr(SDAuditRs(0)) <> "0" Then
						UserIDSTR = SDAuditRs(0)
					Else
						UserIDSTR = ""
					End If		
				Else
					UserIDSTR = ""
				End If
			Else
				UserIDSTR = ""
			End If
			SDAuditRs.Close : Set SDAuditRs = NOthing
			Set MustAuditObj = Conn.ExeCute("Select Top 1 PublicPoint,PublicMoney,isLock From FS_SD_Config Where ID > 0 Order By ID")
			If Not MustAuditObj.Eof Then
				MustPoint = MustAuditObj(0)
				MustMoney = MustAuditObj(1)
				MustAuditTF = MustAuditObj(2)
			Else
				MustPoint = 0
				MustMoney = 0
				MustAuditTF = 0
			End If
			MustAuditObj.Close : Set MustAuditObj = Nothing
			If MustAuditTF = 1 Then
				If UserIDSTR <> "" Then
					User_Conn.ExeCute("Update Fs_Me_Users Set Integral = Integral - "&CintStr(MustPoint)&",FS_Money = FS_Money - "&CintStr(MustMoney)&" Where UserNumber = '" & NoSqlHack(UserIDSTR) & "'")
				End If	
			End If	
			'--------------
		end if
	Next 
	strShowErr = "<li>操作成功</li>"
	Response.Redirect("../Success.asp?ErrCodes="&Server.URLEncode(strShowErr)&"&ErrorUrl=supply/news.asp")
	Response.end
End If 
dim str_pass,str_lock,tmp_valite,para_rs,tmp_valite_1,tmp_type
if Request.QueryString("ispass")="0" then
	str_pass =" and ispass=0"
elseif Request.QueryString("isPass")="1" then
	str_pass =" and ispass=1"
else
	str_pass =""
end if
if Request.QueryString("islock")="1" then
	str_lock =" and islock=1"
else
	str_lock =""
end if
if Request.QueryString("Valid")="1" then
	if G_IS_SQL_DB=1 then
		tmp_valite =  " and DateDiff(d,editTime,getdate())>ValidTime"
	else
		tmp_valite =  " and DateDiff('d',editTime,now)>ValidTime"
	end if
else
	tmp_valite = " "
end if
if Request.QueryString("OrderId")="1" then
	tmp_OrderId=" and orderid=1"
elseif Request.QueryString("OrderId")="2" then
	tmp_OrderId=" and orderid=2"
else
	tmp_OrderId=""
end if

tmp_type=Request.QueryString("PubType")
if tmp_type="0" then
	tmp_type=" and PubType=0"
elseif tmp_type="1" then
	tmp_type=" and PubType=1"
elseif tmp_type="2" then
	tmp_type=" and PubType=2"
elseif tmp_type="3" then
	tmp_type=" and PubType=3"
elseif tmp_type="4" then
	tmp_type=" and PubType=4"
else
	tmp_type=" "
end if
set para_rs=Conn.execute("select top 1 warnTime from FS_SD_Config")
if para_rs.eof then
	response.Write("找不到供求配置信息")
	response.end
	set para_rs=nothing
else
	if request.QueryString("usvalite")="1" then
		if G_IS_SQL_DB=1 then
			tmp_valite_1 =  " and DateDiff(d,editTime,getdate())>=(ValidTime-"&para_rs(0)&") and DateDiff(d,editTime,getdate())<ValidTime"
		else
			tmp_valite_1 =  " and DateDiff('d',editTime,now)>=(ValidTime-"&para_rs(0)&") and DateDiff('d',editTime,now)<ValidTime"
		end if
	else
		tmp_valite_1=""
	end if
	set para_rs=nothing
end if
NewsSql = "select  isLock,ID,pubtitle,UserNumber,AdminUserName,isPass,OrderID,ClassID,EditTime,ValidTime from FS_SD_News  where 1=1 "& str_pass &tmp_OrderId& tmp_valite & str_lock& tmp_valite_1 & tmp_type &" order by OrderID desc,EditTime desc,id desc"
Set ObjNews = Server.CreateObject(G_FS_RS)
ObjNews.open NewsSql,Conn,1,1
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript" src="../../FS_Inc/PublicJS.js"></script>
<script language="javascript" src="../../FS_Inc/prototype.js"></script>
<script language="javascript" src="../../FS_Inc/CheckJs.js"></script>
<title>信息管理</title>
</head>
<link href="../images/skin/Css_<%=Session("Admin_Style_Num")%>/<%=Session("Admin_Style_Num")%>.css" rel="stylesheet" type="text/css">
<body topmargin="2" leftmargin="2" >
<table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" class="table">
  <tr class="xingmu"> 
    <td class="xingmu">供求管理</td>
  </tr>
  <tr class="hback"> 
    <td class="hback"><a href="News.asp">首页</a>┆<a href="NewsAdd.asp"><strong>新建供求</strong></a>┆<a href="News.asp?ispass=1">已审核</a>┆<a href="News.asp?ispass=0">未审核</a>┆<a href="News.asp?islock=1">用户已锁定</a>┆<a href="News.asp?Valid=1">过期信息</a>┆<a href="News.asp?OrderId=1">推荐信息</a>┆<a href="News.asp?OrderId=2">置顶信息</a>┆<a href="News.asp?usvalite=1">即将过期的信息</a>┆<%tmp_type="":tmp_type=Request.QueryString("PubType")%><select name="PubType" id="PubType" onChange="javascript:ShowPub(this.value);">
          <option value="0" <% If tmp_type="0" Then Response.Write("selected")%> > 供 应 </option>
          <option value="1" <% If tmp_type="1" Then Response.Write("selected")%> > 求 购 </option>
          <option value="2" <% If tmp_type="2" Then Response.Write("selected")%> > 合 作 </option>
          <option value="3" <% If tmp_type="3" Then Response.Write("selected")%> > 代 理 </option>
          <option value="4" <% If tmp_type="4" Then Response.Write("selected")%> > 其 他 </option>
        </select></td>
  </tr>
</table>
<table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" class="table">
    <form name="myForm" method="post" action=""><tr> 
      <td width="31%" class="xingmu"> <div align="center">主题</div></td>
      <td width="15%" class="xingmu"> <div align="center">所属栏目</div></td>
      <td width="11%"  class="xingmu"> <div align="center">发布者</div></td>
      <td width="10%" class="xingmu"><div align="center">审核</div></td>
      <td width="27%"  class="xingmu"><div align="center">操作</div></td>
    </tr>
    <% 
if Not ObjNews.eof then 
	dim strpage,o_title
	strpage=request("page")
	'if trim(strpage)="" or len(strpage)=0 Or strpage<1 Then
	'	strpage="1"
	'end if
	ObjNews.PageSize=int_RPP
	cPageNo=NoSqlHack(Request.QueryString("Page"))
	If cPageNo="" Then cPageNo = 1
	If not isnumeric(cPageNo) Then cPageNo = 1
	cPageNo = Clng(cPageNo)
	If cPageNo<=0 Then cPageNo=1
	If cPageNo>ObjNews.PageCount Then cPageNo=ObjNews.PageCount 
	ObjNews.AbsolutePage=cPageNo
	for i=1 to ObjNews.PageSize
	if ObjNews.eof then exit For
	if ObjNews("OrderID")=1 then
		o_title="<span class=""tx"">[推荐]</span>"
	elseif ObjNews("OrderID")=2 then
		o_title="<span class=""tx"">[置顶]</span>"
	else
		o_title=" "
	end if
%>
    <tr onMouseOver=overColor(this) onMouseOut=outColor(this)> 
      <td height="26" class="hback"><a href="../../Supply/Supply.asp?id=<%=ObjNews("id")%>" target="_blank" title="过期时间:<%=datevalue(objNews("EditTime"))+objNews("ValidTime")%>,最后更新日期：<%=objNews("EditTime")%>"><%=o_title%><% = ObjNews("pubtitle") %></a></td>
      <td class="hback"><div align="center"> 
          <%
		  dim cl_rs
		  set cl_rs = Conn.execute("select GQ_ClassName From FS_SD_Class where ID="&CintStr(objNews("ClassID")))
		  response.Write cl_rs(0)
		  cl_rs.close:set cl_rs=nothing
		  %>
        </div></td>
		<%if ObjNews("UserNumber")="0" or isnull(ObjNews("UserNumber")) then%>
      <td class="hback"><div align="center">管理员：<%=ObjNews("AdminUserName")%></div></td>
      <%else%>
	  <td class="hback"><div align="center"><a href="../../<% = G_USER_DIR %>/ShowUser.asp?UserNumber=<%=ObjNews("UserNumber")%>" target="_blank"><%=GetFriendName(ObjNews("UserNumber"))%></a></div></td>
      <%end if%>
	  <td class="hback"><div align="center"> 
          <%
		  if ObjNews("islock") = 1 then
		  	Response.Write("用户已经锁定") 
		  else
		  	if ObjNews("isPass") = 1 then
				response.Write("已审核")
			else
				response.Write("<span class=""tx"">未审核</span>")
			end if
		 end if
		  %>
        </div></td>
      <td width="6%" class="hback"><div align="center"><a href="NewsEdit.asp?act=edit&id=<%=ObjNews("id")%>">修改</a>┆
	  <%if  ObjNews("islock") = 0 then%>
	  <a href="News.asp?act=audit&id=<%=ObjNews("id")%>">审核通过</a>
	  <%else%>
	  <span class="tx">用户锁定</span>
	  <%end if%>
	  ┆<a href="News.asp?act=cancelaudit&id=<%=ObjNews("id")%>">取消审核</a>┆<a href="News.asp?act=del&id=<%=ObjNews("id")%>" onClick="{if(confirm('确定清除您所选择的记录吗？')){return true;}return false;}">删除</a> 
          <input name="id" type="checkbox" id="id" value="<%=ObjNews("id")%>">
        </div></td>
    </tr>
    <%
		ObjNews.MoveNext
	Next
end if	
%>
    <tr class="hback">
      <td height="26" colspan="6" class="hback"><div align="right">
          <%
		response.Write "<p>"&  fPageCount(ObjNews,int_showNumberLink_,str_nonLinkColor_,toF_,toP10_,toP1_,toN1_,toN10_,toL_,showMorePageGo_Type_,cPageNo)
		%>
          <input type="checkbox" name="chkall" value="checkbox" onClick="CheckAll(this.form);">
          选中/取消所有 
          <input name="act" type="hidden" id="act">
          <input type="button" name="Submit4" value="批量审核" onClick="document.myForm.act.value='audit';{if(confirm('确定所选择的记录审核吗？')){this.document.myForm.submit();return true;}return false;}">
          <input type="button" name="Submit42" value="取消审核" onClick="document.myForm.act.value='cancelaudit';{if(confirm('确定所选择的记录取消审核吗？')){this.document.myForm.submit();return true;}return false;}">
          <input type="button" name="Submit" value="删除"  onClick="document.myForm.act.value='del';{if(confirm('确定清除您所选择的记录吗？')){this.document.myForm.submit();return true;}return false;}">
        </div></td>
    </tr>
</form>
  </table>
</td>
</tr>
</table>
<script language="JavaScript" type="text/JavaScript">
function CheckAll(form)  
  {  
  for (var i=0;i<form.elements.length;i++)  
    {  
    var e = myForm.elements[i];  
    if (e.name != 'chkall')  
       e.checked = myForm.chkall.checked;  
    }  
	}
function ShowPub(type)
{
	self.location='?PubType='+type;
}
</script>

</body>
</html>
<%
ObjNews.Close
Set ObjNews = Nothing
Conn.Close
Set Conn = Nothing
set User_Conn = nothing
%>





