<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="ko">
<head>
<title>시스템 엔티티</title>
<%@ include file="/WEB-INF/jsp/adm/include/topLinkTag.jsp"%>
</head>
<body>
<h1>ICOMSYS ADMIN</h1>
	<div class="skip_navigation">
		<ul>
			<li><a href="#Content" class="go_content">본문 바로가기</a></li>
			<li><a href="#Gnb">메뉴 바로가기</a></li>
		</ul>
	</div>
	<header id="header">
		<%@ include file="/WEB-INF/jsp/adm/include/header.jsp"%>
	</header>
	<c:import url="/adm/menu/getLnbMenu.do" />
  <script>
        $(document).ready(function () {
            // getOpr($("#custCode"));
            // $("#custCode").on('change', function() {
            //     getOpr($(this));
            // });

            if (!checkPermissionPolicy("rcpconversationsystemEntitymanageFull")) {
                $("#btnSystemEntitySynchronize").hide();
            }

	        var opts = {
	        		columns: [
		            	{data: ""},
		                {data: "entityName"}

		            ],
		            columnDefs: [
                        {
		                    "defaultContent": "-",
		                    "targets": "_all",
		                    "className": "center"
		                },
                        {
                            targets: 0,
                            /*render: function (data) {
                                return '<a style="display: block;text-align: center;">' + data + '</a>';
                            }*/
                            render: function (data, type, row, meta) {
                                return meta.row + meta.settings._iDisplayStart + 1;
                            }
                        },
                        {
                            targets: 1,
                            render: function (data) {
                                return '<a style="display: block;text-align: center;">' + data + '</a>';
                            }
                        }
                    ],
	        }
	        <%--$.utils.dataTable.init('<c:url value="/admin/rcp/conversation/systemEntity/search.do"/>', opts);--%>
            $.utils.dataTable.init('<c:url value="/admin/rcp/conversation/scenario/systemEntity/search"/>', opts);
	        <%--// 초기 리스트 조회--%>
	        search();

	        $("[data-role=synchronize]").click(function() {

                synchronize();
	        });
        });

        function fncKeyPresshandler(e) {
            if (event.keyCode == 13) {
                fncSendData();
                return false;
            }
        }

        // 리스트 검색
        function search() {
        	$.utils.dataTable.getListData({
            	// oprMngCode: $("#custCode").val() + "_RCP_" + $("select[name=serviceGroup]").val(),
            	// entityName: $("input[name=entityName]").val()
            }, function(d) {
            	//console.log('result', d)
            	$("#resultTable").renderTable(d.list);
            });
        }

        function synchronize() {

            $.ajax({
                url: '<c:url value="/admin/rcp/conversation/systemEntity/synchronize.do"/>',
                type: "POST",
                datatype: "JSON",
                async: false,
                contentType: "application/json",
                success: function(d) {
                    // console.log(d);

                    if (d.result) {
                        $.utils.success(d.message);
                        $("#resultTable").renderTable(d.list);
                    } else {
                        $.utils.error(d.message);
                        $("#resultTable").renderTable(d.list);
                    }
                }
            });
        }

    </script>

    <!-- 컨텐트 시작 -->
    <section id="Content" class="conversation">
        <div class="cont_top">
            <div class="location">
                <ul>
                    <li class="home"><a href="#">HOME</a></li>
                    <li><a href="#">대화관리</a></li>
                    <li><a href="#">시스템 엔티티</a></li>
                </ul>
            </div>
        </div>
        <div class="sub_cont">
            <div class="cont_box">
                <div class="box_title">

                    <div class="fl">
                        <h2 class="mt12">시스템 엔티티</h2>
                    </div>
                    <div class="fr">
                   <dl class="customer fl">
		                        <dt class="fl">
		                            <c:if test="${'SYS_ADMIN'==LoginVO.authCode}">
		                                고객사 :
		                            </c:if>
		                        </dt>
		                        <dd class="fl">
		                            <div class="sel_box">
								<c:choose>
									<c:when test="${'SYS_ADMIN'==LoginVO.authCode}">
		                                <select class="top" name="custCode" id="custCode">
					                    <c:forEach var="siteInfo" items="${siteLists}" varStatus="status">
					                    	<option value="<c:out value="${siteInfo.custCode}"/>"><c:out value="${siteInfo.custName}"/></option>
					                    </c:forEach>
		                                </select>
									</c:when>
									<c:otherwise>
										<input name="custCode" id="custCode"  type="hidden" value="${LoginVO.siteCode}"/>
									</c:otherwise>
								</c:choose>
		                            </div>
		                        </dd>
		                    </dl>
                       <div class="btn_wrap fr">
							<a id="btnSystemEntitySynchronize" href="#" class="btn" data-role="synchronize">동기화</a>
						</div>
                    </div>
                </div>
            </div>
            <div class="cont_box">
<%--                <div class="box_title">--%>
<%--                    <div class="fl">--%>
<%--                        <h2 class="mt12">시스템 엔티티 리스트</h2>--%>
<%--                    </div>--%>

<%--                </div>--%>
                <div class="tbl">
                    <div id="resultTable_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                        <table id="resultTable" class="click dataTable no-footer table-fixed" aria-describedby="resultTable_info" role="grid">
                            <colgroup>
                                <col width="10%">
                                <col width="90%">
                            </colgroup>
                            <thead>
                                <tr role="row">
                                    <th class="center sorting_disabled" rowspan="1" colspan="1">순번</th>
                                    <th class="center sorting_disabled" rowspan="1" colspan="1">시스템 엔티티명</th>
                                </tr>
                            </thead>
                            <tbody>
                                <!-- 내용 없을 경우 -->
                                <tr>
                                    <td valign="middle" colspan="2" class="dataTables_empty">No data available in table</td>
                                </tr>

                            </tbody>
                        </table>
                        <div class="bottom"></div>
                        <div class="clear"></div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- 컨텐트 끝 -->

    <ul class="vakata-context"></ul>
    <div id="jstree-marker" style="display: none;">&nbsp;</div>
</body>

</html>