<html xmlns="http://www.w3.org/1999/xhtml">
<!--#include file="../Inc/Conn.asp" -->
<!--#include file="../Inc/SK.Session.asp" -->
<!--#include file="../Inc/SK.Funtion.asp" -->
<!--#include file="../Inc/SK.PageClass.asp" -->
<%if Not (Getconfig("SK_Finance")="0" AND (Session("Manager")="1" OR JudgePopedomTF(Session("UserName"),"SK700000000"))) then Call ReturnError()%>
<%
Set Page = new MyPages				'创建对象
Set Page.Conn = conn				'得到数据库连接对象
With Page
if Cint(F("PNum"))="" then
.PageSize=20		             '每页记录条数
else
.PageSize=Cint(F("PNum"))		'每页记录条数
end if
.PageParm = "P"					'页参数
'.PageIndex = 10				'当前页，可选参数，一般是生成静态时需要
.Database = "mssql"				'数据库类型,AC为access,MSSQL为sqlserver2000存储过程版,MYSQL为mysql,PGSQL为PostGreSql
.Table="SK_ProcureOrders INNER JOIN SK_SystemUsers ON SK_ProcureOrders.SK_SalesID=SK_SystemUsers.UsersID INNER JOIN SK_ProcureVend ON SK_ProcureOrders.SK_VendID=SK_ProcureVend.VendID"				'表名
.Pkey="OrdersID"						'主键
.Field="SK_ProcureOrders.OrdersID,SK_ProcureOrders.SK_Di,SK_ProcureOrders.SK_VendID,SK_ProcureOrders.SK_OrdersTitle,SK_ProcureOrders.SK_OrdersNo,SK_ProcureOrders.SK_Fettle,SK_ProcureOrders.SK_ShUID,SK_ProcureOrders.SK_ShFeet,SK_ProcureOrders.SK_ShContent,SK_ProcureOrders.SK_ShTime,SK_ProcureOrders.SK_Currency,SK_ProcureOrders.SK_SalesID,SK_ProcureOrders.SK_Atime"	'字段

'//搜索关键字开始
Stime=F("STime")&" 00:00:00"
Etime=F("ETime")&" 23:59:59"

if F("AA")="1" AND F("Akey")<>"" then srt1=" AND (SK_ProcureVend.SK_Wname Like '%"&F("Akey")&"%' OR SK_ProcureVend.SK_Jname Like '%"&F("Akey")&"%')"
if F("AA")="2" AND F("Akey")<>"" then srt1=" AND (SK_ProcureOrders.SK_OrdersNo Like '%"&F("Akey")&"%' OR SK_ProcureOrders.SK_OrdersTitle Like '%"&F("Akey")&"%')"
if F("AA")="3" AND F("Akey")<>"" then srt1=" AND SK_ProcureOrders.SK_Content Like '%"&F("Akey")&"%'"
if F("AA")="4" AND F("Akey")<>"" then srt1=" AND SK_SystemUsers.SK_Oname Like '%"&F("Akey")&"%'"
if F("Di")<>"" then srt2=" AND SK_ProcureOrders.SK_Di="&F("Di")&""
if F("Fettle")<>"" then srt3=" AND SK_ProcureOrders.SK_Fettle="&F("Fettle")&""
if F("Currency")<>"" then srt4=" AND SK_ProcureOrders.SK_Currency="&F("Currency")&""
if F("STime")<>"" AND F("ETime")<>"" then srt5=" AND SK_ProcureOrders.SK_Atime Between '"&Stime&"' AND '"&Etime&"'"
if F("Sh")<>"" then srt6=" AND SK_ProcureOrders.SK_ShFeet="&F("Sh")&""
'//搜索关键字结束

'//权限判断开始
.Condition="SK_ProcureOrders.SK_Del=0 AND SK_ProcureOrders.SK_SalesID<>0 AND SK_ShFeet=2"&srt1&""&srt2&""&srt3&""&srt4&""&srt5&""&srt6&""
'//权限判断结束

'//指定排序条件开始
.OrderBy="OrdersID Desc"

if F("BB")="0" AND F("PX")="1" then
.OrderBy="SK_ProcureOrders.SK_OrdersNo Asc"
elseif F("BB")="0" AND F("PX")="2" then
.OrderBy="SK_ProcureOrders.SK_OrdersNo Desc"
end if

if F("BB")="1" AND F("PX")="1" then
.OrderBy="SK_ProcureOrders.SK_OrdersTitle Asc"
elseif F("BB")="1" AND F("PX")="2" then
.OrderBy="SK_ProcureOrders.SK_OrdersTitle Desc"
end if

if F("BB")="2" AND F("PX")="1" then
.OrderBy="SK_ProcureOrders.SK_Atime Asc"
elseif F("BB")="2" AND F("PX")="2" then
.OrderBy="SK_ProcureOrders.SK_Atime Desc"
end if

if F("BB")="3" AND F("PX")="1" then
.OrderBy="SK_SystemUsers.SK_Oname Asc"
elseif F("BB")="3" AND F("PX")="2" then
.OrderBy="SK_SystemUsers.SK_Oname Desc"
end if

'//指定排序条件结束

.RecordCount = 0	'总记录数，可以外部赋值，0不保存（适合搜索），-1存为session，-2存为cookies，-3存为applacation
.NumericJump = 3 '数字上下页个数，可选参数，默认为3，负数为跳转个数，0为显示所有
.Template = "总记录数：{$RecordCount} 总页数：{$PageCount} 每页记录数：{$PageSize} 当前页数：{$PageIndex} {$FirstPage} {$PreviousPage} {$NumericPage} {$NextPage} {$LastPage} {$InputPage} {$SelectPage}" '整体模板，可选参数，有默认值
.FirstPage = "首页" '可选参数，有默认值
.PreviousPage = "上一页" '可选参数，有默认值
.NextPage = "下一页" '可选参数，有默认值
.LastPage = "尾页" '可选参数，有默认值
.NumericPage = " {$PageNum} " '数字分页部分模板，可选参数，有默认值
End With
rs = Page.ResultSet() '记录集
rc = Page.RowCount() '可选，输出总记录数
nav = Page.Nav() '分页样式
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>选择采购订单</title>
<META http-equiv=Page-Enter content=SKCRM>
<META http-equiv=Page-Exit content=SKCRM>
<META content="MSHTML 6.00.3790.2858" name=GENERATOR>
<LINK href="../images/style.css" type=text/css rel=stylesheet>
<script type="text/javascript" src="../Inc/Check.js"></script>
<script type="text/javascript" src="../Inc/Calendar.js"></script>
<script>
function AdSearch(t_id,b_id){
	var targetTR =eval("document.all.followTR" + t_id);
	var targetDiv =eval("document.all.follow" + t_id);
	
	if ("object"==typeof(targetTR)){
		if (targetDiv.style.display!='block'){
			targetDiv.style.display="block";
			
		}else{
			targetDiv.style.display="none";
		}
	}
}

function OpenDetails(de_id,ta_id){
	var taTd =eval("document.all.DetailsTD" + de_id);
	var taDiv =eval("document.all.Details" + de_id);
	
	if ("object"==typeof(taTd)){
		if (taDiv.style.display!='block'){
			taDiv.style.display="block";
			
		}else{
			taDiv.style.display="none";
		}
	}
}

function CreateReturnValue(closeWindow,i)
{
var Vend=window.opener.document.getElementById("S_Vend");
var VendID=window.opener.document.getElementById("S_VendID");
var Orders=window.opener.document.getElementById("S_Orders");
var OrdersID=window.opener.document.getElementById("S_OrdersID");
    Vend.value=document.getElementById('MyList').rows[i].cells[2].innerHTML;
    VendID.value=document.getElementById('MyList').rows[i].cells[1].innerHTML;
    Orders.value=document.getElementById('MyList').rows[i].cells[3].innerHTML;
	OrdersID.value=document.getElementById('MyList').rows[i].cells[0].innerHTML;
    if (closeWindow){
                     window.opener=null;
                     window.close();
                     }
}
</script>
<style type="text/css">
<!--
body {
margin: 5px 0px 5px 0px;
overflow-x:hidden;
overflow-y:auto;
}
-->
</style>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<TBODY>
  <tr>
    <td class="SK_Td_Top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12" height="25"><img src="../images/tab_03.gif" width="12" height="25" /></td>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="46%" valign="middle">选择采购订单</td>
<td width="54%"><table border="0" align="right" cellpadding="0" cellspacing="0">
 <tr>
 <td>
</td>
 </tr>
</table></td>
</tr>
</table></td>
        <td width="16"><img src="../images/tab_07.gif" width="16" height="25" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form method="Get">
<tr>
<td background="../images/tab_12.gif"></td>
<td>
<select name="AA" size="1">
<option value="1" <%if RQ("AA")=1 OR RQ("AA")="" then Response.Write("selected=""selected""")%>>供应厂商</option>
<option value="2" <%if RQ("AA")=2 then Response.Write("selected=""selected""")%>>主题编号</option>
<option value="3" <%if RQ("AA")=3 then Response.Write("selected=""selected""")%>>采购备注</option>
<option value="5" <%if RQ("AA")=4 then Response.Write("selected=""selected""")%>>采购人员</option>
</select> 
<input name="Akey" type="text" value="<%=F("Akey")%>" size="20">
 排序
<select name="BB" size="1">
<option value="0" <%if RQ("BB")=0 OR RQ("BB")="" then Response.Write("selected=""selected""")%>>订单编号</option>
<option value="1" <%if RQ("BB")=1 then Response.Write("selected=""selected""")%>>采购主题</option>
<option value="2" <%if RQ("BB")=2 then Response.Write("selected=""selected""")%>>采购日期</option>
<option value="3" <%if RQ("BB")=3 then Response.Write("selected=""selected""")%>>采购人员</option>
</select>
<select name="PX" size="1">
<option value="1" <%if RQ("PX")=1 then Response.Write("selected=""selected""")%>> 升序</option>
<option value="2" <%if RQ("PX")=2 then Response.Write("selected=""selected""")%>> 降序</option>
</select>
 每页显示
<select name="Pnum" size="1">
<option value="20" <%if RQ("Pnum")=20 then Response.Write("selected=""selected""")%>>20</option>
<option value="25" <%if RQ("Pnum")=25 then Response.Write("selected=""selected""")%>>25</option>
<option value="30" <%if RQ("Pnum")=30 then Response.Write("selected=""selected""")%>>30</option>
<option value="40" <%if RQ("Pnum")=40 then Response.Write("selected=""selected""")%>>40</option>
<option value="50" <%if RQ("Pnum")=50 then Response.Write("selected=""selected""")%>>50</option>
<option value="60" <%if RQ("Pnum")=60 then Response.Write("selected=""selected""")%>>60</option>
<option value="80" <%if RQ("Pnum")=80 then Response.Write("selected=""selected""")%>>80</option>
<option value="100" <%if RQ("Pnum")=100 then Response.Write("selected=""selected""")%>>100</option>
<option value="120" <%if RQ("Pnum")=120 then Response.Write("selected=""selected""")%>>120</option>
<option value="150" <%if RQ("Pnum")=150 then Response.Write("selected=""selected""")%>>150</option>
<option value="200" <%if RQ("Pnum")=200 then Response.Write("selected=""selected""")%>>200</option>
<option value="300" <%if RQ("Pnum")=300 then Response.Write("selected=""selected""")%>>300</option>
<option value="400" <%if RQ("Pnum")=400 then Response.Write("selected=""selected""")%>>400</option>
<option value="500" <%if RQ("Pnum")=500 then Response.Write("selected=""selected""")%>>500</option>
<option value="600" <%if RQ("Pnum")=600 then Response.Write("selected=""selected""")%>>600</option>
<option value="800" <%if RQ("Pnum")=800 then Response.Write("selected=""selected""")%>>800</option>
<option value="1000" <%if RQ("Pnum")=1000 then Response.Write("selected=""selected""")%>>1000</option>
<option value="2000" <%if RQ("Pnum")=2000 then Response.Write("selected=""selected""")%>>2000</option>
<option value="5000" <%if RQ("Pnum")=5000 then Response.Write("selected=""selected""")%>>5000</option>
<option value="10000" <%if RQ("Pnum")=10000 then Response.Write("selected=""selected""")%>>10000</option>
</select>
<input type="submit" name="go" value="查询" class="button1" />  
<span id="followTR1" style="CURSOR: hand" onClick="AdSearch(1,5)">高级查询</span>
</td>
<td background="../images/tab_15.gif"></td>
</tr>
<tr style="display:none" id="follow1">
<td background="../images/tab_12.gif"></td>
<td><select name="Di">
<option value="" <%if RQ("Di")="0" OR RQ("Di")="" then Response.Write("selected=""selected""")%>></option>
<%
Set rsDi=Server.CreateObject("ADODB.RecordSet") 
sqlDi="SELECT * from SK_SystemCategory where SK_Di=80 order by CategoryID asc" 
rsDi.Open sqlDi,conn,1,1
do while not rsDi.eof
%><option value="<%=rsDi("CategoryID")%>" <%if RQ("Di")=""&rsDi("CategoryID")&"" then Response.Write("selected=""selected""")%>><%=rsDi("SK_Name")%></option>
<%
rsDi.movenext
loop
rsDi.close
set rsDi=Nothing
%></select>  
<select name="Currency" style="width:100">
<option value="" <%if RQ("Currency")="0" OR RQ("Currency")="" then Response.Write("selected=""selected""")%>></option>
<%
Set rsCurrency=Server.CreateObject("ADODB.RecordSet") 
sqlCurrency="SELECT * from SK_SystemCategory where SK_Di=142 order by CategoryID asc" 
rsCurrency.Open sqlCurrency,conn,1,1
do while not rsCurrency.eof
%><option value="<%=rsCurrency("CategoryID")%>" <%if RQ("Currency")=""&rsCurrency("CategoryID")&"" then Response.Write("selected=""selected""")%>><%=rsCurrency("SK_Name")%></option>
<%
rsCurrency.movenext
loop
rsCurrency.close
set rsCurrency=Nothing
%></select>  
下单日期：
<input name="STime" type="text" size="12" onClick="new Calendar().show(this);" value="<%=RQ("STime")%>" readOnly /> 至 <input name="ETime" type="text" size="12" onClick="new Calendar().show(this);" value="<%=RQ("ETime")%>" readOnly />
</td>
<td background="../images/tab_15.gif"></td>
</tr>
</form>

<tr>
<td width="8" background="../images/tab_12.gif"></td>
<td>
<%
If IsNull(Rs) Then
response.write"对不起，没有你要的信息!"
else
%>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="b5d6e6" ID="MyList">
<form name="thisForm" id="form1" method="post" action="">	  
<tr>
  <td width="49" class="SK_Title">订单ID</td>
  <td width="50" class="SK_Title">厂商ID</td>
  <td width="151" class="SK_Title">供应厂商</td>
<td width="121" class="SK_Title">订单编号</td>
<td width="90" class="SK_Title">金额</td>
<td width="90" class="SK_Title">已付款</td>
<td width="90" class="SK_Title">应付款</td>
<td width="90" class="SK_Title">状态</td>
<td width="90" class="SK_Title">采购日期</td>
<td width="90" class="SK_Title">采购人员</td>
<td width="40" class="SK_Title">选择</td>
</tr>
<%For i=0 To Ubound(Rs,2)%>
<tr onMouseOver="changeto()" onMouseOut="changeback()">
  <td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><%=Rs(0,i)%></td>
  <td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><%=Rs(2,i)%></td>
  <td <%if i mod 2 = 0 then%>class="SK_Text1"<%else%>class="SK_Text1two"<%end if%>>
<%
set RsVend=server.createobject("adodb.recordset")
SqlVend="select * from SK_ProcureVend where VendID="&Rs(2,i)&""
RsVend.open SqlVend,conn,1,1
Response.write""&RsVend("SK_Wname")&""
iVend=RsVend("SK_Wname")
RsVend.close
Set RsVend=Nothing
%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text1"<%else%>class="SK_Text1two"<%end if%>><%=Rs(4,i)%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>>
<%
set RsCurrency=server.createobject("adodb.recordset")
SqlCurrency="select * from SK_SystemCategory where SK_Di=142 and CategoryID="&Rs(10,i)&""
RsCurrency.open SqlCurrency,conn,1,1
Response.write"<font color=""#999999"">"&RsCurrency("SK_Name")&"</font> "
RsCurrency.close
Set RsCurrency=Nothing
set RsZG=server.createobject("adodb.recordset")
SqlZG="select sum(SK_Total*SK_Price) as ZG from SK_ProcureOrdersDetail where SK_OrdersID="&Rs(0,i)&""
RsZG.open SqlZG,Conn,1,1
if RsZG("ZG")<>"" OR RsZG("ZG")<>"0" then
iZG=formatnumber(RsZG("ZG"),2)
else
iZG="0"
end if
Response.write"<font color=blue>"&iZG&"</font>"
RsZG.close
set RsZG=Nothing
%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>>
<%
set RsYF=server.createobject("adodb.recordset")
SqlYF="select sum(SK_Amount) as YF from SK_Accounts where SK_Di=1 and SK_Del=0 and SK_ProcureOrders="&Rs(0,i)&""
RsYF.open SqlYF,Conn,1,1
if RsYF("YF")<>"" OR RsYF("YF")>"0" then
iYF=formatnumber(RsYF("YF"),2)
else
iYF="0"
end if
Response.write"<font color=blue>"&iYF&"</font>"
RsYF.close
set RsYF=Nothing
%></td>

<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><%=formatnumber((iZG-iYF),2)%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>>
<% 
if Rs(5,i)="0" then
Response.write"<font color=blue>等待采购</font>"
elseif Rs(5,i)="1" then
Response.write"<font color=red>正在采购</font>"
elseif Rs(5,i)="2" then
Response.write"<font color=red>已经采购</font>"
elseif Rs(5,i)="3" then
Response.write"<font color=red>已经入库</font>"
elseif Rs(5,i)="4" then
Response.write"<font color=red>取消采购</font>"
end if
%>
</a></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><%=split(Rs(12,i))(0)%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><%
set RsFuser=server.createobject("adodb.recordset")
SqlFuser="select * from SK_SystemUsers where UsersID="&Rs(11,i)&""
RsFuser.open SqlFuser,conn,1,1
Response.write""&RsFuser("SK_OName")&""
RsFuser.close
Set RsFuser=Nothing
%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><a onClick="CreateReturnValue(true,<%=i+1%>);" style="cursor:hand">选择</a></td>
</tr>
<%next%>
</form>

<tr>
<td colspan="11" class="SK_Text"><%Response.Write nav%></td>
</tr>
</table>
<%end if%>
</td>
<td width="8" background="../images/tab_15.gif"></td>
</tr>
</table></td>
</tr>
<tr>
<td class="SK_Td_Foot">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%" height="20"><img src="../images/tab_18.gif" width="12" height="20" /></td>
<td width="98%" class="SK_Td_Page"></td>
<td width="1%"><img src="../images/tab_20.gif" width="16" height="20" /></td>
</tr>
</table>

</td>
</tr>
</TBODY>
</table>
</body>
<%
Page = Null
Set Page = Nothing
Call CloseDB()
%>
</html>