<%--
  - FileName   : dlgCodePopup.jsp
  - Author(s)  : Kim Myung HO
  - Date       : 2014.10.02
  - Description: Sub 코드 검색
  --%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="kr.co.hsnc.common.sql.RowSet" %>
<%@ page import="kr.co.hsnc.common.util.ValueObject" %>
<%@ page import="com.udapsoft.waf.system.*" %>
<%@ page import="com.udapsoft.waf.common.*" %>
<%@ page import="kr.co.udapsoft.common.*" %>
<%@ page import="com.udapsoft.waf.common.ui.HTMLMaker" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>

<%@ include file="/jsp/work/taglib.jsp" %>

<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />
<%
    ctx.init(request, response);

    HandlerStorage storage = ctx.getHandlerStorage();
    ValueObject user       = ctx.getUser();
    ValueObject params     = storage.getParams();
    String event           = storage.getEvent();
    String search_yn       = params.get("p_search");
%>

<SCRIPT language="JavaScript">
var sheet2;
var sheet2Row;
var sheet2PageNo = 1;
var pageLastRowIndex = 1;
var validationResult = false;
var filterShow = false;

// 마지막으로 선택된 행의 번호를 기억하고 있음
var CurMasterRow = 0;
	
    function _onReady(){
		gridInit(sheet2);
		init_menu();
		autoResize();
		
		jQuery("#btnSearch").click(function() {
        	jQuery("#fevent").val("GET_STANDARDCODEDETAIL_LIST");
        	var url = Modular.model.PageContext.CONTEXT_ROOT + "/sycs/code/SYSInputStandardCodeListDetail_sheet.screen";
        	Modular.view.IBSheet7.doSearch(sheet2, url, jQuery("#form1"), 30, "");
            
            //마지막으로 선택된 행이 없음
              CurMasterRow= 0;
		});
		
		jQuery("#btnClose").click(function() {
			setTimeout(function(){parent.SearchPayItemClose(null);},100);
		});
		
		jQuery("#btnSearch").click();
		
	}
    
    function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:30};
		init_sheet.Cols = [
			    			{Header:'내역코드',		Type:"Text", 	SaveName:"DETAILCD", 	Width:80, 	Align:"Center", Edit:"false"},
			    			{Header:'내역코드명',		Type:"Text", 	SaveName:"DETAILNM", 	Width:200, 	Align:"Left", 	Edit:"false"},
			    			{Header:'기본코드',		Type:"Text", 	SaveName:"BASECD", 		Width:200, 	Align:"Left", 	Edit:"false" ,		Hidden:"True"}
		];

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

    function sheet2_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
    
    function sheet2_OnLoad(){
    	jQuery("#fevent").val("GET_STANDARDCODEDETAIL_LIST");
    	var url = Modular.model.PageContext.CONTEXT_ROOT + "/sycs/code/SYSInputStandardCodeListDetail_sheet.screen";
    	Modular.view.IBSheet7.doSearch(sheet2, url, jQuery("#form1"), 30, "");
    }

    function sheet2_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
    	returnValue = new Array(sheet2.GetCellValue(Row, 0),sheet2.GetCellValue(Row, 1),sheet2.GetCellValue(Row, 2));
    	setTimeout(function(){parent.SearchCodeDetailClose(returnValue);},100);
    	
    }
    
    function sheet2_OnSmartResize(Width, Height) { 
		sheet2.FitColWidth();
		autoResize();
	}
    
   /**
    *  enter click 시 자동으로 검색이되도록 조
    */ 
	function check_Enter(){
		if (event.keyCode==13) 
			jQuery("#btnSearch").click();
	}

	function autoResize(){
		var t1_height = document.getElementById("search-table").scrollHeight + document.getElementById("title_pop").scrollHeight + 20;
		var iframeHeight= document.body.scrollHeight - t1_height;   
		var iframeWidth= document.body.scrollWidth;   

		sheet2.SetSheetHeight(iframeHeight); 
	}
	
	function init_menu(){
		<%if(params.get("p_search").equals("Y") ){ %>
		
		<%}else{%> 
			document.getElementById("search-table").style.display = "none";
		<%}%>
	}
    document.onkeydown 		= closePopupWindow;
    
    document.body.onresize = addEvent( document.body.onresize, "autoResize()");
</SCRIPT>

<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<!-- <BODY onresize="autoResize()" > -->
<FORM id="form1" name="form1" method="post" modular:type="search">
<INPUT type="hidden" name="fevent" id="fevent" value="">
 <INPUT	type="hidden" name="p_basecd" value="<%=params.get("p_basecd")%>" />
 <INPUT	type="hidden" name="p_search" value="<%=params.get("p_search")%>" />
 <table id="search-table" class="search-form-table">
		<colgroup>	
			<col width="100" />
			<col width="250" />
			<col width="100" />
			<col width="130" />
			<col width="*" />
		</colgroup>
		<tr>
			<TH>코드명</TH>
			<td>
				<INPUT type="text" name="DETAILNM" class="input" value="<%=params.get("DETAILNM") %>" style="width:90%"> 
			</td>
			<TH>구분</TH>
			<TD> 
				<SELECT class='input_select' id='CHG_CODE01' name='CHG_CODE01' style='width:80px;' ><option value=''>--전체--</option><OPTION value='C'>토건</OPTION><OPTION value='P'>플랜트</OPTION>	</SELECT>
			</TD>
			<td class="button">
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnSearch">검색</a></span>
			</td>
		</tr>
	</table>
	<!-- 검색조건 종료 -->
	<div id="sheet2_div" style="padding-top:5px; height: auto; min-height: 330px; overflow: auto;">
		<script>createIBSheet('sheet2','100%', '330px');</script>
	</div>
</form>
<!-- </BODY> -->
