  <%--
  - FileName   : SYSRightRegPgmList.jsp
  - Author     : gyeongmo an
  - Date       : 2014.06.22
  - Copyright  : Copyright (c) www.udapsoft.co.kr, Inc.
  - All rights reserved.
--%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="kr.co.hsnc.common.util.ValueObject"%>
<%@ 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();
 String USER_ID = user.get("ACCT_ID");
 
 HandlerStorage storage = ctx.getHandlerStorage();
 String systemSelectTag = (String)storage.getObject("SystemSelectTag");
 String selectText 	    = (String)storage.getObject("selectText");    
 String selectValue     = (String)storage.getObject("selectValue"); 
 
 String url = request.getRequestURL().toString();
 url = url.substring(0, url.indexOf("/",7));
%>

<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() {
		var sort_gb_value = $(':radio[name="sort_gb"]:checked').val();
		document.form1.sort_gb_value.value = sort_gb_value;
		jQuery("#fevent").val("GET_PGL_LIST");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/sycs/security/SYSRightRegPgmList_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
	});
	
	jQuery("#btnAdd").click(function() {
		var rowIdx = sheet1.DataInsert(-1);
	});
	
	jQuery("#btnSave").click(function() {
		if (confirm("저장하시겠습니까?")) {
			jQuery("#fevent").val("SAVE_PGL_LIST");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/sycs/security/SYSRightRegPgmList_sheet.screen";
			var result = Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), false);
		}
	}); 
	
	jQuery("#btnReset").click(function() {
		var f = document.form1;
		f.system_id.value = "";
		f.pgm_name2.value = "";
		f.screen_name2.value = "";
		setRadio(f.sort_gb, "PGM_ID");
	});
	
	autoResize();
}

	function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:30};
		init_sheet.Cols = [
			    			{Header:'상태',			Type:"Status", 			SaveName:"STATUS", 			Width:0, 	Align:"Center", Hidden:"True"},
			       			{Header:'삭제',				Type:"DelCheck",		SaveName:"DEL_CHECK", 		Width:50, 	Align:"Center"},
			    			{Header:'번호',				Type:"Seq", 			SaveName:"NO",				Width:80, 	Align:"Center"},
			    			{Header:'시스템',			Type:"Combo", 			SaveName:"SYSTEM_ID", 		Width:100,  KeyField:"True",	Align:"Center", ComboText:"<%=selectText%>", ComboCode:"<%=selectValue%>"},
			    			{Header:'프로그램',			Type:"Text", 			SaveName:"PGM_NAME", 		Width:150, 	KeyField:"True", Align:"Left"  },    
			    			{Header:'☞ Screen',			Type:"PopupEdit", 			SaveName:"SCREEN_NAME", 	Width:290, 	Align:"Left"  },
			    			{Header:'비고',			Type:"Text",	 		SaveName:"DSCR", 			Width:220, 	Align:"Left"  },
			    			{Header:'수정자',			Type:"Text", 			SaveName:"UPD_BY", 			Width:60, 	Align:"Center", Edit:"false"},
			    			{Header:'수정일자',		Type:"Date", 			SaveName:"UPD_DATE", 		Width:100, 	Align:"Center", Edit:"false"},
			    			{Header:'screen_code',		Type:"Text", 			SaveName:"SYSTEM_CODE", 	Width:120, 	Align:"Left", Hidden:"True"  },
			    			{Header:'프로그램ID.',			Type:"Text", 			SaveName:"PGM_ID", 			Width:0, 	Align:"Left", Hidden:"True" }
		];

		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		setGridSize();
	}

	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
		} else {
			//조회 에러 수행
			//alert(message);
			alert("조회 실패");
		}
	}
	
	function sheet1_OnSaveEnd(code, msg) {
	    if(code >= 0) {
	    	alert("저장 성공!");
	    } else {
	    	//alert(msg);
	    	alert("저장 실패");
        }
	    jQuery("#btnSearch").click();
	}

	function setGridSize() {
		sheet1.FitColWidth();
	}

	function sheet1_OnPopupClick(Row, Col) {
		//행을 클릭했을 때 다른 페이지로 이동하도록 처리
	      var sName = sheet1.ColSaveName(Col);
	      var sScreen = sheet1.GetCellValue(Row,Col);
	      var url = "<%=url%>";
	      
	      if(sName == "SCREEN_NAME")
	      {
	 	      var sUrl = url + sScreen;
		      window.open(sUrl);
	     }
	}
	
	function sheet1_OnSmartResize(Width, Height) { 
		sheet1.FitColWidth();
		autoResize();
	}

	function autoResize(){
		var t1_height = document.getElementById("search-table").scrollHeight + document.getElementById("title").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" id="fevent" value="">
<INPUT type="hidden" name="sort_gb_value" id="sort_gb_value" value="">

<div align="left" id="title">
    <ul>
     <li>프로그램 관리</li>
    </ul>
  </div> 
	<!-- 검색조건 시작 -->
	<table id="search-table" class="search-form-table">
		<colgroup>
			<col width="100" />
			<col width="400" />
			<col width="100" />
			<col width="*" />
			<col width="250" />
		</colgroup>
		<tr>
			<th>시스템</th>
			<td>
		   		<%=systemSelectTag%> 				
			</td>
			<th>프로그램</th>
			<td>
				<input type='text' name="pgm_name2" class="input" style="width:90%">
			</td>
			<td class="button" rowspan="2">
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnSearch">검색</a></span>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnClear">초기화</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>
		<tr>
			<th>Screen</th>
			<td>
				<input type='text' name="screen_name2" class="input" style="width:94%">
			</td>
			<th>정렬</th>
			<td>
				<LABEL for="sort_gb_1"><INPUT id="sort_gb_1" type="radio" name="sort_gb" value="PGM_ID" checked>등록순</LABEL>
				<LABEL for="sort_gb_2"><INPUT id="sort_gb_2" type="radio" name="sort_gb" value="PGM_NAME">프로그램명</LABEL>
				<LABEL for="sort_gb_3"><INPUT id="sort_gb_3" type="radio" name="sort_gb" value="SCREEN_NAME">SCREEN</LABEL>
			</td>
		</tr>
	</table>
	<!-- 검색조건 종료 -->
	
<div id="sheet1_div" style="padding-top:5px; height: auto; min-height: 350px; overflow: auto;">
	<script>createIBSheet('sheet1','100%', '350px');</script>
</div>
</FORM>
