<!--#include file="../inc/Secure.htm"-->
<!--#include file="../inc/conn.htm"-->
<!--#include file="../inc/dbtools.htm"-->
<%
ID=trim(request("ID"))
Outin=2
FromID=session("LoginID")
if FromID="" then response.end
UserName= trim(session("RealName"))
FromDepartment=getTableValue("tblUser","Department","ID",FromID)
CheckList_Usr=trim(request("CheckList_Usr"))
CheckList=trim(request("CheckList"))
if CheckList="" then CheckList=0
if CheckList_Usr="" then CheckList_Usr=0
CheckIDs=trim(request("CheckIDs"))
CheckNames=trim(request("CheckNames"))
CheckStepIDs=trim(request("CheckStepIDs"))
CheckStepNames=trim(request("CheckStepNames"))

inDepartment=cRequest("inDepartment")
inTime=cRequest("inTime")
intoDepartment=cRequest("intoDepartment")
inFromName=cRequest("inFromName")
intoName=cRequest("intoName")
inSerial=cRequest("inSerial")
inTelcode=cRequest("inTelcode")
inRecieved=cRequest("inRecieved")

title=replace(trim(request("title")),"'","''")
nClass=trim(request("Class"))
if nClass="" then nClass=0
body=replace(rtrim(request("body")),"'","''")
remark=replace(rtrim(request("remark")),"'","''")
attachfile=replace(trim(request("attachfile")),"'","''")
OutWord=trim(cRequest("OutWord"))
OutSerial=trim(cRequest("OutSerial"))
JinjiClass=trim(cRequest("JinjiClass"))
SecureClass=trim(cRequest("SecureClass"))
SecureTime=trim(cRequest("SecureTime"))
Author=trim(cRequest("Author"))
OutGoing=trim(cRequest("OutGoing"))
PrintDepartment=trim(cRequest("PrintDepartment"))
PrintTime=trim(cRequest("PrintTime"))
NigaoDepartment=trim(cRequest("NigaoDepartment"))
Nigao=trim(cRequest("Nigao"))
Printer=trim(cRequest("Printer"))
Publish=trim(cRequest("Publish"))
Jiaodui=trim(cRequest("Jiaodui"))
Copys=trim(cRequest("Copys"))
MainTo=trim(cRequest("MainTo"))
CopyTo=trim(cRequest("CopyTo"))
Title2=trim(cRequest("Title2"))
FinishTime=trim(cRequest("FinishTime"))
AttachFileBody=trim(cRequest("AttachFileBody"))
if FinishTime="" then FinishTime=date()
if PrintTime="" then PrintTime=date()
if Nigao="" then Nigao=userName

dim DocID,CurrentID
CurrentID=FromID

if request("cmdDel")<>"" then
	oConn.execute "delete from tblDoc where ID="& ID
	oConn.close
	response.redirect "main.htm"
end if
if request("cmdUp")<>"" then	
	if CheckIDs<>"" and CheckIDs<>"0" then
		arrCheckID0=split(CheckIDs,".")
		arrCheckID=split(arrCheckID0(0),",")
		if not isempty(arrCheckID) then CurrentID=arrCheckID(0)
	end if
	if CheckStepIDs<>"" and CheckStepIDs<>"0" then
		arrCheckStepIDs=split(CheckStepIDs,",")
		if not isempty(arrCheckStepIDs) then currentStep=arrCheckStepIDs(0)
	end if

	if Title<>"" then
		updateDoc(ID)
		if Attachfile<>"" then
			CopyOneFile "../File_Up/DocTemp/"&FromID&"/"&Attachfile, "../File_Up/Doc/"&DocID, attachfile
			DeleteOneFile "../File_Up/DocTemp/"& FromID &"/" & AttachFile
			Session("DocAttachFile")=""
		end if
		response.write "<h2>公文已经成功发出，谢谢！</h2><BR><BR>"
		response.write "<a href=Main.htm><img src=""../images/return.gif"" alt=返回 border=0></a>"
		oConn.close
		response.end
	end if
end if

set rs=server.createobject("adodb.recordset")
sql="select * from tblDoc where ID="& ID
rs.open sql,oConn
if not rs.eof then
	FromID=trim(rs("FromID"))
	CheckIDs=trim(rs("CheckIDs"))
	CheckNames=trim(rs("CheckNames"))
	CheckStepIDs=trim(rs("CheckStepIDs"))
	CheckStepNames=trim(rs("CheckStepNames"))

	inDepartment=trim(rs("inDepartment"))
	inTime=trim(rs("inTime"))
	intoDepartment=trim(rs("intoDepartment"))
	inFromName=trim(rs("inFromName"))
	intoName=trim(rs("intoName"))
	inSerial=trim(rs("inSerial"))
	inTelcode=trim(rs("inTelcode"))
	inRecieved=trim(rs("inRecieved"))

	title=replace(trim(rs("title")),"'","''")
	nClass=trim(rs("Class"))
	if nClass="" then nClass=0
	body=replace(trim(rs("body")),"'","''")
	body2=replace(trim(rs("body2")),"'","''")
	remark=replace(trim(rs("remark")),"'","''")
	attachfile=replace(trim(rs("attachfile")),"'","''")
	OutWord=trim(rs("OutWord"))
	OutSerial=trim(rs("OutSerial"))
	JinjiClass=trim(rs("JinjiClass"))
	SecureClass=trim(rs("SecureClass"))
	SecureTime=trim(rs("SecureTime"))
	Author=trim(rs("Author"))
	OutGoing=trim(rs("OutGoing"))
	PrintDepartment=trim(rs("PrintDepartment"))
	PrintTime=trim(rs("PrintTime"))
	NigaoDepartment=trim(rs("NigaoDepartment"))
	Nigao=trim(rs("Nigao"))
	Printer=trim(rs("Printer"))
	Publish=trim(rs("Publish"))
	Jiaodui=trim(rs("Jiaodui"))
	Copys=trim(rs("Copys"))
	MainTo=trim(rs("MainTo"))
	CopyTo=trim(rs("CopyTo"))
	Title2=trim(rs("Title2"))
	FinishTime=trim(rs("FinishTime"))
	AttachFileBody=trim(rs("AttachFileBody"))
	Recieved=trim(rs("Recieved"))&""
	Untread=trim(rs("Untread"))&""
	UntreadTime=trim(rs("UntreadTime"))
	CurrentStep=trim(rs("CurrentStep"))
end if
rs.close
set rs=nothing
%>
<html>
<head>
<title>Folders</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../CSS/main.css">
</head>
<script src="Popup.js"></script>
<body bgcolor="#FFFFFF">
<form name="DocForm" method="post" action="Doc_untread2.htm">
<div align=center>
<h2><font color=#ff0000> 被退收文单</font></h2>
<table border=1 cellpadding=3 cellspacing=1 width="95%" bgcolor=#FFFFFF bordercolordark="#FFFFFF" bordercolorlight="#999999">

<tr>
<td>退回理由：</td>
<td colspan=3><%=untread&"<font color=red> (退回时间："&untreadTime&")</font>"%></td>
</tr>
<tr>
	<td align=right>来文单位：</td>
	<td><input class="doc_txt" type="text" name="inDepartment" size=20 maxlength=50 value="<%=inDepartment%>"></td>
	<td align=right>来文时间：</td>
	<td>
		<input class="doc_txt" type="text" name="inTime" size=10 maxlength=20 value="<%=inTime%>">
		<a href=# title="选择日期" onClick="fPopUpDlg('../inc/calendar.htm', document.DocForm.inTime, 'winpop', 172, 210);return false"><img src="../images/datetime.gif" border=0></a>
	</td>
</tr>
<tr>
	<td align=right>发件人：</td>
	<td><input class="doc_txt" type="text" name="inFromName" size=20 maxlength=50 value="<%=inFromName%>"></td>
	<td align=right>联系电话：</td>
	<td><input class="doc_txt" type="text" name="inTelcode" size=12 maxlength=50 value="<%=inTelcode%>"></td>

</tr>
<tr>
	<td align=right>来文编号：</td>
	<td><input class="doc_txt" type="text" name="inSerial" size=20 maxlength=50 value="<%=inSerial%>"></td>
	<td align=right>收文编号：</td>
	<td><input class="doc_txt" type="text" name="inToName" size=12 maxlength=50 value="<%=inToName%>"></td>

</tr>
<tr>
	<td align=right>承办部门：</td>
	<td><input class="doc_txt" type="text" name="inToDepartment" size=20 maxlength=50 value="<%=inToDepartment%>"></td>
	<td align=right>收单人：</td>
	<td><input class="doc_txt" type="text" name="inRecieved" size=12 maxlength=50 value="<%=inRecieved%>"></td>
</tr>
<tr>
	<td align=right>紧急程度：</td>
	<td>
	<select name="JinjiClass">
		<option value=0 <%if Jinjiclass="0" then response.write " selected"%>>未定义
		<option value=1 <%if Jinjiclass="1" then response.write " selected"%>>缓
		<option value=2 <%if Jinjiclass="2" then response.write " selected"%>>急
		<option value=3 <%if Jinjiclass="3" then response.write " selected"%>>加急
	</select>
	</td>
	<td nowrap align=right>秘密等级：</td>
	<td>
	<select name="SecureClass">
		<option value=0 <%if Secureclass="0" then response.write " selected"%>>未定义
		<option value=1 <%if Secureclass="1" then response.write " selected"%>>普通
		<option value=2 <%if Secureclass="2" then response.write " selected"%>>秘密
		<option value=3 <%if Secureclass="3" then response.write " selected"%>>机密
		<option value=4 <%if Secureclass="4" then response.write " selected"%>>绝密
	</select>
	</td>
</tr>

<tr>
	<td align=right>公文种类：</td>
	<td><%options "Class","tblDocClass","Name",nClass%></td>
	<td align=right>保密期限：</td>
	<td>
		<select name="SecureTime">
		<option value="未定义" <%if SecureTime="未定义" then response.write " selected"%>>未定义
		<option value="永久" <%if SecureTime="永久" then response.write " selected"%>>永久
		<option value="长期" <%if SecureTime="长期" then response.write " selected"%>>长期
		<option value="短期" <%if SecureTime="短期" then response.write " selected"%>>短期
	</select>
	</td>
</tr>

<tr>
	<td align=right>印发机关：</td>
	<td><input class="doc_txt" type="text" name="PrintDepartment" size=20 maxlength=30 value="<%=PrintDepartment%>"></td>
	<td align=right>印发日期：</td>
	<td>
		<input class="doc_txt" type="text" name="PrintTime" size=10 maxlength=20 value="<%=PrintTime%>">
		<a href=# title="选择日期" onClick="fPopUpDlg('../inc/calendar.htm', document.DocForm.PrintTime, 'winpop', 172, 210);return false"><img src="../images/datetime.gif" border=0></a>
	</td>
</tr>
<tr>
	<td align=right>拟稿单位：</td>
	<td><input class="doc_txt" type="text" name="NigaoDepartment" size=20 maxlength=30 value="<%=NigaoDepartment%>"></td>
	<td align=right>拟稿人：</td>
	<td>
		<input class="doc_txt" type="text" name="Nigao" size=10 maxlength=20 value="<%=Nigao%>">
	</td>
</tr>
<tr>
	<td align=right>&nbsp;</td>
	<td colspan=3>
	打字：<input class="doc_txt" type="text" name="Printer" size=10 maxlength=20 value="<%=Printer%>">
	印刷：<input class="doc_txt" type="text" name="Publish" size=10 maxlength=20 value="<%=Publish%>">
	校对：<input class="doc_txt" type="text" name="Jiaodui" size=10 maxlength=20 value="<%=Jiaodui%>">
	份数：<input class="doc_txt" type="text" name="Copys" size=10 maxlength=20 value="<%=Copys%>">
	</td>
</tr>
<tr>
	<td align=right>主送机关：</td>
	<td colspan=3><input class="doc_txt" type="text" name="MainTo" size=50 maxlength=50 value="<%=Mainto%>"></td>
</tr>
<tr>
	<td align=right>抄送机关：</td>
	<td colspan=3><input class="doc_txt" type="text" name="CopyTo" size=50 maxlength=50 value="<%=Copyto%>"></td>
</tr>
<tr>
	<td align=right>主题词：</td>
	<td colspan=3><input class="doc_txt" type="text" name="Title2" size=50 maxlength=50 value="<%=Title2%>"></td>
</tr>
<tr>
	<td align=right>标题：</td>
	<td colspan=3><input class="doc_txt" type="text" name="Title" size=50 maxlength=50 value="<%=Title%>"></td>
</tr>

<tr>
	<td align=right valign=top>内容摘要：</td>
	<td colspan=3><textarea name="body" rows=10 cols=60><%if trim(body2)<>"" then
	response.write body2
	else
	response.write body
	end if%></textarea></td>
</tr>
<tr>
	<td align=right valign=top>附注：</td>
	<td colspan=3><textarea name="Remark" rows=5 cols=60><%=remark%></textarea></td>
</tr>
<tr>
	<td align=right>附件：</td>
	<td colspan=3><input type="text" name="AttachFile" value="<%=AttachFile%>" size=40 readonly class="doc_txt">
	<INPUT TYPE="button" name="cmdAttach" value="添加附件" onclick="OpenWindow1('AddFileForm.htm','filewindow')" class="font9boldwhite">
	</td>
</tr>
<tr>
	<td align=right valign=top>附件说明：</td>
	<td colspan=3><textarea name="AttachFileBody" rows=3 cols=60><%=AttachFileBody%></textarea></td>
</tr>
<tr>
	<td align=right>选择路径：</td>
	<td colspan=3><%options1 "CheckList","tblDocCheck","Name",CheckList%>（选择定义好的路径）</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td colspan=3>
		<INPUT TYPE="submit" name="cmdUp" value="重新发出" onclick="return CheckData();" class="font9boldwhite">&nbsp;&nbsp;
		<INPUT TYPE="button" name="cmdAttach" value="重新指定公文路径" onclick="OpenWindow('AddPath_User.htm','UserWindow')" class="font9boldwhite">&nbsp;&nbsp;
		<INPUT TYPE="button" name="cmdCancel" value="返  回" onclick="javascript:window.location.href='main.htm'"  class="font9boldwhite">&nbsp;&nbsp;
		<INPUT TYPE="submit" name="cmdDel" value="删  除" onclick="return CheckDelete();"  class="font9boldwhite">
	</td>

</tr>
<tr bgcolor=#3366CC>
	<td colspan=4><font color=#EEEEEE><b>公文流转路径</b></font></td>
</tr>
<tr>
<%
FromName=getTableValue("tblUser","Name","ID",FromID)
arrName=split(CheckNames,".")
arrStep=split(CheckStepNames,",")	
if not isempty(arrName) then
str1=""
for i=0 to ubound(arrName)
	str1=str1&"("&arrName(i)&")"&"["&arrStep(i)&"]—>"
next
str1=str1&"(完成)"
end if


if CheckList_Usr<>0 then
	set rstmp=server.createobject("adodb.recordset")
	sql="select * from tblDocCheckTmp where ID="& CheckList_Usr
	rstmp.open sql,oConn
	if not rstmp.eof then
		CheckIDs=trim(rstmp("CheckList"))
		CheckStepIDs=trim(rstmp("CheckStepID"))
		CheckNames=trim(rstmp("CheckNameList"))
		CheckStepNames=trim(rstmp("CheckStepName"))
		arrName=split(CheckNames,".")
		arrStep=split(CheckStepNames,",")	
	end if
	rstmp.close
	set rstmp=nothing
	if not isempty(arrName) then
	str1=""
	for i=0 to ubound(arrName)
		str1=str1&"("&arrName(i)&")"&"["&arrStep(i)&"]—>"
	next
	str1=str1&"(完成)"
	end if
elseif CheckList<>"0" then
	set rstmp=server.createobject("adodb.recordset")
	sql="select * from tblDocCheck where ID="& CheckList
	rstmp.open sql,oConn
	if not rstmp.eof then
		CheckIDs=trim(rstmp("CheckList"))
		CheckStepIDs=trim(rstmp("CheckStepID"))
		CheckNames=trim(rstmp("CheckNameList"))
		CheckStepNames=trim(rstmp("CheckStepName"))
		arrName=split(CheckNames,".")
		arrStep=split(CheckStepNames,",")	
	end if
	rstmp.close
	set rstmp=nothing
	if not isempty(arrName) then
	str1=""
	for i=0 to ubound(arrName)
		str1=str1&"("&arrName(i)&")"&"["&arrStep(i)&"]—>"
	next
	str1=str1&"(完成)"
	end if
end if

	
%>

	<td align=right valign=top>公文路径</td>
	<td colspan=3>
	<textarea name="CheckNameList" rows=4 cols=60><%=str1%></textarea>
	</td>
</tr>
</table>
</div>
<INPUT TYPE="hidden" name="CheckList_Usr" value="">
<INPUT TYPE="hidden" name="ID" value="<%=ID%>">
<INPUT TYPE="hidden" name="CheckIDs" value="<%=CheckIDs%>">
<INPUT TYPE="hidden" name="CheckNames" value="<%=CheckNames%>">
<INPUT TYPE="hidden" name="CheckStepIDs" value="<%=CheckStepIDs%>">
<INPUT TYPE="hidden" name="CheckStepNames" value="<%=CheckStepNames%>">
</form>
</body>
<BR><BR>
</html>
<!--#include file="../inc/conn_close.htm"-->
<script language="JavaScript">
function OpenWindow(url,windowname)
{
window.open(url,windowname,'left=100,top=50,height=450,width=550,toolbar=no,menubar=no,scrollbars=yes')
}
function OpenWindow1(url,windowname)
{
window.open(url,windowname,'left=150,top=100,height=80,width=420,toolbar=no,menubar=no,scrollbars=yes')
}

function CheckData()
{
	if(jtrim(document.DocForm.Title.value)=="")
	{
		alert("您必须输入标题。")
		document.DocForm.Title.focus();
		return false;
	}
	if(jtrim(document.DocForm.CheckNameList.value)=="")
	{
		alert("请指定公文路径。")
		return false;
	}
			
	return true;
}
function CheckDelete()
{
	return confirm("确实删除吗？");
}
</script>
<script language=javascript src="../inc/jtrim.js"></script>
<%
Function GetTableValue(TableName,Field,ValueField,Value)
	if TableName<>"" and Value<>"" then
		Set RsTmp = Server.Createobject("Adodb.recordset")
		strSql = "Select "& Field &" from "& TableName &" where "& ValueField &"='"& Value &"'"
		Rstmp.open strSql,oConn,1,1
		If not Rstmp.eof then
			GetTableValue=trim(Rstmp(Field))
		else
			GetTableValue=""
		end if
		Rstmp.close
		set RsTmp = Nothing
	else
		GetTableValue=""
	end if
End Function


Sub UpdateDoc(ID)
	'sql="SET NOCOUNT ON;"
	sql=" update tblDoc set BackTo=0,Untread='',PreID="&FromID&",CurrentStep="&CurrentStep&", Class="&nClass&",CurrentID="&CurrentID&", Title='"&Title&"',Title2='"&Title2&"', Body='"&Body&"', Remark='"&Remark&"',Attachfile='"&AttachFile&"',CheckIDs='"&CheckIDs&"',CheckNames='"&CheckNames&"',CheckStepIDs='"&CheckStepIDs&"',CheckStepNames='"&CheckStepNames&"',OutWord='"&OutWord&"',OutSerial='"&OutSerial&"',JinjiClass='"&JinjiClass&"',SecureClass='"&SecureClass&"',SecureTime='"&SecureTime&"',Author='"&Author&"',OutGoing='"&OutGoing&"',PrintDepartment='"&PrintDepartment&"',PrintTime='"&PrintTime&"',NigaoDepartment='"&NigaoDepartment&"',Nigao='"&Nigao&"',Printer='"&Printer&"',Publish='"&Publish&"',Jiaodui='"&Jiaodui&"',Copys='"&Copys&"',MainTo='"&Mainto&"',CopyTo='"&Copyto&"',FinishTime='"&FinishTime&"',AttachFileBody='"&AttachFileBody&"',inDepartment='"&inDepartment&"',inToDepartment='"&inToDepartment&"',inFromName='"&inFromName&"',inTime='"&inTime&"',inToName='"&inToName&"',inTelcode='"&inTelcode&"',inSerial='"&inSerial&"',inRecieved='"&inRecieved&"',Recieved='',ThroughStep=0 where ID="& ID
	oConn.execute (sql)
	if CheckList_Usr<>"0" then oConn.execute "delete tblDocCheckTmp where ID="&CheckList_Usr
end sub

sub DeleteOneFile (FilePathName)
	FilePathName=Server.Mappath(FilePathName)
	dim fs
	Set fs = server.CreateObject("Scripting.FileSystemObject")
	if trim(FilePathName)<>"" and fs.FileExists(FilePathName) then 
		fs.DeleteFile FilePathName
	end if
	set fs=nothing	
end sub

sub CopyOneFile (FileName1,PathName2,FileName)
	FileName1=Server.Mappath(FileName1)
	PathName2=Server.Mappath(PathName2)
	dim fs,f
	Set fs = server.CreateObject("Scripting.FileSystemObject")
	if not fs.FolderExists(PathName2) then
	   fs.CreateFolder PathName2
	end if
	if trim(FileName1)<>"" and fs.FileExists(FileName1) then
		set f=fs.GetFile(FileName1)
		f.Copy PathName2&"\"&FileName,true
	end if
	set fs=nothing	
end sub
%>