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

<!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 src="../scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            InitList();
        });
        var gridlist;
        function InitList() {
            try {
                gridlist = $("#divDataList").ligerGrid({
                    checkbox: true,
                    height: '99%',
                    columns: [
                { display: 'Id', name: 'FaxID', width: '1%', hide: 'false' },
                { display: '传真号码', name: 'TelNum', align: 'left', width: '10%' },
                { display: '客户姓名', name: 'F_Name', width: '19%' },
                { display: '传真备注', name: 'Remark', width: '25%' },
                { display: '提交时间', name: 'CommitTime', width: '14%', type: 'date', format: 'yyyy-MM-dd hh:mm:ss' },
                { display: '发送时间', name: 'SendTime', width: '14%', type: 'date', format: 'yyyy-MM-dd hh:mm:ss' },
                { display: '发送状态', name: 'State', width: '10%',render: function (rowdata, rowindex) {  if (rowdata.State == "-1") { return '发送失败'; } else if(rowdata.State == "0") { return '未发送';} else if(rowdata.State == "1") { return '正在发送';} else if(rowdata.State == "2") { return '发送成功'; } }  }
                ],

                    url: '../faxmanage/ajax/faxSendAjax.ashx?action=getLoadAlrlist&tel=' + document.getElementById("txtF_OptName").value + '&uid='+<%=GetUserID() %>, pageSize: 10, rownumbers: true,
                    onSelectRow: function (data, rowindex, rowobj) {
                        singleClick = data.FaxID;
                    },
                    onDblClickRow: function (data, rowindex, rowobj) {
                        Show('SendAlready');
                    }
                });
            }
            catch (e) {
                alert(e.Message);
            }
            gridlist.changePage('first');
            $("#pageloading").hide();
        }

        function Show(params) {
                if (singleClick == "" || singleClick == undefined) {
                    alert("请选择查看传真！");
                } else {
                    $.ligerDialog.open({ url: 'faxsendshow.aspx?otype=' + params + '&singleFlage=' + singleClick, title: '查看传真详情', height: 600, width: 880, 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++) {
                                    if (rows[i].FaxID != "") {
                                        arr[i] = rows[i].FaxID;
                                    }
                                }
                                $.post("../faxmanage/ajax/faxSendAjax.ashx?action=deleteAlready&arrid=" + arr.toString(), function (data) {
                                    if (data == "success") {
                                        $.ligerDialog.success('删除成功');
                                        InitList();
                                    }
                                    else {
                                        $.ligerDialog.error('删除失败');
                                    }
                                });
                            }
                            catch (e) {
                                alert(e.Message);
                            }
                        }
                        else {
                        }
                    });
                }
                else {
                    $.ligerDialog.error('没有选择要删除的参数');
                }
            }
            catch (e) {
                $.ligerDialog.error(e.Message);
            }
        }

        function AgainSend() {
            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++) {
                                    if (rows[i].FaxID != "") {
                                        arr[i] = rows[i].FaxID;
                                    }
                                }
                                $.post("../faxmanage/ajax/faxSendAjax.ashx?action=againSend&arrid=" + arr.toString(), function (data) {
                                    if (data == "success") {
                                        $.ligerDialog.success('重发成功');
                                        InitList();
                                    }
                                    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) {
                InitList();
            }
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="tools_box">
        <div class="tools_bar">
        <a class="tools_btn" href="#" onclick="Delete();"><span>
                    <b class="delete">批量删除</b></span> </a>
        <a class="tools_btn" href="#" onclick="AgainSend();"><span>
                    <b class="add">批量重发</b></span> </a>
            <div class="search_box">
                传真号码：<asp:TextBox ID="txtF_OptName" runat="server" CssClass="txtInput"></asp:TextBox>&nbsp;&nbsp;
                
                <input id="btnSearch" type="button" value="搜 索" class="btnSearch" onclick="InitList();" />
            </div>
        </div>
    </div>
    <div id="layout1">
      <div position="center" title="已发传真列表">
            <div id="divDataList">
            </div>
        </div>
    </div>
    </form>
</body>
</html>
