<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserEdit.aspx.cs" Inherits="HySoft.BaseCallCenter.Web.smsmanage.UserEdit" %>

<!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>用户导入</title>
    <link href="../scripts/ui/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../scripts/ui/json2.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/core/base.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/ligerui.min.js" type="text/javascript"></script>
    <link href="../scripts/ui/skins/Tab/css/tab.css" rel="stylesheet" type="text/css" />
    <link href="../scripts/ui/skins/Tab/css/grid.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/ui/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerLayout.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerTree.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerMenu.js" type="text/javascript"></script>
    <script src="../scripts/CustomersData.js" type="text/javascript"></script>
    <link href="../scripts/ui/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="../images/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        var actionNodeID;
        $(function () {
            $("#layout1").ligerLayout({
                leftWidth: 200,
                allowCenterBottomResize: false
            });
            $("#tree1").ligerTree({
                nodeWidth: 135,
                checkbox: false,
                url: '/sysmanage/ajax/deptcategory.ashx?action=gettreelist',
                onClick: function (node, e) {
                    actionNodeID = node.data.id;
                    LoadList(node.data.id);
                }
            });
            LoadList("");
        });
        var gridlist;
        function LoadList() {
            var sql = getWhereStr();
            gridlist = $("#divDataList").ligerGrid({
                height: '85%',
                checkbox: true,
                columns: [
                 { display: '用户ID', name: '_f_userid', minWidth: 140, hide: "false" },
                { display: '用户编号', name: '_f_usercode', minWidth: 140 },
                { display: '用户名称', name: '_f_username', minWidth: 140 },
                { display: '用户电话号码', name: '_f_telephone', minWidth: 140 }
                //                { display: '分机号', name: '_f_extensionnumber', minWidth: 140 }
                ],
                url: '../smsmanage/ajax/smsSentAjax.ashx?action=getUserList' + '&keyWords=' + sql, pageSize: 10, rownumbers: true,
                onSelectRow: function (data, rowindex, rowobj) {
                    //                    singleClick = data.F_UserId;
                }

            });
            gridlist.changePage('first');
            $("#pageloading").hide();
        }
        function LoadList(id) {
            var sql = getWhereStr();
            if (actionNodeID == undefined) {
                actionNodeID = "";
            }
            gridlist = $("#divDataList").ligerGrid({
                height: '85%',
                checkbox: true,
                columns: [
                { display: 'Id', name: '_f_userid', width: '1%',hide: "Id" },
                { display: '用户编号', name: '_f_usercode', width: '25%' },
                { display: '用户名称', name: '_f_username', width: '25%' },
                { display: '用户电话号码', name: '_f_telephone', align: 'left', width: '49%' }
                // display: '分机号', name: '_f_extensionnumber', minWidth: 140 }
                ],
                url: 'ajax/smsSentAjax.ashx?action=getUserList' + '&keyWords=' + sql + '&id=' + id, pageSize: 10, rownumbers: true,
                onSelectRow: function (data, rowindex, rowobj) {
                    //                    singleClick = data.F_UserId;
                }
            });
            gridlist.changePage('first');
            $("#pageloading").hide();
        }
        function getWhereStr() {
            var sql = "";
            if (document.getElementById("F_DictionaryFlag").value != "") {
                sql += " and  F_UserCode='" + escape(document.getElementById("F_DictionaryFlag").value) + "'";
            }
            if (document.getElementById("F_Name").value != "") {
                sql += " and  F_UserName='" + escape(document.getElementById("F_Name").value) + "'";
            }
            if (document.getElementById("F_TelPhone").value != "") {
                sql += " and  F_Telephone='" + escape(document.getElementById("F_TelPhone").value) + "'";
            }
            return sql;
        }

//        function GetCheckBoxId() {
//            var rows = gridlist.getSelectedRows();
//            if (rows.length > 0) {
//                try {
//                    var arr = new Array();
//                    var i = 0;
//                    for (var i = 0; i < rows.length; i++) {
//                        if (rows[i]._f_telephone != "") {
//                            arr[i] = rows[i]._f_telephone;
//                        }

//                    }
//                    parent.OnInnerCallback(arr);
//                    var dialog = frameElement.dialog;
//                    dialog.close();
//                }
//                catch (e) {
//                    alert(e.Message);
//                }
//            }
//        }
        function GetCheckBoxId() {
            var rows = gridlist.getSelectedRows();
            if (rows.length > 0) {
                try {
                    var arr = new Array();
                    var i = 0;
                    for (var i = 0; i < rows.length; i++) {
                        if (rows[i]._f_telephone != "") {
                            arr[i] = rows[i]._f_telephone;
                        }
                    }
                    var str = document.getElementById("txtTelPhone").value;
                    if (str.charAt(str.length - 1) != ',') {
                        document.getElementById("txtTelPhone").value += "," + arr;
                    }
                    var stringvalue = document.getElementById("txtTelPhone").value;
                    if (stringvalue.substr(0, 1) == ',') document.getElementById("txtTelPhone").value = stringvalue.substr(1);
                }
                catch (e) {
                    alert(e.Message);
                }
            }
        }
        function GetTelePhone() {
            try {
                var arr = document.getElementById("txtTelPhone").value;
                parent.OnInnerCallback(arr);
                var dialog = frameElement.dialog;
                dialog.close();
            }
            catch (e) {
                alert(e.Message);
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="tools_box">
        <div class="tools_bar">
            <div class="search_box">
                员工工号 ：
                <asp:TextBox ID="F_DictionaryFlag" runat="server" CssClass="txtInput" Width="80px"></asp:TextBox>
                员工姓名 ：
                <asp:TextBox ID="F_Name" runat="server" CssClass="txtInput" Width="80px"></asp:TextBox>
                手机号码 ：
                <asp:TextBox ID="F_TelPhone" runat="server" CssClass="txtInput" Width="80px"></asp:TextBox>
                <input id="Button1" type="button" value="搜 索" class="btnSubmit" onclick="LoadList();" />
            </div>
        </div>
    </div>
    <div id="layout1" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px;
        padding-top: 0px">
        <div style="height: 95%; overflow: scroll;" position="left" title="部门信息">
            <ul id="tree1">
                <li isexpand="false" id="-1"><span>部门信息</span>
                    <ul>
                    </ul>
                </li>
            </ul>
        </div>
        <div position="center" title="用户列表">
            <div>
                <div id="divDataList">
                </div>
                <div style="text-align: center; margin-top: 10px">
                    <input id="butSercher" type="button" onclick="GetCheckBoxId();" class="btnSubmit"
                        value="选择" style="text-align: center; width: 80px" />
                </div>
            </div>
        </div>
        <div position="right" title="已选号码">
            <textarea id="txtTelPhone" rows="20" style="width: 100%;"></textarea><br />
            <div style="text-align:center"><input id="btnConfirm" type="button" onclick="GetTelePhone();" class="btnSubmit"
                        value="确定" style="text-align: center; width: 80px" /></div>
        </div>
    </div>
    </form>
</body>
</html>
