<!--#include file="islogin.asp"-->
<!--#INCLUDE FILE="fupload.asp"-->
<%
Response.Expires =0

if Request.ServerVariables("REQUEST_METHOD") = "POST" Then
	
	if CLng(Request.ServerVariables("HTTP_Content_Length"))>10240 then
		call deal_msg("公文档案",0,"发送不成功,附件不能超过10k!")
	end if
	
	Dim Fields,doc_id,way,doc_type,doc_state,drafter,phone,department,title,filetitle,priority,secrecy,addfile_name,addfile_type,addfile_size,addfile_content,content,audit_dept,auditor	
	dim from_dept,from_comp,doc_word,doc_serial_recv,keyword_recv,postil
	dim send_type,doc_header,doc_serial_send,sendto_main,sendto_copy,keyword_send
	dim room_address,conferee,meet_time,meet_time_total,organizer,compere,recorder,res,collator,toman
	dim use_time,man_num,start_addr,des_addr
	dim sql,rs,page
	UploadSizeLimit=10000000
	Set Fields = GetUpload()
	dim Field
	
	For Each Field In Fields.Items
		select case Field.name
		case "doc_state":
			doc_state=trim(BinaryToString(Field.value))
		case "page":
			page=trim(BinaryToString(Field.value))
		case "doc_id":
			doc_id=trim(BinaryToString(Field.value))
		case "way":
			way=trim(BinaryToString(Field.value))
		case "doc_type":
			doc_type=trim(BinaryToString(Field.value))
		case "Drafter":
			drafter=trim(BinaryToString(Field.value))
		case "Phone":
			phone=trim(BinaryToString(Field.value))
		case "Department":
			department=trim(BinaryToString(Field.value))		
		case "Title":
			title=trim(BinaryToString(Field.value))
		case "fileTitle":
			filetitle=trim(BinaryToString(Field.value))
		case "Priority":
			priority=trim(BinaryToString(Field.value))		
		case "Secrecy":
			secrecy=trim(BinaryToString(Field.value))
			if(secrecy="") then	secrecy=0
		case "Content":
			content=trim(BinaryToString(Field.value))
		case "Audit_dept":
			audit_dept=trim(BinaryToString(Field.value))
		case "Auditor":
			auditor=trim(BinaryToString(Field.value))
		case "From_dept":
			from_dept=trim(BinaryToString(Field.value))
		case "From_comp":
			from_comp=trim(BinaryToString(Field.value))
		case "Doc_word":
			doc_word=trim(BinaryToString(Field.value))
		case "Doc_serial_send":
			doc_serial_send=trim(BinaryToString(Field.value))
		case "Doc_serial_recv":
			doc_serial_recv=trim(BinaryToString(Field.value))
		case "Keyword_recv":
			keyword_recv=trim(BinaryToString(Field.value))
		case "Keyword_send":
			keyword_send=trim(BinaryToString(Field.value))
		case "Postil":
			postil=trim(BinaryToString(Field.value))
		case "Send_type":
			send_type=trim(BinaryToString(Field.value))
		case "Doc_header":
			doc_header=trim(BinaryToString(Field.value))
		case "Sendto_main":
			sendto_main=trim(BinaryToString(Field.value))
		case "Sendto_copy":
			sendto_copy=trim(BinaryToString(Field.value))
		case "Room_address":
			room_address=trim(BinaryToString(Field.value))
		case "Conferee":
			conferee=trim(BinaryToString(Field.value))
		case "Meet_time":
			meet_time=trim(BinaryToString(Field.value))
		case "Meet_time_total":
			Meet_time_total=trim(BinaryToString(Field.value))
		case "Organizer":
			organizer=trim(BinaryToString(Field.value))
		case "Compere":
			compere=trim(BinaryToString(Field.value))
		case "Recorder":
			recorder=trim(BinaryToString(Field.value))
		case "Res":
			res=trim(BinaryToString(Field.value))
		case "Collator":
			collator=trim(BinaryToString(Field.value))
		case "Toman":
			toman=trim(BinaryToString(Field.value))
		case "Use_time":
			use_time=trim(BinaryToString(Field.value))
		case "Man_num":
			man_num=trim(BinaryToString(Field.value))
		case "Start_addr":
			start_addr=trim(BinaryToString(Field.value))
		case "Des_addr":
			des_addr=trim(BinaryToString(Field.value))
		case "Addfile":
			addfile_name=trim(field.FileName)
			addfile_type=trim(field.ContentType)
			addfile_size=trim(field.Length)
			addfile_content=trim(field.value)
		end select
	next
		
	'--------------------------------------
	'response.write "title=" & title & "<br>"
	'response.write "content=" & content & "<br>"
	'response.write "sendto=" & sendto & "<br>"
	'response.write "filedname=" & filename & "<br>"
	'response.write "fileContentType=" & fileContentType & "<br>"
	'----------------------------------------
	
	connect_db()
	call get_recordset(rs)
	'Response.Write doc_id
	'Response.End 
	'Response.Write "type:"&doc_type&"<br>"
	select case doc_type
	case 1:		
		sql = "select * from tb_doc_recv where id="	&doc_id
		rs.Open sql,conn,1,2
		'rs.addnew		
		'rs("doc_type")=doc_type		
		'rs("drafter")=drafter
		rs("phone")=phone		
		rs("department")=department		
		rs("title")=title		
		rs("priority")=priority		
		rs("from_dept")=from_dept				
		rs("from_comp")=from_comp				
		rs("doc_serial")="["&doc_word&"]"&doc_serial_recv		
		rs("keyword")=keyword_recv		
		rs("postil")=postil				
		rs("content")=content
		rs("audit_dept")=audit_dept
		rs("auditor")=auditor
		rs("secrecy")=secrecy
		rs("doc_state")=doc_state
filetitle=Session("flname")
		if filetitle<>"" then
		rs("addfile_name")=filetitle
		end if
session("flname")=""
		if addfile_name<>"" then
			rs("addfile_name")=addfile_name
			rs("addfile_type")=addfile_type
			rs("addfile_size")=addfile_size
			rs("addfile_content").appendchunk addfile_content
		end if		
		rs.update		
		rs.close 
	case 2:
		conn.BeginTrans
		sql = "select * from tb_doc_send where id="&doc_id
		rs.Open sql,conn,1,2
		'rs.addnew
		'rs("doc_type")=doc_type
		'rs("drafter")=drafter
		doc_type=rs("doc_type")
		drafter=rs("drafter")
		rs("phone")=phone
		rs("department")=department
		rs("title")=title
		rs("priority")=priority		
		rs("content")=content
		rs("audit_dept")=audit_dept
		rs("auditor")=auditor
		rs("secrecy")=secrecy
		rs("doc_state")=doc_state
		rs("source_id")=doc_id
filetitle=Session("flname")
		if filetitle<>"" then
		rs("addfile_name")=filetitle
		end if
session("flname")=""
		if addfile_name<>"" then
			rs("addfile_name")=addfile_name
			rs("addfile_type")=addfile_type
			rs("addfile_size")=addfile_size
			rs("addfile_content").appendchunk addfile_content
		end if
		if doc_state=0 then
			rs("doc_active")=1
		end if
		rs.update
		rs.close()
		if doc_state=0 then
			sql="select * from tb_doc_audit where id is null"
			rs.Open sql,conn,1,2
		
			rs.addnew
			rs("doc_id")=doc_id
		
			rs("fromman")=drafter
			rs("auditor")=auditor
		
			rs("source_id")=doc_id
			rs("doc_type")=doc_type
			'Response.Write doc_state&":"&doc_id
			'Response.End 
			rs.update()
			rs.close()
		end if
		conn.CommitTrans
		
	case 3:
		sql="select * from tb_meet_send where id="&doc_id
		rs.Open sql,conn,1,2
		'doc_type=rs("doc_type")
		'drafter=rs("drafter")
		rs("phone")=phone
		rs("department")=department
		rs("title")=title
		rs("priority")=priority
		rs("room_address")=room_address
		rs("conferee")=conferee
		rs("meet_time")=meet_time
		if meet_time_total<>"" then
			rs("meet_time_total")=meet_time_total
		end if
		rs("organizer")=organizer
		rs("compere")=compere
		rs("recorder")=recorder
		rs("res")=res
		rs("collator")=collator
		rs("toman")=toman
		rs("content")=content
		rs("audit_dept")=audit_dept
		rs("auditor")=auditor
		rs("doc_state")=doc_state
		
		rs.update
		rs.close
	case 4:
		sql="select * from tb_car_askuse where id="&doc_id
		rs.Open sql,conn,1,2
		
		'rs("doc_type")=doc_type
		'rs("drafter")=drafter
		rs("phone")=phone
		rs("department")=department
		rs("title")=title
		rs("priority")=priority
		rs("use_time")=use_time
		if man_num<>"" then
			rs("man_num")=man_num
		end if
		rs("start_addr")=start_addr
		rs("des_addr")=des_addr
		rs("content")=content
		rs("audit_dept")=audit_dept
		rs("auditor")=auditor
		rs("doc_state")=doc_state
		
		rs.update
		rs.close()
		
	case 5,6,7,8,9,10,11,12:
		sql="select * from tb_doc_request where id="&doc_id
		rs.Open sql,conn,1,2
		
		'rs("doc_type")=doc_type
		'rs("doc_type")=drafter
		drafter=rs("drafter")		
		rs("phone")=phone
		rs("department")=department
		rs("title")=title
		rs("priority")=priority
		rs("content")=content
		rs("audit_dept")=audit_dept
		rs("auditor")=auditor
		rs("doc_state")=doc_state
		
		rs.update()
		rs.close()
		if doc_state=0 then
			sql="select * from tb_doc_audit where id is null"
			
			rs.Open sql,conn,1,2
		
			rs.addnew
			rs("doc_id")=doc_id
		
			rs("fromman")=drafter
			rs("auditor")=auditor
		
			rs("source_id")=doc_id
			rs("doc_type")=doc_type
			
			rs.update()
			rs.close()
			
		end if
		
	end select
		
	set rs=nothing
	close_db()
		
	if Err.number <> 0 then
		close_db()
		call deal_msg("公文档案",0,"数据库错误,提交领导审核不成功!")
	end if
	call deal_msg("公文档案",0,"数据提交成功!")
end if
%>