<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Collection" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.tool.SzDateHelp" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.flow.*" %>
<%@ include file="/sessionInfo.jsp"%>
<%
  String strLevel = "../../";
%>
<head>
<title></title>
<BASE target=_self>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
</head>
<%
    //是否来自弹出窗口的修改？
    String sWin = SzConvert.strWriteData(request.getParameter("win"));
    //获取提交的参数
    //type就是流程ID
    //PKEY就是流程前一步骤ID
    String sType = SzConvert.toZeroStr(request.getParameter("type"));
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
    String sPKEY = SzConvert.toZeroStr(request.getParameter("PKEY"));
        
    String sTable_type = "SZKC_CPFL";
    
%>
<%
    SzData szData = null;
    SzDataInfo szDataInfo = null;

    String sOPERATOR = request.getParameter("OPERATOR");    
    String sKEY =  SzConvert.toZeroStr(request.getParameter("KEY"));
    
    //是否来自修改窗口
    //禁止拟稿添加、更换流程的情况下修改流程，就可以避免很多麻烦问题！！！
    //下一步再实现。
    if (sWin.equals("win") && sOPERATOR.equals("add") && sType.equals("0")) {
       //拟稿的时候，手工增加一个步骤。需要先手工增加一个流程
       LcFlow lcFlow = new LcFlow();
       
       String sFlowName = lcFlow.addDefaultFlow(iDLID_SESSION, sDLXM_SESSION);
       int iFlowID = lcFlow.getKeyValue();
       //获得新增加的拟稿节点
		   LcStep lcStep = new LcStep();
       //System.out.println(sFlowName + "==" + iFlowID);
       sType = Integer.toString(iFlowID);
       sPKEY = "1";
       //更新窗口
   	   out.println("<script language='javascript'>");
  	   out.println("  var oWindow = window.dialogArguments;");
  	   out.println("  eval(\"oWindow.document.formList.LCID.value='" + iFlowID + "'\");");
  	   out.println("  eval(\"oWindow.document.formList.LCMC.value='" + sFlowName + "'\");");  		 
  	   out.println("</script>");
    }
    
    
    String sReadonly = "";
    boolean bReadonly = false;
    if (sOPERATOR.equals("detail")) {
        sReadonly = "readonly";
        bReadonly = true;
    }
    //读取数据
    LcStepInfo lcStepInfo = null;
    LcStep lcStep = new LcStep();
    if (!sKEY.equals("0")) {
        lcStepInfo = (LcStepInfo)lcStep.getInfoByKey(Integer.parseInt(sKEY));
    }
    if (lcStepInfo == null) {
        lcStepInfo = new LcStepInfo();
        lcStepInfo.setBZLC(Integer.parseInt(sType));
        lcStepInfo.setBZXH(Integer.parseInt(sPKEY));
        lcStepInfo.setBZTXLX("2");
        lcStepInfo.setBZTXFS("1");    
        lcStepInfo.setBZQXFJ(1);
        
        //如果是手动发起的流程，默认可以修改流程、修改表单
        if (sWin.equals("win") && sOPERATOR.equals("add")) {
        	lcStepInfo.setBZQXBD(1);
        	lcStepInfo.setBZQXLC(1);
        }
    } else {
    }
%>

<body>
<!-----上面的工具栏------>
<form name="formUpdate" method="post" action="">
  <input type="hidden" name="PKEY" value="<%=sPKEY%>">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
  <input type="hidden" name="KEY" value="<%=sKEY%>">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="detailCount" value="0">
  <input type="hidden" name="win" value="<%=sWin%>">
  <input type="hidden" name="winName" value="">  
<% //2012-01-10
	if (!sWin.equals("win")) {  %>
<%@ include file="/share/title.jsp"%>
<% } %>
<table width="100%">
  <tr>
    <td>
    <% if (!bReadonly) { %>
      <%=SzPageHelp.saveButton()%>
    <% } %>
    <% if (!sWin.equals("win")) { %>    
      <%=SzPageHelp.backButton()%>
    <% } else {%>
      <%=SzPageHelp.closeButton()%>    
    <% } %>
    </td>
  </tr>
</table>

<!-----信息维护------>
<TABLE id=SZFORMtable1 style="CURSOR: hand" cellSpacing=0 borderColorDark=#ffffff cellPadding=3 width=650 borderColorLight=#c0c0c0 border=1>
<DIV id=divSZFORMtable1 style="BACKGROUND: #c0c0c0; CURSOR: hand; HEIGHT: 0px; display:none;">
<INPUT id=XX1 size=10 name=XX1>
<INPUT id=XX26 size=10 name=XX26>
<INPUT class=txtClass1 id=XX2 size=10 name=XX2>
<INPUT class=txtClass1 id=XX5 size=10 name=XX5>
<INPUT class=txtClass1 id=XX14 size=10 name=XX14>
</DIV>
<TBODY>
<TR id=SZFORMtr1>
<TD class=trMouseOut id=SZFORMtd3 style="CURSOR: hand">步骤名称
<input type="button" name="btnSelect" class="btnClassShort" value="选择" OnClick="javascript:OpenIdSingleWin('SZLC_MC', '','formUpdate.XX3');">
</TD>
<TD class=trMouseOut id=SZFORMtd4 style="CURSOR: hand">
<INPUT class=txtClass1 id=XX3 size=10 name=XX3>
</TD>
<TD class=trMouseOut id=SZFORMtd5 style="CURSOR: hand" width="15%">办理期限</TD>
<TD class=trMouseOut id=SZFORMtd6 style="CURSOR: hand">
  <INPUT class=txtClass60 id=XX4 name=XX4>(小时，天换算成小时：<INPUT class=txtClassPage id="limitDay" name="limitDay" OnChange="javascript:DateToHour(formUpdate.limitDay, formUpdate.XX4);">)
</TD>
</TR>
<!-- 
<TR id=SZFORMtr1>
<TD class=trMouseOut id=SZFORMtd3>自动跳转时间</td>
<td colspan="3">
  <INPUT class=txtClass60 id=XX16 name=XX16>(小时，天换算成小时：<INPUT class=txtClassPage id="limitDay2" name="limitDay2" OnChange="javascript:DateToHour(formUpdate.limitDay2, formUpdate.XX16);">
  办理期限之后的自动跳转时间。0表示不跳转)
</TD>
</TR>
 -->
<TR id=SZFORMtr3>
<TD class=trMouseOut id=SZFORMtd9 style="CURSOR: hand">办理说明</TD>
<TD class=trMouseOut id=SZFORMtd10 style="CURSOR: hand" colSpan=3><TEXTAREA class=areaClass2 id=XX6 name=XX6></TEXTAREA></TD></TR>
<TR id=SZFORMtr4>
<TD class=trMouseOut id=SZFORMtd13 style="CURSOR: hand">办理属性</TD>
<TD class=trMouseOut id=SZFORMtd14 style="CURSOR: hand" colspan="3">
<span style="width:140;"><INPUT id=XX19 type=checkbox value=1 name=XX19>是否可以修改表单</span>
<span style="width:100;"><INPUT id=XX18 type=checkbox value=1 name=XX18>是否会签&nbsp;</span>
<span style="width:100;"><INPUT id=XX21 type=checkbox value=1 name=XX21>是否可以退回</span>
<span style="width:100;"><INPUT id=XX22 type=checkbox value=1 name=XX22>是否可以办结</span>

</TD>
</TR>
<TR id=SZFORMtr5>
<TD class=trMouseOut id=SZFORMtd17 style="CURSOR: hand">&nbsp;</TD>
<TD class=trMouseOut id=SZFORMtd18 style="CURSOR: hand" colspan="3">
<span style="width:140;"><INPUT id=XX20 type=checkbox value=1 name=XX20>是否可以修改流程</span>
<span style="width:100;"><INPUT id=XX23 type=checkbox value=1 name=XX23>是否可以否决</span>
<span style="width:100;"><INPUT id=XX24 type=checkbox value=1 name=XX24>是否可以跳签</span>
<span style="width:100;"><INPUT id=XX25 type=checkbox value=2 name=XX25>手机短信提醒</span>
</TD>
</TR>
<TR id=SZFORMtr10>
<TD class=trMouseOut id=SZFORMtd37 style="CURSOR: hand">&nbsp;</TD>
<TD class=trMouseOut id=SZFORMtd38 style="CURSOR: hand" colSpan=3>
<span style="width:140;"><INPUT id=XX17 type=checkbox value=2 name=XX17>信息提醒申请人</span>
</TD></TR>
<!---------------------------------
<TR id=SZFORMtr11>
<TD class=trMouseOut id=SZFORMtd41 style="CURSOR: hand" width="20%">消息提醒方式</TD>
<TD class=trMouseOut id=SZFORMtd42 style="CURSOR: hand" colSpan=3>
<span style="width:140;"><INPUT id=XX25 type=checkbox value=1 name=XX25>及时信息</span>
<span style="width:100;"><INPUT id=XX25 type=checkbox value=2 name=XX25>手机短信</span>
<span style="width:100;"><INPUT id=XX25 type=checkbox value=3 name=XX25>内部邮件</span>
<span style="width:100;"><INPUT id=XX25 type=checkbox value=4 name=XX25>外部邮件</span>
</TD></TR>

<TR id=SZFORMtr10>
<TD class=trMouseOut id=SZFORMtd37 style="CURSOR: hand">消息提醒类型</TD>
<TD class=trMouseOut id=SZFORMtd38 style="CURSOR: hand" colSpan=3>
<span style="width:140;"><INPUT id=XX17 type=checkbox value=1 name=XX17>当前审批人</span>
<span style="width:100;"><INPUT id=XX17 type=checkbox value=2 name=XX17>申请人</span>
<span style="width:100;"><INPUT id=XX17 type=checkbox value=3 name=XX17>前一步审批人</span><br>
<span style="width:140;"><INPUT id=XX17 type=checkbox value=4 name=XX17>模块管理人员</span>
<span style="width:100;"><INPUT id=XX17 type=checkbox value=5 name=XX17>系统管理员</span>
<span style="width:100;"><INPUT id=XX17 type=checkbox value=6 name=XX17>下一步审批人</span></TD></TR>

<TR id=SZFORMtr12>
<TD id=SZFORMtd45 style="CURSOR: hand">消息提醒人员</TD>
<TD class=trMouseOut id=SZFORMtd46 style="CURSOR: hand" colSpan=3><INPUT class=txtClass2 id=XX16 size=10 name=XX16></TD></TR>

<TR id=SZFORMtr8>
<TD class=trMouseOut id=SZFORMtd29 style="CURSOR: hand">开始时间</TD>
<TD class=trMouseOut id=SZFORMtd30 style="CURSOR: hand"><INPUT class=txtClass1 id=XX15 size=10 name=XX15 readonly></TD>
<TD class=trMouseOut id=SZFORMtd31 style="CURSOR: hand">步骤序号</TD>
<TD id=SZFORMtd32 style="CURSOR: hand"><INPUT class=txtClass1 id=XX14 size=10 name=XX14  readonly></TD></TR>

------------>
</TBODY>
</TABLE>

<!-----人员选择------>
<%
    LcPerson lcPerson = new LcPerson();
    Collection collPerson = lcPerson.getPerson(lcStepInfo.getBZID());
    //System.out.println(collPerson.size() + "=========" + lcStepInfo.getBZID());
    String sPersonOther = lcPerson.getPersonOther(collPerson);
    //javascript中的CheckCheckBox(oChk, vValue)是用;作为分割
    sPersonOther = sPersonOther.replaceAll(",", ";");
%>
<!-----信息维护------>
<TABLE id=SZFORMtable2 style="CURSOR: hand" cellSpacing=0 borderColorDark=#ffffff cellPadding=3 width=650 borderColorLight=#c0c0c0 border=1>
<DIV id=divSZFORMtable1 style="BACKGROUND: #c0c0c0; CURSOR: hand; HEIGHT: 0px; display:none;">
<INPUT id=XX1 size=10 name=XX1>
<INPUT id=XX12 size=10 name=XX12>
<INPUT class=txtClass1 id=XX2 size=10 name=XX2>
</DIV>
<TBODY>
<tr class="trClassTitle"><td colspan="4">办理人员&nbsp;</td></tr>

<TR id=SZFORMtr8>
<TD id=SZFORMtd29 style="CURSOR: hand">其他办理人员</TD>
<TD class=trMouseOut id=SZFORMtd30 style="CURSOR: hand" colSpan=3>
  <INPUT id=RYLX type=checkbox value=4 name=RYLX>申请人部门负责人
  <INPUT id=RYLX type=checkbox value=5 name=RYLX>申请人直系上级
<!-- 
  <INPUT id=RYLX type=checkbox value=6 name=RYLX>申请人直系下属 
-->    
  <INPUT id=RYLX type=checkbox value=3 name=RYLX>申请人  <br> 
  
  <INPUT id=RYLX type=checkbox value=7 name=RYLX>办理人部门负责人   
  <INPUT id=RYLX type=checkbox value=8 name=RYLX>办理人直系上级  
<!--   
  <INPUT id=RYLX type=checkbox value=9 name=RYLX>办理人直系下属
-->   
</TD></TR>
<TR id=SZFORMtr2>
<TD width="100" valign="top">办理人员选择
<input type="button" class="btnClassShort" value="选择" OnClick="javascript:OpenFlowUserWin();"></TD>
<TD colspan="3">
    <input type="hidden" name="RYDLID1" value="<%=lcPerson.getPersonId(collPerson, 0)%>" >
    <input type="hidden" name="RYDLID2" value="<%=lcPerson.getPersonId(collPerson, 1)%>" >
    <input type="hidden" name="RYDLID3" value="<%=lcPerson.getPersonId(collPerson, 2)%>" >
    直接选择人员
    <textarea name="RYDLXM1" class="areaClass2" readonly><%=lcPerson.getPersonName(collPerson, 0)%></textarea><br>
    直接选择部门
    <textarea name="RYDLXM2" class="areaClass2" readonly><%=lcPerson.getPersonName(collPerson, 1)%></textarea><br>
    直接选择职务
    <textarea name="RYDLXM3" class="areaClass2" readonly><%=lcPerson.getPersonName(collPerson, 2)%></textarea>
</TD>
</TR>

<TR id=SZFORMtr7>
<TD class=trMouseOut id=SZFORMtd25 style="CURSOR: hand">约束条件</TD>
<TD class=trMouseOut id=SZFORMtd26 style="CURSOR: hand" colSpan=3>
<INPUT id=BZYSTJ type=radio CHECKED value=0 name=BZYSTJ OnClick="javascript:CheckYueshu(0);">无约束
<INPUT id=BZYSTJ type=radio value=1 name=BZYSTJ OnClick="javascript:CheckYueshu(0);">申请人同部门
<INPUT id=BZYSTJ type=radio value=2 name=BZYSTJ OnClick="javascript:CheckYueshu(0);">申请人一级直系内
<INPUT id=BZYSTJ type=radio value=3 name=BZYSTJ OnClick="javascript:CheckYueshu(0);">申请人二级直系内
<INPUT id=BZYSTJ type=radio value=4 name=BZYSTJ OnClick="javascript:CheckYueshu(4);">指定部门<br>
</TD></TR>
<TR id=SZFORMtr77 style="display:none;">
<TD class=trMouseOut id=SZFORMtd25 style="CURSOR: hand">指定的部门</TD>
<TD class=trMouseOut id=SZFORMtd26 style="CURSOR: hand" colSpan=3>
<INPUT id=BZYSBM type=hidden name=BZYSBM value="<%=lcStepInfo.getBZYSTJ()%>">
<INPUT id=BZYSBMMC type=text class="txtClass2" name=BZYSBMMC  value="<%=lcStepInfo.getBZYSBMMC()%>" readonly style="BACKGROUND: #eaf2f3">
<input type="button" class="btnClassShort" value="选择" OnClick="javascript:OpenWin24('formUpdate.BZYSBM', 'formUpdate.BZYSBMMC');">
</TD></TR>
<script language="javascript">
  function CheckYueshu(v) {
  	if (v == 4) {
  		document.getElementById("SZFORMtr77").style.display = "block";
  	} else {
  		document.getElementById("SZFORMtr77").style.display = "none";
  	}
  }
</script>
</TBODY></TABLE>
</form>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="type" value="<%=sType%>">
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">
  //弹出窗口，选择人员。这里特定是流程里某个步骤的选择人员。
  function OpenFlowUserWin() {
    var type = "all";
    var url = "../../share/organize/user_win3.jsp";

    url = url + "?objId=formUpdate.RYDLID1&objName=formUpdate.RYDLXM1";
    url = url + "&objDesc=formUpdate.RYDLID2&objDescName=formUpdate.RYDLXM2";
    url = url + "&objPostId=formUpdate.RYDLID3&objPostName=formUpdate.RYDLXM3";
    
    window.showModalDialog(url,window,"status=no;dialogWidth=800px;dialogHeight=450px");
  }

  //动态的隐藏
  var oDivSZFORMtable1 = document.getElementById("divSZFORMtable1");
  if (oDivSZFORMtable1 != null) {
    oDivSZFORMtable1.style.display="none";
  }
  //动态的加入XX2的值
  var oXX1 = document.getElementById("XX1");
  if (oXX1 != null) {
    oXX1.value = "<%=lcStepInfo.getBZID()%>";
  }
  var oXX2 = document.getElementById("XX2");
  if (oXX2 != null) {
    oXX2.value = "<%=lcStepInfo.getBZLC()%>";
  }
  var oXX3 = document.getElementById("XX3");
  if (oXX3 != null) {
    oXX3.value = "<%=lcStepInfo.getBZMC()%>";
  }
  var oXX4 = document.getElementById("XX4");
  if (oXX4 != null) {
    oXX4.value = "<%=lcStepInfo.getBZBLQX()%>";
  }
  var oXX5 = document.getElementById("XX5");
  if (oXX5 != null) {
    oXX5.value = "<%=lcStepInfo.getBZZT()%>";
  }
  var oXX6 = document.getElementById("XX6");
  if (oXX6 != null) {
    oXX6.value = "<%=lcStepInfo.getBZBLSM()%>";
  }
  var oXX14 = document.getElementById("XX14");
  if (oXX14 != null) {
    oXX14.value = "<%=lcStepInfo.getBZXH()%>";
  }
  var oXX15 = document.getElementById("XX15");
  if (oXX15 != null) {
    oXX15.value = "<%=lcStepInfo.getBZKSSJ()%>";
  }
  var oXX16 = document.getElementById("XX16");
  if (oXX16 != null) {
    oXX16.value = "<%=lcStepInfo.getBZTXRY()%>";
  }
  var oXX17 = document.getElementById("XX17");
  if (oXX17 != null) {
    CheckCheckBox(formUpdate.XX17, "<%=lcStepInfo.getBZTXLX()%>");  
  }
  var oXX18 = document.getElementById("XX18");
  if (oXX18 != null) {
    CheckCheckBox(formUpdate.XX18, "<%=lcStepInfo.getBZSX()%>");  }
  var oXX19 = document.getElementById("XX19");
  if (oXX19 != null) {
    CheckCheckBox(formUpdate.XX19, "<%=lcStepInfo.getBZQXBD()%>");  }
  var oXX20 = document.getElementById("XX20");
  if (oXX20 != null) {
    CheckCheckBox(formUpdate.XX20, "<%=lcStepInfo.getBZQXLC()%>");  }
  var oXX21 = document.getElementById("XX21");
  if (oXX21 != null) {
    CheckCheckBox(formUpdate.XX21, "<%=lcStepInfo.getBZQXTH()%>");  }
  var oXX22 = document.getElementById("XX22");
  if (oXX22 != null) {
    CheckCheckBox(formUpdate.XX22, "<%=lcStepInfo.getBZQXBJ()%>");  }
  var oXX23 = document.getElementById("XX23");
  if (oXX23 != null) {
    CheckCheckBox(formUpdate.XX23, "<%=lcStepInfo.getBZQXFJ()%>");  }
  var oXX24 = document.getElementById("XX24");
  if (oXX24 != null) {
    CheckCheckBox(formUpdate.XX24, "<%=lcStepInfo.getBZQXTQ()%>");  }
  var oXX25 = document.getElementById("XX25");
  if (oXX25 != null) {
    CheckCheckBox(formUpdate.XX25, "<%=lcStepInfo.getBZTXFS()%>");  }
  var oXX26 = document.getElementById("XX26");
  if (oXX26 != null) {
    oXX26.value = "<%=lcStepInfo.getBZQY()%>";
  }
  
  var oBZYSTJ = document.getElementById("BZYSTJ");
  if (oBZYSTJ != null) {
    CheckCheckBox(formUpdate.BZYSTJ, "<%=lcStepInfo.getBZYSTJ()%>");  
    if ("<%=lcStepInfo.getBZYSTJ()%>" == "4") {
    	CheckYueshu(4);
    }
  }  
  
  //其他办理人员
  CheckCheckBox(formUpdate.RYLX, "<%=sPersonOther%>");
</script>
<script language="javascript">

  function FormSave(formName, url) {
    //检查是否可以保存
    /*
    if (!notSpace(formName.XX3, "步骤名称")) {
      return false;
    }
    */
    if (!notNum(formName.XX4, "办理期限")) {
      return false;
    }    

    //如果选择了会签XX18，那么跳签XX21、退回XX24将无效
    if ( formName.XX18.checked == true && 
        (formName.XX21.checked == true || formName.XX24.checked == true) ) {
      if (confirm("选择了会签，跳签、退回将无效")) {
        formName.XX21.checked = false;
        formName.XX24.checked = false;
      } else {
		return false;
      }
          
    }

    //请选择办理人员
    if ( (formName.RYDLID1.value == "" || formName.RYDLID1.value == "0")
      && (formName.RYDLID2.value == "" || formName.RYDLID2.value == "0") 
      && (formName.RYDLID3.value == "" || formName.RYDLID3.value == "0")      
      && (NumberOfCheck(formName.RYLX) == 0)
      ) {
      alert("至少选择一个办理人员！");
      return false;      
    }
    //ValueOfCheck(oChk) 
    formName.action = url;
    formName.submit();
  }
  
  formUpdate.winName.value =  window.dialogArguments;
  
  function DateToHour(obj1, obj2) {
    
    if (!notPrice(obj2, "办理期限")) {
      obj2.focus();
      return false;
    }
    var limitDay = obj1.value;
    obj2.value = limitDay * 24;
    obj1.value = "";
  }
</script>
</body>
<%
    out.println(SzPageHelp.calendar2Frame2());
%>
