<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetUserWindows.aspx.cs"
    Inherits="RM.Web.RMBase.SysUser.GetUserWindows" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>
        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("GetUserWindows")%></title>
    <link href="/Themes/Styles/Site.css" rel="stylesheet" type="text/css" />
    <style>
        .btnbartitle div { overflow: hidden; padding: 5px; white-space: normal; }
    </style>
    <style type="text/css">
        .div-frm { border-bottom: 1px #ccc solid; }
        .stubox{ min-height:100px; padding:5px; background-color:#f4f4f4; border:1px #ccc solid; margin-left:5px;}
        .stubox h5{ padding:0; margin:0;}
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="frmtop">
        <table style="padding: 0px; margin: 0px;" cellpadding="0" cellspacing="0">
            <tr>
                <td id="menutab" style="vertical-align: bottom;">
                    <div id="tab0" class="Tabsel" onclick="GetTabClick(this);panel(1)">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Organization")%></div>
                    <div id="tab1" class="Tabremovesel" onclick="GetTabClick(this);panel(2);">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Role")%></div>
                    <div id="tab2" class="Tabremovesel" onclick="GetTabClick(this);panel(3);">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserGroup")%></div>
                    <div id="tab4" class="Tabremovesel" onclick="GetTabClick(this);panel(5);">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserGroupSet_ulist")%></div>
                    <div id="tab3" class="Tabremovesel" onclick="GetTabClick(this);panel(4);">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Exstu")%></div>
                </td>
            </tr>
        </table>
    </div>
    <div class="div-frm" style="height: 232px;">
        <%--部门--%>
        <div id="table1">
            <div class="btnbartitle">
                <div>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Organization")%>
                    <input type="button" data="0" value='<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Quanxuan")%>'
                        style="float: right; margin-top: -3px;" onclick="AllCheck(this,'Orgul')" />
                </div>
            </div>
            <ul class="strTree" id="Orgul">
                <%=strOrgHtml.ToString()%>
            </ul>
        </div>
        <%--所属角色--%>
        <div id="table2" style="display: none">
            <div class="btnbartitle">
                <div>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Role")%>
                    <input type="button" data="0" value='<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Quanxuan")%>'
                        style="float: right; margin-top: -3px;" onclick="AllCheck(this,'roleul')" />
                </div>
            </div>
            <ul class="strTree" id="roleul">
                <%=strRoleHtml.ToString()%>
            </ul>
        </div>
        <%--所属工作组--%>
        <div id="table3" style="display: none">
            <div class="btnbartitle">
                <div>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserGroup")%>
                    <input type="button" data="0" value='<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Quanxuan")%>'
                        style="float: right; margin-top: -3px;" onclick="AllCheck(this,'Groupul')" />
                </div>
            </div>
            <ul class="strTree" id="Groupul">
                <%=strUserGroupHtml.ToString()%>
            </ul>
        </div>
        <%--外部学员--%>
        <div id="table4" style="display: none">
            <div class="btnbartitle">
                <div>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Exstu")%>
                </div>
            </div>
            <ul class="strTree">
                <%=strOpenUserHtml.ToString()%>
            </ul>
        </div>
        <%--单个学员--%>
        <div id="table5" style="display: none">
            <div class="btnbartitle">
                <div>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("GetUserWindows_Xzyh")%>
                    <input type="button" data="0" value='<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Quanxuan")%>'
                        style="float: right; margin-top: -3px;" onclick="AllCheck(this,'stu_list')" />
                </div>
            </div>
            <div style="text-indent: 24px; padding: 10px;">
                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("GetUserWindows_qsrxsm")%>
                <input type="text" id="stu_name" onkeyup="GetUser()" />
                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("GetUserWindows_bzsrxyxmzdjsry")%>
                <br />
                组织机构查询学员:<select id="orgUser" runat="server" onchange="OrgSeletChange()"></select>
            </div>
            <ul class="strTree stubox" style="width: 40%;" id="stu_list">
                <h5>备选学员</h5>
            </ul>
            <ul class="strTree stubox" style="width: 40%; margin-left:10px;" id="kelonglist">
                <h5>已选学员</h5>
            </ul>
        </div>
    </div>
    <div class="frmbottom">
        <a class="l-btn" href="javascript:void(0)" onclick="CheckValid();"><span class="l-btn-left">
            <img src="/Themes/Images/disk.png" alt="" /><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Save")%></span></a>
        <a class="l-btn" href="javascript:void(0)" onclick="parent.UsersWindowsClose();"><span
            class="l-btn-left">
            <img src="/Themes/Images/cancel.png" alt="" /><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Close")%></span></a>
    </div>
    </form>
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/artDialog.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/iframeTools.js" type="text/javascript"></script>
    <link href="/Themes/Scripts/TreeView/treeview.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/TreeView/treeview.pack.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            treeAttrCss();
            if("<%=ordertype%>"=="2")
            {
            $("#tab1").hide();
            $("#tab2").hide();
            }
        });
        function AllCheck(obj,id) {

            if ($(obj).attr("data") == 0) {
                $("#" + id).find("li").each(
          function () {
              $(this).children("div").find("input[type=checkbox] ").attr("checked", true);

          }
          );
                $(obj).attr("data", "1");
            } else {
                $("#" + id).find("li").each(
          function () {
              $(this).children("div").find("input[type=checkbox] ").attr("checked", false);
          }
          );
                $(obj).attr("data", "0");
            }

        }
       
        //点击切换面板
        function panel(obj) {
            if (obj == 1) {
                $('#table1').show();
                $('#table2').hide();
                $('#table3').hide();
                $('#table4').hide(); $('#table5').hide();
            } else if (obj == 2) {
                $('#table1').hide();
                $("#table2").show();
                $('#table3').hide();
                $('#table4').hide();
                $('#table5').hide();
            } else if (obj == 3) {
                $('#table1').hide();
                $("#table2").hide();
                $('#table3').show();
                $('#table4').hide();
                $('#table5').hide();
            } else if (obj == 4) {
                $('#table1').hide();
                $("#table2").hide();
                $('#table3').hide();
                $('#table4').show();
                $('#table5').hide();
            } else if (obj == 5) {
                $('#table1').hide();
                $("#table2").hide();
                $('#table3').hide();
                $('#table4').hide();
                $('#table5').show();
            }
        }
        //获取表单值
        function CheckValid() {
            parent.UsersWindowsClear();
            var r = document.getElementsByName("checkbox");
            for (var i = 0; i < r.length; i++) {
                if (r[i].checked) {
                    // alert(r[i].value + "," + r[i].nextSibling.nodeValue);
                    if(r[i].nextSibling!=null){
                        parent.Getusers2Input(r[i].value, r[i].nextSibling.nodeValue);
                    }
                }
            }
            parent.UsersWindowsClose();
        }
        function getAjax(url, parm, callBack) {
            $.ajax({
                type: 'post',
                dataType: "text",
                url: url,
                data: parm,
                cache: false,
                async: false,
                success: function (msg) {
                    callBack(msg);
                }
            });
        }
        //通过部门查询人员
        function OrgSeletChange()
        {
          getAjax("GetUserByName.ashx", "org=" + $("#orgUser").val(), function (rs) {
                if (rs != 1) {
                    var json = eval('(' + rs + ')')
                    UserHtml(json);
                } else {
                    $("#stu_list").html("<li ><div><span style='color:red;'><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Null") %></span></div></li>");
                }
            });
        }
      
        //通过人名查询人员
        function GetUser() {
            getAjax("GetUserByName.ashx", "name=" + $("#stu_name").val(), function (rs) {
                if (rs != 1) {
                    var json = eval('(' + rs + ')')
                    UserHtml(json);
                } else {
                    $("#stu_list").html("<li><div><span style='color:red;'><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Null") %></span></div></li>");
                }
            });
        }
        function UserHtml(User) {
            var str = "";
            for (var i = 0; i < User.length; i++) {
                str += "<li onclick=\"KeLong(this)\"><div><input style='vertical-align: middle;margin-bottom:2px;' type=\"checkbox\"  value=\"" + User[i].User_ID + "|用户" + "\" name=\"checkbox\" />" + User[i].User_Account+" - "+User[i].User_Name + "</li></div>";
            }
            if (User.length<=0) {
    str="<li><div><span style='color:red;'><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Null") %></span></div></li>";
}
             $("#stu_list").html(str);
        }
        
           function KeLong(obj)
        {
          $(obj).children("div").find("input[type=checkbox] ").attr("checked", true);
          var oldstr = $(obj).html();
        $("#kelonglist").append(oldstr);
        $(obj).remove();
        }
    </script>
</body>
</html>
