<!--#include file="../inc/Secure.htm"-->
<!--#include file="../inc/conn.htm"-->
<!--#include file="../inc/dbtools.htm"-->
<%
ID=trim(request("ID"))
if ID="" then ID=0
msg=trim(request("msg"))
if msg<>"" then response.write "<p align=center><font color=red>"& msg &"</font></p>"
dim NewID

'if request("cmdUp")<>"" then	
	Name=replace(trim(request("Name")),"'","''")
	CheckNamelist=replace(trim(request("CheckNameList")),"'","''")
	CheckIDList=TRIM(request("CheckIDList"))
	StepID=TRIM(request("StepID"))
	StepName=TRIM(request("StepName"))
	if CheckIDList="" then CheckIDList=0
	if CheckIDlist<>"" and StepID<>"" then
		if ID=0 then
			AddDocCheck()
			ID=NewID
		else
			strCheckNameList2=GetTableValue("tblDocCheckTmp","CheckNameList","ID",ID)&"."&CheckNamelist
			strCheckIDList2=GetTableValue("tblDocCheckTmp","CheckList","ID",ID)&"."&CheckIDList
			strCheckStepID2=GetTableValue("tblDocCheckTmp","CheckStepID","ID",ID)&","&StepID
			strCheckStepName2=GetTableValue("tblDocCheckTmp","CheckStepName","ID",ID)&","&StepName

			UpdateDocCheck(ID)
		end if
		oconn.close
		response.redirect "AddPath_user.htm?ID="& ID &"&Msg="& SERVER.URLencode("请继续选择添加，或点确定结束！")

	end if
'end if
if ID<>0 then
	set rstmp=server.createobject("adodb.recordset")
	sql="select * from tblDocCheckTmp where ID="& ID
	rstmp.open sql,oConn
	if not rstmp.eof then
	strCheckName=trim(rstmp("CheckNameList"))
	strCheckStepName=trim(rstmp("CheckStepName"))
	arrName=split(strCheckName,".")
	arrStep=split(strCheckStepName,",")
	
	end if
	rstmp.close
	set rstmp=nothing
end if

%>
<html>
<head>
<title>定义路径</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">
<BR><BR>
<div align=center>
<form name="DocForm" method="post" action="">
<table border=1 cellpadding=3 cellspacing=1 width="100%" bgcolor=#FFFFFF bordercolordark="#FFFFFF" bordercolorlight="#999999">
<tr>
	<td align=center colspan=2>
	<b>自定义路径</b>(其中“分发”只能作为发文的最后一步)
	</td>
</tr>

<tr>
	<td align=center>
	<table border=0 width="90%">
	<%
	if id<>0 and (not isempty(arrName)) then
	for i=0 to ubound(arrName)%>
		<tr><td align=center><%="("&arrName(i)&")"&"——<font color=red>"&arrStep(i)&"</font>"%></td></tr>
		<tr><td align=center>|<br>|</td></tr>
	<%next
	end if%>
	</table>
	</td>
</tr>

<tr>
	<td align=center>
	人名：<INPUT TYPE="text" class="doc_txt" size=30 readonly name="CheckNameList" value="<%=strCheckNameList%>">
	操作：<INPUT TYPE="text" class="doc_txt" size=10 readonly name="StepName" value="<%=StepName%>">添加步骤
	<INPUT TYPE="button" name="cmdAttach" value="选择人" onclick="OpenWindow('MultiUsers_usr.htm','SelUserWindow')" class="font9boldwhite"></td>
</tr>
<INPUT TYPE="hidden" name="CheckIDList" value="<%=strCheckIDList%>">
<INPUT TYPE="hidden" name="StepID" value="<%=StepID%>">
<INPUT TYPE="hidden" name="ID" value="<%=ID%>">
</form>
<form name="closeform" method="post" action="AddPath_close.htm">
<tr>
	<td align=center><BR>
		<INPUT TYPE="submit" name="cmdUp" value="确定流程完成" onclick="return CheckData();" class="font9boldwhite">		
		<INPUT TYPE="button" name="cmdCancel" value="取 消" onclick="javascript:window.location.href='PathClose.htm?ID=<%=ID%>'"  class="font9boldwhite">
	</td>

</tr>
</table>
<INPUT TYPE="hidden" name="CheckList_Usr" value="<%=ID%>">
</form>
</body>
<BR><BR>
</html>
<!--#include file="../inc/conn_close.htm"-->
<script language="JavaScript">
function OpenWindow(url,windowname)
{
window.open(url,windowname,'left=80,top=50,height=350,width=640,toolbar=no,menubar=no,scrollbars=yes,status=no')
}
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.closeform.CheckList_Usr.value)=="0")
	{
		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 AddDocCheck()
	sql="SET NOCOUNT ON;"
	sql=sql&" INSERT INTO tblDocCheckTmp(Name,CheckList,CheckNameList,CheckStepID,CheckStepName) VALUES('" & Name & _
		"','"& CheckIDlist & _
		"','"& CheckNameList & _
		"','"& StepID & _
		"','"& StepName & _
		"');"
		sql=sql & "Select @@IDENTITY AS NewID;"
		'response.write sql
		Set Rs1=oConn.execute (sql)
		NewID = Rs1("NewID")
end sub

Sub UpdateDocCheck(ID)
	sql="Update tblDocCheckTmp set Name='"& Name &"',CheckList='"& strCheckIDList2 &"',CheckNameList='"& strCheckNameList2 &"',CheckStepID='"& strCheckStepID2 &"',CheckStepName='"& strCheckStepName2 &"' where ID="& ID
	'response.write sql
	oConn.execute (sql)
end sub


%>