<!--#include file="pysjzx_conn.asp"-->
<!--#include file="session.asp"-->
<html><head><title>管理租赁车</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<%

selectkey=trim(request(trim("selectkey")))
selectm=trim(request("selectm"))
action=request("action")

'-------------- 刷新 --------------
newid=request("newid")
if newid<>"" then
set rs=server.createobject("adodb.recordset") 
sql="select  adddate,attop,topadddate from lease where id="&newid
rs.open sql,conn,1,3
if rs("attop")= 1 then
rs("topadddate")=now()
else
rs("adddate")=now()
end if
rs.update
response.Redirect "managelease.asp?action="&action
end if

'-------------- 固顶 --------------
gdid=request("gdid")
if gdid<>"" then
set rs=server.createobject("adodb.recordset") 
sql="select adddate,attop,topadddate  from lease where id="&gdid
rs.open sql,conn,1,3
rs("attop")=1
rs("topadddate")=rs("adddate")
rs("adddate")="3000-1-1 1:1:1"
rs.update
response.Redirect "managelease.asp?action="&action
end if

'-------------- 解固 --------------
jgid=request("jgid")
if jgid<>"" then
set rs=server.createobject("adodb.recordset") 
sql="select adddate,top,topadddate from lease where id="&jgid
rs.open sql,conn,1,3
rs("attop")=0
rs("adddate")=rs("topadddate")
rs.update
response.Redirect "managelease.asp?action="&action
end if

'-------------- 通过 --------------
pass=request("pass")
if pass<>"" then
set rs=server.createobject("adodb.recordset") 
sql="select  estate from lease where id="&pass
rs.open sql,conn,1,3
rs("estate")=1
rs.update
response.Redirect "managelease.asp?action="&action
end if

'-------------- 等待 --------------
wait=request("wait")
if wait<>"" then
set rs=server.createobject("adodb.recordset") 
sql="select  estate from lease where id="&wait
rs.open sql,conn,1,3
rs("estate")=0
rs.update
response.Redirect "managelease.asp?action="&action
end if

'-------------- 未通过 --------------
fall=request("fall")
if fall<>"" then
set rs=server.createobject("adodb.recordset") 
sql="select  estate from lease where id="&fall
rs.open sql,conn,1,3
rs("estate")=-1
rs.update
response.Redirect "managelease.asp?action="&action
end if

'-------------- 推荐 --------------
commend=request("commend")
if commend<>"" then
set rs=server.createobject("adodb.recordset") 
sql="select commend  from lease where id="&commend
rs.open sql,conn,1,3
rs("commend")=1
rs.update
response.Redirect "managelease.asp?action="&action
end if

'-------------- 取消推荐 --------------
notcommend=request("notcommend")
if notcommend<>"" then
set rs=server.createobject("adodb.recordset") 
sql="select commend from lease where id="&notcommend
rs.open sql,conn,1,3
rs("commend")=0
rs.update
response.Redirect "managelease.asp?action="&action
end if

'-------------- 保存固顶排序 --------------
if request("submit")="保存固顶排序" then
    for i=1 to request.form("id").count
	id=replace(request.form("id")(i),"'","")
	toporder=replace(request.form("toporder")(i),"'","")
	toporder2=-toporder
	gudingdate="3000-1-1 1:1:1"
	dd=DateAdd("h",toporder2,gudingdate)
conn.execute("update lease set toporder="&toporder&" ,adddate='"&dd&"' where id="&id)
next
end if

'-------------- 审核 --------------
if request("submit")="审核" then
selectid=request("selectid")
if selectid<>"" then
conn.execute "update lease set estate=1 where id in ("&selectid&")"
response.Redirect "managelease.asp?action="&action
response.End
end if
end if

'-------------- 等待 --------------
if request("submit")="等待" then
selectid=request("selectid")
if selectid<>"" then
conn.execute "update lease set estate=0 where id in ("&selectid&")"
response.Redirect "managelease.asp?action="&action
response.End
end if
end if

'-------------- 未通过 --------------
if request("submit")="未通过" then
selectid=request("selectid")
if selectid<>"" then
conn.execute "update lease set estate=-1 where id in ("&selectid&")"
response.Redirect "managelease.asp?action="&action
response.End
end if
end if

'-------------- 推荐 --------------
if request("submit")="推荐" then
selectid=request("selectid")
if selectid<>"" then
conn.execute "update lease set commend=1 where id in ("&selectid&")"
response.Redirect "managelease.asp?action="&action
response.End
end if
end if

'-------------- 取消推荐 --------------
if request("submit")="取消推荐" then
selectid=request("selectid")
if selectid<>"" then
conn.execute "update lease set commend=0 where id in ("&selectid&")"
response.Redirect "managelease.asp?action="&action
response.End
end if
end if

'-------------- 删除 --------------
if request("submit")="删除" then
selectid=request("selectid")
if selectid<>"" then
conn.execute "delete from lease where id in ("&selectid&")"
response.Redirect "managelease.asp?action="&action
response.End
end if
end if


if selectkey="" then
selectkey=request.QueryString("selectkey")
end if
if selectkey="请输入关键字" then
selectkey=""
end if
%>
<SCRIPT language=javaScript>
<!--
function mOvr(src,clrOver){ 
	if (!src.contains(event.fromElement)) { 
		src.bgColor = clrOver; 
	}
}
function mOut(src,clrIn)  { 
	if (!src.contains(event.toElement)) { 
		src.bgColor = clrIn; 
	}
} 
//-->
</SCRIPT>
<script>
function IsDigit()
{
  return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
</script>
<div align="center">
<table cellpadding="3" cellspacing="1" border="1" width="100%" class="tableBorder" style="border-collapse: collapse" bordercolor="#C0C0C0">
  <tr align="center"> 
    <td  class="forumRowHighlight" width=25% bgcolor="#F7F7F7"> <a href="managelease.asp?action=all"><%if action="all" then %><font  color="#FF0000"><% end if%>所有</font></a>
    <%
    set rs=server.createobject("adodb.recordset") 
    	rs.open "select * from [lease] ",conn,1,1
    	response.write rs.recordcount
    	rs.close
    %>
    </td>
    <td  class="forumRowHighlight"  width=25% bgcolor="#F7F7F7"><a href="managelease.asp?action=pass"><%if action="pass" then %><font  color="#FF0000"><% end if%>通过审核</font></a>
        <%
    set rs=server.createobject("adodb.recordset") 
    	rs.open "select * from [lease] where estate=1 ",conn,1,1
    	response.write rs.recordcount
    	rs.close
    %>
    </td>
    <td  class="forumRowHighlight"  width=25% bgcolor="#F7F7F7"><a href="managelease.asp?action=wait"><%if action="wait" then %><font  color="#FF0000"><% end if%>待审核</font></a>
        <%
    set rs=server.createobject("adodb.recordset") 
    	rs.open "select * from [lease] where estate=0",conn,1,1
    	response.write rs.recordcount
    	rs.close
    %></td>
    <td  class="forumRowHighlight"  width=25% bgcolor="#F7F7F7"><a href="managelease.asp?action=fall"><%if action="fall" then %><font  color="#FF0000"><% end if%>未通过审核</font></a>
     <%
    set rs=server.createobject("adodb.recordset") 
    	rs.open "select * from [lease] where estate=-1",conn,1,1
    	response.write rs.recordcount
    	rs.close
    %>
    </td>
  </tr>
</table>
</div>
<table border="0" width="100%">
	<tr>
		<td>
		<p align="center">注:<font color="#FF0000">红色</font>为固顶信息 
		<font color="#008080">青色</font>为高级会员发布信息</td>
	</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr> 
<form name="form1" method="post" action="">
 <td  height="100"> 
				<%'开始分页
				Const MaxPerPage=20
   				dim totalPut   
   				dim CurrentPage
   				dim TotalPages
   				dim j
   				dim sql
    				if Not isempty(request("page")) then
      				currentPage=Cint(request("page"))
   				else
      				currentPage=1
   				end if 
			set rs=server.CreateObject("adodb.recordset")
			select case selectm
			case ""
           				  select case action
		  case "all"
		 	rs.open "select * from [lease] order by adddate desc ",conn,1,1
		  case "pass"
		 	rs.open "select * from [lease] where estate=1 order by adddate desc ",conn,1,1
		  case "wait"
		 	rs.open "select * from [lease] where estate=0 order by adddate desc ",conn,1,1
		 	 case "fall"
		 	rs.open "select * from [lease] where estate=-1 order by adddate desc ",conn,1,1
		  end select		    
		    case "id"
			if selectkey="" then
			selectkey=0
			end if
			rs.open "select * from lease where id="&selectkey&" order by adddate desc",conn,1,1
			case "model"
			rs.open "select * from lease where model like '%"&selectkey&"%' order by adddate desc",conn,1,1
					  	end select
		   	if err.number<>0 then
				response.write "数据库中无数据"
				end if


	  				totalPut=rs.recordcount

      				if currentpage<1 then
          				currentpage=1
      				end if

      				if (currentpage-1)*MaxPerPage>totalput then
	   					if (totalPut mod MaxPerPage)=0 then
	     					currentpage= totalPut \ MaxPerPage
	   					else
	      					currentpage= totalPut \ MaxPerPage + 1
	   					end if
      				end if

       				if currentPage=1 then
            			showContent
            			showpage totalput,MaxPerPage,"managelease.asp"
       				else
          				if (currentPage-1)*MaxPerPage<totalPut then
            				rs.move  (currentPage-1)*MaxPerPage
            			
            				showContent
             				showpage totalput,MaxPerPage,"managelease.asp"
        				else
	        				currentPage=1
           					showContent
           					showpage totalput,MaxPerPage,"managelease.asp"
	      				end if
	   				end if
   				

   				sub showContent

	   			i=0%>

				<div align="center">

<table class="tableBorder" width="100%" border="1" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF" bordercolor="#C0C0C0" style="border-collapse: collapse">
<tr> 
<td colspan="11" bgcolor="#E8F1FF" >
<p align="center">管理租赁车</td>
</tr>
<tr bgcolor="#E8F1FF"> 
 <td class="forumRowHighlight"  width="4%" align="center" bgcolor="#F7F7F7">序号</td>
 <td class="forumRowHighlight"  width="18%" align="center" bgcolor="#F7F7F7">
	<span lang="zh-cn">车型</span></td>
 <td class="forumRowHighlight"  width="4%" align="center" bgcolor="#F7F7F7">照片</td>
 <td class="forumRowHighlight"  width="10%" align="center" bgcolor="#F7F7F7">
	<span lang="zh-cn">发布</span>时间</td>
 <td class="forumRowHighlight"  width="12%" align="center" bgcolor="#F7F7F7">发布者</td>
 <td class="forumRowHighlight"  width="13%" align="center" bgcolor="#F7F7F7">审核状态</td>
 <td class="forumRowHighlight"  width="5%" align="center" bgcolor="#F7F7F7">
	<span lang="zh-cn">刷新</span></td>
 <td class="forumRowHighlight"  width="7%" align="center" bgcolor="#F7F7F7">固顶</td>
 <td class="forumRowHighlight"  width="4%" align="center" bgcolor="#F7F7F7">
	<span lang="zh-cn">排序</span></td>
 <td class="forumRowHighlight"  width="10%" align="center" bgcolor="#F7F7F7">
	<span lang="zh-cn">推荐</span></td>
 <td class="forumRowHighlight"  width="5%" align="center" bgcolor="#F7F7F7">选择</td>
</tr>
<%
  				if  rs.eof and rs.bof then
  				%>
  				<tr bgcolor="#E8F1FF"> 
 <td class="forumRowHighlight"  height="30" colspan="11" align="right" bgcolor="#F7F7F7">
<p align="center">暂无信息</a></td>
</tr>

  				<%
  				else
do while not rs.eof%>
<tr bgColor="#f7f7f7" onmouseout="mOut(this,'#F7F7F7');" onmouseover="mOvr(this,'#FFD28E');"> 
 <td class="forumRowHighlight"  align="center" ><a href=editlease.asp?id=<%=rs("id")%>><%=rs("id")%></a></td>
 <td class="forumRowHighlight"   STYLE='PADDING-LEFT: 10px' > <a href=editlease.asp?id=<%=rs("id")%>> 
             
			
	<%
	if rs("attop")=1 then
	response.write "<font color='#FF0000'>"
	end if	
		if rs("attop")=2 then
	response.write "<font color='#008080'>"
	end if	
 response.write rs("model")
  
  %></font>
</a></td>
 <td class="forumRowHighlight"   ><p align="center"><%if rs("pic") <>"" then%><a href="../<%=rs("pic")%>"  target=_blank>有</a><%else%>无<%end if%></td>
 <td class="forumRowHighlight"  align="center" > <%if rs("attop")=1 then%>
				<%=right(year(rs("topadddate")),2)%>-<%=right("0"&month(rs("topadddate")),2)%>-<%=right("0"&day(rs("topadddate")),2)%>
				<%elseif rs("attop")=2 then%>
				<%else%>
	<%=right(year(rs("adddate")),2)%>-<%=right("0"&month(rs("adddate")),2)%>-<%=right("0"&day(rs("adddate")),2)%>
	<%end if%></td>
 <td class="forumRowHighlight"  align="center" >
<%
 color=""
   if rs("username") <>"" then
				set rs4=server.createobject("adodb.recordset")
sql4="select company,username,userid,sort,reglx,linkname from pysjzx_user  where username='"&rs("username")&"'"
rs4.open sql4,conn,1,1
if not rs4.eof then
if rs4("reglx")=2 then
color="<font color='#008080'>"
end if
if rs4("sort")=2 then
response.write "<a href=listcompany.asp?id="&rs4("userid")&" target=_blank>"&color&rs4("company")&"</a>"
end if
if rs4("sort")=1 then
response.write "<a href=listuser.asp?id="&rs4("userid")&" target=_blank>"&color&rs4("linkname")&"</a>"
end if
rs4.close
else
response.write "该经销商已删除"
end if
else
response.write "<font color='#ff0000'>本站发布</font>"
end if
%></td>
 <td class="forumRowHighlight"  align="center" >
     <% if rs("estate")=1 then
 %>
<font color="#FF0000">通过</font>&nbsp;<a href="managelease.asp?action=<%=action%>&wait=<%=rs("id")%>">等待</a>&nbsp;<a href="managelease.asp?action=<%=action%>&fall=<%=rs("id")%>">未通过</a>
 <%
 end if
 if rs("estate")=0 then
%>
<a href="managelease.asp?action=<%=action%>&pass=<%=rs("id")%>">通过</a>&nbsp;<font color="#FF0000">等待</font>&nbsp;<a href="managelease.asp?action=<%=action%>&fall=<%=rs("id")%>">未通过</a>
<%
 end if
 if rs("estate")=-1 then
%>
<a href="managelease.asp?action=<%=action%>&pass=<%=rs("id")%>">通过</a>&nbsp;<a href="managelease.asp?action=<%=action%>&wait=<%=rs("id")%>">等待</a>&nbsp;<font color="#FF0000">未通过</font>
<%
 end if

 %> 　 　</td>
 <td class="forumRowHighlight"  align="center" ><a href="managelease.asp?action=<%=action%>&newid=<%=rs("id")%>">刷新</a> </td>
 <td class="forumRowHighlight"  align="center" > <%if rs("attop")=1 then%><font color="#FF0000">固顶</font> <a href="managelease.asp?action=<%=action%>&jgid=<%=rs("id")%>">解固</font></a><%end if%><%if rs("attop")=0 then%><a href="managelease.asp?action=<%=action%>&gdid=<%=rs("id")%>">固顶</a><span lang="zh-cn"> 
	<font color="#FF0000">解固</font><%end if%></span></td>
 <td class="forumRowHighlight"  align="center" ><%if rs("attop")=1 then%><input type="hidden" name="id" value="<%=rs("id")%>"><input class=text type="text" name="toporder" size="2" value="<%=rs("toporder")%>" ONKEYPRESS="event.returnValue=IsDigit();" ><%end if%></td>
 <td class="forumRowHighlight"  align="center" ><%if rs("commend")=1 then%><font color="#FF0000">推荐</font> <a href="managelease.asp?action=<%=action%>&notcommend=<%=rs("id")%>">取消推荐</a><%end if%>
 <%if rs("commend")=0 then%><a href="managelease.asp?action=<%=action%>&commend=<%=rs("id")%>">推荐</a> <font color="#FF0000">取消推荐</font><%end if%></td>
 <td class="forumRowHighlight"  align="center" >
<input name="selectid" type="checkbox" id="selectid" value="<%=rs("id")%>" >
</td></tr>
          <%i=i+1
		if i>=MaxPerPage then Exit Do
		rs.movenext
		loop
		rs.close
		set rs=nothing
		   	end if
		%>
<tr bgcolor="#E8F1FF"> 
 <td class="forumRowHighlight"  height="30" colspan="11" align="right" bgcolor="#F7F7F7">
<p align="center">
<input type="submit" name="Submit" class=go-wenbenkuang value="保存固顶排序" onClick="return test();"></td>
</tr>
<tr bgcolor="#E8F1FF"> 
 <td class="forumRowHighlight"  height="30" colspan="11" align="right" bgcolor="#F7F7F7">
&nbsp;全选 
<input type="checkbox" name="checkbox" value="Check All" onClick="mm()">
<input type="submit" name="Submit" class=go-wenbenkuang value="审核" onClick="return pass();">
	<input type="submit" name="Submit" class=go-wenbenkuang value="等待" onClick="return wait();">
	<input type="submit" name="Submit" class=go-wenbenkuang value="未通过" onClick="return fall();">&nbsp;&nbsp;
<input type="submit" name="Submit" class=go-wenbenkuang value="推荐" onClick="return commend();">
<input type="submit" name="Submit" class=go-wenbenkuang value="取消推荐" onClick="return notcommend();">&nbsp;&nbsp;
<input type="submit" name="Submit" class=go-wenbenkuang value="删除" onClick="return del();">
&nbsp;</td>
</tr>
</table>
				</div>
				<%  
				End Sub   
  
				Function showpage(totalnumber,maxperpage,filename)  
  				Dim n
  				
				If totalnumber Mod maxperpage=0 Then  
					n= totalnumber \ maxperpage  
				Else
					n= totalnumber \ maxperpage+1  
				End If
				
				Response.Write "<p align='center' class='contents'> "  
				If CurrentPage<2 Then  
					Response.Write "<font class='contents'>首页 上一页</font> "  
				Else  
					Response.Write "<a href="&filename&"?page=1&selectm="&selectm&"&selectkey="&selectkey&"action="&action&" class='contents'>首页</a> "  
					Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&selectm="&selectm&"&selectkey="&selectkey&"action="&action&" class='contents'>上一页</a> "  
				End If
				
				If n-currentpage<1 Then  
					Response.Write "<font class='contents'>下一页 尾页</font>"  
				Else  
					Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&selectm="&selectm&"&selectkey="&selectkey&"action="&action&" class='contents'>"  
					Response.Write "下一页</a> <a href="&filename&"?page="&n&"&selectm="&selectm&"&selectkey="&selectkey&"action="&action&" class='contents'>尾页</a>"  
				End If  
					Response.Write "<font class='contents'> 页次：</font><font class='contents'>"&CurrentPage&"</font><font class='contents'>/"&n&"页</font> "  
					Response.Write "<font class='contents'> 共有"&totalnumber&"条信息 " 
					Response.Write "<font class='contents'>转到：</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="&currentpage&">"  
				End Function  
			%>
<table width="12" height="7" border="0" cellpadding="0" cellspacing="0">
<tr> 
 <td class="forumRowHighlight"  height=7></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<div align="center">
<table class="tableBorder" width="100%" border="1" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF" style="border-collapse: collapse" bordercolor="#C0C0C0">
<tr>
<td bgcolor="#E8F1FF" >
<p align="center">查询租赁车</span></td>
</tr>
<tr bgcolor="#E8F1FF"> 
<form name="form2" method="post" action="">
 <td class="forumRowHighlight" bgcolor="#F7F7F7"  > 
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr> 
 <td class="forumRowHighlight"  width="35%" align="center">
<input name="selectkey" type="text" id="selectkey" class=wenbenkuang onFocus="this.value=''" value="请输入关键字">
</td>
 <td class="forumRowHighlight"  width="45%" align="center"> 
 <input type="hidden" name="action" value="<%=action%>">
<select name="selectm" class=wenbenkuang  id="selectm">
<option value="model">按车型</option>
<option value="id">按序号</option>
</select>
</td>
 <td class="forumRowHighlight"  width="20%" height="30" align="center">
<input type="submit" name="Submit2" class=go-wenbenkuang value="查 询">
</td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</div>
</body>
</html>
<script>
function pass()
{
  if(!confirm('确认批量审核,通过吗？')) return false;
}
</script>

<script>
function wait()
{
  if(!confirm('确认批量审核,等待吗？')) return false;
}
</script>

<script>
function fall()
{
  if(!confirm('确认批量审核,不通过吗？')) return false;
}
</script>

<script>
function commend()
{
  if(!confirm('确认批量推荐吗？')) return false;
}
</script>

<script>
function notcommend()
{
  if(!confirm('确认批量取消推荐吗？')) return false;
}
</script>

<script>
function del()
{
  if(!confirm('确认删除吗？')) return false;
}
</script>

<script language=javascript>
function mm()
{
   var a = document.getElementsByTagName("input");
   if(a[0].checked==true){
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = false;
   }
   else
   {
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = true;
   }
}
</script> 
  