<%--
  - FileName   : dlgSearchUser.jsp
  - Author(s)  : gyeongmo an
  - Date       : 2014.06.18
  - Copyright  : Copyright (c) 2014 www.udapsoft.co.kr, Inc.
  -
  - Description: 
--%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="kr.co.udapsoft.common.code.*" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ include file="/jsp/work/taglib.jsp" %>
<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />

<%
    String event = request.getParameter("fevent");
%>
<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 f = document.form1;
        	if(f.user_sabun.value == "" && f.user_name.value == "") {
        		alert("이름 혹은 사번을 입력해 주세요.");
        		return;
        	} else {
        		jQuery("#fevent").val("GET_USER_LIST");
    			var url = Modular.model.PageContext.CONTEXT_ROOT + "/sycs/user/dlgSearchUser_sheet.screen";
    			Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
        	}
        	
		});
	
		jQuery("#btnClose").click(function() {
			setTimeout(function(){parent.searchInsaUserClose(null);},100);
		}); 
    }
	
	function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:30};
		init_sheet.Cols = [
			       			{Header:'번호',			Type:"Seq",			SaveName:"NO", 		Width:30, 	Align:"Center", Edit:"false"},
			    			{Header:'상태',		Type:"Status",		SaveName:"STATUS",				Width:80, 	Align:"Center", Hidden:"True"},
			    			{Header:'사원번호',		Type:"Text",		SaveName:"user_sabun", 			Width:80, 	Align:"Center", Edit:"false"},
			    			{Header:'이름',			Type:"Text", 		SaveName:"user_name", 	Width:80,  	Align:"Center", Edit:"false" },
			    			{Header:'현장코드',		Type:"Text", 		SaveName:"site_cd", 		Width:0, 	Align:"Center", Hidden:"True"},    
			    			{Header:'현장',			Type:"Text", 		SaveName:"site_name", 		Width:110, 	Align:"Left", Edit:"false"  },
			    			{Header:'직위코드',	Type:"Text",	 	SaveName:"position_code", 			Width:0, 	Align:"Center", Hidden:"True"  },
			    			{Header:'직위',		Type:"Text", 		SaveName:"position_name", 			Width:80, 	Align:"Center", Edit:"false"  },
			    			{Header:'전화번호',		Type:"Text", 		SaveName:"tel_no", 		Width:0, 	Align:"Center", Hidden:"True"  },
			    			{Header:'휴대폰번호',	Type:"Text", 		SaveName:"hand_tel_no", 			Width:0, 	Align:"Center", Hidden:"True"},
			    			{Header:'주민번호',		Type:"Text", 		SaveName:"jumin", 		Width:0, 	Align:"Center", Hidden:"True"},
			    			{Header:'계정ID',		Type:"Text", 		SaveName:"acct_id", 		Width:0, 	Align:"Center", Hidden:"True"},
			    			{Header:'근무구분',		Type:"Text", 		SaveName:"cutyc", 		Width:0, 	Align:"Center", Hidden:"True"},
			    			{Header:'현장약어',		Type:"Text", 		SaveName:"dept_ini", 		Width:0, 	Align:"Center", Hidden:"True"},
			    			{Header:'체크여부',		Type:"Text", 		SaveName:"ischeck", 		Width:0, 	Align:"Center", Hidden:"True"},
			    			{Header:'E-mail',		Type:"Text", 		SaveName:"email", 		Width:0, 	Align:"Center", Hidden:"True"},
			    			{Header:'부서코드',		Type:"Text", 		SaveName:"dept_code", 		Width:0, 	Align:"Center", Hidden:"True"},
			    			{Header:'부서',		Type:"Text", 		SaveName:"dept_name", 		Width:0, 	Align:"Center", 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 doKeyPress() {
	    if( event.keyCode == 13 ) {
	    	jQuery("#btnSearch").click();
	    }
	}

	 function sheet1_OnClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		 var isExist = sheet1.GetCellValue(Row,14);
		
		 if (isExist == 0){
			var user_sabun, user_name, site_cd, site_nm, position_code, position_name, tel_no, hand_tel_no, email, acc_id, dept_code, dept_name;
	  		user_sabun	= sheet1.GetCellValue(Row, "user_sabun");
	  		user_name	= sheet1.GetCellValue(Row, "user_name");
	  		
	  		site_cd  = sheet1.GetCellValue(Row, "site_cd");
	  		site_nm  = sheet1.GetCellValue(Row, "site_name");
	  		
	  		position_code = sheet1.GetCellValue(Row, "position_code");
	  		position_name = sheet1.GetCellValue(Row, "position_name");
	  		
	  		tel_no  	 = sheet1.GetCellValue(Row, "tel_no");
	  		hand_tel_no  = sheet1.GetCellValue(Row, "hand_tel_no");
	  		email 		 = sheet1.GetCellValue(Row, "email");
	  		acc_id 		 = sheet1.GetCellValue(Row, "acct_id");
	  		
	  		dept_code = sheet1.GetCellValue(Row, "dept_code");
	  		dept_name = sheet1.GetCellValue(Row, "dept_name");
	  		
	  		returnValue = new Array(user_sabun, user_name, site_cd, site_nm, position_code, position_name, tel_no, hand_tel_no, email, acc_id, dept_code, dept_name);
	  		
	  		setTimeout(function(){parent.searchInsaUserClose(returnValue);},100);
	  	}else{
	  		alert("이미 등록된 유저 입니다.");  			
	  	}  	
	 }
	
	 function sheet1_OnSmartResize(Width, Height) { 
			sheet1.FitColWidth();
			autoResize();
			
		}

		function autoResize(){
			var t1_height = document.getElementById("search-table").scrollHeight + 10;
			var iframeHeight= document.body.scrollHeight - t1_height;   
			sheet1.SetSheetHeight(iframeHeight); 
		}	
		
	 document.body.onresize = addEvent( document.body.onresize, "setGridSize()");
</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="acct_id" value="">

<!-- 검색조건 시작 -->
	<table id="search-table" class="search-form-table">
		<colgroup>
			<col width="100" />
			<col width="250" />
			<col width="100" />
			<col width="250" />
			<col width="200" />
		</colgroup>
		<tr>
			<th>이름</th>
			<td>
		   		<%= InputText.get("user_name", "", 70, 10, "ID,PerSize") %>
			</td>
			<th>사원번호</th>
			<td>
				<%= InputText.get("user_sabun", "", 70, 10, "ID,PerSize") %>
			</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: 450px; overflow: auto;">
		<script>createIBSheet('sheet1','100%', '450px');</script>
	</div>
</body>