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

<!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>
    <title>12345便民服务热线</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/js/ligerBuild.min.js" type="text/javascript"></script>
    <script src="../scripts/function.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/ligerui.min.js" type="text/javascript"></script>
    <link href="../images/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="seatformjs/ocxopt.js"></script>
    <script src="seatformjs/formopt.js" type="text/javascript"></script>
    <script type="text/javascript">
        /*
        操作ligerui控件 左侧菜单及tab页面操作
        */
        //框架操作
        var tab = null;
        var accordion = null;
        var tree = null;
        $(function () {
            //页面布局
            $("#global_layout").ligerLayout({ leftWidth: 180, height: '100%', topHeight: 65, bottomHeight: 24, allowTopResize: false, allowBottomResize: false, allowLeftCollapse: true, onHeightChanged: f_heightChanged });

            var height = $(".l-layout-center").height();

            //Tab
            $("#framecenter").ligerTab({ height: height });

            //左边导航面板
            $("#global_left_nav").ligerAccordion({ height: height - 25, speed: null });

            $(".l-link").hover(function () {
                $(this).addClass("l-link-over");
            }, function () {
                $(this).removeClass("l-link-over");
            });

            //快捷菜单
            var menu = $.ligerMenu({
                width: 120, items:
                [
                    { text: '管理首页', click: itemclick },
                    { text: '修改密码', click: itemclick },
                    { line: true },
                    { text: '关闭菜单', click: itemclick }
                ]
            });
            $("#tab-tools-nav").bind("click", function () {
                var offset = $(this).offset(); //取得事件对象的位置
                menu.show({ top: offset.top + 27, left: offset.left - 120 });
                return false;
            });
            InitTree();
            tab = $("#framecenter").ligerGetTabManager();
            accordion = $("#global_left_nav").ligerGetAccordionManager();
            $("#pageloading_bg,#pageloading").hide();
        });

        function InitTree() {
            var HdModuleFunIdCount = $("#HdModuleFunIdCount").val();
            for (var i = 1; i <= HdModuleFunIdCount; i++) {
                $("#tree" + i.toString() + "").ligerTree({
                    checkbox: false,
                    nodeWidth: 135,
                    onClick: function (node) {
                        if (!node.data.url) return;
                        var tabid = $(node.target).attr("tabid");
                        if (!tabid) {
                            tabid = new Date().getTime();
                            $(node.target).attr("tabid", tabid)
                        }
                        f_addTab("frame_" + node.data.id, node.data.text, node.data.url);
                        //                        if (node.data.id == "zxjkgl") {
                        //                            f_addTab("zxjkgl", node.data.text, node.data.url);
                        //                        }
                        //                        else {
                        //                            f_addTab(tabid, node.data.text, node.data.url);
                        //                        }
                    }
                });
            }
        }

        //快捷菜单回调函数
        function itemclick(item) {
            switch (item.text) {
                case "管理首页":
                    f_addTab('home', '管理中心', 'center.aspx');
                    break;
                case "快捷导航":
                    //调用函数
                    break;
                case "修改密码":
                    ChangePwd();
                    break;
                default:
                    //关闭窗口
                    break;
            }
        }
        function ChangePwd() {
            //testfun();
            //f_addTab('manager_pwd', '修改密码', 'rightsmanage/userpsdedit.aspx');
            var ResetPass = document.getElementById("hfUserId").value;
            OpenWindowShow('sysmanage/userResetPasswod.aspx?ResetPass=' + ResetPass, '修改密码', 500, 380);
        }
        function OpenWindowShow(Url, Title, Width, Height) {
            $.ligerDialog.open({
                title: Title, url: Url, height: Height, width: Width, isResize: true, modal: true, buttons: [
                    { text: '关闭', onclick: function (item, dialog) { dialog.close(); } }
                ], isResize: true
            });
        }
        function f_heightChanged(options) {
            if (tab)
                tab.addHeight(options.diff);
            if (accordion && options.middleHeight - 24 > 0)
                accordion.setHeight(options.middleHeight - 24);
        }
        //添加Tab，可传3个参数
        function f_addTab(tabid, text, url, iconcss) {
            if (!tab.isTabItemExist(tabid)) {
                if (arguments.length == 4) {
                    tab.addTabItem({ tabid: tabid, text: text, url: url, iconcss: iconcss });
                } else {
                    tab.addTabItem({ tabid: tabid, text: text, url: url });
                }
            }
            else {
                tab.selectTabItem(tabid);
            }
        }
        //删除Tab，通过tabid
        function f_removeTab(tabid) {
            if (tab.isTabItemExist(tabid)) {
                tab.removeTabItem(tabid);
            }
        }
        //提示Dialog并关闭Tab
        function f_errorTab(tit, msg) {
            $.ligerDialog.open({
                isDrag: false,
                allowClose: false,
                type: 'error',
                title: tit,
                content: msg,
                buttons: [{
                    text: '确定',
                    onclick: function (item, dialog, index) {
                        //查找当前iframe名称
                        var itemiframe = "#framecenter .l-tab-content .l-tab-content-item";
                        var curriframe = "";
                        $(itemiframe).each(function () {
                            if ($(this).css("display") != "none") {
                                curriframe = $(this).attr("tabid");
                                return false;
                            }
                        });
                        if (curriframe != "") {
                            tab.removeTabItem(curriframe);
                            dialog.close();
                        }
                    }
                }]
            });
        }
        function userExit() {
            $.ligerDialog.confirm("确定要退出吗？", "提示信息", function (result) {
                if (result) {
                    try {
                        if (document.getElementById("txtIsAgent").value == "true") {
                            OCX_AgentLogOut();
                        }
                    }
                    catch (e) {
                    }
                    __doPostBack('lbtnExit', '');
                }
            });
        }
        document.oncontextmenu = function (e) { return false; }
    </script>
    <script type="text/javascript">
        //图片操作
        //切换头部文件
        function backImgOver(num, obj) {
            var st = obj.attributes["ostate"].value;
            if (st == "1") {
                obj.src = "../images/totle/" + num + "1.png";
            }
            else {
                obj.src = "../images/totle/" + num + "3.png";
            }
        }
        function backOutImg(num, obj) {
            var st = obj.attributes["ostate"].value;
            if (st == "1") {
                obj.src = "../images/totle/" + num + "2.png";
            }
            else {
                obj.src = "../images/totle/" + num + "3.png";
            }
        }
        function setLinkStatus(str) {

            var imgServerState = document.getElementById("imgServerState");
            if (str == "True") {
                imgServerState.src = "../images/server1.png";
                imgServerState.alt = "签入";
                ServerResInfo("服务签入");
            }
            else {
                imgServerState.src = "../images/server0.png";
                imgServerState.alt = "未签入";
                ServerResInfo("服务未签入");
                //AutographJoin();
            }
        }
        function setAgentStatus(str) {
            var imgAgentState = document.getElementById("imgAgentState");
            switch (str) {
                case "离席":
                    imgAgentState.src = "../images/zx2.png";
                    imgAgentState.alt = "未登录";
                    ServerResInfo("坐席未登录");
                    break;
                case "空闲":
                    imgAgentState.src = "../images/zx1.png";
                    imgAgentState.alt = "空闲";
                    ServerResInfo("坐席空闲");
                    break;
                case "忙":
                    imgAgentState.src = "../images/zx3.png";
                    imgAgentState.alt = "忙";
                    ServerResInfo("坐席忙");
                    break;
                case "业务处理":
                    imgAgentState.src = "../images/zx4.png";
                    imgAgentState.alt = "业务处理";
                    ServerResInfo("业务处理");
                    break;
            }
        }
        function ServerResInfo(res) {
            //document.getElementById("spanServerRes").innerHTML = res;
        }
        //变换图标 挂断转满意度 .外乎。置忙。置闲。三方通话。转移。保持。接回
        function Form_setWinfromenble(begd, beMakeCall, bezm, bezx, behy, beTransfer, bebc, bejh, beqr, beqc) {
            if (begd == "True") {
                OptByName("gd");
            }
            else {

                OptNullByName("gd");
            }


            if (beMakeCall == "True") {
                OptByName("wh");
            }
            else {
                OptNullByName("wh");
            }

            if (bezm == "True") {//示忙可以用
                OptByName("zm");
            }
            else {
                OptNullByName("zm");
            }

            if (bezx == "True") {//示闲可以用
                OptByName("zx");
            }
            else {
                OptNullByName("zx");
            }

            if (behy == "True") {
                OptByName("dfth");
            }
            else {
                OptNullByName("dfth");
            }

            if (beTransfer == "True") {
                OptByName("zy");
            }
            else {
                OptNullByName("zy");
            }

            if (bebc == "True") {
                OptByName("bc");
            }
            else {
                OptNullByName("bc");
            }

            if (bejh == "True") {
                OptByName("jh");
            }
            else {
                OptNullByName("jh");
            }
            if (beqr == "True") {
                OptByName("qr");
            }
            else {
                OptNullByName("qr");
            }
            if (beqc == "True") {
                OptByName("qc");
            }
            else {
                OptNullByName("qc");
            }
        }
        function OptNull() {
            document.getElementById("gd").src = "../images/totle/gd3.png";
            document.getElementById("wh").src = "../images/totle/wh3.png";
            document.getElementById("zm").src = "../images/totle/zm3.png";
            document.getElementById("zx").src = "../images/totle/zx3.png";
            document.getElementById("dfth").src = "../images/totle/dfth3.png";
            document.getElementById("zy").src = "../images/totle/zy3.png";
            document.getElementById("bc").src = "../images/totle/bc3.png";
            document.getElementById("jh").src = "../images/totle/jh3.png";
            document.getElementById("qr").src = "../images/totle/qr3.png";
            document.getElementById("qc").src = "../images/totle/qc3.png";
            document.getElementById("gd").src = 0;
            document.getElementById("wh").src = 0;
            document.getElementById("zm").src = 0;
            document.getElementById("zx").src = 0;
            document.getElementById("dfth").src = 0;
            document.getElementById("zy").src = 0;
            document.getElementById("bc").src = 0;
            document.getElementById("jh").src = 0;
            document.getElementById("qr").src = 0;
            document.getElementById("qc").src = 0;
            document.getElementById("gd").style.cursor = "default";
            document.getElementById("wh").style.cursor = "default";
            document.getElementById("zm").style.cursor = "default";
            document.getElementById("zx").style.cursor = "default";
            document.getElementById("dfth").style.cursor = "default";
            document.getElementById("zy").style.cursor = "default";
            document.getElementById("bc").style.cursor = "default";
            document.getElementById("jh").style.cursor = "default";
            document.getElementById("qr").style.cursor = "default";
            document.getElementById("qc").style.cursor = "default";
        }

        function OptNullByName(name) {
            var obj = document.getElementById(name);
            obj.src = "../images/totle/" + name + "3.png";
            obj.attributes["ostate"].value = 0;
            //obj.ostate = 0;
            obj.style.cursor = "default";
        }

        function OptByName(name) {
            var obj = document.getElementById(name);
            obj.src = "../images/totle/" + name + "2.png";
            obj.attributes["ostate"].value = 1;
            //obj.ostate = 1;
            obj.style.cursor = "hand";
        }
    </script>
    <script type="text/javascript">
        ///转移
        function PhoneCallZY(tel) {
            try {
                var callinphone = document.getElementById("forZYnumber").value;
                OCX_TransferToPhone(tel);
            }
            catch (e) {
                $.ligerDialog.error(e.message);
            }
        }
        ///多方通话
        function PhoneCallDFTH(tel) {
            try {
                var callinphone = document.getElementById("forZYnumber").value;
                OCX_ThirdParty(tel);
            }
            catch (e) {
                $.ligerDialog.error(e.message);
            }
        }
        ///工单接单时候调用的外呼方法
        function PhoneCallOutJD(type, tel, workorderid) {
            becallout = true;
            becallcome = false;
            //添加外呼记录
            var userid = document.getElementById("txtAgentId").value;
            var usercode = document.getElementById("lblAgentCode").innerHTML;
            var username = document.getElementById("lblAgentName").innerHTML;
            var extnumber = document.getElementById("lblAgentExt").innerHTML;
            username = encodeURI(username);
            $.ligerDialog.waitting('开始呼叫...');
            $.ajax({
                type: 'get',
                url: '../telmanage/ajax/telrecords.ashx?action=callout&phone=' + tel + "&workorderid=" + workorderid + "&userid=" + userid + "&usercode=" + usercode + "&username=" + username + "&extnumber" + extnumber,
                dataType: 'html',
                success: function (res) {
                    try {
                        var DialIsOK = false;
                        var arr = res.split('|');
                        document.getElementById("CallHjbh").value = arr[2];
                        //成功执行外呼叫
                        if (arr[0] == "1") {   //呼叫内部（座席）电话
                            //2015-04-20
                            becallout = true;
                            becallcome = false;
                            DialIsOK = OCX_CallOut(5, "", arr[1]);
                        }
                        else {   //呼叫外部电话
                            DialIsOK = OCX_CallOut(5, "", arr[1]);
                        }
                        if (DialIsOK != true) {
                            $.ligerDialog.error('外呼失败');
                        }
                    } catch (e) {
                        $.ligerDialog.error(e.message);
                    }
                    $.ligerDialog.closeWaitting();
                }
            });
        }
        ///外呼
        function PhoneCallOut(type, tel) {
            becallout = true;
            becallcome = false;
            //添加外呼记录
            var userid = document.getElementById("txtAgentId").value;
            var usercode = document.getElementById("lblAgentCode").innerHTML;
            var username = document.getElementById("lblAgentName").innerHTML;
            var extnumber = document.getElementById("lblAgentExt").innerHTML;
            username = encodeURI(username);
            $.ligerDialog.waitting('开始呼叫...');
            $.ajax({
                type: 'get',
                url: '../telmanage/ajax/telrecords.ashx?action=callout&phone=' + tel + "&userid=" + userid + "&usercode=" + usercode + "&username=" + username + "&extnumber" + extnumber,
                dataType: 'html',
                success: function (res) {
                    try {
                        var DialIsOK = false;
                        var arr = res.split('|');
                        document.getElementById("CallHjbh").value = arr[2];
                        //成功执行外呼叫
                        if (arr[0] == "1") {   //呼叫内部（座席）电话
                            //2015-04-20
                            becallout = true;
                            becallcome = false;
                            DialIsOK = OCX_CallOut(5, "", arr[1]);
                        }
                        else {   //呼叫外部电话
                            DialIsOK = OCX_CallOut(5, "", arr[1]);
                        }
                        if (DialIsOK != true) {
                            $.ligerDialog.error('外呼失败');
                        }
                    } catch (e) {
                        $.ligerDialog.error(e.message);
                    }
                    $.ligerDialog.closeWaitting();
                }
            });
        }
        var hfcallstate = false;
        var outtype = "";
        function SetCallState(state) {
            hfcallstate = state;
        }
        function GetCallOutHFRes() {
            if (hfcallstate) {
                hfcallstate = false;
                return true;
            }
            else {
                return false;
            }
        }
        ///外呼
        function PhoneCallOutHF(type, tel, hfid) {
            becallout = true;
            becallcome = false;
            hfcallstate = false;
            outtype = "hf";
            //添加外呼记录
            var userid = document.getElementById("txtAgentId").value;
            var usercode = document.getElementById("lblAgentCode").innerHTML;
            var username = document.getElementById("lblAgentName").innerHTML;
            var extnumber = document.getElementById("lblAgentExt").innerHTML;
            var timeno = new Date().getTime();
            username = encodeURI(username);
            $.ligerDialog.waitting('开始呼叫...');
            $.ajax({
                type: 'get',
                url: '../telmanage/ajax/telrecords.ashx?action=callouthf&hfid=' + hfid + '&phone=' + tel + "&userid=" + userid + "&usercode=" + usercode + "&username=" + username + "&extnumber" + extnumber + "&timeno=" + timeno,
                dataType: 'html',
                success: function (res) {
                    try {
                        var DialIsOK = false;
                        var arr = res.split('|');
                        document.getElementById("CallHjbh").value = arr[2];
                        //成功执行外呼叫
                        if (arr[0] == "1") {   //呼叫内部（座席）电话
                            //2015-04-20
                            becallout = true;
                            becallcome = false;
                            DialIsOK = OCX_CallOut(5, "", arr[1]);
                        }
                        else {   //呼叫外部电话
                            DialIsOK = OCX_CallOut(5, "", arr[1]);
                        }
                        if (DialIsOK != true) {
                            $.ligerDialog.error('外呼失败');
                        }
                    } catch (e) {
                        $.ligerDialog.error(e.message);
                    }
                    $.ligerDialog.closeWaitting();
                }
            });
        }
        function OpenWindowShow1(Url, Title, Width, Height) {
            $.ligerDialog.open({
                title: Title, url: Url, height: Height, width: Width, isResize: true, modal: true, buttons: [
                    { text: '关闭', onclick: function (item, dialog) { dialog.close(); AgentFree(); } }
                ], isResize: true
            });
        }
        function OptClick(name) {
            var obj = document.getElementById(name);
            if (obj.attributes["ostate"].value != 0) {
                switch (name) {
                    case "gd":
                        button_ReleaseAnswer();
                        //挂断
                        break;
                    case "wh":
                        //外呼先示忙
                        //AgentBusy();
                        //otype 1外呼 2转移 3多方通话
                        OpenWindowShow1('telmanage/calloutopt.aspx?otype=1', '电话外呼', 800, 500);
                        break;
                    case "zm":
                        //示忙
                        AgentBusy();
                        break;
                    case "zx":
                        AgentFree();
                        break;
                    case "dfth":
                        //多方会话
                        OpenWindowShow1('telmanage/calloutopt.aspx?otype=3', '多方通话', 800, 500);
                        break;
                    case "zy":
                        //转移
                        OpenWindowShow1('telmanage/calloutopt.aspx?otype=2', '电话转移', 800, 500);

                        break;
                    case "bc":
                        //保持
                        button_KeepCall(); //保持方法
                        break;
                    case "jh":
                        //接回
                        button_GetKeepCall();
                        break;
                    case "qr":
                        //签入
                        button_QRCall();
                        break;
                    case "qc":
                        //签出
                        button_QCCall();
                        break;
                }
            }
        }

        //签入
        function button_QRCall() {
            Init();

        }

        //签出
        function button_QCCall() {
            try {
                var result = OCX_AgentLogOut();
            }
            catch (e) {
                document.getElementById("spanServerRes").innerHTML = e.message;
            }
        }

        //转移
        function ZYhj(callnumber) {
            var zyzj = document.getElementById("forZYnumber").value;

            if (zyzj != "") {
                Form_setWinfromenble("false", "false", "false", "false", "false", "false", "false", "false", "false", "false");
            }
            else {
                alert("转移失败！");
            }
        }

        //释放呼叫  2.1.8
        function button_ReleaseAnswer() {//挂机
            try {
                //MydTransToIVR();
            }
            catch (e) { }
            try {
                var rtn = OCX_Hangup();
            }
            catch (e) { }
        }
        //满意度
        function MydTransToIVR() {
            var rtn = OCX_TransferToIVR("8897", "");
        }

        //座席示忙 2.1.12
        function AgentBusy() {
            //将座席状态设置为忙态。
            var rtn = OCX_SetBusy();
            //2014-10-22
            becallout = true;
            becallcome = false;
        }

        //座席示闲 2.1.13
        function AgentFree() {
            //将座席状态设置为闲态。
            var rtn = OCX_SetFree();
            //2014-10-22
            becallout = false;
            becallcome = true;
            return rtn;
        }

        //保持呼叫 2.1.17	
        function button_KeepCall() {
            //该方法把座席正在通话的普通语音呼叫保持（只对语音呼叫有效）。
            var rtn = OCX_Hold();
        }

        //取保持  2.1.18
        function button_GetKeepCall() {
            //查询座席当前保持的所有语音呼叫
            var rtn = OCX_UnHold();
        }

        function buttonCallNew(telNum) {
            becallout = true;
            becallcome = false;
            var strHjbhout = AjaxPost("../WinIVR/GetAjaxPageInf.aspx?PgType=3&tel=" + telNum); //呼叫编号
            document.getElementById("CallHjbh").value = strHjbhout;
            //判断电话是本地还是外地的
            var callNumberNew = "";
            var res = _framepage_headframe.getPhone(telNum);

            if (res != "") {

                callNumberNew = res.value;
            }
            button_CallOut(callNumberNew, strHjbhout);
        }

        //外呼事件 2.1.7
        function button_CallOut(callnumber, hjbh) {
            var res = true;
            var cssok = 0;
            cssok = OCX_CallOut(5, "", callnumber);
            if (cssok == "0") {
                res = true;
            }
            else {
                res = false;
            }
            return res;
        }

        //修改密码
        function updatePwd() {
            window.showModalDialog('../SysSettings/UserChangePassword.aspx', window, 'dialogWidth:350px;dialogHeight:200px;status:off;help:no;scrollbas:no;');
        }
        //重新登录
        function resetlogin() {

            var bol = window.confirm("确定要重新登录吗？");
            if (bol) {
                if (document.getElementById("txtIsAgent").value == "true") {
                    //button_QCCallNew();
                }
                window.open("../SignIn.aspx", "_top");
            }
        }

        //退出方法
        function relogout() {
            var bol = window.confirm("确定要退出登录吗？");
            if (bol) {
                AjaxPost("../WinIVR/GetAjaxPageInf.aspx?PgType=14");
                _framepage_headframe.UpdateLoginOutInfo(document.getElementById("hfUserId").value);
                top.close();
            }
        }
    </script>
    <script type="text/javascript">
        //电话操作
        var becallout = false; //呼出
        var becallcome = true; //来电
        var CallOutRecordIsWrite = false; //呼出记录是否已写入
        //
        var Phone = document.getElementById("Phone");

        //测试方法
        function testfun() {
            fun();
            //1000 * 60 * 5  是五分钟
            setInterval(fun, 1000 * 15);

        }
        var i = 0;
        function fun() {
            i++;
            if (i > 3)
            { return; }
            Form_callCommingCaller('13335140729', '1402107209-5226' + i); //13335140729
        }

        //20150324薛广兴
        var oPopup = window.createPopup();
        function PopUpNotify() {
            var oPopupBody = oPopup.document.body;
            var HTMLBody = document.getElementById("emessagecontent").innerHTML;
            oPopupBody.innerHTML = HTMLBody;
        }
        function popupShow() {
            oPopup.show(screen.availWidth - 275, screen.availHeight - 161, 267, 160);
        }
        function popupHide() {
            oPopup.hide();
        }

        var showLong = null; //计时器，弹出框显示多久后关闭
        function showMsg() {
            var res;
            $.ajax({
                async: false,
                type: "Post",
                url: "default.aspx/Get",
                //方法传参的写法一定要对，str为形参的名字,str2为第二个形参的名字
                data: "{'id':'" + document.getElementById("UserID").value + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var pandaun = data.d;
                    GetMsg_CallBack(pandaun);
                },
                error: function (err) {
                }
            });
        }

        function show() {
            showMsg();
            //1000 * 60 * 5  是五分钟
            setInterval(showMsg, 1000 * 60 * 5);
        }
        function GetMsg_CallBack(res) {
            if (res != null) {
                if (res != "0") {
                    document.getElementById("countspan").innerHTML = "你有" + res + "个工单未处理。";
                    PopUpNotify();
                    popupShow();
                    if (showLong != null) {
                        clearTimeout(showLong);
                    }
                    showLong = setTimeout(popupHide, 1000 * 30);
                }

            }
            res = null;
        }


        //初始化页面
        function Init() {
            //show();
            var typed = document.getElementById("HdIswin"); //是否是坐席用户
            if (typed.value == "true") {
                $.ligerDialog.waitting('电话服务连接中...');
                $.ajax({
                    type: 'get',
                    url: '../telmanage/ajax/telrecords.ashx?action=insertCallLogs&serverip=' + document.getElementById("txtMostlyAddress").value + '&ctiusercode=' + document.getElementById("txtLabourNo").value,
                    dataType: 'html',
                    success: function (res) {
                        InitPhoneBack();
                    }
                });
            }
            else {
                document.getElementById("spanServerRes").innerHTML = "非坐席登录";
            }
        }
        function InitPhoneBack() {
            Initialize();
        }
        function Initialize() {
            try {
                //alert("ip" + document.getElementById("txtMostlyAddress").value + "服务器类型" + document.getElementById("ServerType").value + "工号"
                //    + document.getElementById("txtLabourNo").value + "密码" + document.getElementById("pwd").value + "通讯进程号" + document.getElementById("txtPhoneID").value + "备用ip" + document.getElementById("txtSubordinationAddress").value);

                var result = OCX_AgentLogin(document.getElementById("txtMostlyAddress").value, document.getElementById("txtServerPort").value, document.getElementById("txtLabourNo").value, document.getElementById("txtAgentGroup").value, document.getElementById("txtPhoneNum").value);
            }
            catch (e) {
                document.getElementById("spanServerRes").innerHTML = e.message;
            }
            $.ligerDialog.closeWaitting();
        }
    </script>
</head>
<body onload="Init();" style="margin: 0px; padding: 0px; overflow: hidden;" scroll="no">
    <form id="form1" runat="server">
        <!-- 功能模块Id -->
        <input id="HdModuleFunIdCount" runat="server" style="display: none;" value="0" /><asp:HiddenField ID="ismonitoring" runat="server" Value="false" />
        <asp:HiddenField ID="HdIswin" runat="server" Value="fase" />
        <asp:HiddenField ID="UserID" runat="server" Value="fase" />
        <asp:HiddenField ID="hfUserId" runat="server" />
        <%--（用于初始化用的信息）--%>
        <input id="txtMostlyAddress" runat="server" type="hidden" value="192.168.172.50" /><%--（主用CTI服务器IP）--%>
        <input id="ServerType" type="hidden" runat="server" value="20" /><%--（服务器类型）--%>
        <input id="txtLabourNo" runat="server" type="hidden" value="8011" /><%--<%=Request.Cookies["ID"].Value %>（工号）--%>
        <input id="pwd" type="hidden" runat="server" value="000000" /><%--<%=Request.Cookies["ID"].Value %>（密码）--%>
        <input id="txtPhoneID" runat="server" type="hidden" value="43" /><%--（通讯进程号）--%>
        <input id="txtSubordinationAddress" runat="server" type="hidden" value="192.168.172.50" /><%--（备用CTI服务器IP）--%>
        <input id="txtIsAgent" runat="server" style="display: none;" value="" />
        <!-- 是否具有话务功能，是否坐席登录 -->
        <input id="txtAgentId" runat="server" style="display: none;" value="0" /><!-- 坐席ID -->
        <input id="txtAgentName" runat="server" style="display: none;" value="" />
        <input id="txtAgentRight" runat="server" style="display: none;" value="" />
        <input id="txtAgentGroup" runat="server" style="display: none;" value="10" />
        <input id="txtServerPort" runat="server" style="display: none;" value="" />
        <!-- 坐席权限 -->
        <%--（用于登录的信息）--%>
        <input id="SeatType" type="hidden" runat="server" value="4" /><%--<%=Request.Cookies["SkillSet"].Value %>（坐席类型）--%>
        <input id="txtPhoneNum" runat="server" type="hidden" value="86010" /><%--<%=Request.Cookies["ExtNum"].Value %>（分机号）--%>
        <input id="keepcall" type="hidden" value="" />
        <%--（keep号码）--%>
        <input id="txtLabourwork" runat="server" type="hidden" value="" /><%--（登录工号）--%>
        <input id="passwd" runat="server" type="hidden" value="" /><%--（登录坐席密码）--%>
        <input id="hjbh" type="hidden" runat="server" value="" /><%--（外乎呼叫编号）--%>
        <input id="CallHjbh" type="hidden" runat="server" value="" /><%--（来电呼叫编号）--%>
        <input id="forZYnumber" type="hidden" runat="server" value="" /><%--（用来存储来电号码--%>
        <input id="callnum" type="hidden" runat="server" value="" /><%--（来电主叫号码）--%>
        <div class="pageloading_bg" id="pageloading_bg">
        </div>
        <div id="pageloading">
            数据加载中，请稍等...
        </div>
        <div id="global_layout" class="layout" style="width: 100%">
            <!--头部-->
            <div position="top">
                <div style="width: 100%;" class="header">
                    <div class="header_box">
                        <table cellpadding="0" cellspacing="0" border="0" width="100%">
                            <tr>
                                <td align="left">
                                    <div style="float: left;">
                                        <a class="logo">Logo</a>
                                    </div>
                                </td>
                                <td align="center">
                                    <div style="float: left; padding-top: 5px; font-size: 15pt; color: White; font-weight: bold; padding-left: 10px; padding-left: 10px;"
                                        id="TelToolBar">
                                        <span id="spanTel">
                                            <a style="cursor: pointer">
                                                <img id="gd" ostate="0" src="../images/totle/gd3.png" onclick="OptClick('gd')" onmouseout="backOutImg('gd',this)" onmouseover="backImgOver('gd',this)" />
                                            </a> 
                                            <a style="cursor: pointer; margin-left: 5px">
                                                <img id="wh" ostate="0" src="../images/totle/wh3.png" onclick="OptClick('wh')" onmouseout="backOutImg('wh',this)" onmouseover="backImgOver('wh',this)" />
                                            </a> 
                                            <a style="cursor: pointer; margin-left: 5px">
                                                <img id="zm" ostate="0" src="../images/totle/zm3.png" onclick="OptClick('zm')" onmouseout="backOutImg('zm',this)" onmouseover="backImgOver('zm',this)" />
                                            </a> 
                                            <a style="cursor: pointer; margin-left: 5px">
                                                <img id="zx" ostate="0" src="../images/totle/zx3.png" onclick="OptClick('zx')" onmouseout="backOutImg('zx',this)" onmouseover="backImgOver('zx',this)" />
                                            </a> 
                                            <a style="cursor: pointer; margin-left: 5px">
                                                <img id="dfth" ostate="0" src="../images/totle/dfth3.png" onclick="OptClick('dfth')" onmouseout="backOutImg('dfth',this)" onmouseover="backImgOver('dfth',this)" />
                                            </a>
                                            <a style="cursor: pointer; margin-left: 5px">
                                                <img id="zy" ostate="0" src="../images/totle/zy3.png" onclick="OptClick('zy')" onmouseout="backOutImg('zy',this)" onmouseover="backImgOver('zy',this)" />
                                            </a> 
                                            <a style="cursor: pointer; margin-left: 5px">
                                                <img id="bc" ostate="0" src="../images/totle/bc3.png" onclick="OptClick('bc')" onmouseout="backOutImg('bc',this)" onmouseover="backImgOver('bc',this)" />
                                            </a>
                                            <a style="cursor: pointer; margin-left: 5px">
                                                <img id="jh" ostate="0" src="../images/totle/jh3.png" onclick="OptClick('jh')" onmouseout="backOutImg('jh',this)" onmouseover="backImgOver('jh',this)" />
                                            </a> 
                                            <a style="cursor: pointer;">
                                                <img id="qr" ostate="0" src="../images/totle/qr3.png" onclick="OptClick('qr')" onmouseout="backOutImg('qr',this)" onmouseover="backImgOver('qr',this)" />
                                            </a> 
                                            <a style="cursor: pointer;">
                                                <img id="qc" ostate="0" src="../images/totle/qc3.png" onclick="OptClick('qc')" onmouseout="backOutImg('qc',this)" onmouseover="backImgOver('qc',this)" />
                                            </a>
                                        </span>
                                    </div>
                                </td>
                                <td align="right">
                                    <div class="header_right">
                                        <span class="member"><b id="userInfo" runat="server"></b></span>工号：<asp:Label ID="lblAgentCode"
                                            runat="server" Text="0000" ForeColor="Red"></asp:Label>
                                        &nbsp;&nbsp; 姓名：<asp:Label ID="lblAgentName" runat="server" Text=""></asp:Label>
                                        <%--&nbsp;&nbsp; 分机号：--%><asp:Label ID="lblAgentExt" runat="server" Text="0000" Style="display: none;" ForeColor="Red"></asp:Label>
                                        <br />
                                        <a href="javascript:f_addTab('home','管理中心','center.aspx')">管理中心</a> | <a href="javascript:ChangePwd();">修改密码</a> |
                                    <asp:LinkButton ID="lbtnExit" runat="server" OnClick="lbtnExit_Click"></asp:LinkButton>
                                        <a style="cursor: pointer" onclick="userExit()">安全退出</a>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
            <!--左边-->
            <div position="left" title="管理菜单" id="global_left_nav">
                <%=GetFunTree() %>
            </div>
            <div position="center" id="framecenter" toolsid="tab-tools-nav">
                <div tabid="home" title="管理中心" iconcss="tab-icon-home" style="height: 300px">
                    <iframe frameborder="0" name="sysMain" src="center.aspx"></iframe>
                </div>
            </div>
            <div position="bottom" class="footer">
                <div style="float: left; padding-left: 8px;" id="TelState">
                    <div style="float: left; padding-top: 4px;">
                        服务状态：
                    </div>
                    <div style="float: left; padding-top: 3px;">
                        <img id="imgServerState" src="/images/server0.png" alt="未连接" />
                    </div>
                    <div style="float: left; padding-top: 3px;">
                        &nbsp;&nbsp;坐席状态：
                    </div>
                    <div style="float: left; padding-top: 3px;">
                        <img id="imgAgentState" src="/images/zx2.png" alt="未登录" />
                    </div>
                    <div style="float: left; padding-top: 3px;">
                        &nbsp;&nbsp;<span id="spanServerRes" style="color: Red"></span>
                    </div>
                </div>
                <div class="copyright" style="float: right; width: ">
                    <span id="spanIVRInTelCount" style="color: Red;"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Copyright
                &copy; 西安众擎电子科技有限公司 All Rights Reserved.
                </div>
                <%-- 20150324薛广兴--%>
                <div id="emessagecontent" style="display: none;">
                    <div style="width: 250px; height: 150px; font-size: 12px; font-family: '宋体'; background: url(images/kkback.gif) repeat-x 0px 0px; text-align: left; padding: 5px; border: 1px solid #8EC6D8;">
                        <div style="width: 248px; height: 149px; background: url(images/kk_01.gif) repeat-x 0px 0px; border: 1px solid #C9C9C9; float: left;">
                            <div style="width: 245px; height: 145px;">
                                <div style="width: 245px; height: 25px; text-align: left; padding: 5px 0px 0px 5px; margin-bottom: 15px; float: left;">
                                    <ul style="height: 18px; color: #E9B709; display: block; list-style-type: none; padding: 0px; margin: 0px;">
                                        <li style="display: inline; list-style-type: none; padding-right: 5px; font-size: 14px; font-weight: bold; width: 150px; padding: 2px 0px 0px 10px; float: left;">提示</li>
                                        <li style="display: inline; list-style-type: none; padding-right: 5px; font-size: 14px; font-weight: bold; width: 9px; height: 9px; padding-top: 2px; float: right;">
                                            <img src="images/close.gif" style="cursor: hand;" onclick="parent.oPopup.hide();"
                                                alt="关闭" />
                                        </li>
                                    </ul>
                                </div>
                                <div style="width: 220px; margin: 0px 10px 5px 13px; line-height: 18px;">
                                    <table border="0" cellpadding="0" cellspacing="0" width="230px" height="70px">
                                        <tr>
                                            <td align="center" style="color: Red;">
                                                <b><span id="countspan"></span></b>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <%-- 20150324薛广兴--%>
            </div>
        </div>
        <script type="text/javascript">
            function telajaxopt(opturl) {
                var r = "";
                try {
                    $.ajax({
                        type: 'get',
                        url: opturl,
                        dataType: 'html',
                        async: false,
                        cache: false,
                        success: function (res) {
                            r = res;
                        }
                    });
                }
                catch (e) {
                    $.ligerDialog.error(e.message);
                }
                return r;
            }
            //电话操作事件
            //话机状态改变事件
            function OnPhoneStatusNotify(status) {
                try {
                    var _UserNo = document.getElementById("txtLabourNo").value;
                    var _CallId = "";
                    try {
                        Phone.QueryCallIDOnAgentEx(_UserNo);
                        for (i = 0; i < Phone.CallIDNum; i++) {
                            _CallId = Phone.GetCallIDByIdx(i);
                            //                        alert(_CallId);
                        }
                        Phone.QueryCallInfoEx(_CallId);
                    }
                    catch (e) {
                    }
                    /*
                    0; //振铃
                    1; //摘机
                    2; //挂机
                    */

                    if (status == 0) {
                        if (becallcome) {
                            var telphone = Phone.CallInfoEx_Ani;
                            try {
                                var userid = document.getElementById("txtAgentId").value;
                                var usercode = document.getElementById("lblAgentCode").innerHTML;
                                var username = document.getElementById("lblAgentName").innerHTML;
                                var extnumber = document.getElementById("lblAgentExt").innerHTML;
                                //获取呼叫编号
                                var callid = telajaxopt("../telmanage/ajax/telrecords.ashx?action=getCallIdByPhone&telphone=" + telphone);
                                document.getElementById("CallHjbh").value = callid;
                                username = encodeURI(username);
                                telajaxopt("../telmanage/ajax/telrecords.ashx?action=zhenlingEvent&callid=" + callid + "&userid=" + userid + "&usercode=" + usercode + "&username=" + username + "&extnumber" + extnumber);   //更新摘机事件
                            } catch (e) {
                            }
                            Form_callCommingCaller(telphone, callid);
                        }
                        becallout = false;
                        becallcome = true;
                    }
                    else if (status == 1) {
                        //改变按钮图片
                        telajaxopt("../telmanage/ajax/telrecords.ashx?action=zhaijiEvent&callid=" + document.getElementById("CallHjbh").value); //更新摘机事件
                        Form_setWinfromenble("True", "false", "false", "false", "True", "True", "True", "false", "false", "false");
                        setAgentStatus("忙");

                    }
                    else if (status == 2) {
                        telajaxopt("../telmanage/ajax/telrecords.ashx?action=guajiEvent&callid=" + document.getElementById("CallHjbh").value); //更新挂机事件
                        Form_setWinfromenble("false", "True", "True", "false", "false", "false", "false", "false", "false", "false");

                        setAgentStatus("空闲");
                        //2014-10-22
                        becallout = false;
                        becallcome = true;
                    }
                }
                catch (e) {
                    $.ligerDialog.error(e.message);
                }
                //document.getElementById("spanServerRes").innerHTML = "状态：" + status;
            }
            //来电弹屏事件
            function Form_callCommingCaller(callerNum, CBnumber) {
                becallout = false;
                becallcome = true;
                document.getElementById("forZYnumber").value = callerNum;
                document.getElementById("callnum").value = callerNum;
                f_addTab('callin_' + CBnumber + callerNum, callerNum + '来电', '../telmanage/callinopt.aspx?callid=' + CBnumber + "&phone=" + callerNum);

            }
            //录音成功
            function Form_callComming(callerNum, parth) {
                telajaxopt("../telmanage/ajax/telrecords.ashx?action=luyinEvent&callid=" + document.getElementById("CallHjbh").value + "&path=" + parth);  //录音开始事件
                Form_setWinfromenble("True", "false", "false", "false", "True", "True", "True", "false", "false", "false");
            }

            function getCallerNum() {
                var calnum = document.getElementById("callnum").value;
                return calnum;

            }
            function clearCallerNum() {
                document.getElementById("callnum").value = "";
            }
            function getCallHjbh() {
                var cid = document.getElementById("CallHjbh").value;
                return cid;
            }

            function clearCallHjbh() {
                document.getElementById("CallHjbh").value = "";
            }
        </script>
        <iframe src="iframeocx.aspx" name="iframeocx" frameborder="0" height="0" width="0" style="display: none;"></iframe>
    </form>
</body>
</html>
