<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.database.SzPageInfo" %>
<%@ page import="net.sz600.system.SzProperties" %>
<%@ page import="net.sz600.system.SzPageHelp" %>
<%@ page import="net.sz600.system.SzLevelNumber" %>
<%@ page import="net.sz600.organize.*" %>

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
<SCRIPT src="../../share/js/ftiens4_tree.js"></SCRIPT>
</head>

<body>
<table width=100% border="0" cellpadding=0 cellspacing=0>
  <tr>
    <td align="center" width="33">
    <td width="751" colspan="2" align="center"><p align="left">
      <!--名字，连接，定位的页面，图片---->
      <SCRIPT>
        USETEXTLINKS = 1
        level_0 = gFld("<b>组织结构</b>", "","","images/skin1/menu/asset.gif")
<%
    String sCond = "";
    int i = 0;
    int j = 0;

    //读取数据
    SzDepart szDepart = new SzDepart();
    SzDepartInfo departInfo = null;
    Iterator iter = szDepart.getArrayList().iterator();
    HashMap mapDepart = szDepart.getMainHashMap("1=1");

    SzUserPost szUserPost = new SzUserPost();
    SzUserPostInfo szUserPostInfo = null;
    Iterator iterUserPost = null;

    //获取员工，部门，职务的hashMap
    SzLogin szLogin = new SzLogin();
    HashMap mapLogin = szLogin.getMainHashMap("1=1");
    Iterator iterLogin = null;
    SzLoginInfo szLoginInfo = null;

    SzPost szPost = new SzPost();
    HashMap mapPost = szPost.getMainHashMap("1=1");
    Iterator iterPost = null;
    SzPostInfo szPostInfo = null;

    String sUserInfo = "";
    String sPostInfo = "";
    String str_ZWID = "0";
    String str_DLID = "0";
%>
<%
    String sBMBH = "";
    String sBMBH_SJ = "";
    while (iter != null && iter.hasNext()) {
        departInfo = (SzDepartInfo)iter.next();
        sBMBH = departInfo.getBMBH();
        sBMBH_SJ = SzConvert.toZeroStr(SzLevelNumber.getParentNumber(sBMBH));

        i++;
%>
        level_<%=sBMBH%> = insFld(level_<%=sBMBH_SJ%>, gFld("<b><%=departInfo.getBMMC()%></b>", "","","images/skin1/menu/asset.gif"))
<%
        //取得部门下的职务
        sCond = "RZBM=" + departInfo.getBMID() + " and RZZW>0";
        str_ZWID = szUserPost.getRZZWByCond(sCond);

        //通过职务ID获取职务名称，因为只有这样才能有效的排序
        sCond = "ZWID IN (" + str_ZWID + ") ORDER BY ZWDJ ASC";
        iterPost = szPost.getArrayList(sCond).iterator();
        //iterUserPost = szUserPost.getArrayList("RZBM=" + departInfo.getBMID()).iterator();
        while (iterPost != null && iterPost.hasNext()) {
            szPostInfo = (SzPostInfo)iterPost.next();
            //获取姓名、职务名称
            sPostInfo =  "[" + mapPost.get(new Integer(szPostInfo.getZWID())) + "]";
            j++;

            //根据所在的部门以及职务======获取员工
            sCond = "RZBM=" + departInfo.getBMID() + " and RZZW=" + szPostInfo.getZWID();
            str_DLID = szUserPost.getRZDLByCond(sCond);

            //通过用户ID获取用户
            sCond = "DLID IN (" + str_DLID + ")";
            iterLogin = szLogin.getArrayList(sCond).iterator();
            while (iterLogin != null && iterLogin.hasNext()) {
                szLoginInfo = (SzLoginInfo)iterLogin.next();
                sUserInfo = sPostInfo + mapLogin.get(new Integer(szLoginInfo.getDLID()));
%>
                level_<%=sBMBH%>0<%=j%> = insFld(level_<%=sBMBH%>, gFld("<%=sUserInfo%>", "","","images/skin1/menu/asset.gif"))
<%
            }
        }

        //取得部门下的用户，该用户还没有设置职务
        sCond = "RZBM=" + departInfo.getBMID() + " and RZZW=0";
        str_DLID = szUserPost.getRZDLByCond(sCond);

        //通过用户ID获取用户
        sCond = "DLID IN (" + str_DLID + ")";
        iterLogin = szLogin.getArrayList(sCond).iterator();
        while (iterLogin != null && iterLogin.hasNext()) {
            szLoginInfo = (SzLoginInfo)iterLogin.next();
            sUserInfo = (String)mapLogin.get(new Integer(szLoginInfo.getDLID()));
%>
            level_<%=sBMBH%>0<%=j%> = insFld(level_<%=sBMBH%>, gFld("<%=sUserInfo%>", "","","images/skin1/menu/asset.gif"))
<%
        }
    }
%>
      </SCRIPT>
<SCRIPT>
    initializeDocument(level_01);
</SCRIPT>
    </td>
  </tr>
</table>
</body>

