<%--
  - FileName  :  SYSRightList.jsp
  - Author(s)  : gyeongmo an
  - Date       :  2014.6.22
  - Copyright  : www.udapsoft.co.kr
  -
  - Description: 권한별 사용가능 프로그램 관리
  --%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*"%>
<%@ include file="/jsp/work/taglib.jsp" %>
<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />
<% 
    ctx.init(request, response);
	ValueObject user    = ctx.getUser();
	
    HandlerStorage storage = ctx.getHandlerStorage();
    ValueObject params = storage.getParams();
    RowSet rowSet = storage.getRowSet("ROWSET");
   	
	String temp1="";
	String temp2="";
	for(int i=0;i<rowSet.size();i++){
		if(i==rowSet.size()-1){
		    temp1 +=(rowSet.getColumn(i,"ACCT_TYPE_NAME").toString()).substring(15);
		    temp2 +=(rowSet.getColumn(i,"ACCT_TYPE_ID").toString()).substring(13);
		}else{
		    temp1 =temp1+(rowSet.getColumn(i,"ACCT_TYPE_NAME").toString()+"|").substring(15);
			temp2 =temp2+(rowSet.getColumn(i,"ACCT_TYPE_ID").toString()+"|").substring(13);
		}
    }
%>	

<SCRIPT language="JavaScript">
	/*예약함수*/
	var sheet1;
	var sheet1Row;
	var sheet1PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;

	function _onReady(){
		gridInit(sheet1);
		
		jQuery("#btnSearch").click(function() {
			jQuery("#fevent").val("GET_SYS_LIST");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/sycs/security/SYSRightList_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
		});
		
		jQuery("#btnAdd").click(function() {
			sheet1.DataAutoTrim = false;
			sheet1.DataInsert();
		});
		
		jQuery("#btnSave").click(function() {
			if (confirm("저장하시겠습니까?")) {
				jQuery("#fevent").val("SAVE_SYS_LIST");
				var url = Modular.model.PageContext.CONTEXT_ROOT + "/sycs/security/SYSRightList_sheet.screen";
				var result = Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), false);
			}
		}); 
		
		autoResize();
	}
	
	function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:30};
		init_sheet.Cols = [
			       			{Header:'삭제',				Type:"DelCheck",		SaveName:"DEL_CHECK", 		Width:50, 	Align:"Center"},
			    			{Header:'번호',				Type:"Seq", 			SaveName:"NO",				Width:60, 	Align:"Center"},
			    			{Header:'상태',			Type:"Status", 			SaveName:"STATUS", 			Width:0, 	Align:"Center", Hidden:"True"},
			    			{Header:'계정타입',			Type:"Combo", 			SaveName:"ACCT_TYPE_ID", 		Width:100,  KeyField:"true",	Align:"Center", ComboText:"<%=temp1%>", ComboCode:"<%=temp2%>"},
			    			{Header:'권한ID',			Type:"Text", 			SaveName:"RIGHT_ID", 		Width:150, 	KeyField:"false", Align:"Left", Hidden:"True", Edit:"false" },    
			    			{Header:'☞ 권한',			Type:"Text", 			SaveName:"RIGHT_NAME", 	Width:290, 	Align:"Left", KeyField:"true", Cursor:"Pointer"},
			    			{Header:'Description',			Type:"Text",	 		SaveName:"DSCR", 			Width:260, 	Align:"Left"  },
			    			{Header:'등록자',			Type:"Text", 			SaveName:"CRE_BY", 			Width:60, 	Align:"Center", Edit:"false"  },
			    			{Header:'등록일',		Type:"Date", 			SaveName:"CRE_DATE", 		Width:90, 	Align:"Center", Edit:"false"  },
			    			{Header:'수정자',		Type:"Text", 			SaveName:"UPD_BY", 	Width:60, 	Align:"Center", Edit:"false"},
			    			{Header:'수정일',			Type:"Date", 			SaveName:"UPD_DATE", 			Width:90, 	Align:"Center", Edit:"false"}
		];

		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		setGridSize();
	}
	
	function setGridSize() {
		sheet1.FitColWidth();
	}
	
	 function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		if (sheet1.ColSaveName(Col) == "RIGHT_NAME") {//right_name 일떄만 리턴하기
		    jQuery("#right_id").val(sheet1.GetCellValue(Row, "RIGHT_ID"));
			jQuery("#fevent").val("");
			jQuery("#form1").attr("action", "/sycs/security/SYSRightPgmList.screen");
			jQuery("#form1").attr("target", "_self");
			jQuery("#form1").attr("method", "post");
			jQuery("#form1").submit();
		}
	 }	
	
	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
	    	sheet1.SetColFontColor("RIGHT_NAME", "#0000ff");
		} else {
			//조회 에러 수행
			//alert(message);
			alert("조회 실패");
		}
	}
	
	function sheet1_OnSaveEnd(code, msg) {
	    if(code >= 0) {
	    	alert("저장 성공");
	    } else {
	    	alert(msg);
        }
	    jQuery("#btnSearch").click();
	}
	
	function sheet1_OnSmartResize(Width, Height) { 
		sheet1.FitColWidth();
		autoResize();
	}

	function autoResize(){
		var t1_height = document.getElementById("search-table").scrollHeight + 24;
		var iframeHeight= document.body.scrollHeight - t1_height;   
		
		sheet1.SetSheetHeight(iframeHeight); 
	}
	
	document.body.onresize = addEvent( document.body.onresize, "autoResize()");
</SCRIPT>

<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>

<form id="form1" name="form1" method="post" modular:type="search" style="width:100%;height:100%;">

<INPUT type="hidden" name="fevent" value="">
<input type="hidden" value="" name="right_id">
<TABLE id="search-table" border="0" cellspacing="0" cellpadding="0" width="100%">
	<TR>
		<td>
			<div align="left" id="title">
		    <ul>
		     <li>권한관리</li>
		    </ul>
		  </div>
		</td> 
		<td class="button" align="right">
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnSearch">검색</a></span>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnAdd">추가</a></span>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnSave">저장</a></span>
		</td>
	</tr>
		<!-- 검색조건 영역, 테이터 영역 구분 여백 : 종료 -->
</TABLE>
<div id="sheet1_div" style="padding-top:5px; height: auto; min-height: 450px; overflow: auto;">
	<SCRIPT>
		createIBSheet('sheet1','100%', '450px');
	</SCRIPT>
</div>
</FORM>



