<!--#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">
<script language="javascript" src="../JavaScript/jquery.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="../My97DatePicker/WdatePicker.js"></script>
<script language="javascript" src="../JavaScript/Admin.js"></script>
<script type="text/javascript">
<!--
function checktasksseach()
{
   if (tasks.st.value.replace(/[ ]/g,"")=="")
   {
	  alert("需要制定计划的起始日期！");
	  return false;
   }
}
function changePos(thisID){
		var st=document.getElementById(thisID);
		if(document.body.clientWidth+document.body.scrollLeft-st.offsetLeft>=st.clientWidth){
			st.style.left=st.offsetLeft+'px';
		}else{
			st.style.left=(document.body.clientWidth>=st.clientWidth)? (document.body.clientWidth-st.clientWidth+document.body.scrollLeft-10)+'px':document.body.scrollLeft+'px';
			}
		if (document.body.clientHeight + document.body.scrollTop - st.offsetTop - st.clientHeight < st.clientHeight){
			//st.style.top  = (st.offsetTop - document.body.scrollTop < st.clientHeight) ? (st.offsetTop + st.clientHeight) +'px': (st.offsetTop - st.clientHeight)+'px';
			st.style.top=(st.offsetTop - document.body.scrollTop < st.clientHeight) ? (document.body.clientHeight-st.clientHeight+document.body.scrollTop-10) +'px': (st.offsetTop - st.clientHeight)+'px';
		}
	}
function display(display,indexID){
        document.getElementById(indexID).style.display=display;
}
function Show_bt(btID,rid){
		 document.getElementById(btID).style.display="";
		 document.getElementById(rid).style.width="250px";
		 //document.getElementById(rid).style.height="30px";
 }
function Ushow_bt(btID,rid)
{
	//document.getElementById(btID).style.display="none";
	document.getElementById(rid).style.width="250px";
	document.getElementById(rid).style.height="";
}
function checkkhreedit(checkid,forms)
{
  if (document.getElementById(checkid).value.replace(/^\s*/g,"")==""){
	   alert("事件不能为空,请认真填写!");
	   document.getElementById(checkid).focus();
	   return false;
	   }
   
}
function checkformmake(formmake) //验证是否已选择计划日期
{ 
   var count=0;
   for (var i=0;i<form.elements.length;i++)
   {
      var e = form.elements[i];
      if (e.checked==false)
      {
	     
      }
      else
      {
	     count++;
      }
   }
    if (count == 0)
    {
        return false;
    }
}


function optsAll(a){
	$("input[name='"+a+"']").each(function(){
		if(this.checked!="checked"){$(this).click();}
	});
}

-->
</script>
<%
Dim Result,st,et,s,showpan
Dim mOr_status
Result = request.QueryString("Result")
ID = request.QueryString("ID")
mOr_status=trim(request.QueryString("Or_status"))
Action = request.QueryString("Action")
'------------初始计划起始日期------
st=trim(request("st")) '
    If Action = "seach" Then
	   st=trim(request.Form("st"))
	      if st="" then '查询分页时
	         st=trim(request("st"))
	      end if
	end if
if st="" then
   st=dateadd("d",date+2,7-weekday(date))
end if
st=cdate(st)
'------------初始计划起始日期结束-----
s=1
%>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  <form name="tasks" method="post" action="?Action=seach&Or_status=<%=mOr_status%>&st=<%=st%>&Page=1" onSubmit="return checktasksseach()">
    <tr>
      <td class="forumRow">
      
      订单状态：
      <select name="Or_status" onchange="window.location='?Or_status=' + this.value+'&st=<%=st%>'">
      <option value="">所有</option>
      <option value="D" <%if mOr_status="D" then response.Write "selected"%>>D</option>
      <option value="C" <%if mOr_status="C" then response.Write "selected"%>>C</option>
      <option value="B" <%if mOr_status="B" then response.Write "selected"%>>B</option>
      <option value="A" <%if mOr_status="A" then response.Write "selected"%>>A</option>
      <option value="O" <%if mOr_status="O" then response.Write "selected"%>>O</option>
   </select>
 &nbsp;&nbsp; 需要制定计划的起始日期：
   <input name="st" class="Wdate" type="text" id="st" style="background-color:#EBF2F9" value="<%=st%>" maxlength="16" onFocus="WdatePicker({skin:'blueFresh'})">
   <input name="submit" type="submit" id="submit" value="显示" />
  
      </td>
    </tr>
    <tr>
    <td class="forumRow">
	<%PlaceFlag()%></td>
  </tr>
  </form>
</table>
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1" style="background-color:#e6eff8">
<form action="Make_bypeople1_Edit.asp?Action=SaveEdit&Result=Add&st=<%=st%>" method="post" name="formmake" onSubmit="return checkformmake('formmake')">

  <tr>
    <th width="30">序号</th>
     <th>更新日期</th>
    <th align="left">公 司</th>
    <th>联系人</th>
    <th>电 话</th>
    <th align="center" >订单状态</th>	
    <th ><font color="#006600"><%=getWeek(st)%></font><br><font color="#6600FF"><%=st%></font></th>
    <th ><font color="#006600"><%=getWeek(st+1)%></font><br><font color="#6600FF"><%=st+1%></font></th>
    <th ><font color="#006600"><%=getWeek(st+2)%></font><br><font color="#6600FF"><%=st+2%></font></th>
    <th ><font color="#006600"><%=getWeek(st+3)%></font><br><font color="#6600FF"><%=st+3%></font></th>
    <th ><font color="#006600"><%=getWeek(st+4)%></font><br><font color="#6600FF"><%=st+4%></font></th>
   
  </tr>
  <% MyTasksKehutodo2() %>
  <%if showpan>0 then%>
  <tr>
  <td colspan="11" bgcolor="#ABD200">&nbsp; 
  <input name="st1" type="hidden" id="st1" value="<%=st%>" >
  选择一个分类：
     <select name="PlanSort">
     <option value="电话">电话</option>
	  <option value="拜访">拜访</option>
      <option value="其它">其它</option>
	 </select> &nbsp;
     <input name="submitp" type="submit" id="submitp" value="保存计划" />
     </td>
  </tr>
  <%end if%>
  <tr>
  <td colspan="11">&nbsp;</td>
  </tr>
</form>
</table>
<%
'==============================
'函 数 名：MyTasksKehutodo2
'作    用：客户任务分页列表
'参    数：
'==============================
Function MyTasksKehutodo2()
    Dim idCount
    Dim pages
    pages = 50
    Dim pagec
    Dim page
    page = CLng(request("Page"))
    Dim pagenc
    pagenc = 2
    Dim pagenmax
    Dim pagenmin
    Dim datafrom
    datafrom = "Zqj_Contactperson LEFT JOIN Zqj_Company ON Zqj_Contactperson.Co_ID = Zqj_Company.Co_ID"
    Dim datawhere
	if mOr_status<>"" then
        datawhere="where Zqj_Contactperson.Cp_status='"&mOr_status&"' and Zqj_Contactperson.Memname='"&session("UserName")&"' and Zqj_Contactperson.Cp_working "
	else
	    datawhere="where Zqj_Contactperson.Memname='"&session("UserName")&"' and Zqj_Contactperson.Cp_working "
	end if	
    Dim Myself, PATH_INFO, QUERY_STRING
    PATH_INFO = request.servervariables("PATH_INFO")
    QUERY_STRING = request.ServerVariables("QUERY_STRING")'
    If QUERY_STRING = "" Or InStr(PATH_INFO & "?" & QUERY_STRING, "Page=") = 0 Then
        Myself = PATH_INFO & "?Or_status="&mOr_status&"&st="&st&"&"
    Else
        Myself = Left(PATH_INFO & "?" & QUERY_STRING, InStr(PATH_INFO & "?" & QUERY_STRING, "Page=") -1)
    End If
    Dim taxis
    taxis = "order by Zqj_Contactperson.Cp_updatime DESC"
    Dim i
    Dim rs, sql
    sql = "select Zqj_Contactperson.*,Zqj_Company.Co_ID as coid, Zqj_Company.Co_name , Zqj_Contactperson.Memname from "& datafrom &" "&datawhere &taxis
    Set rs = server.CreateObject("adodb.recordset")
    rs.Open sql, conn, 1, 1
	   idCount = rs.RecordCount
	   showpan=idCount
       If(idcount>0) Then
               If(idcount Mod pages = 0)Then
                  pagec = Int(idcount / pages)
               Else
                  pagec = Int(idcount / pages) + 1
               End If
               rs.pagesize = pages
               If page < 1 Then page = 1
               If page > pagec Then page = pagec
               If pagec > 0 Then rs.absolutepage = page
        End If
    noli=1
	if not(rs.bof and rs.eof) then
	repeat_rows = 0
    While(repeat_rows < rs.PageSize and Not rs.EOF)
%>
    <tr <%if (noli mod 2)=1 then%>bgcolor='#F0F8FF'<%end if%> onMouseOver="this.style.backgroundColor='#F3D2A8'" onMouseOut="this.style.backgroundColor=''">
    <td align="center"><%=(page-1)*pages+noli%></td>
    <td style="color:#2C5322">
    <%
	strDateTime=rs("Cp_updatime")
    If datediff("d",strDateTime,Now())=0 then
       response.Write "<font color=""#ff0000"">"&strDateTime&"</font>"
    else
       response.Write strDateTime
    End if
	%>
    </td>
    <td><%=rs("Co_name")%></td>
    <td><a href="../Kehu/My_people_KehuView.Asp?Result=Modify&ID=<%=rs("Cp_ID")%>&showid=0" target="_blank"><%=rs("Cp_name")%></a></td>
    <td><%=rs("Cp_tel")%></td>
    <td align="center"><b>
	<%
	Select Case rs("Cp_status")
	    case "D"
		    response.Write "<font color=""#6699FF"">D</font>"
	    case "C"
		    response.Write "<font color=""gray"">C</font>"
		case "B"
		    response.Write "<font color=""#354C80"">B</font>"
		case "A"
		    response.Write "<font color=""#C87701"">A</font>"
		case "O"
		     response.Write "<font color=""#FF0000"">O</font>"
		case else
	End Select
	%></b></td>
    <td align="center"><input name="selectID" type="checkbox" value="<%=rs("Cp_ID")%>§§§<%=rs("Co_ID")%>" <%
	if rs("Cp_ID") then
	call selectc(rs("Cp_ID"),rs("Co_ID"),st)
	end if
	%>></td>
    <td align="center"><input name="selectID2" type="checkbox" value="<%=rs("Cp_ID")%>§§§<%=rs("Co_ID")%>" <%
	if rs("Cp_ID") then
	call selectc(rs("Cp_ID"),rs("Co_ID"),st+1)
	end if
	%>></td>
    <td align="center"><input name="selectID3" type="checkbox" value="<%=rs("Cp_ID")%>§§§<%=rs("Co_ID")%>" <%
	if rs("Cp_ID") then
	call selectc(rs("Cp_ID"),rs("Co_ID"),st+2)
	end if
	%>></td>
    <td align="center"><input name="selectID4" type="checkbox" value="<%=rs("Cp_ID")%>§§§<%=rs("Co_ID")%>" <%
	if rs("Cp_ID") then
	call selectc(rs("Cp_ID"),rs("Co_ID"),st+3)
	end if
	%>></td>
    <td align="center"><input name="selectID5" type="checkbox" value="<%=rs("Cp_ID")%>§§§<%=rs("Co_ID")%>" <%
	if rs("Cp_ID") then
	call selectc(rs("Cp_ID"),rs("Co_ID"),st+4)
	end if
	%>></td>
  </tr>
<%
   noli=noli+1
   s=s+1
   repeat_rows = repeat_rows + 1
   rs.movenext
   Wend
Response.Write "<tr bgcolor='#F5F5DC'>" & vbCrLf
Response.Write "<td>&nbsp;</td>" & vbCrLf
Response.Write "<td></td>" & vbCrLf
Response.Write "<td></td>" & vbCrLf
Response.Write "<td></td>" & vbCrLf
Response.Write "<td></td>" & vbCrLf
Response.Write "<td align='right'>全选/反选</td>" & vbCrLf
Response.Write "<td align='center'><input type=""checkbox"" onclick=""optsAll('selectID')"" /></td>" & vbCrLf
Response.Write "<td align='center'><input type=""checkbox"" onclick=""optsAll('selectID2')"" /></td>" & vbCrLf
Response.Write "<td align='center'><input type=""checkbox"" onclick=""optsAll('selectID3')"" /></td>" & vbCrLf
Response.Write "<td align='center'><input type=""checkbox"" onclick=""optsAll('selectID4')"" /></td>" & vbCrLf
Response.Write "<td align='center'><input type=""checkbox"" onclick=""optsAll('selectID5')"" /></td>" & vbCrLf
Response.Write "</tr>" & vbCrLf
    Else
        response.Write "<tr><td nowrap align='center' colspan='11'><img src=""../Images/question.gif"" width=""18"" height=""18""/> <font color='#999999'>暂无相关的联系人，请先<a href=""../Kehu/My_people_KehuEdit.Asp?Result=Add&showid=0"">添加</a>...</font></td></tr>"
    End If


Response.Write "<tr>" & vbCrLf
Response.Write "<td colspan='11' nowrap class=""forumRow"">" & vbCrLf
Response.Write "<table width='98%' border='0' align='center' cellpadding='5' cellspacing='1' style=""margin-bottom:0px;"">" & vbCrLf
Response.Write "<tr>" & vbCrLf
Response.Write "<td class=""forumRow"">&nbsp; 共计：<font color='red'>"&idcount&"</font>条记录 页次：<font color='red'>"&page&"</font></strong>/"&pagec&" 每页：<font color='red'>"&pages&"</font>条</td>" & vbCrLf
Response.Write "<td align='right' class=""forumRow"">" & vbCrLf
pagenmin = page - pagenc
pagenmax = page+pagenc
If(pagenmin<1) Then pagenmin = 1
If(page>1) Then response.Write ("<a href='"& myself &"Page=1'><font style='font-size: 14px; font-family: Webdings'>9</font></a> ")
If(pagenmin>1) Then response.Write ("<a href='"& myself &"Page="& page - (pagenc * 2 + 1) &"'><font style='font-size: 14px; font-family: Webdings'>7</font></a> ")
If(pagenmax>pagec) Then pagenmax = pagec
For i = pagenmin To pagenmax
    If(i = page) Then
    response.Write (" <font color='red'>"& i &"</font> ")
Else
    response.Write ("[<a href="& myself &"Page="& i &">"& i &"</a>]")
End If
Next
If(pagenmax<pagec) Then response.Write (" <a href='"& myself &"Page="& page+(pagenc * 2 + 1) &"'><font style='font-size: 14px; font-family: Webdings'>8</font></a> ")
If(page<pagec) Then response.Write ("<a href='"& myself &"Page="& pagec &"'><font style='font-size: 14px; font-family: Webdings'>:</font></a> ")
Response.Write "第<input name='SkipPage' onKeyDown='if(event.keyCode==13)event.returnValue=false' onchange=""if(/\D/.test(this.value)){alert('请输入需要跳转到的页数并且必须为整数！');this.value='"&Page&"';}"" style='width: 28px;' type='text' value='"&Page&"'>页" & vbCrLf
Response.Write "<input name='submitSkip' type='button' onClick='GoPage("""&Myself&""")' value='转到'>" & vbCrLf
Response.Write " </td>" & vbCrLf
Response.Write "</tr>" & vbCrLf
Response.Write "</table>" & vbCrLf
Response.Write "</td>" & vbCrLf
Response.Write "</tr>" & vbCrLf
rs.Close
Set rs = Nothing
End Function

Function companyText(ID) '显示相关联公司
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From Zqj_Company where Co_ID="&ID
    rs.Open sql, conn, 1, 1
	if rs.bof and rs.eof then
	response.Write ""
	else
	   response.Write "<a href=""../Kehu/My_Companies_KehuView.Asp?Result=Modify&ID="&rs("Co_ID")&"&showid=0"" target=""_blank"">"&rs("Co_name")&"</a> "
	end if 
    rs.Close
    Set rs = Nothing
End Function

Function PlaceFlag()
        If mOr_status<>"" Then
            Response.Write "<img src='../Images/current.jpg' /> 当前位置：订单状态 -> <font color='#ff6600'>"&mOr_status&"</font>"
        Else
            Response.Write "<img src='../Images/current.jpg' /> 当前位置：订单状态 -> <font color='#ff6600'>全部</font>"
        End If
End Function

Function selectc(Cp_ID,CoID,PL_time)
    'if OrID="" then
	   'OrID=0
	'end if
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From Zqj_Plan where Cp_ID="&Cp_ID&" and DATEDIFF('d',PL_time,'"&PL_time&"')=0 and MemName='"&session("UserName")&"'"
    rs.Open sql, conn, 1,3
	if rs.bof and rs.eof then
	selectc = ""
	else
	response.Write "checked=""checked"" disabled"	
	end if
    rs.Close
    Set rs = Nothing
End Function
%>
