<!--#include file="../inc/Secure.htm"-->
<!--#include file="../inc/conn.htm"-->
<!--#include file="../inc/dbtools.htm"-->
<%
ID=trim(request("ID"))
Outin=1
LoginID=session("LoginID")
if LoginID="" then response.end
UserName= trim(session("RealName"))

if request("cmdUntread")<>"" then
	DocID=ID
	set rs=server.createobject("adodb.recordset")
	sql="select * from tblDoc where ID="& DocID
	rs.open sql,oConn
	if not rs.eof then
		PreID=TRIM(rs("PreID"))
		FromID=TRIM(rs("FromID"))
		PreStep=TRIM(rs("PreStep"))
		ThroughStep=trim(rs("ThroughStep"))
		CheckIDs=trim(rs("CheckIDs"))&""
		CheckStepIDs=trim(rs("CheckStepIDs"))&""
	end if
	rs.close
	set rs=nothing

	arrOldCheckIDs=split(CheckIDs,".")
	CheckIDs=replace(CheckIDs,".",",")
	arrCheckIDs=split(CheckIDs,",")
	arrCheckStepIDs=split(CheckStepIDs,",")

	if cint(ThroughStep-2)>=0 then
		newPreID=arrCheckIDs(ThroughStep-2)
	else
		newPreID=FromID
	end if

	temp=0
	nn=0
	for i=0 to ubound(arrOldCheckIDs)
		strtmp=arrOldCheckIDs(i)
		arrtmp=split(strtmp,",")
		bExit=false
		if not isempty(arrtmp) then
			for j=0 to ubound(arrtmp)
			nn=cint(nn)+1
			temp=i
			'response.write arrtmp(j)&"@"&PreID&"@"&nn&"<br>"
			if trim(arrtmp(j))=trim(PreID) and (nn=cint(ThroughStep)) then
				if cint(j)=0 then
					temp=temp-1
				end if
				bExit=true
				exit for
			end if
			next
		end if
		if bExit then
		exit for
		end if
	next

	if cint(temp)>=0 then
		newPreStep=arrCheckStepIDs(cint(temp))
	else
		newPreStep=0
	end if
	
	Untread=server.htmlencode(trim(request("Untread"))&"")
	if Untread<>"" then
	Untread=UserName&" 退回的公文！"& Untread
		oConn.execute "update tblDoc set ThroughStep=ThroughStep-1,backto=1, Untread='"&Untread&"',UntreadTime='"&now()&"',PreID="&NewPreID&",CurrentID="& PreID &",CurrentStep="& PreStep &",PreStep="&NewPreStep&" where ID="& ID
		'response.write "update tblDoc set ThroughStep=ThroughStep-1,backto=1, Untread='"&Untread&"',UntreadTime='"&now()&"',PreID="& NewPreID &",CurrentID="& PreID &",CurrentStep="& PreStep &",PreStep="& NewPreStep &" where ID="& ID
		oConn.close
		response.Redirect "main.htm"
	end if
end if

if request("cmdRecieved")<>"" then
	Recieved=GettableValue("tblDoc","Recieved","ID",ID)
	RecievedTime=GettableValue("tblDoc","RecievedTime","ID",ID)
	arrRecieved=split(Recieved&"",",")
	bRecieved=false
	for i=0 to ubound(arrRecieved)
		if trim(arrRecieved(i))=trim(LoginID) then
		bRecieved=true
		exit for
		end if
	next
	if not bRecieved then oConn.execute "update tblDoc set ThroughStep=ThroughStep+1, Recieved='"& Recieved&", "&LoginID &"',RecievedTime='"&RecievedTime&", "&now()&"' where ID="& ID
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"))

	title=replace(trim(rs("title")),"'","''")
	nClass=trim(rs("Class"))
	if nClass="" then nClass=0
	body=replace(rtrim(rs("body")),"'","''")
	body2=replace(trim(rs("body2")),"'","''")
	remark=replace(rtrim(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"))&""
	CurrentStep=trim(rs("CurrentStep"))
	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"))
end if
rs.close
set rs=nothing

arrRecieved=split(Recieved,",")
bRecieved=false
for i=0 to ubound(arrRecieved)
	if trim(arrRecieved(i))=trim(LoginID) then
	bRecieved=true
	exit for
	end if
next

CurrentStepName=GettableValue("tblDocStep","Name","ID",CurrentStep)
if trim(CurrentStepName)="审核" and bRecieved then
	oConn.close
	response.redirect "Doc_update2.htm?ID="&ID
end if
%>
<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">
<script language="javascript">

function CheckUntread()
{
	var temp=window.prompt("请输入退回理由:","");
	document.UntreadForm.Untread.value = temp;
	if ((jtrim(document.UntreadForm.Untread.value)=="")||(temp==null)){ alert('必须输入退回理由!');return false;}else return true;
}
</script>
<script language=javascript src="../inc/jtrim.js"></script>
<%if not bRecieved then%>
<form name="UntreadForm" method="post" action="Doc_Recieved.htm">
<div align=center>
<table border=0 cellpadding=3 cellspacing=1 width="95%" bgcolor=#FFFFFF bordercolordark="#FFFFFF" bordercolorlight="#999999">
<tr><td>
<input class="font9boldwhite" type="submit" name="cmdRecieved" value="签  收">

<input name="cmdUntread" class="font9boldwhite" type="submit" value="退拟稿人" onclick="return CheckUntread();">
<input type="hidden" name="ID" Value="<%=ID%>">
<input type="hidden" name="Untread" Value="">
</form>
</td></tr>
</table>
</div>
<%end if%>
<div align=center>
<h2><font color=#ff0000> 收文处理</font></h2>
<table border=0 width="95%">
<tr><td align=right><font color=red>当前流程：<%=GetTableValue("tblDocStep","Name","ID",CurrentStep)%></font></td></tr></table>
<table border=1 cellpadding=3 cellspacing=1 width="95%" bgcolor=#FFFFFF bordercolordark="#FFFFFF" bordercolorlight="#999999">
<tr>
	<td align=right width="15%">来文单位：</td>
	<td><%=inDepartment%>&nbsp;</td>
	<td align=right>来文时间：</td>
	<td>
		<%=inTime%>&nbsp;
	</td>
</tr>
<tr>
	<td align=right>发件人：</td>
	<td><%=inFromName%>&nbsp;</td>
	<td align=right>联系电话：</td>
	<td><%=inTelcode%>&nbsp;</td>

</tr>
<tr>
	<td align=right>来文编号：</td>
	<td><%=inSerial%>&nbsp;</td>
	<td align=right>收文编号：</td>
	<td><%=inToName%>&nbsp;</td>

</tr>
<tr>
	<td align=right>承办部门：</td>
	<td><%=inToDepartment%>&nbsp;</td>
	<td align=right>收单人：</td>
	<td><%=inRecieved%>&nbsp;</td>
</tr>
<tr>
	<td align=right>紧急程度：</td>
	<td><%=GetJinjiClass(JinjiClass)%></td>
	<td nowrap align=right>秘密等级：</td>
	<td><%=GetSecureClass(SecureClass)%>&nbsp;
	</td>
</tr>

<tr>
	<td align=right>公文种类：</td>
	<td><%=getTableValue ("tblDocClass","Name","ID",nClass)%>&nbsp;</td>
	<td align=right>保密期限：</td>
	<td>
		<%=SecureTime%>&nbsp;
	</td>
</tr>

<tr>
	<td align=right>印发机关：</td>
	<td><%=PrintDepartment%>&nbsp;</td>
	<td align=right>印发日期：</td>
	<td><%=PrintTime%>&nbsp;</td>
</tr>
<tr>
	<td align=right>拟稿单位：</td>
	<td><%=NigaoDepartment%>&nbsp;</td>
	<td align=right>拟稿人：</td>
	<td><%=Nigao%>&nbsp;
	</td>
</tr>
<tr>
	<td align=right>&nbsp;</td>
	<td colspan=3><table border=0 width="100%"><tr>
	<td width="25%">打字：<%=Printer%>&nbsp;</td>
	<td width="25%">印刷：<%=Publish%>&nbsp;</td>
	<td width="25%">校对：<%=Jiaodui%>&nbsp;</td>
	<td width="25%">份数：<%=Copys%></td>
	</tr></table>
	</td>
</tr>
<tr>
	<td align=right>主送机关：</td>
	<td colspan=3><%=Mainto%>&nbsp;</td>
</tr>
<tr>
	<td align=right>抄送机关：</td>
	<td colspan=3><%=Copyto%>&nbsp;</td>
</tr>
<tr>
	<td align=right>主题词：</td>
	<td colspan=3><%=Title2%>&nbsp;</td>
</tr>
<tr>
	<td align=right>标题：</td>
	<td colspan=3><%=Title%>&nbsp;</td>
</tr>

<tr>
	<td align=right valign=top>内容摘要：</td>
	<td colspan=3>
	<%if trim(body2)<>"" and trim(body)<>trim(body2) then%>
	<font color=red>审核人修改稿：</font><BR>
	<%=replace(replace(server.htmlencode(body2&" ")," ","&nbsp;"),chr(13),"<BR>")%>
	<%else%>
	<%=replace(replace(server.htmlencode(body&" ")," ","&nbsp;"),chr(13),"<BR>")%>
	<%end if%>
	</td>
</tr>
<tr>
	<td align=right valign=top>附注：</td>
	<td colspan=3><%=replace(replace(server.htmlencode(remark&" ")," ","&nbsp;"),chr(13),"<BR>")%></td>
</tr>
<tr>
	<td align=right>附件：</td>
	<td colspan=3><a target="_blank" href="../File_Up/Doc/<%=ID%>/<%=AttachFile%>"><%=AttachFile%></a>&nbsp;</td>
</tr>
<tr>
	<td align=right valign=top>附件说明：</td>
	<td colspan=3><%=replace(replace(server.htmlencode(AttachFileBody&" ")," ","&nbsp;"),chr(13),"<BR>")%></td>
</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)&")"&"<font color=red>["&arrStep(i)&"]</font>—>"
	next
	str1=str1&"<font color=red>(完成)</font>"
	end if
%>
<tr>
	<td align=right valign=top>发稿人：</td>
	<td colspan=3><%=FromName%></td>
</tr>
<tr>

	<td align=right valign=top>公文路径</td>
	<td colspan=3><%=FromName&"<font color=red>[拟稿]</font>—>"&str1%></td>
</tr>
<tr bgcolor=#CCCCFF disabled>
	<td align=right>&nbsp;</td>
	<td colspan=3>处理过的意见</td>
</tr>
<tr>
	<td align=right>&nbsp;</td>
	<td colspan=3>
	<%
	set rs=server.createobject("adodb.recordset")
	sql="select * from tblDocsuggest where DocID="& ID &" order by ID"
	rs.open sql,oConn
	n=0
	while not rs.eof
	n=n+1
	if n mod 2 =0 then
		strColor="#E6F2FF"
	else
		strColor="#FFFFFF"
	end if
		response.write "<table border=1 cellpadding=3 cellspacing=1 width='95%' bgcolor=#FFFFFF bordercolordark=#FFFFFF bordercolorlight=#999999><tr bgcolor="&strColor&"><td>"
		response.write trim(rs("FromName"))&" 在 "&trim(rs("Times"))&" 的处理："
		response.write "</td></tr><tr bgcolor="&strcolor&"><td>"
		response.write replace(replace(rtrim(rs("body")),chr(13),"<br>")," ","&nbsp;")&"&nbsp;"
		response.write "</td></tr></table>"
	rs.movenext
	wend
	rs.close
	set rs=nothing
	%>
	&nbsp;
	</td>
</tr>
<tr disabled>
	<td>&nbsp;</td>
	<td colspan=3 disabled>
	<%
	set rs=server.createobject("adodb.recordset")
	sql="select * from tblDocPress where DocID="& ID &" order by ID"
	rs.open sql,oConn
	while not rs.eof
		response.write "<table border=1 cellpadding=1 cellspacing=1 width='100%' bgcolor=#FFFFFF bordercolordark=#FFFFFF bordercolorlight=#999999><tr bgcolor=#FFCC66><td>"
		response.write trim(rs("FromName"))&" 在 "&trim(rs("Times"))&" 的催办意见："
		response.write "</td></tr><tr><td>"
		response.write replace(replace(rtrim(rs("body")),chr(13),"<br>")," ","&nbsp;")&"&nbsp;"
		response.write "</td></tr></table>"
	rs.movenext
	wend
	rs.close
	set rs=nothing
	%>
	&nbsp;
	</td>
</tr>
<form name="SuggestForm" method="post" action="SaveSuggest.htm">
<%if bRecieved then%>
<tr>
	<td>修改正文</td>
	<%if trim(body2)<>"" and trim(body)<>trim(body2) then%>
	<td colspan=3><textarea rows=8 cols=60 name="body"><%=body2%></textarea>
	<%else%>
	<td colspan=3><textarea rows=8 cols=60 name="body"><%=body%></textarea>
	<%end if%>
	</td>
</tr>
<tr>
	<td>处理意见</td>
	<td colspan=3><textarea rows=4 cols=60 name="Suggest"></textarea>
	</td>
<tr>
	<td>&nbsp;</td>
	<td colspan=3>
	<INPUT TYPE="button" name="cmdCancel" value="打印收文单" onclick="OpenPrint('Doc2_Print_Pre.htm?ID=<%=ID%>','PrintWindow')" class="font9boldwhite">
		<INPUT TYPE="submit" name="cmdUp" value="保 存" onclick="return CheckData();" class="font9boldwhite">&nbsp;&nbsp;		
		<INPUT TYPE="button" name="cmdCancel" value="返  回" onclick="javascript:window.location.href='main.htm'"  class="font9boldwhite">
	</td>
</tr>
<%else%>
<tr>
	<td>&nbsp;</td>
	<td colspan=3 align=right>
		<INPUT TYPE="button" name="cmdCancel" value="返  回" onclick="javascript:window.location.href='main.htm'"  class="font9boldwhite">
	</td>
</tr>
<%end if%>
</table>
</div>
<INPUT TYPE="hidden" name="ID" value="<%=ID%>">
<INPUT TYPE="hidden" name="StepID" value="<%=CurrentStep%>">
</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 OpenPrint(url,windowname)
{
window.open(url,windowname,'left=90,top=20,height=500,width=620,toolbar=no,menubar=no,scrollbars=yes')
}
function CheckData()
{
	
	if(jtrim(document.SuggestForm.Suggest.value)=="")
	{
		alert("请填写处理意见。")
		return false;
	}
			
	return true;
}
</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 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

Private function GetJinjiClass(byval nClass)
select case trim(nClass)
	case "0"
	GetJinjiClass="未定义"
	case "1"
	GetJinjiClass="缓"
	case "2"
	GetJinjiClass="急"
	case "3"
	GetJinjiClass="加急"
	case else
	GetJinjiClass="未定义"
end select
end function

Private function GetSecureClass(byval nClass)
select case trim(nClass)
	case "0"
	GetSecureClass="未定义"
	case "1"
	GetSecureClass="普通"
	case "2"
	GetSecureClass="秘密"
	case "3"
	GetSecureClass="机密"
	case "4"
	GetSecureClass="绝密"
	case else
	GetSecureClass="未定义"
end select
end function
%>