<%--
  - FileName   : dlgSearchAccDept.jsp
  - Author(s)  : gyeongmo an
  - Date       : 2014.06.22
  - Description: 부서 검색
  --%>
<%@ 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();
%>

<SCRIPT language="JavaScript">
var sheet1;
var sheet1Row;
var sheet1PageNo = 1;
var pageLastRowIndex = 1;
var validationResult = false;
var filterShow = false;

// 마지막으로 선택된 행의 번호를 기억하고 있음
var CurMasterRow = 0;
	
    function _onReady(){
		gridInit(sheet1);

		autoResize();
		
		jQuery("#btnSearch").click(function() {
        	jQuery("#fevent").val("GET_DEPT_LIST");
        	jQuery("#deadflg").val(jQuery(':radio[name="r_deadflg"]:checked').val());
        	
        	var url = Modular.model.PageContext.CONTEXT_ROOT + "/lib/dlgSearchAccDept_sheet.screen";
        	Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
            
            //마지막으로 선택된 행이 없음
              CurMasterRow= 0;
		});
		
		jQuery("#btnClose").click(function() {
			setTimeout(function(){parent.searchAccDeptClose(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:"DEPT_HR_CD",		Width:100, 	Align:"Left", Edit:"false"},
			    			{Header:'부서명',	Type:"Text",	SaveName:"DEPT_NM",		Width:150, 	Align:"Left", Edit:"false"},
		];

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

    function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
    
    function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
    	returnValue = new Array(sheet1.GetCellValue(Row, 0),sheet1.GetCellValue(Row, 1));
    	setTimeout(function(){parent.searchAccDeptClose(returnValue);},100);
    	
    }
    
    function sheet1_OnSmartResize(Width, Height) { 
		sheet1.FitColWidth();
		autoResize();
	}
    
   /**
    *  enter click 시 자동으로 검색이되도록 조
    */ 
	function check_Enter(){
		if (event.keyCode==13) 
			jQuery("#btnSearch").click();
	}
   
   function doSearch(){
	   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;   

		sheet1.SetSheetHeight(iframeHeight); 
	}
    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="deadflg" id="deadflg" value="">
 
<!-- 검색조건 시작 -->
	<table id="search-table" class="search-form-table">
		<colgroup>
			<col width="150" />
			<col width="250" />
			<col width="*" />
		</colgroup>
		<tr>
			<th>부서명</th>
			<td>
				<input type="text" id="deptNm" name="deptNm" value="" style="width:96%;" class="input" onKeyDown="check_Enter();"/>
			</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="btnClose">닫기</a></span>
			</td>
		</tr>
		<tr>
			<th>사용구분</th>
			<td>
				<LABEL for="deadflg_0"><INPUT id="deadflg_0" type="radio" name="r_deadflg" value="" onClick="doSearch();">전체</LABEL>
                <LABEL for="deadflg_1"><INPUT id="deadflg_1" type="radio" name="r_deadflg" value="Y" onClick="doSearch();" checked>사용</LABEL>
                <LABEL for="deadflg_2"><INPUT id="deadflg_2" type="radio" name="r_deadflg" value="N" onClick="doSearch();">미사용</LABEL>
			</td>
		</tr>
	</table>
	<!-- 검색조건 종료 -->
	<div id="sheet1_div" style="padding-top:5px; height: auto; min-height: 330px; overflow: auto;">
		<script>createIBSheet('sheet1','100%', '330px');</script>
	</div>
</form>
<!-- </BODY> -->