<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"),"SK300000700")))) 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_SalesReturns where ReturnsID="&JCID(F("ID"))&""
elseif Session("Manager")=3 then
sql="SELECT * from SK_SalesReturns INNER JOIN SK_SystemUsers ON SK_SalesReturns.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SalesReturns.ReturnsID="&JCID(F("ID"))&""
elseif Session("Manager")=4 then
sql="SELECT * from SK_SalesReturns INNER JOIN SK_SystemUsers ON SK_SalesReturns.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_SalesReturns.ReturnsID="&JCID(F("ID"))&""
elseif Session("Manager")=5 then
sql="SELECT * from SK_SalesReturns INNER JOIN SK_SystemUsers ON SK_SalesReturns.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_SalesReturns.ReturnsID="&JCID(F("ID"))&""
elseif Session("Manager")=6 then
sql="SELECT * from SK_SalesReturns where SK_SalesID="&Session("UID")&" and ReturnsID="&JCID(F("ID"))&""
end if
rs.Open sql,conn,1,1
if rs.eof and rs.bof then Call ReturnError4()
%>
<HEAD>
<TITLE>打印退货单</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="../images/Style.css" type=text/css rel=stylesheet>
<style type="text/css"> 
<!-- 
.headtitle{font-size: 18px;font-weight:bold; text-align: center; }

.headcompany {background:#FFFFFF;text-align:center;font-size: 13px;height: 20px;line-height: 20px;font-weight:bold;}

.headcontact {background:#FFFFFF;text-align:center;font-size: 12px;height: 18px;line-height: 18px;}

.td01 { BORDER-RIGHT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid;background-color: #FFFFFF; height: 25px;line-height: 25px;font-size: 12px;} 

.td02 {BORDER-RIGHT: #000000 1px solid;BORDER-BOTTOM: #000000 1px solid;background-color: #FFFFFF;text-align: center;height: 25px;line-height: 25px;font-size: 12px;}

.td03 {BORDER-RIGHT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid;background-color: #FFFFFF;text-align: left;height: 50px;font-size: 12px;padding: 2px 2px 2px 2px;}

.td04 {background:#FFFFFF;text-align:right;font-size: 12px;height: 25px;line-height: 25px;padding: 2px 10px 2px 2px;}

.td05 {background:#FFFFFF;text-align: left;font-size: 12px;height: 25px;line-height: 25px;padding: 2px 2px 2px 2px;}

.ProList{BORDER-top: #000000 1px solid; BORDER-left: #000000 1px solid;background-image:#000000;} 
.prin{ 
font: 15pt "宋体"; color: #FFFFF; text-decoration: none; 
} 
.pageEnd {page-break-before:always} 
--> 
</style> 
<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="headtitle">退货单</td> 
</tr>
<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 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 class="td04">日期：<%=Rs("SK_ATime")%></td> 
</tr> 
<tr><td colspan="2"> 
<%
Dim Rs11,J
set rs11=Server.createobject("adodb.recordset")
sql11="select * from SK_SalesReturnsDetail where SK_ReturnsID="&Rs("ReturnsID")&" order by ReturnsDetailID asc"
rs11.open sql11,conn,1,1
if rs11.bof and rs11.eof then 
Call ReturnError8()
else
%>
<table width="100%" cellpadding="1" cellspacing="0" class="ProList"> 
<tr> 
<th width="34%" class="td01">产品名称</th> 
<th width="28%" class="td01">产品编码</th>
<th class="td01">产品型号</th>
<th width="14%" class="td01">数量</th>
</tr>
<%
J=0
while not rs11.eof
J=J+1
set rsProduct=server.createobject("adodb.recordset")
sqlProduct="select * from SK_Product where ProID="&Rs11("SK_ProID")&""
rsProduct.open sqlProduct,conn,1,1
%>
<tr> 
<td class="td02"><%=rsProduct("SK_ProName")%></td> 
<td class="td02"><%=rsProduct("SK_ProNo")%></td>
<td class="td02"><%=rsProduct("SK_ProNum")%></td>
<td class="td02"><%=Rs11("SK_Total")%> / 
<%
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
Response.write""&RsUnit("SK_Name")&""
RsUnit.close
Set RsUnit=Nothing
%>
</td>
</tr>
<%
RsProduct.close
RsProduct=Nothing
rs11.movenext
wend
%>
<tr>
  <td colspan="2" class="td02">&nbsp;</td>
  <td class="td02">合计</td>
  <td class="td02"><%
set RsAG=server.createobject("adodb.recordset")
AGSql="select sum(SK_Total) as AG from SK_SalesReturnsDetail where SK_ReturnsID="&Rs("ReturnsID")&""
RsAG.open AGSql,Conn,1,1
Response.write"<font color=blue>"&RsAG("AG")&"</font>"
RsAG.close
set RsAG=Nothing
%></td>
</tr>
<tr>
<td colspan="4" valign="top" class="td03">备注：<br><%=Rs("SK_ReContent")%></td>
</tr>
</table> 
<%
end if
rs11.close
Set Rs11=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>