<%--
  - FileName   : dlgSearchUserPop.jsp
  - Author(s)  : gyeongmo an
  - Date       : 2014-06-30
  - Copyright  : Copyright (c) 2014 www.udapsoft.co.kr, Inc.
  -
  - Description: 사용자 검색
  --%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="kr.co.udapsoft.common.code.*" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ 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" %>

<%@ 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 = null;
	user = ctx.getUser();
	ValueObject params = ctx.getParams();
	
	HandlerStorage storage = ctx.getHandlerStorage();
	String GB =   (String) storage.get("GB");
	String CODE =   (String) storage.get("CODE");
	String NAME =   (String) storage.get("NAME");
	String deptNameYn =   (String) storage.get("deptNameYn");
	if("purchase".equals(deptNameYn)){
		deptNameYn = "구매팀";
	}else if("outside".equals(deptNameYn)){
		deptNameYn = "외주팀";
	}else{
		deptNameYn = "";
	}
	request.setCharacterEncoding("utf-8");
%>
<SCRIPT language="JavaScript">
/*예약함수*/
var sheet1;
var sheet1Row;
var sheet1PageNo = 1;
var pageLastRowIndex = 1;
var validationResult = false;
var filterShow = false;

var argObj = window.dialogArguments;

function _onReady(){
	gridInit(sheet1);
	
	jQuery("#btnSearch").click(function() {
		jQuery("#fevent").val("SearchUserPop");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "dlgSearchUserPop_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
	});
	
	jQuery("#btnClose").click(function() {
		setTimeout(function(){parent.SearchUserClose(null);},100);
	});
	
	//jQuery("#btnSearch").click();
}


function gridInit(sheetName){
	var init_sheet = {};
	init_sheet.Cfg = {SearchMode:2, Page:30};
	init_sheet.Cols = [

	                  {Header:'계정ID',				Type:"Text",		SaveName:"ACCT_ID", 		Width:0, 	Align:"Center",	Hidden:"True"},
	    			{Header:'사번',			Type:"Text", 			SaveName:"USER_SABUN", 			Width:30, 	Align:"Center"},
	    			{Header:'권한구분',			Type:"Text", 			SaveName:"RIGHT_GB", 		Width:0, 	Align:"Left",	Hidden:"True"},
	    			{Header:'담당업무',		Type:"Text",	 		SaveName:"JOB_DSCR", 		Width:0, 	Align:"Left",	Hidden:"True"},
	    			{Header:'ACCT_TYPE_ID',		Type:"Text", 			SaveName:"ACCT_TYPE_ID", 		Width:0, 	Align:"Left",	Hidden:"True"},
	    			{Header:'퇴사일자',			Type:"Text", 			SaveName:"INACTIVE_DATE", 		Width:0, 	Align:"Left",	Hidden:"True"},
	    			{Header:'이름',		Type:"Text", 			SaveName:"USER_NAME", 		Width:20, 	Align:"Center"},
	    			{Header:'직책코드',			Type:"Text", 			SaveName:"POSITION_CODE", 			Width:0, 	Align:"Center",	Hidden:"True"},
	    			{Header:'직책명',		Type:"Text", 			SaveName:"POSITION_NAME", 	Width:0, 	Align:"Left",	Hidden:"True"},
	    			{Header:'부서코드',			Type:"Text", 			SaveName:"BUSEO", 			Width:30, 	Align:"Center", Hidden:"True"},
	    			{Header:'부서명',			Type:"Text", 			SaveName:"BUSEO_NAME", 			Width:40, 	Align:"Left"},
	    			{Header:'겸직현장1',		Type:"Text", 			SaveName:"DSO1", 		Width:0, 	Align:"Left",	Hidden:"True"},
	    			{Header:'겸직현장2',			Type:"Text", 			SaveName:"DSO2", 		Width:0, 	Align:"Left", Hidden:"True"},
	    			{Header:'현장',			Type:"Text", 			SaveName:"PSOSO", 		Width:0, 	Align:"Left", Hidden:"True"},
	    			{Header:'근무구분',			Type:"Text", 			SaveName:"DUTYC", 		Width:0, 	Align:"Left", Hidden:"True"},
	    			{Header:'직위코드',			Type:"Text", 			SaveName:"GRADE_CODE", 		Width:0, 	Align:"Left", Hidden:"True"},
	    			{Header:'직위명',			Type:"Text", 			SaveName:"GRADE_NAME", 		Width:20, 	Align:"Center"},
	    			{Header:'전화번호',				Type:"Text", 			SaveName:"TEL_NO",				Width:30, 	Align:"Center"},
	    			{Header:'휴대폰번호',		Type:"Text", 			SaveName:"HAND_TEL_NO", 		Width:30,	Align:"Center"},
	    			{Header:'이메일주소',			Type:"Text", 			SaveName:"E_MAIL", 		Width:40, 	Align:"Left"}
	];

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

function autoResize(){
	var t1_height = document.getElementById("search-table").scrollHeight + 10;
	var iframeHeight= document.body.scrollHeight - t1_height;   
	
	var iframeWidth = document.body.scrollWidth;
	sheet1.SetSheetHeight(iframeHeight); 
	//sheet1.SetSheetWidth(iframeWidth);
}	

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

function sheet1_OnSearchEnd(code, message) {
    if(code == 0) {
    	setGridSize();
	} else {
		//조회 에러 수행
		//alert(message);
		alert("조회 실패");
	}
}

	function prcKeyPress()
	{
  	  	if( event.keyCode == 13 )
  	  	{
  	  		jQuery("#btnSearch").click();
		}
	}
	
	//키처리
	document.onkeydown = function(){
		//F5 새로고침
		if(event.keyCode == "13"){
			jQuery("#btnSearch").click();
		}
		//ESC 창닫기
		if(event.keyCode == "27"){
    		window.close();
		} 
	}
   
	function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		if(Row == 0)return;
		var retArray = new Array();

		if("<%=CODE%>".length > 0){
			parent.$("#"+"<%=CODE%>").val(sheet1.GetCellValue(Row, "ACCT_ID"));
			parent.$("#"+"<%=NAME%>").val(sheet1.GetCellValue(Row, "USER_NAME"));
		}else{
			retArray[0] = sheet1.GetCellValue(Row, "USER_SABUN");	// 사번
			retArray[1] = sheet1.GetCellValue(Row, "USER_NAME");	// 이름
			retArray[2] = sheet1.GetCellValue(Row, "BUSEO");	// 부서코드
			retArray[3] = sheet1.GetCellValue(Row, "BUSEO_NAME");	// 부서
			retArray[4] = sheet1.GetCellValue(Row, "GRADE_CODE");	// 직위코드
			retArray[5] = sheet1.GetCellValue(Row, "GRADE_NAME");	// 직위
			retArray[6] = sheet1.GetCellValue(Row, "TEL_NO");	// 일반전화
			retArray[7] = sheet1.GetCellValue(Row, "HAND_TEL_NO");	// 휴대폰번호
			retArray[8] = sheet1.GetCellValue(Row, "E_MAIL");	// 이메일
			retArray[9] = sheet1.GetCellValue(Row, "ACCT_ID");	// ACCT_ID
			retArray[10] = "<%=GB%>";	// 입력구분
		}
		
		setTimeout(function(){parent.SearchUserClose(retArray);},100);
	}

</SCRIPT>
<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<BODY onresize="autoResize()" >
<form id="form1" name="form1" method="post" modular:type="search" style="width:100%;height:100%;">
<INPUT type="hidden" name="fevent" id="fevent" value="">
<!-- 검색조건 시작 -->
	<table id="search-table" class="search-form-table">
		<colgroup>
			<col width="100" />
			<col width="230" />
			<col width="100" />
			<col width="*" />
			<col width="150" />
		</colgroup>
		<tr>
			<th>부서명</th>
			<td>
				<%if(deptNameYn =="") { %>
			   		<%=InputText.get("S_DEPT_NAME", "", 30, 20, "hangule, required")%> 				
				<%} else { %>
			   		<%=InputText.get("S_DEPT_NAME", deptNameYn, 30, 20, "hangule, required, readOnly")%> 				
				<%} %>
			</td>
			<th>사용자명</th>
			<td>
				<%=InputText.get("S_NAME", "", 30, 20, "hangule, required")%>
			</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>
	</table>
	<!-- 검색조건 종료 -->
<div id="sheet1_div" style="padding-top:5px; height: auto; min-height: 350px; overflow: auto;">
	<script>createIBSheet('sheet1','100%', '350px');</script>
</div>

</FORM>
</body>
