<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="callblacklist.aspx.cs" Inherits="HySoft.BaseCallCenter.Web.telmanage.callblacklist" %>
<!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 id="Head1" runat="server">
    <title>黑名单管理</title>
    <script src="../scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <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/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/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 singleClick;
        function itemclick(item) 
        {
            alert(item.text);
        }
        var gridlist;
        $(function () 
        {
            LoadList();
        });
        function LoadList() 
        {
            gridlist = $("#divDataList").ligerGrid({
                checkbox: true,
                height: '100%',
                columns: [
//                { display: 'ID', name: '_f_blackid', width: '1%' },
                { display: '电话号码', name: '_f_telphone', minWidth: 60 },
                {display: '开始时间', name: '_f_settime', minWidth: 110, type: 'date', format: 'yyyy-MM-dd hh:mm:ss' },
                { display: '结束时间', name: '_f_removetime', minWidth: 110, type: 'date', format: 'yyyy-MM-dd hh:mm:ss' },
                //{ display: '拦截次数', name: '_f_interceptnum', minWidth: 60 },
                { display: '屏蔽说明', name: '_f_describe', editor: { type: 'text'} }
                ], url: 'ajax/callblack.ashx?action=getlist&telnum=' + document.getElementById("txtTelphone").value + '&settime='+ document.getElementById("txtSetTime").value + '&removetime=' + document.getElementById("txtRemoveTime").value, pageSize: 10, rownumbers: true,
                onSelectRow: function (data, rowindex, rowobj)
                {
                    singleClick = data._f_blackid;
                }
            });
            gridlist.changePage('first');
            $("#pageloading").hide();
        }


        function formatDateTime(value, rowData, rowIndex) 
        {
            if (value != null) 
            {
                var date = new Date(parseInt(value.replace("/Date(", "").replace(")/", ""), 10));
                var result = date.getFullYear() + "-" + (date.getMonth() + 1 < 10 ? "0"
                    + (date.getMonth() + 1) : date.getMonth() + 1) + "-"
                    + (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " "
                    + (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":"
                    + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":"
                    + (date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds());
                return result;
            }
            return value;
        }
        function deleteRow() 
        {
            g.deleteSelectedRow();
        }
        function Add() {
            $.ligerDialog.open({ url: 'callblacklisteditor.aspx?getPuction=Add', title: '添加黑名单', height: 370, width: 700, isResize: true });
        }
        function ModifyEdit() {
            if (singleClick == "" || singleClick == undefined) {
                alert("请选择修改行！");
            }
            else {
                $.ligerDialog.open({ url: 'callblacklisteditor.aspx?getPuction=Edit' + '&singleFlage=' + singleClick, title: '修改黑名单', height: 370, width: 700, isResize: true });
            }
        }
        function Delete() {
            try {
                //获取选择的行
                var rows = gridlist.getSelectedRows();
                if (rows.length > 0) {
                    $.ligerDialog.confirm('确定要批量删除选择的记录吗？', function (yes) {
                        if (yes) {
                            try {
                                var arr = new Array();
                                var i = 0;
                                for (var i = 0; i < rows.length; i++) {
                                    arr[i] = rows[i]._f_blackid;
                                }
                                $.post("ajax/callblack.ashx?action=deletelist&arrid=" + arr.toString(), function (data) {
                                    if (data == "success") {
                                        $.ligerDialog.success('删除成功');
                                        LoadList();
                                    }
                                    else {
                                        $.ligerDialog.error('删除失败');
                                    }
                                });
                            }
                            catch (e) {
                                alert(e.Message);
                            }
                        }
                        else {
                        }
                    });
                }
                else {
                    $.ligerDialog.error('没有选择要删除的行');
                }
            }
            catch (e) {
                $.ligerDialog.error(e.Message);
            }
        }
        document.onkeydown = function (event) {
            var e = event || window.event || arguments.callee.caller.arguments[0];
            if (e && e.keyCode == 13) {
                LoadList();
            }
        };
    </script>
</head>
<body style="margin: 0px; padding: 0px; overflow: hidden;">
    <form id="form1" runat="server">
    <div class="l-loading" style="display: block" id="pageloading">
    </div>
    <div class="tools_box">
        <div class="tools_bar">
           <a class="tools_btn" href="#" onclick="Add();">
                <span><b class="add">添加</b></span>
            </a>
            <a class="tools_btn" href="#" onclick="ModifyEdit();">
                <span><b class="modify">修改</b></span>
            </a>
            <a class="tools_btn" href="#" onclick="Delete();"><span>
                    <b class="delete">批量删除</b></span> </a>
            <div class="search_box">
                电话号码：<asp:TextBox ID="txtTelphone" runat="server" CssClass="txtInput" Width="80px"></asp:TextBox>&nbsp;&nbsp;
                开始时间：<asp:TextBox ID="txtSetTime" runat="server" CssClass="txtInput" Width="80px" onfocus="WdatePicker({skin:'whyGreen'})"></asp:TextBox>&nbsp;&nbsp;
                结束时间：<asp:TextBox ID="txtRemoveTime" runat="server" CssClass="txtInput" Width="80px" onfocus="WdatePicker({skin:'whyGreen'})"></asp:TextBox>&nbsp;&nbsp;
                <input id="btnSearch" type="button" value="搜 索" class="btnSearch" onclick="LoadList();" />
            </div>
        </div>
    </div>
    <div id="divDataList">
    </div>
    </form>
</body>
</html>
