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

<!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>
    <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 type="text/javascript" src="/scripts/jquery/jquery.form.js"></script>
    <script type="text/javascript" src="/scripts/jquery/jquery.validate.min.js"></script>
    <script type="text/javascript" src="/scripts/jquery/messages_cn.js"></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>
    <link href="../scripts/ui/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/My97DatePicker/lang/zh-cn.js" type="text/javascript"></script>
    <link href="../images/style.css" rel="stylesheet" type="text/css" />
     <script src="../scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        var selectplan = "";
        var tellist;
        var planname = "";
        function CallOutRes() {
            return parent.GetCallOutHFRes();
        }
        function CallOut(id, taskid, phone) {
            var vheight = $("#form1").height();
            var vwidth = $("#form1").width() * 0.9;
            if (vwidth > 700) {
                vwidth = 700;
            }
            var vtitle = "拨打电话";
            try {
                vtitle = "拨打电话【<font color='red'>" + phone + "</font>】";
                parent.PhoneCallOutHF(1, phone, id);
            }
            catch (e) {
            }
            $.ligerDialog.open({ url: 'calloutopt.aspx?otype=new&id=' + id + '&taskid=' + taskid + '&phone=' + phone, title: vtitle, height: vheight, width: vwidth, isResize: true
            });
        }
        function ShowInfo(id, taskid, phone) {
            var vheight = $("#form1").height();
            var vwidth = $("#form1").width() * 0.9;
            if (vwidth > 700) {
                vwidth = 700;
            }
            var vtitle = "查看任务信息";
            try {
                vtitle = "查看任务信息【<font color='red'>" + phone + "</font>】";
            }
            catch (e) {
            }
            $.ligerDialog.open({ url: 'calloutoptshow.aspx?otype=new&id=' + id + '&taskid=' + taskid + '&phone=' + phone, title: vtitle, height: vheight, width: vwidth, isResize: true
            });
        }
        function ShowTelInfo(id, taskid, phone) {
            var vheight = $("#form1").height();
            var vwidth = $("#form1").width() * 0.9;
            if (vwidth > 700) {
                vwidth = 700;
            }
            var vtitle = "查看回访历史通话信息";
            try {
                vtitle = "查看回访历史通话信息【<font color='red'>" + phone + "</font>】";
            }
            catch (e) {
            }
            $.ligerDialog.open({ url: 'calloutoptrecordlist.aspx?otype=new&id=' + id + '&taskid=' + taskid + '&phone=' + phone, title: vtitle, height: vheight, width: vwidth, isResize: true
            });
        }
        function LoadTelList() {
            selectplan = document.getElementById("txtPlanId").value;
            var key = escape(document.getElementById("txtKeywords").value);
            var userid = document.getElementById("ddlAccount").value;
            var fpstate = document.getElementById("dropFP").value;
            var hcstate = document.getElementById("dropHC").value;
            var yjstate = document.getElementById("dropYJ").value;
            var starttime = document.getElementById("txtStartTime").value;
            var endtime = document.getElementById("txtEndTime").value;
            var hjjg = document.getElementById("dropHJJG").value;
            tellist = $("#divTelList").ligerGrid({
                height: '97%',
                checkbox: true,
                columns: [
                { display: '外呼计划', align: 'center', width: '130', name: '_taskname' },
                { display: '结果', width: '60', name: '_f_phone', render: function (rowdata, rowindex, value) {
                    return "<a href=" + "\"javascript:onclick=ShowInfo('" + rowdata._f_id + "','" + rowdata._f_taskid + "','" + value + "')\">查看</a> "; ;
                }
                },
                { display: '号码', width: '130', name: '_f_phone', render: function (rowdata, rowindex, value) {
                    return "<img src='../images/phone3.png' style=\"cursor:hand; width:24px;\" title=\"拨打" + value + "\" onclick='CallOut(\"" + rowdata._f_id + "\",\"" + rowdata._f_taskid + "\",\"" + value + "\")' />&nbsp;&nbsp;<font color='green'>" + value + "</font>";
                }
                },
                { display: '名称', align: 'left', width: '130', name: '_f_customer' },
                { display: '门店', align: 'left', width: '130', name: '_expandvchfield1' },
                { display: '导入时间', align: 'center', width: '130', name: '_f_createtime', type: 'date', format: 'yyyy-MM-dd hh:mm:ss' },
                { display: '分配坐席', align: 'center', width: '70', name: '_f_username' },
                { display: '呼叫状态', align: 'center', width: '70', name: '_f_hcstate', render: function (rowdata, rowindex, value) {
                    if (value == 0) {
                        return "未呼叫";
                    }
                    else {
                        return "已呼叫";
                    }
                }
            },
                { display: '呼叫结果', align: 'center', width: '70', name: '_f_hjjgname' },
                { display: '最后接通状态', align: 'center', width: '90', name: '_f_yjstate', render: function (rowdata, rowindex, value) {
                    if (value == 0) {
                        return "未接通";
                    }
                    else {
                        return "已接通";
                    }
                }
                },
                { display: '最后呼叫时间', align: 'center', width: '130', name: '_lastcalltime', type: 'date', format: 'yyyy-MM-dd hh:mm:ss' },
                { display: '呼叫次数', align: 'center', width: '70', name: '_calloutcount' },
                { display: '接通次数', align: 'center', width: '70', name: '_calloutjtcount' },
                { display: '通话记录', width: '60', name: '_f_id', render: function (rowdata, rowindex, value) {
                    return "<a href=" + "\"javascript:onclick=ShowTelInfo('" + rowdata._f_id + "','" + rowdata._f_taskid + "','" + rowdata._f_phone + "')\">查看</a> "; ;
                }
                }
                ],
            url: 'ajax/callplantelnum.ashx?action=getsearchresultlist&userid=' + userid + '&taskid=' + selectplan + '&key=' + key + '&fpstate=' + fpstate + '&hcstate=' + hcstate + '&yjstate=' + yjstate + '&starttime=' + starttime + '&endtime=' + endtime + '&hjjg=' + hjjg, pageSize: 50, pageSizeOptions: [10, 20, 50, 100], rownumbers: true,
                onSelectRow: function (data, rowindex, rowobj) {
                },
                onSuccess: function (data, obj) {
                },
                onAfterShowData: function (data) {
                }
            });
            $("#pageloading").hide();
        }
        $(function () {
            selectplan = "";
            LoadTelList();
        });
        function Init() {
            selectplan = "";
            LoadTelList();
        }
        document.onkeydown = function (event) {
            var e = event || window.event || arguments.callee.caller.arguments[0];
            if (e && e.keyCode == 13) {
                Init();
            }
        };
        var sflag = true;
        function SelectPlan() {
            sflag = true;
            document.getElementById("divShowPlanList").style.display = "block";
            LoadPlanList();
        }
        function ChangeFlag() {
            sflag = true;
        }
        function HideList() {
            document.getElementById("divShowPlanList").style.display = "none";
        }
        function ChangeKey() {
            if (sflag) {
                if (document.getElementById("txtPlanName").value == "") {
                    document.getElementById("txtPlanId").value = "";
                    document.getElementById("divShowPlanList").style.display = "none";
                }
                else {
                    document.getElementById("divShowPlanList").style.display = "block";
                    LoadPlanList();
                }
            }
        }
        var planlist;
        function LoadPlanList() {
            var key = escape(document.getElementById("txtPlanName").value);
            planlist = $("#divPlanList").ligerGrid({
                height: 300,
                width: 300,
                columns: [
                { display: '计划名称', align: 'left', width: '130', name: '_taskname' },
                { display: '号码数量', align: 'center', width: '60', name: '_y_hmcount' }
                ],
                toolbar: {
                    items: [
                    { text: '关闭', click: itemclick1, icon: 'delete' }
                    ]
                },
                url: 'ajax/callplan.ashx?action=getlist&key=' + key, pageSize: 20, pageSizeOptions: [10, 20, 50], rownumbers: true,
                onDblClickRow: function (data, rowindex, rowobj) {
                    sflag = false;
                    var vid = "0";
                    var vname = "";
                    try {
                        vid = data._taskid;
                        vname = data._taskname;
                        document.getElementById("txtPlanId").value = vid;
                        document.getElementById("txtPlanName").value = vname;
                        LoadTelList();
                    }
                    catch (e) {
                    }
                    document.getElementById("divShowPlanList").style.display = "none";
                }
            });
        }
        function itemclick1(item) {
            switch (item.icon) {
                case "delete":
                    HideList();
                    break;
            }
        }
        function DeleteTelList() {
            var row = tellist.getSelectedRows();
            var idStr = "";
            jQuery.each(row, function (i, val) {
                idStr += val._f_id + ",";
            });
            idStr = idStr.substring(0, idStr.length - 1);
            if (idStr == "") {
                alert("请选择行！");
            } else {
            $.ligerDialog.confirm('确定要删除选择的任务吗?', function (yes) {
                if (yes) {
                    var timeno = new Date().getTime();
                    $.ajax({
                        type: "get",
                        url: "ajax/callplantelnum.ashx?action=deletetelnum&arrid=" + idStr.toString() + "&timeno=" + timeno,
                        dataType: "html",
                        success: function (res) {
                            if (res == "success") {
                                $.ligerDialog.success("删除成功");
                                LoadTelList();
                            } else {
                                $.ligerDialog.error("删除失败");
                            }
                        }
                    });
                }
            });
            }
        }
        function QXTelList() {
            var row = tellist.getSelectedRows();
            var idStr = "";
            jQuery.each(row, function (i, val) {
                idStr += val._f_id + ",";
            });
            idStr = idStr.substring(0, idStr.length - 1);
            if (idStr == "") {
                alert("请选择行！");
            } else {
                $.ligerDialog.confirm('确定要取消分配选择的任务吗?', function (yes) {
                    if (yes) {
                        var timeno = new Date().getTime();
                        $.ajax({
                            type: "get",
                            url: "ajax/callplantelnum.ashx?action=qxfptelnum&arrid=" + idStr.toString() + "&timeno=" + timeno,
                            dataType: "html",
                            success: function (res) {
                                if (res == "success") {
                                    $.ligerDialog.success("取消分配成功");
                                    LoadTelList();
                                } else {
                                    $.ligerDialog.error("取消分配失败");
                                }
                            }
                        });
                    }
                });
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="divShowPlanList" style="display: none; position: absolute; z-index: 9999;
        top: 38px; left: 7px; width: 470px; height: 230px;">
        <div id="divPlanList" style="width: 470px; height: 200px;">
        </div>
    </div>
    <table id="tableMessage" cellpadding="3" cellspacing="3" border="0" style="width: 100%;">
        <tr>
            <td valign="top" style="padding: 0px 2px 5px 2px;">
                <div class="tools_box">
                    <asp:HiddenField ID="txtUserId" runat="server" />
                    <div class="tools_bar">
                        <div class="search_box" style="float: left;">
                            外呼计划：
                            <asp:HiddenField ID="txtPlanId" runat="server" Value="" />
                            <asp:TextBox ID="txtPlanName" runat="server" CssClass="txtInput normal" onclick="SelectPlan();"
                                onPropertyChange="ChangeKey();" Style="width: 100px;"></asp:TextBox>&nbsp;关键字：<asp:TextBox
                                    ID="txtKeywords" runat="server" Style="width: 80px;" CssClass="txtInput"></asp:TextBox>&nbsp;&nbsp;开始回访时间：<asp:TextBox ID="txtStartTime" runat="server" CssClass="txtInput" Width="100px" onfocus="WdatePicker({skin:'whyGreen'})"></asp:TextBox>&nbsp;&nbsp;结束时间：<asp:TextBox ID="txtEndTime" runat="server" CssClass="txtInput" Width="100px" onfocus="WdatePicker({skin:'whyGreen'})"></asp:TextBox>
                        </div>
                    </div>
                </div>
                <div class="tools_box">
                    <div class="tools_bar">
                        <div class="search_box" style="float: left;">坐席： <asp:DropDownList ID="ddlAccount" runat="server" CssClass="selectBox" onchange="LoadTelList();" Width="70px"> </asp:DropDownList>&nbsp;&nbsp;分配状态：<asp:DropDownList ID="dropFP" runat="server" onchange="LoadTelList();" CssClass="selectBox" Width="80px">
                                <asp:ListItem Value="">--全部--</asp:ListItem>
                                <asp:ListItem Value="0">未分配</asp:ListItem>
                                <asp:ListItem Value="1">已分配</asp:ListItem>
                            </asp:DropDownList>&nbsp;&nbsp;呼叫状态：<asp:DropDownList ID="dropHC" runat="server" onchange="LoadTelList();" CssClass="selectBox" Width="80px">
                                <asp:ListItem Value="">--全部--</asp:ListItem>
                                <asp:ListItem Value="0">未呼叫</asp:ListItem>
                                <asp:ListItem Value="1">已呼叫</asp:ListItem>
                            </asp:DropDownList>&nbsp;&nbsp;接通状态：<asp:DropDownList ID="dropYJ" runat="server" onchange="LoadTelList();" CssClass="selectBox" Width="80px">
                                <asp:ListItem Value="">--全部--</asp:ListItem>
                                <asp:ListItem Value="0">未接通</asp:ListItem>
                                <asp:ListItem Value="1">已接通</asp:ListItem>
                            </asp:DropDownList>&nbsp;&nbsp;呼叫结果：<asp:DropDownList ID="dropHJJG" runat="server" onchange="LoadTelList();" CssClass="selectBox" Width="80px">
                                <asp:ListItem Value="">--全部--</asp:ListItem>
                            </asp:DropDownList>&nbsp;&nbsp;
                            <input id="btnSearch" type="button" value="搜 索" class="btnSearch" onclick="LoadTelList();" />&nbsp;&nbsp;
                            <input id="Button1" type="button" value="删 除" class="btnSearch" style="color:Red;" onclick="DeleteTelList();" />&nbsp;&nbsp;
                            <input id="Button2" type="button" value="取消分配" class="btnSearch" style="color:Red;" onclick="QXTelList();" />
                        </div>
                    </div>
                </div>
                <div id="divTelList">
                </div>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
