<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta name="viewport"
	content="width=device-width, maximum-scale=1.0, initial-scale=1.0,initial-scale=1.0,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title><#if systemConfig?? && systemConfig.title?? && systemConfig.title != ''>${systemConfig.title}<#else>春松客服-全渠道智能客服</#if></title>
<link rel="shortcut icon" type="image/x-icon" href="<#if systemConfig?? && systemConfig.favlogo?? && systemConfig.favlogo != ''>/res/image.html?id=${systemConfig.favlogo?url}<#else>/images/favicon.ico?t=${.now?long}</#if>"/>
<link rel="stylesheet" href="/css/flexboxgrid.min.css">
<link rel="stylesheet" type="text/css" href="/css/darktooltip.css" />
<link rel="stylesheet" href="css/layui.css">
<link rel="stylesheet" href="/js/ztree/zTreeStyle/zTreeStyle.css">
<link rel="stylesheet" href="/js/select/css/select2.min.css"/>
<link rel="stylesheet" href="/res/css.html">
<link rel="stylesheet" type="text/css" href="/js/kindeditor/themes/default/default.css">

<script src="/js/jquery-1.10.2.min.js"></script>
<script src="/js/jquery.form.js"></script>
<script src="/js/select/js/select2.min.js"></script>
<script src="/js/moment.min.js"></script>
<script src="/js/moment-timezone.js"></script>
<script src="/js/moment-timezone-with-data.js"></script>

<script src="/layui.js"></script>
<!-- #894 和原生Map行为不一致 -->
<!-- <script src="/js/utils.js"></script> -->
<script src="/js/cskefu.js"></script>
<script src="/im/js/socket.io.js"></script>
<script src="/js/CSKeFu_IM.v1.js"></script>
<script src="/js/CSKeFu_Rest_Request.v1.js"></script>
<script src="/js/CSKeFu_Agent_State.v1.js"></script>
<script src="/js/CSKeFu_Admin.v1.js"></script>

<#if models?seq_contains("callout")>
<script src="/js/CSKeFu_Callout.v1.js"></script>
</#if>

<#if models?seq_contains("callcenter")>
<script src="/plugins/callcenter/js/sip-0.15.10.js"></script>
<script src="/plugins/callcenter/js/UKeFu-SoftPhone.js"></script>
</#if>

<script src="/js/ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/ace/theme-chrome.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/weixinAudio.js"></script>
<#if systemConfig?? && systemConfig.mapkey?? && systemConfig.mapkey!=''>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=${systemConfig.mapkey}"></script>
</#if>

<#if infoacq?? && infoacq == "true">
<script src="/js/UKeFu-InfoAcq.js"></script>
</#if>
<#if systemConfig?? && systemConfig.callcenter && systemConfig.callout>
<script src="/js/UKeFu-CallOut.js"></script>
</#if>
<style>
	.ztree li span {
		display: inline-block !important;
		white-space: pre-wrap;
		width: 90px;
		overflow:hidden;
		white-space:nowrap;
		text-overflow:ellipsis;
	}
</style>
<script src="/js/ztree/jquery.ztree.all.min.js"></script>
<script type="text/javascript" src="/js/kindeditor/kindeditor.js"></script>
<script type="text/javascript" src="/js/kindeditor/lang/zh-CN.js"></script>

<script type="text/javascript" src="/js/jquery.darktooltip.js"></script>
<script language="javascript">
	var hostname = "${hostname!''}" , adminuser = "<#if user.admin?? && user.admin>true<#else>false</#if>" , schema = "${schema!'http'}", port = "${webimport!''}" , userid = "${user.id!''}" , session = "${sessionid!''}" , orgi = "${orgi!''}";
	var layinx , layerhelper ;
	var isImIndex = false;

	$(document).ready(function(){
		layui.use('layer', function(){
			layerhelper = layer ;
			<#if Request["msg"]?? && Request["msg"] == "security">
				layer.msg('您访问的资源需要安全验证，请确认您有系统管理员权限！',{icon: 2, time: 3000})
			<#elseif msg?? && msg == 't0'>
				layer.msg('当前坐席就绪或对话未结束，不能切换${systemConfig.namealias!''}',{icon: 2, time: 3000})
			<#elseif msg?? && msg == 't1'>
				layer.msg('当前用户坐席就绪或对话未结束，不能切换为非坐席',{icon: 2, time: 3000})
			</#if>
			<#if models?seq_contains("entim")>
			var imDialogHelper = {
				open : function(){
					layinx = layer.open({
						  type: 2,
						  title: false,
						  closeBtn: 0, //不显示关闭按钮
						  shade: [0],
						  area: ["120px", "50px"],
						  offset: "rb", //右下角弹出
						  anim: 2,
						  shade: 0,
						  content: "/ent/im/point.html",
						  end:function(){
							  if(isImIndex == true){
								  layinx = layer.open({
								  type: 2,
										  title: false,
										  closeBtn: 0, //不显示关闭按钮
										  shade: [0],
										  area: ["30px", "50px"],
										  offset: "rb", //右下角弹出
										  anim: 2,
										  shade: 0,
										  content: "/ent/im/expand.html",
										  end: function(){ //此处用于演示
											  imDialogHelper.open();
											  isImIndex = false;
										  }
									  })
								  isImIndex = false;
							  }else{
								  layinx = layer.open({
									  type: 2,
									  title: false,
									  closeBtn: 0, //不显示关闭按钮
									  shade: [0],
									  area: ["260px", "520px"],
									  offset: "rb", //右下角弹出
									  anim: 2,
									  shade: 0,
									  content: ["/ent/im/index.html", "no"], //iframe的url，no代表不显示滚动条
									  end: function(){ //此处用于演示
										  imDialogHelper.open();
									  }
								  });
							  }
						  }
					});
				}
			}
			imDialogHelper.open();
			</#if>
		});

	    $(".ukefu-left-menu").darkTooltip({
	    		gravity: "west"
	    	});
	});

	function closeentim(){
		if(layerhelper){
			layerhelper.close(layinx);
		}
	}

	<#if tongjiBaiduSiteKey??>
	var _hmt = _hmt || [];
	(function() {
		var hm = document.createElement("script");
		hm.src = "https://hm.baidu.com/hm.js?${tongjiBaiduSiteKey}";
		var s = document.getElementsByTagName("script")[0];
		s.parentNode.insertBefore(hm, s);
	})();
	</#if>
</script>

</head>

<body οnunlοad="CloseOpen(event)">
	<div class="layui-layout layui-layout-admin">
		<div class="layui-header header header-ukefu">
			<div class="layui-main">
				<a class="logo" href="/"><img src="<#if systemConfig?? && systemConfig.consolelogo?? && systemConfig.consolelogo != ''>/res/image.html?id=${systemConfig.consolelogo?url}<#else>images/logo.png</#if>"></a>
				<ul class="layui-nav">
					<li class="layui-nav-item layui-this">
						<a href="javascript:void(0)" onclick="return false;" data-title="首页" data-href="/apps/content.html" class="iframe_btn" data-id="maincontent" data-type="tabChange">
							<i class="kfont" style="position: relative;">&#xe717;</i>
							首页
						</a>
					</li>
					<#if istenantshare?? && istenantshare==true>
						<li class="layui-nav-item">
							<a href="javascript:void(0)" onclick="return false;" data-title="${systemConfig.namealias!''}" data-href="/apps/tenant/index.html" class="iframe_btn" data-id="maincontent" data-type="tabChange">
								<i class="layui-icon" style="position: relative;">&#xe620;</i>
								${systemConfig.namealias!''}
							</a>
						</li>
					</#if>
					<#if (user?? && user.agent == true) || user.admin>
					<#if (user?? && user.roleAuthMap["A01"]??) || user.admin>
					<li class="layui-nav-item " style="position: relative;">
						<div class="ukefu-last-msg" data-num="0" id="ukefu-last-msg">
							<small class="ukefu-msg-tip bg-red" id="msgnum">0</small>
						</div>
						<a href="javascript:void(0)" id="agentdesktop" onclick="return false;"  data-title="坐席工作台" data-href="/agent/index.html" class="iframe_btn" data-id="multiMediaDialogWin" data-type="tabAdd">
							<i class="kfont icon-iconfontagent"	style="position: relative;"></i>
							坐席
						</a>
					</li>
					</#if>
					</#if>
					<#if (user?? && user.roleAuthMap["B02"]??) || user.admin>
					<li class="layui-nav-item ">
						<a href="javascript:void(0)" onclick="return false;"  data-title="系统管理" data-href="/admin/content.html" class="iframe_btn" data-id="admin" data-type="tabAdd">
							<i class="layui-icon" style="position: relative;">&#xe631;</i>
							系统
						</a>
					</li>
					</#if>

					<#if organList?? && currentOrgan??>
					<li class="layui-nav-item">
						<a href="javascript:void(0)">
							<i class="csfont" style="position: relative;float:left;">&#xe61b;</i>
							<span style="display: inline-block;max-width: 90px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;float: left">
								${currentOrgan.name}
							</span>
						</a>
						<dl class="layui-nav-child">
					      <dd>
						  	<div style=" background: white;">
								<ul style="width: 240px;max-height: 800px;overflow-y: auto;" id="homeOrganTree" class="ztree"></ul>
						  	</div>
						  </dd>
					    </dl>
					</li>
					</#if>

					<li class="layui-nav-item"><a href="javascript:void(0)">
						<i class="layui-icon" style="position: relative;float:left;">&#xe612;</i>
						<span style="display: inline-block;max-width: 90px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;float: left">
							<#if user??>${user.uname!''}<#if tenant??&&tenant.tenantname??>（${tenant.tenantname!''}）</#if></#if></span></a>
						<dl class="layui-nav-child">
					      	<dd><a href="/apps/profile.html" data-toggle="ajax" data-width="750" data-title="修改资料">个人资料</a></dd>
							<dd><a href="javascript:void(0)" onclick="showSystemBuildInfo()">关于产品</a></dd>
							<dd><a href="javascript:void(0)" onclick="quitSystem()" >退出系统</a></dd>
					    </dl>
					</li>
				</ul>
			</div>
		</div>
		<div class="layui-side layui-bg-black">
			<div class="layui-side-scroll">
				<ul class="layui-nav layui-nav-tree site-ukefu-nav">

					<li class="layui-nav-item layui-nav-itemed">
						<dl class="layui-nav-child">

							<dd class="ukefu-left-menu">
								<a href="javascript:void(0)" onclick="return false;" data-title="首页" data-href="/apps/content.html" class="iframe_btn" data-id="maincontent" data-type="tabChange">
									<i class="kfont" style="top: 1px;">&#xe717;</i>
								</a>
							</dd>
							<#if user?? && user.agent == true>
								<#if user?? && (user.roleAuthMap["A01"]?? || user.admin) >
								<dd class="ukefu-left-menu" data-tooltip="坐席工作台" >
									<a href="javascript:void(0)" href="javascript:void(0)" id="agentdeskleft" onclick="return false;" data-title="坐席对话" data-href="/agent/index.html" class="iframe_btn" data-id="multiMediaDialogWin" data-type="tabAdd"> <i class="layui-icon"
										style="top: 3px;">&#xe63a;</i>
									</a>
								</dd>
								</#if>
							</#if>

							<#if models?seq_contains("contacts")>
								<#if user?? && (user.roleAuthMap["A02"]??  || user.admin)>
								<dd class="ukefu-left-menu" data-tooltip="全部联系人">
									<a href="javascript:void(0)" data-title="全部联系人" onclick="return false;" data-href="/apps/contacts/index.html" class="iframe_btn" data-id="contactsMainContentWin" data-type="tabAdd">
									<i class="layui-icon"	style="position: relative;">&#xe612;</i>
									</a>
								</dd>
								</#if>
								<#if user?? && (user.roleAuthMap["A03"]?? || user.admin)>
									<dd class="ukefu-left-menu" data-tooltip="全部客户">
										<a href="javascript:void(0)" data-title="全部客户" onclick="return false;" data-href="/apps/customer/index.html" class="iframe_btn" data-id="customersMainContentWin" data-type="tabAdd">
										<i class="kfont" style="position: relative;">&#xe650;</i>
										</a>
									</dd>
								</#if>
							</#if>

							<#if models?seq_contains("workorders")>
								<#if user?? && (user.roleAuthMap["A04"]??  || user.admin)>
									<dd class="ukefu-left-menu" data-tooltip="工单管理">
										<a href="javascript:void(0)" data-title="工单管理" data-href="<#if systemConfig?? && systemConfig.workorders>/apps/workordersthree/index.html<#else>/apps/workorders/index.html</#if>" class="iframe_btn" data-id="maincontent" data-type="tabChange">
										<i class="kfont" style="position: relative;">&#xe607;</i>
										</a>
									</dd>
								</#if>
								<!-- <#if user?? && (user.roleAuthMap["A05"]?? || user.admin) >
									<dd class="ukefu-left-menu" data-tooltip="业务流程">
										<a href="javascript:void(0)" data-title="业务流程" data-href="/apps/bpm/index.html" class="iframe_btn" data-id="maincontent" data-type="tabChange">
										<i class="kfont" style="position: relative;">&#xe636;</i>
										</a>
									</dd>
								</#if> -->
							</#if>

							<!-- 会话监控 Customer Chats Audit -->
							<#if models?seq_contains("cca")>
							<#if user?? && (user.roleAuthMap["A13_A01"]?? || user.admin) >
							<dd class="ukefu-left-menu" data-tooltip="会话监控">
								<a href="javascript:void(0)" href="javascript:void(0)" id="customerchatsaudit"  onclick="return false;" data-title="会话监控" data-href="/apps/cca/index.html" class="iframe_btn" data-id="customerChatAudit" data-type="tabAdd">
									<i class="csfont" style="position: relative;">&#58906;</i>
								</a>
							</dd>
							</#if>
							</#if>

							<#if models?seq_contains("xiaoe")>
								<#if user?? && (user.roleAuthMap["A09_A02_A01"]?? || user.admin) >
									<a href="javascript:void(0)" data-title="知识库" data-href="/apps/topic.html" class="iframe_btn" data-id="maincontent" data-type="tabChange">
										<i class="kfont" style="position: relative;">&#xe62a;</i>
									</a>
								</#if>
							</#if>

							<#if currentOrgan?? && user?? &&( user.roleAuthMap["A06"]?? || user.admin)>
								<dd class="ukefu-left-menu" data-tooltip="客服设置">
									<a href="javascript:void(0)" data-title="客服设置" data-href="/setting/agent/index.html" class="iframe_btn" data-id="maincontent" data-type="tabChange"> <i class="layui-icon"
										style="position: relative;">&#xe614;</i>
									</a>
								</dd>
							</#if>

							<#if currentOrgan?? && user?? &&( user.roleAuthMap["A08"]?? || user.admin) >
								<dd class="ukefu-left-menu" data-tooltip="会话历史">
									<a href="javascript:void(0)" data-title="会话历史" data-href="/service/history/index.html" class="iframe_btn" data-id="maincontent" data-type="tabChange"> <i class="kfont"
										style="position: relative;">&#xe7eb;</i>
									</a>
								</dd>
							</#if>

							<!--
							<dd class="ukefu-left-menu" data-tooltip="会话质检">
								<a href="javascript:void(0)" data-title="会话质检" data-href="/apps/quality/index.html" class="iframe_btn" data-id="maincontent" data-type="tabChange">
									<i class="kfont" style="position: relative;">&#xe644;</i>
								</a>
							</dd>
							 -->
<!-- #915 呼叫中心管理员 暂时没有开发该页面 -->
<!--https://gitlab.chatopera.com/chatopera/cosinee/issues/915 -->
<!--							<#if models?seq_contains("callcenter")>-->
<!--								<#if user?? &&( user.roleAuthMap["A11"]?? || user.admin) >-->
<!--								<dd class="ukefu-left-menu" data-tooltip="呼叫中心">-->
<!--									<a href="javascript:void(0)" data-title="呼叫中心" onclick="return false;" data-href="/apps/callcenter/index.html" class="iframe_btn" data-id="calloutIntegrationWin" data-type="tabAdd">-->
<!--									<i class="kfont"	style="position: relative;">&#xe629;</i>-->
<!--									</a>-->
<!--								</dd>-->
<!--								</#if>-->
<!--							</#if>-->

							<#if models?seq_contains("sample")>
								<dd class="ukefu-left-menu" data-tooltip="插件示例">
									<a href="javascript:void(0)" data-title="插件示例" onclick="return false;" data-href="/apps/sample/index.html" class="iframe_btn" data-id="samplePluginWin" data-type="tabAdd">
										<i class="kfont" style="position: relative;">&#xe62e;</i>
									</a>
								</dd>
							</#if>

                            <!--暂时隐藏https://github.com/chatopera/cosin/issues/52-->
							<!--<#if user?? && (user.roleAuthMap["A13"]?? || user.admin) >-->
							<!--<dd class="ukefu-left-menu" data-tooltip="数据报表">-->
								<!--<a href="javascript:void(0)" data-title="数据报表" data-href="/apps/view/index.html" class="iframe_btn" data-id="maincontent" data-type="tabChange">-->
								<!--<i class="kfont"	style="position: relative;">&#xe6d6;</i>-->
								<!--</a>-->
							<!--</dd>-->
							<!--</#if>-->
						</dl>
					</li>
<!--					<li class="layui-nav-item" style="height: 30px; text-align: center"></li>-->
				</ul>
			</div>
		</div>
		<div class="layui-body">
			<div class="layui-tab product-tab" lay-filter="ukefutab" lay-allowClose="true">
				<div style="padding-bottom: 5px">
					<div class="ukefu-switch" style="position:relative;margin-left: 10px">
						<#if user?? && user.agent == true>
						<#include "/public/agentstatus.html"/>
					    </#if>
				    </div>
					<#if models?seq_contains("callcenter")>
						<div style="float: right">
							<#include "/admin/channel/callcenter/softphone.html">
						</div>
					</#if>
				</div>
				<ul class="layui-tab-title">
					<li lay-id="maincontent" class="layui-this ukefu-home"><i class="kfont"
						style="position: relative;">&#xe717;</i> 首页</li>
				</ul>

				<div class="layui-tab-content product-content ukefu-tab">
					<div class="layui-tab-item layui-show" style="height:100%;">
						<iframe frameborder="0" src="<#if vt?? && vt==true>/apps/tenant/index.html<#else>/apps/content.html</#if>" id="maincontent" name="maincontent" width="100%" height="100%"></iframe>
					</div>
				</div>
			</div>

		</div>
	</div>

	<script>
		var setting = {
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				onClick: onClick
			}
		};

		function onClick(e, treeId, treeNode) {
			if(treeNode.topic){
				$.post('/setorgan',{organ:treeNode.id}).success(function () {
					location.href = '/';
				})
			}else if(treeNode.id == "0"){
				// location.href = "/admin/organ/index.html";
			}else if(treeNode.area){
				// $('#areaadd').attr("href" , "/admin/organ/add.html?area="+treeNode.id);
			}
		}

		var zNodes =[
			<#if organList??>
		<#list organList as organ>
				{ id:'${organ.id!''}', pId:'${organ.parent!'0'}', name:"${organ.name!''}", open:true , topic : true ,  <#if organ.area?? && organ.area != "">icon:"/images/area.png" <#else>icon:"/images/dept.png"</#if> },
		</#list>
		</#if>
		];

		$(document).ready(function(){
			var ztree = $.fn.zTree.init($("#homeOrganTree"), setting, zNodes);
		<#if organData??>
			var node = ztree.getNodeByParam('id', '${organData.id!''}');//获取id为1的点
			ztree.selectNode(node);//选择点
		</#if>

		});

		// 展示系统构建信息
		function showSystemBuildInfo(){
			layer.confirm('<div style="text-align:center;"> <img src="/images/favicon.ico" width="50px" height="50px"><p>春松客服<span>&#174;</span></p></div> Release: ${appVersionNumber} <a href="https://docs.chatopera.com/products/cskefu/index.html" target="_blank">文档中心</a> <br> Build: ${appBuildDate}.${appVersionAbbrev} <br> Copyright (2018-2020) <a href="https://www.chatopera.com" target="_blank">北京华夏春松科技有限公司</a> <br> Business License applied to ${appCustomerEntity} <br>  <a href="https://docs.chatopera.com/products/cskefu/index.html#%E5%95%86%E4%B8%9A%E6%94%AF%E6%8C%81" target="_blank">购买春松客服企业版或服务</a>',
					{icon: -1, title:'关于产品', btn:["关闭"]}, function(index, layero){
				//do something
				layer.close(index);
			});
		}

		<#if webrtc??>
			// 呼叫中心连接信息
			top.CSKEFU_WEBRTC = {"ip": "${webrtc.callCenterWebrtcIP}", "port": "${webrtc.callCenterWebRtcPort}", "extension": "${webrtc.callCenterExtensionNum}", "password": "${webrtc.callCenterExtensionPassword}", "error":"${webrtc.callCenterError}"}
		</#if>

		// TODO 打印前端中WebRTC链接信息，调试结束后删除打印日志
		// https://gitlab.chatopera.com/chatopera/cosinee/issues/926
		console.log("top.CSKEFU_WEBRTC", top.CSKEFU_WEBRTC);

		// 登出系统
		// https://gitlab.chatopera.com/chatopera/cosinee.w4l/issues/291
		function quitSystem() {
			// 当坐席从就绪状态，切换到非就绪状态前，请求接口查看当前坐席服务到客户数。
			checkAgentStatusData().then(handleAgentStatusData)
					.then(function (data) {
						if(data.length == 0){
							// 执行登出
							window.location.href = "/logout.html";
						} else {
							// 弹出对话框提示
							layer.alert("您有正在服务中的访客" + data.length + "人！结束全部会话，或转接后可登出。", {title: "提示", icon: 2});
						}
					}, function(error){
						// 执行登出
						window.location.href = "/logout.html";
					});
		}

		//  获取时间差
		var timeDifference=${timeDifference};
		var skills='${skills}'.split(',');

		layui.use('element', function(){
			var $ = layui.jquery,element = layui.element(); //Tab的切换功能，切换事件监听等，需要依赖element模块
			//触发事件
			$(".layui-tab").on("click",function(e){
			  	if($(e.target).is(".layui-tab-close")){
					var win = $(e.target).parent().attr("lay-id");
					if(win == "outboundCallConsole" && uKeFuSoftPhone){
						uKeFuSoftPhone.cancleoutbound();
					}
				}
			})

			$('.iframe_btn').on('click', function(){
				var type = $(this).data('type');
				if(type == "tabAdd"){
					active.tabAdd($(this).data('href') , $(this).data('title'), $(this).data('id'));
				}else if(type == "tabChange"){
					active.tabChange($(this).data('href') , $(this).data('title'), $(this).data('id'));
				}
			});
		});

		console.log("新的转机和闪闪星斗/正在缀满没有遮拦的天空\n春松客服，开源的智能客服系统 https://github.com/chatopera/cosin")

	</script>
</body>

</html>
