<%--
  Class Name : EgovAuthorGroupManage.jsp
  Description : EgovAuthorGroupManage List 화면
  Modification Information
 
      수정일         수정자                   수정내용
    -------    --------    ---------------------------
     2009.03.23    lee.m.j              최초 생성
     2011.08.31   JJY       경량환경 버전 생성
 
    author   : 공통서비스 개발팀 lee.m.j
    since    : 2009.03.23
--%>
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Language" content="ko" >
<%-- <link href="<c:url value='/'/>css/common.css" rel="stylesheet" type="text/css" > --%>
<title>권한그룹 목록</title>

<script type="text/javaScript" language="javascript" defer="defer">
<!--

function fncCheckAll() {
    var checkField = document.listForm.delYn;
    if(document.listForm.checkAll.checked) {
        if(checkField) {
            if(checkField.length > 1) {
                for(var i=0; i < checkField.length; i++) {
                    checkField[i].checked = true;
                }
            } else {
                checkField.checked = true;
            }
        }
    } else {
        if(checkField) {
            if(checkField.length > 1) {
                for(var j=0; j < checkField.length; j++) {
                    checkField[j].checked = false;
                }
            } else {
                checkField.checked = false;
            }
        }
    }
}

function fncManageChecked() {

    var resultCheck = false;

    var checkField = document.listForm.delYn;
    var checkId = document.listForm.checkId;
    var selectAuthor = document.listForm.authorManageCombo;
    var booleanRegYn = document.listForm.regYn;
    var listMberTyCode = document.listForm.mberTyCode;
        
    var returnId = "";
    var returnAuthor = "";
    var returnRegYn = "";
    var returnmberTyCode = "";

    var checkedCount = 0;

    if(checkField) {
        if(checkField.length > 1) {
            for(var i=0; i<checkField.length; i++) {
                if(checkField[i].checked) {
                    checkedCount++;
                    checkField[i].value = checkId[i].value;
                    if(returnId == "") {
                        returnId = checkField[i].value;
                        returnAuthor = selectAuthor[i].value;
                        returnRegYn = booleanRegYn[i].value;
                        returnmberTyCode = listMberTyCode[i].value;
                    }
                    else {
                        returnId = returnId + ";" + checkField[i].value;
                        returnAuthor = returnAuthor + ";" + selectAuthor[i].value;
                        returnRegYn = returnRegYn + ";" + booleanRegYn[i].value;
                        returnmberTyCode = returnmberTyCode + ";" + listMberTyCode[i].value;
                        
                    }
                }
            }

            if(checkedCount > 0) 
                resultCheck = true;
            else {
                alert("선택된  항목이 없습니다.");
                resultCheck = false;
            }
            
        } else {
             if(document.listForm.delYn.checked == false) {
                alert("선택 항목이 없습니다.");
                resultCheck = false;
            }
            else {
                returnId = checkId.value;
                returnAuthor = selectAuthor.value;
                returnRegYn = booleanRegYn.value;
                returnmberTyCode = listMberTyCode.value;

                resultCheck = true;
            }
        } 
    } else {
        alert("조회된 결과가 없습니다.");
    }
    
    document.listForm.userIds.value = returnId;
    document.listForm.authorCodes.value = returnAuthor;
    document.listForm.regYns.value = returnRegYn;
    document.listForm.mberTyCodes.value = returnmberTyCode ;
    return resultCheck;
}

function fncSelectAuthorGroupList(){
	linkPage(1);
}

function fncAddAuthorGroupInsert() {

    if(!fncManageChecked()) return;
    
    if(confirm("등록하시겠습니까?")) {
        document.listForm.action = "<c:url value='/sec/rgm/EgovAuthorGroupInsert.do'/>";
        document.listForm.submit();
    }
}

function fncAuthorGroupDeleteList() {
 
    if(!fncManageChecked()) return;

    if(confirm("등록취소 하시겠습니까?")) {
        document.listForm.action = "<c:url value='/sec/rgm/EgovAuthorGroupDelete.do'/>";
        document.listForm.submit(); 
    }
}

function linkPage(pageNo){
	var searchForm = document.searchForm ;
	searchForm.pageIndex.value = pageNo ;
	searchForm.searchCondition.value = $('#searchCondition').val();
	searchForm.searchKeyword.value = $('#searchKeyword').val();
	searchForm.action = "<c:url value='/sec/rgm/EgovAuthorGroupList.do'/>";
	searchForm.submit();
}

function fncSelectAuthorGroupPop() {

    if(document.listForm.searchCondition.value == '3') {
        window.open("<c:url value='/sec/gmt/EgovGroupSearchView.do'/>","notice","height=500, width=800, top=50, left=20, scrollbars=no, resizable=no");
    } else {
        alert("그룹을 선택하세요.");
        return;
    }
}

function onSearchCondition() {
    document.listForm.searchKeyword.value = "";
    if(document.listForm.searchCondition.value == '3') {
        document.listForm.searchKeyword.readOnly = true;
    } else {
        document.listForm.searchKeyword.readOnly = false;
    }
}

function press() {

    if (event.keyCode==13) {
        fncSelectAuthorGroupList();
    }
}
//-->
</script>

</head>

<body>
<form:form id="listForm" name="listForm" action="<c:url value='/sec/rgm/EgovAuthorGroupList.do'/>" method="post">
	<input type="hidden" name="userId"/>
	<input type="hidden" name="userIds"/>
	<input type="hidden" name="authorCodes"/>
	<input type="hidden" name="regYns"/>
	<input type="hidden" name="mberTyCodes"/>
	<input type="hidden" name="pageIndex" value="<c:out value='${authorGroupVO.pageIndex}'/>"/>
	
	<div class="ad_content">
	<div class="ad_con_head">
		<div class="ad_head_text">
			<p class="today_txt">권한관리</p>
			<div class="ad_head_ment">
				<p class="today_last_txt"><span id="cnt_cate_list"></span></p>
			</div>
		</div>
	</div>
	<div class="ad_subcon">
		<div class="ad_con_body">
			<div class="ad_bo_h3">
				<div class="board1_div1">
					<select id="searchCondition" name="searchCondition" onchange="onSearchCondition()" title="조회조건">
		                 <option value="1" <c:if test="${authorGroupVO.searchCondition == '1'}">selected</c:if> >사용자 ID</option>
		                 <option value="2" <c:if test="${authorGroupVO.searchCondition == '2'}">selected</c:if> >사용자 명</option>
		             </select>
             
					<input id="searchKeyword" name="searchKeyword" type="text" value="<c:out value='${authorGroupVO.searchKeyword}'/>" size="25" title="검색" onkeypress="press();" />
					<ul class="board1_div2_ul">
						<li style="visibility: hidden;"><button class="board1_del_btn" onclick="fncAuthorGroupDeleteList(); return false;">삭 제</button></li>
						<li><button class="board1_list_btn" onclick="fncSelectAuthorGroupList(); return false;">검 색</button></li>
						<li><button class="board1_save_btn" onclick="fncAddAuthorGroupInsert(); return false;">등 록</button></li>
					</ul>
				</div>
			</div>
		</div>
		<p class="mem_count">조회건수 : <c:out value="${paginationInfo.totalRecordCount}"/></p>
		<div class="ad_mem_list">
			<table>
				<tr>
					<th>번호</th>
					<th style="vertical-align: middle">
						<input type="checkbox" name="checkAll" title="선택여부" class="check2" onclick="fncCheckAll();">
					</th>
					<th>사용자 ID</th>
					<th>사용자 명</th>
					<!-- <th>사용자 유형</th> -->
					<th>권한</th>
					<th>등록 여부</th>
				</tr>
				<c:forEach var="authorGroup" items="${authorGroupList}" varStatus="status">
				<tr>
					<td><c:out value="${(authorGroupVO.pageIndex - 1) * authorGroupVO.pageSize + status.count}"/></td>
					<td>
						<input type="checkbox" name="delYn" class="check2" title="선택"><input type="hidden" name="checkId" value="<c:out value="${authorGroup.uniqId}"/>"/>
					</td>
					<td><c:out value="${authorGroup.userId}"/></td>
					<td><c:out value="${authorGroup.userNm}"/>
					<input type="hidden" name="mberTyCode" value="${authorGroup.mberTyCode}"/></td>
					<%-- <td>
						<c:out value="${authorGroup.mberTyNm}"/>
						<input type="hidden" name="mberTyCode" value="${authorGroup.mberTyCode}"/>
					</td> --%>
					<td>
						<select name="authorManageCombo" title="권한">
				            <c:forEach var="authorManage" items="${authorManageList}" varStatus="status">
				                <option value="<c:out value="${authorManage.authorCode}"/>" <c:if test="${authorManage.authorCode == authorGroup.authorCode}">selected</c:if> ><c:out value="${authorManage.authorNm}"/></option>
				            </c:forEach>
				        </select>
					</td>
					<td>
						<c:out value="${authorGroup.regYn}"/>
                        <input type="hidden" name="regYn" value="<c:out value="${authorGroup.regYn}"/>">
                     </td>
				</tr>
				</c:forEach>
				<c:if test="${empty authorGroupList}">
		            <tr><td colspan="6"><spring:message code="common.nodata.msg" /></td></tr>
         		</c:if>     
			</table>
			
			<!-- 페이지 네비게이션 시작 -->
			<c:if test="${!empty authorGroupList}">
		 		<div class="board1_btn">
		    		<ul>
		    			<ui:pagination paginationInfo = "${paginationInfo}"  type="image" jsFunction="linkPage" />
		    		</ul>	
		    	</div>  
		  	</c:if>                      
		    <!-- //페이지 네비게이션 끝 --> 
		</div>
	</div>
	</div>
</form:form>
<form name="searchForm" method="get">
	<input name="searchCondition" type="hidden" />
	<input name="searchKeyword" type="hidden" />
	<input name="pageIndex" type="hidden" />
</form>     	
</body>
</html>