<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnSiteData.Asp" -->
<!--#include file="../CheckAdmin.Asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../Images/Admin_style.css">

<%
Dim Result,SelectID,SelectID2,SelectID3,SelectID4,SelectID5
Result = request.QueryString("Result")
st1=request.Form("st1")
PlanSort=request.Form("PlanSort")
SelectID=request.Form("SelectID")
SelectID2=request.Form("SelectID2")
SelectID3=request.Form("SelectID3")
SelectID4=request.Form("SelectID4")
SelectID5=request.Form("SelectID5")
st2=cdate(st1)+1
st3=cdate(st1)+2
st4=cdate(st1)+3
st5=cdate(st1)+4


if SelectID="" and SelectID2="" and SelectID3="" and SelectID4="" and SelectID5="" then
    response.Write "<script language='JavaScript'>alert('未进行计划安排!');" & "history.back()" & "</script>"
    response.End
end if	
    Dim Action, rs, sql
    Action = request.QueryString("Action")
    If Action = "SaveEdit" Then
	    
		
        Set rs = server.CreateObject("adodb.recordset")
        If Result = "Add" Then
		Response.Write("<div style=""margin:30px;line-height:22px;"">")
	    Response.Write("创建计划开始<br />")
	    Response.Flush()
	    Response.Clear()
		    sql = "select * from Zqj_Plan"
            rs.Open sql, conn, 1, 3
            
		'st1 判断及循环所选联系人并创建计划--------------------------------
		   if not(IsNull(trim(SelectID))) then
	             SelectID=Split(SelectID,",")
	          For i = 0 To UBound(SelectID)
			      Spor=Split(trim(SelectID(i)),"§§§") '分离联系人ID和COID
				      'if trim(Spor(1))<>"" then
					     'orid= trim(Spor(1))
					  'else
					     'orid=0
					  'end if
				  'sql = "select * from Zqj_Plan where Cp_ID="&trim(Spor(0))&" and Or_ID="&orid&" and DATEDIFF('d',PL_time,'"&st1&"')=0"
				  'rs.Open sql, conn, 1, 3
				  'if not(rs.bof and rs.eof) then
			      rs.addnew
			      rs("PL_SortName")=Request.Form("PlanSort")
			      rs("Cp_ID")=trim(Spor(0))
				    if trim(Spor(1))<>"" then
				       rs("Co_ID")=trim(Spor(1))
					end if
				  rs("PL_time")=st1
			      rs("MemName")=session("UserName")
				  rs("RealName")=session("RealName")
			      rs.update
				  'rs.close
				  'set rs=nothing
				  'end if
			  next
			     Response.Write("<span style=""color:green;"">"&st1&" "&getWeek(st1)&" 计划成功创建！</span><br />")
				 Response.Flush()
				 Response.Clear()
		   end if
		 'st2 判断及循环所选联系人并创建计划--------------------------------
		   if not(IsNull(trim(SelectID2))) then
	             SelectID2=Split(SelectID2,",")
	          For i = 0 To UBound(SelectID2)
			      Spor=Split(trim(SelectID2(i)),"§§§")
			      rs.addnew
			      rs("PL_SortName")=Request.Form("PlanSort")
			      rs("Cp_ID")=trim(Spor(0))
				    if trim(Spor(1))<>"" then
				       rs("Co_ID")=trim(Spor(1))
					end if
				  rs("PL_time")=st2
			      rs("MemName")=session("UserName")
				  rs("RealName")=session("RealName")
			      rs.update
			  next
			      Response.Write("<span style=""color:green;"">"&st2&" "&getWeek(st2)&" 计划成功创建！</span><br />")
				  Response.Flush()
				  Response.Clear()
		   end if
		   'st3 判断及循环所选联系人并创建计划--------------------------------
		   if not(IsNull(trim(SelectID3))) then
	             SelectID3=Split(SelectID3,",")
	          For i = 0 To UBound(SelectID3)
			      Spor=Split(trim(SelectID3(i)),"§§§")
			      rs.addnew
			      rs("PL_SortName")=Request.Form("PlanSort")
			      rs("Cp_ID")=trim(Spor(0))
				    if trim(Spor(1))<>"" then
				       rs("Co_ID")=trim(Spor(1))
					end if
				  rs("PL_time")=st3
			      rs("MemName")=session("UserName")
				  rs("RealName")=session("RealName")
			      rs.update
			  next
			      Response.Write("<span style=""color:green;"">"&st3&" "&getWeek(st3)&" 计划成功创建！</span><br />")
				  Response.Flush()
				  Response.Clear()
		   end if
		   'st4 判断及循环所选联系人并创建计划--------------------------------
		   if not(IsNull(trim(SelectID4))) then
	             SelectID4=Split(SelectID4,",")
	          For i = 0 To UBound(SelectID4)
			      Spor=Split(trim(SelectID4(i)),"§§§")
			      rs.addnew
			      rs("PL_SortName")=Request.Form("PlanSort")
			      rs("Cp_ID")=trim(Spor(0))
				    if trim(Spor(1))<>"" then
				       rs("Co_ID")=trim(Spor(1))
					end if
				  rs("PL_time")=st4
			      rs("MemName")=session("UserName")
				  rs("RealName")=session("RealName")
			      rs.update
			  next
			      Response.Write("<span style=""color:green;"">"&st4&" "&getWeek(st4)&" 计划成功创建！</span><br />")
				  Response.Flush()
				  Response.Clear()
		   end if
		   'st5 判断及循环所选联系人并创建计划--------------------------------
		   if not(IsNull(trim(SelectID5))) then
	             SelectID5=Split(SelectID5,",")
	          For i = 0 To UBound(SelectID5)
			      Spor=Split(trim(SelectID5(i)),"§§§")
			      rs.addnew
			      rs("PL_SortName")=Request.Form("PlanSort")
			      rs("Cp_ID")=trim(Spor(0))
				    if trim(Spor(1))<>"" then
				       rs("Co_ID")=trim(Spor(1))
					end if
				  rs("PL_time")=st5
			      rs("MemName")=session("UserName")
				  rs("RealName")=session("RealName")
			      rs.update
			  next
			      Response.Write("<span style=""color:green;"">"&st5&" "&getWeek(st5)&" 计划成功创建！</span><br />")
				  Response.Flush()
				  Response.Clear()
		   end if
		   
		   
        rs.Close
        Set rs = Nothing
        End If
'===============================================
' 修改
'===============================================
        If Result = "Modify" Then
		    
        End If
        
    Else
'==================================================
' 其它
'==================================================
        If Result = "Modify" Then
            
        End If
    End If




Response.Write("创建计划过程完成<br />")
Response.Write("<a href=""My_Plan_todo_bypeople.asp"">马上开展销售</a></div>")
%>