<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ page import="java.io.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/jsp/common/include/localemessage.jsp" %>
<%
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Expires", "0");
%>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <jsp:include page="/jsp/common/include/css.jsp"/>
    <jsp:include page="/jsp/common/include/script.jsp"/>
    <script language="javascript">
        var url = '<c:url value="/onl/admin/authserver/clientMan.json" />';
        var url_view = '<c:url value="/onl/admin/authserver/clientMan.view" />';

        $(document).ready(function () {
            var gridPostData = getSearchForJqgrid("cmd", "LIST");
            $('#grid').jqGrid({
                datatype: "json",
                mtype: 'POST',
                url: url,
                postData: gridPostData,
                colNames: ['<%= localeMessage.getString("clntMan.clntNm") %>',
                    '<%= localeMessage.getString("clntMan.clntId") %>',
                    '<%= localeMessage.getString("portalOrg.orgName") %>',
                    '<%= localeMessage.getString("clntMan.scp") %>',
                    '<%= localeMessage.getString("clntMan.grntTp") %>',
                    '<%= localeMessage.getString("clntMan.tknEffTm") %>',
                    'APP 상태'
                ],
                colModel: [
                    {name: 'CLIENTNAME', align: 'left', sortable: false},
                    {name: 'CLIENTID', align: 'left', sortable: false},
                    {name: 'ORGNAME', align: 'left', sortable: false},
                    {name: 'SCOPE', align: 'left', sortable: false},
                    {name: 'GRANTTYPES', align: 'left', sortable: false},
                    {name: 'ACCESSTOKENVALIDITYSECONDS', align: 'center', sortable: false},
                    {
                        name: 'APPSTATUS',
                        align: 'center',
                        sortable: false,
                        formatter: function (cellvalue, options, rowObject) {
                            return cellvalue === '0' ? '차단' : '정상';
                        }
                    }
                ],
                jsonReader: {
                    repeatitems: false
                },
                pager: $('#pager'),
                page: '${param.page}',
                rowNum: '${rmsDefaultRowNum}',
                autoheight: true,
                height: $("#container").height(),
                autowidth: true,
                viewrecords: true,
                rowList: eval('[${rmsDefaultRowList}]'),
                ondblClickRow: function (rowId) {
                    var rowData = $(this).getRowData(rowId);
                    var url2 = url_view;
                    url2 += '?cmd=DETAIL';
                    url2 += '&page=' + $(this).getGridParam("page");
                    url2 += '&returnUrl=' + getReturnUrl();
                    url2 += '&menuId=' + '${param.menuId}';
                    //검색값
                    url2 += '&' + getSearchUrl();
                    //key값
                    url2 += '&clientId=' + rowData['CLIENTID'];
                    goNav(url2);
                }
            });

            resizeJqGridWidth('grid', 'content_middle', '1000');

            $("#btn_search").click(function () {
                var postData = getSearchForJqgrid("cmd", "LIST"); //jqgrid에서는 object 로
                $("#grid").setGridParam({postData: postData, page: "1"}).trigger("reloadGrid");

            });
            $("#btn_new").click(function () {
                var url2 = url_view;
                url2 += '?cmd=DETAIL';
                url2 += '&page=' + $("#grid").getGridParam("page");
                url2 += '&returnUrl=' + getReturnUrl();
                url2 += '&menuId=' + '${param.menuId}';
                //검색값
                url2 += '&' + getSearchUrl();
                goNav(url2);
            });

            $("input[name^=search]").keydown(function (key) {
                if (key.keyCode == 13) {
                    $("#btn_search").click();
                }
            });

            buttonControl();
        });

    </script>
</head>
<body>
<div class="right_box">
    <div class="content_top">
        <ul class="path">
            <li><a href="#">${rmsMenuPath}</a></li>
        </ul>
    </div><!-- end content_top -->
    <div class="content_middle" id="content_middle">
        <div class="search_wrap">
            <button type="button" class="cssbtn" id="btn_new" level="W"><i
                    class="material-icons">add</i> <%= localeMessage.getString("button.new") %>
            </button>
            <button type="button" class="cssbtn" id="btn_search" level="R"><i
                    class="material-icons">search</i> <%= localeMessage.getString("button.search") %>
            </button>
            <%-- 					<img src="<c:url value="/img/btn_new.png"/>" alt="" id="btn_new" level="W" /> --%>
            <%-- 					<img src="<c:url value="/img/btn_search.png"/>" alt="" id="btn_search" level="R" /> --%>

        </div>
        <div class="title" id="title">${rmsMenuName}</div>

        <table class="search_condition" cellspacing=0;>
            <tbody>
            <tr>
                <th style="width:180px;"><%= localeMessage.getString("clntMan.clntNm") %>
                </th>
                <td><input type="text" name="searchClientName" value="${param.searchClientName}"></td>
                <th style="width:180px;"><%= localeMessage.getString("clntMan.clntId") %>
                </th>
                <td><input type="text" name="searchClientId" value="${param.searchClientId}"></td>
            </tr>
            </tbody>
        </table>

        <table id="grid"></table>
        <div id="pager"></div>

    </div><!-- end content_middle -->
</div><!-- end right_box -->
</body>
</html>