<%--
  - FileName   : payItemCodePopup.jsp
  - Author(s)  : Kim Myung HO
  - Date       : 2014.08.14
  - Description: PAY ITEM 검색
  --%>
<%@ 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("SHEET_SELECT");
        	
        	jQuery("#p_condition").val(jQuery(':radio[name="condition"]:checked').val());
        	var url = Modular.model.PageContext.CONTEXT_ROOT + "/cont/outside/payItemCodePopup_sheet.screen";
        	Modular.view.IBSheet7.doSearch(sheet1, 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:'GROUP',	Type:"Text",	SaveName:"GR_ESTDESC",		Width:100, 	Align:"Left", Edit:"false"},
			    			{Header:'PAY ITEM',	Type:"Text",	SaveName:"PCODE",		Width:150, 	Align:"Left", Edit:"false"},
			       			{Header:'PAYITEM',	Type:"Text",	SaveName:"PAYITEM",		Width:100, 	Align:"center", Edit:"false",		Hidden:"True"},
			    			{Header:'COSTCODE',	Type:"Text",	SaveName:"COSTCODE",		Width:150, 	Align:"center", Edit:"false",		Hidden:"True"},
			       			{Header:'COSTTYPE',	Type:"Text",	SaveName:"COSTTYPE",		Width:100, 	Align:"center", Edit:"false",		Hidden:"True"},
			    			{Header:'PAY ITEM DESC',	Type:"Text",	SaveName:"ESTDESC",		Width:150, 	Align:"Left", Edit:"false"},
			    			{Header:'ESTAMT',	Type:"Text",	SaveName:"ESTAMT",		Width:150, 	Align:"Left", Edit:"false",		Hidden:"True"},
		];

		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, 2),sheet1.GetCellValue(Row, 3),sheet1.GetCellValue(Row, 4),sheet1.GetCellValue(Row, 5),sheet1.GetCellValue(Row, 6));
    	setTimeout(function(){parent.SearchPayItemClose(returnValue);},100);
    	
    }
    
    function sheet1_OnSmartResize(Width, Height) { 
		sheet1.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;   

		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="req" value="<%=params.get("req")%>" />
<INPUT	type="hidden" name="site"  value="<%=params.get("site")%>" />
<INPUT	type="hidden" name="p_condition"  value="0" />
<!-- 검색조건 시작 -->
	<table id="search-table" class="search-form-table">
		<colgroup>
			<col width="100" />
			<col width="*" />
			<col width="100" />
		</colgroup>
		<tr>
			<th>검색어</th>
			<td>
		   		<input type="text"   id="estdesc" name="estdesc" size="10" 	maxsize="10" style="width:96%;" class="input" onKeyDown="check_Enter();" />		
			</td>
			<td class="button" rowspan="2">
				<span class="btnSearch center" id="btnSearch"><a href="javascript:void(0);">검색</a></span>
				<span class="btnSearch center" id="btnClose"><a href="javascript:void(0);">닫기</a></span>
			</td>
		</tr>
		<tr>
			<th>구분</th>
			<td>
         		<SELECT name="costtype" size="1" style="width:100px;">
         		<%
         		if(params.get("gb").equals("SUB")){
         		%>
                   <OPTION value='S'>외주</OPTION>
                   <OPTION value='O'>경비</OPTION>
                <%}else if(params.get("gb").equals("PUR")){  %>
                   <OPTION value='M' selected >자재</OPTION>
                   <OPTION value='E'>장비</OPTION>
                <%}else if(params.get("gb").equals("LAB")){  %>
                   <OPTION value='O'>경비</OPTION>
                   <OPTION value='L'>노무</OPTION>
                <%
                }
                %>
            	</SELECT>
                <LABEL for="cond_1"><INPUT id="cond_1" type="radio" name="condition" value="0" checked >PAY ITEM DESC</LABEL>
              	<LABEL for="cond_2"><INPUT id="cond_2" type="radio" name="condition" value="1" >PAY ITEM</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> -->