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

<!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/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>
    <script src="/scripts/ui/js/plugins/ligerTextBox.js" type="text/javascript"></script>
    <script src="/scripts/ui/js/plugins/ligerSpinner.js" type="text/javascript"></script>
    <script src="/scripts/function.js" type="text/javascript"></script>
    <script src="/scripts/utils.js" type="text/javascript"></script>
    <script src="/scripts/ui/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
    <link href="/scripts/ui/skins/Tab/css/grid.css" rel="stylesheet" type="text/css" />
    <link href="/images/style.css" rel="stylesheet" type="text/css" />
    <link href="/scripts/ui/skins/Tab/css/grid.css" rel="stylesheet" type="text/css" />
    <link href="/scripts/ui/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .l-toolbar
        {
            background: none;
            height: 23px;
            border: 0px solid #9CBAE7;
            border-top: 0px solid #EFF7F7;
        }
        .tools_box
        {
            border: 1px solid #D6D6D6;
            border-bottom: 0px;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            var a = $("#navtab1").ligerTab({
                showSwitch: false,
                contextmenu: false,
                onAfterSelectTabItem: function (targettabid) {
                }
            });
            LoadingData();
            $("#txtUpload").bind("change", function () {
                $.ligerDialog.waitting('分析数据中......');
                $("#form1").ajaxSubmit({
                    beforeSubmit: function (formData, jqForm, options) {
                        $("#txtFileName").val("");
                        $("#txtFilePath").val("");
                        $("#txtArrColumn").val("");
                        document.getElementById("spanFileInfo").innerHTML = "";
                        document.getElementById("spanFileType").innerHTML = "";
                    },
                    success: function (data, textStatus) {
                        if (data.msg == 1) {
                            if (data.filetype == "0") {
                                document.getElementById("spanFileType").innerHTML = "[Excel文件]";
                            }
                            if (data.filetype == "1") {
                                document.getElementById("spanFileType").innerHTML = "[txt文本文件]";
                            }
                            $("#txtFileName").val(data.filename);
                            $("#txtFilePath").val(data.filepath);
                            $("#txtArrColumn").val(data.arrcolumn);
                            $("#txtFileType").val(data.filetype);
                            document.getElementById("spanFileInfo").innerHTML = data.info;
                            $.ligerDialog.closeWaitting();
                        } else {
                            $.ligerDialog.closeWaitting();
                            $.ligerDialog.error(data.msbox);
                        }
                    },
                    error: function (data, status, e) {
                        $.ligerDialog.closeWaitting();
                        $.ligerDialog.error("上传失败，错误信息：" + e);
                    },
                    url: "ajax/callplanintophone.ashx?action=excelinto",
                    type: "post",
                    dataType: "json"
                });

            });
            $("#pageloading").hide();
        });
        var arrfieldlist = new Array();
        function LoadingData() {
            try {
                var id = document.getElementById("txtId").value;
                $.ajax({
                    type: 'get',
                    url: 'ajax/callplanintophone.ashx?action=getfieldlist&taskid='+id,
                    data: { userid: '' },
                    dataType: 'html',
                    async: false,
                    cache: false,
                    success: function (res) {
                        var arr = res.split('~');
                        arrfieldlist = arr[0].split(',');
                        document.getElementById("divFieldList").innerHTML = arr[1];
                        $("#pageloading").hide();
                    }
                });
            }
            catch (e) {
                $.ligerDialog.error("加载失败，错误信息：" + e.Message);
            }
        }
        function InitExcelColumns(fieldid) {
            var selectobjid = "select_column_" + fieldid;
            var selectobj = document.getElementById(selectobjid);
            var selectvalue = document.getElementById(selectobjid).value;
            var arrcolumn = document.getElementById("txtArrColumn").value;
            if (arrcolumn != "") {
                var sltList = document.getElementsByTagName("select");
                for (var i = 0; i < sltList.length; i++) {
                    if (sltList[i].value != "" && sltList[i].id != selectobjid) {
                        arrcolumn = arrcolumn.replace(sltList[i].value, "");
                    }
                }
                var optList = arrcolumn.split('|');
                selectobj.options.length = 0;
                selectobj.options.add(new Option("", ""));
                for (var m = 0; m < optList.length; m++) {
                    if (optList[m].toString() != "") {
                        selectobj.options.add(new Option(optList[m].toString(), optList[m].toString()));
                    }
                }

                document.getElementById(selectobjid).value = selectvalue;
            }
        }
        function CloseThis() {
            var dialog = frameElement.dialog;
            parent.LoadTelList();
            dialog.close();
        }
        function SaveInfo(res, msg) {
            switch (res) {
                case 'success':
                    $.ligerDialog.success(msg, function (yes) { CloseThis(); });
                    break;
                case 'warn':
                    $.ligerDialog.error('导入失败，请确认数据正确性');
                    break;
                case 'error':
                    $.ligerDialog.error('导入失败，请联系开发商');
                    break;
                default:
                    break;
            }
        }
        function IntoData() {
            $.ligerDialog.waitting('号码导入中,请稍后...');
            var filename = document.getElementById("txtFileName").value;
            var filepath = document.getElementById("txtFilePath").value;
            var columntofield = "";
            if (filepath == "") {
                $.ligerDialog.closeWaitting();
                $.ligerDialog.error('请选择正确格式的号码文件');
                return false;
            }
            var scount = 0;
            var sltList = document.getElementsByTagName("select");
            for (var i = 0; i < sltList.length; i++) {
                if (sltList[i].value != "") {
                    scount++;
                    var objid = sltList[i].id.replace("select_column_", "");
                    var fieldvalue = document.getElementById("txt_id_" + objid).value;
                    columntofield += fieldvalue + ":" + sltList[i].value + ";";
                }
            }
            if (scount == 0) {
                $.ligerDialog.closeWaitting();
                $.ligerDialog.error('没有设置导入文件的数据对应字段');
                return false;
            }
            document.getElementById("txtColumnToField").value=columntofield;

//            return true;
            var id = document.getElementById("txtId").value;
            $("#form1").ajaxSubmit({
                beforeSubmit: function (formData, jqForm, options) {
                },
                success: function (data, textStatus) {
                    if (data.msg == 1) {
                        SaveInfo("success", data.info);
                        $.ligerDialog.closeWaitting();
                    } else {
                        $.ligerDialog.closeWaitting();
                        $.ligerDialog.error(data.info);
                    }
                },
                error: function (data, status, e) {
                    $.ligerDialog.closeWaitting();
                    $.ligerDialog.error("导入失败，错误信息：" + e);
                },
                url: "ajax/callplanintophone.ashx?action=excelintodata&taskid="+id,
                type: "post",
                dataType: "json"
            });
        }
    </script>
</head>
<body style="overflow: hidden;">
    <form id="form1" runat="server">
    <asp:HiddenField ID="txtId" runat="server" Value="0" />
    <asp:HiddenField ID="txtFileName" runat="server" Value="" />
    <asp:HiddenField ID="txtFilePath" runat="server" Value="" />
    <asp:HiddenField ID="txtFileType" runat="server" Value="" />
    <asp:HiddenField ID="txtArrColumn" runat="server" Value="" />
    <asp:HiddenField ID="txtColumnToField" runat="server" Value="" />
    <div id="pageloading">
        数据加载中，请稍等...
    </div>
    <div id="navtab1" style="width: 100%; height: 450px; border: 1px solid #D3D3d3;">
        <div title="Excel或文本文件" tabid="tab1">
            <table class="form_table">
                <col width="100px" />
                <col />
                <tbody>
                    <tr>
                        <th style="border-right: 1px dotted #cccccc;">
                            <span style="color: red">号码文件：</span>
                        </th>
                        <td>
                            <input id="txtUpload" runat="server" type="file" style="width: 380px; height: 25px;"
                        unselectable="on" class="txtInput normal" />
                        </td>
                    </tr>
                    <tr>
                        <th style="border-right: 1px dotted #cccccc; border-top: 1px dotted #cccccc;">
                            <span>文件信息：</span>
                        </th>
                        <td style="border-top: 1px dotted #cccccc;">
                            <input id="btnDownModel" type="button" value="下载模板" class="btnSearch" style="display:none;" />&nbsp;<span id="spanFileType" style="color:Red;"></span>&nbsp;<span id="spanFileInfo"></span>
                        </td>
                    </tr>
                    
                    <tr>
                        <th style="border-right: 1px dotted #cccccc; border-top: 1px dotted #cccccc;">
                            <span>重复过滤：</span>
                        </th>
                        <td style="border-top: 1px dotted #cccccc;">
                            <input id="chkGL1" type="checkbox" />&nbsp;过滤Excel中重复号码&nbsp;&nbsp;&nbsp;&nbsp;<input id="chkGL2" type="checkbox" />&nbsp;过滤三个月内外呼回访的号码
                        </td>
                    </tr>
                    <tr style="height:250px;">
                        <th style="border-right: 1px dotted #cccccc; border-top: 1px dotted #cccccc; border-bottom: 1px dotted #cccccc;">
                            <span>字段设置：</span>
                        </th>
                        <td style="border-top: 1px dotted #cccccc; border-bottom: 1px dotted #cccccc;">
                            <div id="divFieldList" style="width: 550px; height: 230px;padding:5px; text-align: left; cursor: text;
                                            overflow-y: auto; scrollbar-face-color: #DBEBFE; scrollbar-shadow-color: #B8D6FA;
                                            scrollbar-highlight-color: #FFFFFF; scrollbar-3dlight-color: #DBEBFE; scrollbar-darkshadow-color: #458CE4;
                                            scrollbar-track-color: #FFFFFF; scrollbar-arrow-color: #458CE4; border: 1px dotted #cccccc;" runat="server">
                                          
                                        </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                        <td align="center">
                        <%--<asp:Button ID="btnSubmit" runat="server" Text="导入号码" CssClass="btnSubmit"
                OnClientClick="return IntoData();"  OnClick="btnSubmit_Click" />--%>
                        <input id="btnSubmit" type="button" class="btnSubmit" onclick="IntoData();" value="导入号码" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <%--<div title="通话记录" tabid="tab2">
        </div>
        <div title="客户信息" tabid="tab3">
        </div>
        <div title="内部人员" tabid="tab4">
        </div>
        <div title="号码段" tabid="tab5">
        </div>
        <div title="在计划执行内导入" tabid="tab6">
        </div>--%>
    </div>
    <br />
    </form>
</body>
</html>
