<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" -->
<%if Not (Getconfig("SK_Sales")="0" AND (Session("Manager")="1" OR (JudgePopedomTF(Session("UserName"),"SK300000000") AND JudgePopedomTF(Session("UserName"),"SK300000400")))) then Call ReturnError()%>
<%
if not isnumeric(JCID(F("ID"))) then Call ReturnError10()
set rs=server.createobject("adodb.recordset")
if Session("Manager")=1 or Session("Manager")=2 then
sql="SELECT * from SK_SalesOrders where OrdersID="&JCID(F("ID"))&""
elseif Session("Manager")=3 then
sql="SELECT * from SK_SalesOrders INNER JOIN SK_SystemUsers ON SK_SalesOrders.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SalesOrders.OrdersID="&JCID(F("ID"))&""
elseif Session("Manager")=4 then
sql="SELECT * from SK_SalesOrders INNER JOIN SK_SystemUsers ON SK_SalesOrders.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_SalesOrders.OrdersID="&JCID(F("ID"))&""
elseif Session("Manager")=5 then
sql="SELECT * from SK_SalesOrders INNER JOIN SK_SystemUsers ON SK_SalesOrders.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_SystemUsers.SK_Dept3="&Session("Dept3")&" and SK_SalesOrders.OrdersID="&JCID(F("ID"))&""
elseif Session("Manager")=6 then
sql="SELECT * from SK_SalesOrders where SK_SalesID="&Session("UID")&" and OrdersID="&JCID(F("ID"))&""
end if
rs.Open sql,conn,1,1
if rs.eof and rs.bof then Call ReturnError4()

set RsJE=server.createobject("adodb.recordset")
SqlJE="select sum(SK_Total*SK_Price) as JE from SK_SalesOrdersDetail where SK_ProOrdersID="&Rs("OrdersID")&""
RsJE.open SqlJE,Conn,1,1
dim iJE
aJE=RsJE("JE")
if RsJE("JE")<>"" then
iJE=formatnumber(RsJE("JE"),2)
else
iJE="0"
end if
RsJE.close
set RsJE=Nothing
%>
<HEAD>
<TITLE>打印产品订单</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {
overflow-x:hidden;
overflow-y:auto;
}
td {font-size: 13px;}
.tdhead {height: 28px; line-height:28px; text-align:center;}
.tdtext {height: 24px; line-height:24px; text-align:center;}
.tdtext1 {height: 40px; text-align:left; padding: 2px;}
.headcompany{font-family:"隶书"; height: 24px; line-height:24px; font-size:24px;font-weight:bold;text-align:center;}
.headcontact{font-family:"宋体"; font-size:13px;font-weight:bold;text-align:center;}
.tdtext2 {height: 20px;line-height:20px; text-align:left; padding: 1px;}
.span1{border-bottom:#666666 1px solid; width: 120px;}
.span2{border-bottom:#666666 1px solid; width: 90px;}
.span3{border-bottom:#666666 1px solid; width: 160px;}

.toptable{padding-top:5px;}
-->
</style>
<script type="text/javascript" src="../Inc/mycommon.js"></script>
<SCRIPT language=javascript>
function printpr()   //预览函数
{
document.all("PagesHead").click();//打印之前去掉页眉，页脚
document.all("dayinDiv").style.display="none"; //打印之前先隐藏不想打印输出的元素（此例中隐藏“打印”和“打印预览”两个按钮）
var OLECMDID = 7;
var PROMPT = 1; 
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser); 
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
document.all("dayinDiv").style.display="";//打印之后将该元素显示出来（显示出“打印”和“打印预览”两个按钮，方便别人下次打印）
}
function printTure()   //打印函数
{
    document.all('PagesHead').click();//同上
    document.all("dayinDiv").style.display="none";//同上
    window.print();
    document.all("dayinDiv").style.display="";
}
function doPage()
{
    layLoading.style.display = "none";//同上
}
</SCRIPT>
<script language="VBScript">
dim hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\Software\Microsoft\Internet Explorer\PageSetup"
function pagesetup_null()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="\header" 
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
hkey_key="\footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
end function
function pagesetup_default()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="\header" 
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&w&b页码，&p/&P"
hkey_key="\footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&u&b&d"
end function
</script>
</HEAD>
<BODY leftMargin=0 topMargin=0 rightMargin=0 bottomMargin=0 style="BACKGROUND-POSITION: center 50%">
<DIV align="center">

<table id="table" width="98%" align="center" border="0" cellspacing="1" cellpadding="1" > 

<tr>
  <td colspan="2" class="headcompany"><%=getconfig("SK_Company")%></td>
</tr>
<tr>
  <td colspan="2" class="headcontact">电话：<%=getconfig("SK_Tel")%> &nbsp;&nbsp; 传真：<%=getconfig("SK_Fax")%></td>
</tr>
<tr>
  <td colspan="2" class="td05">订单编号：<b><%=Rs("SK_OrdersNo")%></b></td>
</tr> 
<tr> 
<td width="83%" class="td05">客户名称：<%
set rsClient=server.createobject("adodb.recordset")
sqlClient="select * from SK_Client where ClientID="&Rs("SK_ClientID")&""
rsClient.open sqlClient,conn,1,1
if rsClient.eof and rsClient.bof then Call ReturnError13()
Response.write"<b>"&RsClient("SK_Wname")&"</b>"
RsClient.close
Set RsClient=Nothing
%></td> 
<td width="17%" class="td04">日期：<%=Rs("SK_OrdersTime")%></td> 
</tr> 
<tr><td colspan="2"> 
<%
Dim RsDetail,J
set RsDetail=Server.createobject("adodb.recordset")
sqlDetail="select * from SK_SalesOrdersDetail where SK_ProOrdersID="&Rs("OrdersID")&" order by OrdersDetailID asc"
RsDetail.open sqlDetail,conn,1,1
if RsDetail.bof and RsDetail.eof then 
Call ReturnError8()
else
%>
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" style="border-collapse:collapse;margin-top:5px;">  
<tr>  
<td width="10%" class="tdhead">产品名称</td>
<td width="10%" class="tdhead">产品编码</td>  
<td width="10%" class="tdhead">产品规格</td>  
<td width="6%" class="tdhead">单位</td>
<td width="10%" class="tdhead">数量</td>
<td width="10%" class="tdhead">单价</td>  
<td width="10%" class="tdhead">金额</td>
</tr>
<%
For J = 1 To RsDetail.recordcount

set rsProduct=server.createobject("adodb.recordset")
sqlProduct="select * from SK_Product where ProID="&RsDetail("SK_ProID")&""
rsProduct.open sqlProduct,conn,1,1

set RsUnit=server.createobject("adodb.recordset")
SqlUnit="select * from SK_SystemCategory where SK_Di=161 and CategoryID="&rsProduct("SK_Unit")&""
RsUnit.open SqlUnit,conn,1,1
%>
<tr>
<td class="tdtext"><%=RsProduct("SK_ProName")%></td>
<td class="tdtext"><%=RsProduct("SK_ProNo")%></td>
<td class="tdtext"><%=RsProduct("SK_ProNum")%></td>
<td class="tdtext"><%=RsUnit("SK_Name")%></td>
<td class="tdtext"><%=RsDetail("SK_Total")%></td>
<td class="tdtext"><%=formatnumber(RsDetail("SK_Price"),2)%></td>
<td class="tdtext"><%=formatnumber(RsDetail("SK_Total")*RsDetail("SK_Price"),2)%></td>
</tr>
<%
RsUnit.close
Set RsUnit=Nothing
rsProduct.close

RsDetail.movenext
next
%>
<tr>
<td colspan="7" class="tdtext">
<table width="98%" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="72%" height="24" align="right">合计：<script type="text/javascript">
document.write (number2num1(<%=aJE%>));
</script></td>
<td width="28%" align="right">（小写：<%set RsCurrency=server.createobject("adodb.recordset")
SqlCurrency="select * from SK_SystemCategory where SK_Di=142 and CategoryID="&Rs("SK_Currency")&""
RsCurrency.open SqlCurrency,conn,1,1
Response.write""&RsCurrency("SK_Name")&""
RsCurrency.close
Set RsCurrency=Nothing%>&nbsp;<%=iJE%> ）</td>
</tr>
</table></td>
    </tr>
  <tr>
    <td colspan="16" valign="top" class="tdtext1">备注：<%=Rs("SK_Content")%></td>
  </tr>  
</table> 
<%
end if
RsDetail.close
Set RsDetail=Nothing
%>
</td></tr>
<tr>
  <td class="td05">客户代表签字： </td>
  <td class="td05">我方代表签字：</td>
</tr> 
</table>
</DIV>
<DIV align="center" id="dayinDiv" name="dayinDiv">
<br>
<input type="button" class="button1" value=" 打印 " onClick="printTure();">
<input  type="button" class="button1" value=" 预览 " onClick="printpr();">
<input type="button" value=" 返回 " onClick="history.back(-1);" class="button1" />
<input type="button" value=" 关闭 " onClick="window.close();" class="button1" />
<input type="hidden" name="PagesHead" id="PagesHead" class="tab" value="清空页码" onClick="pagesetup_null()">&nbsp;&nbsp;
<input type="hidden" class="tab" value="恢复页码" onClick="pagesetup_default()">
</DIV>
</BODY>
<%Call CloseDB()%>
</HTML>