<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnSiteData.Asp" -->
<!--#include file="../CheckAdmin.Asp"-->
<%
s = request.QueryString("s")
Operation = request.QueryString("Operation")
strReferer = Request.ServerVariables("http_referer")
strReferer2=Split(strReferer,"#")
strReferer=strReferer2(0)&"#m"&s
	   Dim rs,sql
Select Case Operation
	 Case "modiy"
	    PlanID="PlanID"&s '计划ID
		ReKehuID="ReKehuID"&s '表单中联系人ID名称
		Cpname="Cpname"&s
		CoID="CoID"&s
		Coname="Coname"&s
		ReID="ReID"&s '表单中沟通记录ID 的名称
		ReKehu="ReKehu"&s '表单中沟通记录输入框 名称
		'OrID="OrID"&s '表单中订单ID 的名称
		Orstatus="Orstatus"&s '表单中订单状态 名称
		
		PlanID=trim(Request.Form(PlanID)) '计划ID
		ReKehuID=trim(Request.Form(ReKehuID)) '联系人ID
		Cpname=trim(Request.Form(Cpname)) '联系人姓名
		CoID=trim(Request.Form(CoID))
		Coname=trim(Request.Form(Coname))
		ReID=trim(Request.Form(ReID)) '当天沟通记录ID
		ReKehu=trim(Request.Form(ReKehu)) '沟通记录
		'OrID=trim(Request.Form(OrID)) '订单ID
		Orstatus=trim(Request.Form(Orstatus)) '订单状态
		
		'=====================================================================
		'=更新联系人最终订单状态
		'=====================================================================
		if Orstatus<>"" then
		Set rs = server.CreateObject("adodb.recordset") 
		sql = "select * from Zqj_Contactperson where Cp_ID="&ReKehuID
        rs.Open sql,conn,1,3
		if rs.bof and rs.eof then
		    
		else
		    
			   rs("Cp_status")=Orstatus
			   rs("Cp_updatime")=now()			
		end if
		rs.update
	    rs.close
		set rs=nothing
		end if
		'====================================================================
		'=更新沟通信息
		'====================================================================
		if trim(ReID)<>"" and IsNumeric(ReID) then
		else
		   ReID=0
		end if
		if trim(CoID)="" or not IsNumeric(CoID) then
		   CoID=0
		end if
		
	 	if ReKehu<>"" then
		   Set rs = server.CreateObject("adodb.recordset")
			sql = "select * from Zqj_Records where Re_ID="&ReID
            rs.Open sql, conn, 1, 3
			if rs.bof and rs.eof then
			   rs.addnew
			   rs("MemName")=session("UserName")
			   rs("RealName")=session("RealName")
			   rs("Re_Content")=ReKehu
			   rs("Re_status")=Orstatus
			   rs("Re_time")=now()
			   rs("Cp_ID")=ReKehuID
			   rs("Re_Contactname")=Cpname
			   rs("Re_company")=Coname
			   rs("Co_ID")=CoID
			   Rid=rs.Fields("Re_ID")
			 else
				 rs("Re_Content")=ReKehu
				 if Orstatus<>"" then
				    rs("Re_status")=Orstatus
				 end if
				 rs("Re_time")=now()
				 Rid=rs("Re_ID")
			 end if
			 rs.update
		     rs.close
			 set rs=nothing
			 conn.Execute "update Zqj_Plan set Re_ID="&Rid&",PL_viewflag=false where PL_ID="&PlanID
		 end if
	 Case else
End Select	   
response.Redirect strReferer
%>