<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.myoa.common.util.SysConfUtil"%>
<%@page import="com.myoa.common.components.selectemp.SelectBuilder"%>
<%@page import="com.stfoa.dao.hibernate.CompanyDAO"%>
<%@page import="com.stfoa.domain.Employee"%>
<%@ include file="/common/include/taglibsnocss.jsp"%>
<html>
<head>
<title>人员选择</title>
<script language="JavaScript" src="js/selectemp.js"></script>
<%@ include file="/common/include/meta.jsp"%>
<%@ include file="/common/include/jquery.jsp"%>
<script language=javascript1.2 >
<!--
 var parentwin = window.dialogArguments;
 String.prototype.ReplaceAll = replaceAll;
 <%
 String docId = request.getParameter("docId");
 String instanceId = request.getParameter("instanceId");
 Integer maxBingXing = SysConfUtil.getInstance().getMaxBingXing();
 SelectBuilder select= new SelectBuilder();
 CompanyDAO compdao = new CompanyDAO();
 Employee self = (Employee)session.getAttribute("session_employee");
 String companyname = compdao.findById(9).getCompanyName();
 String authorizehql = (String)session.getAttribute("authorizehql");
 out.print(select.buildSelect(self.getEmpId(),self.getOaTblDepartment().getDeptId(),companyname,authorizehql));
%> 
 
 function  selectEmps(){
   var idstr = '';
   var opiniontext = myform.opiniontext.value;
   for(var i=0;i<myform.list2.length;i++){
     idstr+=myform.list2.options[i].value+",";
   }
   if(idstr==''){
    alert('请选择人员');
    return;
   }
   if(myform.list2.length><%=maxBingXing%>){
     alert('系统允许的并行流程最大节点数为<%=maxBingXing%>个，可以把人员分组、以“组”作为节点，或以部门、职务作为节点。或者请系统管理员修改系统参数');
     return;
   }
   opiniontext = opiniontext.ReplaceAll('\r\n','<br>');
   resendform.opinion.value= opiniontext;
   resendform.docTrack.value= idstr;
   if(document.all.opinionCheck.checked){
    resendform.isSendOpinion.value="1";
   }else{
    resendform.isSendOpinion.value="0";
   }
   document.all.button_ok.disabled=true;
   resendform.action='${ctx}/collaborate.do?actionmethod=checkTrack';
   ajaxSubmitForm('resendform',function(result){
 	  if(result=='success'){
 		 resendform.action='${ctx}/collaborate.do?actionmethod=resend';
		 ajaxSubmitForm('resendform',ajaxSubmitHandler,'text');
		 
 	  }else{
 		  if(window.confirm(result)){
 			 resendform.action='${ctx}/collaborate.do?actionmethod=resend';
 			 ajaxSubmitForm('resendform',ajaxSubmitHandler,'text');
 		  }else{
 			 document.all.button_ok.disabled=false;
 		  }
 	  }
   },'text');
  }
  function ajaxSubmitHandler(responseText){  
   if(responseText=='success'){
    alert('转发成功！');
    self.close();
   }else if(responseText=='fail'){
    alert('转发失败！');
    document.all.button_ok.disabled=false;
   }else{
    alert(responseText);
    document.all.button_ok.disabled=false;
   }
  }
  function  replaceAll(AFindText,ARepText){
   raRegExp = new RegExp(AFindText,"g");
   return this.replace(raRegExp,ARepText)
  }
  function showAdvance(){
	window.showModalDialog("${ctx}/jsp/collaborate/new/advance.jsp",this,"dialogHeight: 400px; dialogWidth:400px;dialogTop:150;dialogLeft: 200;center: yes; scrollbars=no;status=no");
  }
-->
</script>
  

</head>
<style>
.selectBG{background-color:#ffffcc}
.department{color:red;}
.team{color:red;}
.ocupation{color:red;}
.ocupationLevel{color:red;}
.disabledNode{color:#cccccc}
TR.Blue {BACKGROUND: lightblue}
TR.White {BACKGROUND: #ffffff}
TR.Red {BACKGROUND: steelblue}
</style>
<link href="css/divstyle.css" rel="stylesheet" type="text/css">
<body scroll="yes"  text="#C0C0C0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="initDepartment();">
<form name="myform" target="_self" action="" method="post">
    <div align="center" style="">
      <p>
        <input type="hidden" name="teamId" >
      </p>
 <table border="0" cellpadding="0" cellspacing="0" width="540" height="300">
	<tr>
	<td width="100%" align="center">
		
 <div align="center">

 <table width="100%" border=0 >
 <!--//选择部门或组-->
  <tbody>
    <tr> 
         <td height="17" valign="middle"> <div align="left"><font size="2"> 
            <input type="radio" name="rSelect" value="D" checked id="rDep" onclick="initDepartment();">
            <label for="rDep"><font style="font-size:12" color="black"> 部门</font> </label>
			<input type="radio" name="rSelect" value="I" id="rTitle" onclick="initTitle();">
            <label for="rTitle"><font style="font-size:12" color="black"> 职务</font></label>
            <input type="radio" name="rSelect" value="T" id="rTeam" onclick="initTeam();">
            <label for="rTeam"><font style="font-size:12" color="black"> 组</font> </label>  
			<input type="radio" name="rSelect" value="Q" id="rQuery" onclick="initQuery();">
            <label for="rQuery"><font style="font-size:12" color="black">组合查询</font></label>
           </td>        
    </tr>
  </tbody>
</table>

 <hr>

  <table width="100%" border=0 align=center >
    <tbody>
      <tr>        
	    <td width="10">&nbsp; </td>
        <td width="220" valign="middle"> 
		    <div align="left">
		     <!--左上方输入框-->
		     <div id="toolButton"><font size="2" color="#000000"> 
              <img src='images/openFolder.gif' style="cursor:hand" align='absmiddle' id="selectUnitBack" title="上一级"> 
              <img src='images/hiddenUnitButton.gif' align='absmiddle' style="cursor:hand" onclick="hiddenUnit();" title="隐藏/展开"> &nbsp;&nbsp;
			  <input type="text" name="key" id="key" SIZE="16" title="输入人员姓名">
			  <img src="images/DoSearch.gif" width="16" height="16" style="cursor:hand" onclick="openSearch(document.all.deptId.value,key);" title="点击搜索">
		      </div>
              <br>
			   <!--查询显示区域 -->
			  <div id="selectDiv">
			  <input type="hidden" name="deptId">
			  <input type="text" readonly style="width:200;color:red;cursor:hand" name="deptName" onclick="showDept();" title="点击显示树状结构">
			   <img src="images/find.png" width="16" height="16" style="cursor:hand" onclick="showDept();" title="点击显示树状结构">
			  </div>
			   <!--二级显示区域 -->
              <div id="unitDiv" style="width:220;" > 
                 <table width="220" border="0" cellpadding="0" cellspacing="0">
                   <tr> 
                     <td>
					    <div id="selectUnit2" style="display:none">
                          <select name="selectUnit2">
                          </select>
                        </div>
                        <div style="overflow-y:scroll;overflow-x:auto;height:120px;width:220px;background-color:#ffffff;display:block" id="myDiv"> 
                        </div>
					 </td>
                  </tr>
                </table>
              </div>
              <!--组合查询-->
			  <div align="left" id="queryDiv" style="display:none;font-size=12;height:120px;width:220px;background-color:#ffffff;display:block;">
			   查询条件：<br> <br>
			   部门：<input type="text" readonly style="width:160;color:red;cursor:hand" name="querydeptname" onclick="selectDept();" title="点击选择部门">
			   <input type="hidden" name="querydeptid">
			   <img src="images/find.png" width="16" height="16" style="cursor:hand" onclick="selectDept();" title="点击选择部门"><br>
			   是否包含下级部门：
				<input type="radio" name="isContainSub" value="1" id="rYes" checked><label for="rYes">包含</label>
				<input type="radio" name="isContainSub" value="0" id="rNo"><label for="rNo">不包含</label>
			   职务：<input type="text" readonly style="width:160;color:red;cursor:hand" name="querytitlename" onclick="selectTitle();" title="点击选择职务">
			   <input type="hidden" name="querytitleid">
			   <img src="images/find.png" width="16" height="16" style="cursor:hand" onclick="selectTitle();" title="点击选择职务"><br>			    
				<div align=right><button onclick=query() title="查询">查询</button></div>
			  </div>
			  <!--左侧多选列表-->
              <select  multiple  name="list1" size=10 style="width:220" id=list1 ondblclick="moveadd(myform.list1,myform.list2)">
              </select>
          </div>
		</td>
		<!--中间的操作按钮-->
        <td width="65">
		  <div align="center"> 
            <p align="center">
              <br>
              <button onClick=onClick=movedel(myform.list2) width="27" title="移除选中"><--</button>
              <button onClick=moveadd(myform.list1,myform.list2) width="27" title="添加选中">--></button>
              <br><br><br><br><br><br>
              <button onClick=movedelall(myform.list2) width="27" title="移除全部"><<</button>
              <button onClick=moveaddall(myform.list1,myform.list2) width="27" title="添加全部">>></button>
            <p align="center">
		  </div>
	   </td>
	   <!--右侧的多选列表-->
        <td width="203">
           <div align=left>选中人员：<br><br></div>
		   <div align="right"><br><br>
               <select multiple  name=list2 size=15 style="width:200" id=list2 ondblclick="movedel(myform.list2)" >
                </select>
		   </div>
		</td>
        <td width="30"><img src="images/arrowdown.gif" onClick=up(myform.list2) width="27" title="向上移动"><br>
          <img src="images/arrowup.gif" onClick=down(myform.list2) width="27" title="向下移动"> 
          <br>
        </td>
      </tr>
    </tbody>
  </table>
</td>
</tr>
</table>
</div>

 <table width="94%" border=0 align=center>
  <tr>
   <td><font color=midnightblue><b>&nbsp;&nbsp;转发附言：</b></font></td>
  </tr>
  <tr>
   <td align=center><textarea cols=280 rows=4 style="width=98%" name=opiniontext></textarea></td>
  </tr>
  <tr>
   <td>  
   <span style="displey:none;"><input type="checkbox" id=opinionCheck name=opinionCheck value=check><label for=opinionCheck><font color=midnightblue>转发处理结果</font></label></span>
   <br/><input type="button" onclick="showAdvance()" value="高级>>">      
   </td>
  </tr>
 </table>
 <table width="100%" border=0 >
    <tbody>
      <tr>
	<td valign="middle"> <div align="center"><font size="2"> </font> </div>
	  <p align="center">
	    <input value="确&nbsp;&nbsp;定" type="button" onClick="selectEmps();" name="button_ok"  id="button_ok" class="selectBG">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	    <input value="取&nbsp;&nbsp;消" type="button" onClick="self.close();" name="button_cancel" id="button_cancel" class="selectBG">
	  <div align="center"> </div>
	  <div align="center"> <font size="2"> </font></div></td>
	<td width="27"> <br> </td>
      </tr>
    </tbody>
  </table>
</form>
<form action="${ctx}/collaborate.do?actionmethod=resend" id="resendform" method="post">
 <input type="hidden" name="opinion">
 <input type="hidden" name="docId" value=<%=docId%>>
 <input type="hidden" name="instanceId" value="<%=instanceId%>">
 <input type="hidden" name="instanceType" value="1">
 <input type="hidden" name="docTrack">
 <input type="hidden" name="isSendOpinion">
 <input type="hidden" name="isSendSMS" value="0">
 <input type="hidden" name="sendSMSType" value="1">
 <input type="hidden" name="allowProcessMessage" value="0"> 
 <input type="hidden" name="scheduleType" value="0"> 
 <input type="hidden" name="months" value="1,2,3,4,5,6,7,8,9,10,11,12"> 
 <input type="hidden" name="weeks" value=""> 
 <input type="hidden" name="days" value=""> 
 <input type="hidden" name="times" value="">  
</form>
</body>
</html>

