<%--
  - FileName   : UserList.jsp
  - Author(s)  : Joung Kyu Park
  - Date       : 2007.05.16
  - Copyright  : Copyright (c) 2002-2007 www.hwenc.com, 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.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ 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 params = storage.getParams();
    ValueObject user = storage.getUser();
    String event = storage.getEvent();
    //String deptCd   = user.get("site_code");
    //String deptName = user.get("site_name");
    //deptCd   = params.get("buseo");
    //RowSet rowSet = storage.getRowSet("ROWSET");
    //RowSet acctTypeRowSet = storage.getRowSet("AcctTypeRowSet"); //계정 타입
    //System.out.println("acctyType:"+acctTypeRowSet);
   
%>
<SCRIPT language="JavaScript">
	/*예약함수*/
	var sheet1;
	var sheet1Row;
	var sheet1PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;
	
	function _onReady(){
		/**
		 *	IBSheet object initialize
		 */
		gridInit(sheet1);
		
	
		/**
		 *	Application Initialize
		 */
		jQuery("#btnSearch").click(function() {
			
 			jQuery("#fevent").val("GET_LIST");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/sycs/info/NoticeForAdminList_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 10000, ""); 
			 
		});
		
/* 		jQuery("#btnAdd").click(function() {
			//var rowIdx = masterSheet.DataInsert(-1);
			
			jQuery("#fevent").val("UserForm_Reg");
			jQuery("#form1").attr("action", "/sycs/user/UserForm.screen");
			jQuery("#form1").attr("target", "_self");
			jQuery("#form1").attr("method", "post");
			jQuery("#form1").submit();			
			
		});
 */		jQuery("#btnAdd").click(function() {
			var rowIdx = sheet1.DataInsert(-1);
			
		});
		
		jQuery("#btnClear").click(function() {

/* 			var f = document.form1;
			f.dept_cd.value = "";
			f.dept_nm.value = "";
			f.p_dept_cd.value = "";
			f.p_dept_nm.value = "";
			setSelect(f.acct_type_id, "");
			f.user_sabun.value = "";
			f.user_name.value = "";
			f.user_name.focus(); */
			
			jQuery("#dept_cd").val("");
			jQuery("#dept_nm").val("");
			jQuery("#p_dept_cd").val("");
			jQuery("#p_dept_nm").val("");
			jQuery("#acct_type_id").val("");
			jQuery("#user_sabun").val("");
			jQuery("#user_name").val("");
			jQuery("#user_name").val("");
			
		});
		
		jQuery("#btnSave").click(function() {
			if (confirm("저장하시겠습니까?")) {
				jQuery("#fevent").val("SAVE_DATA");
				var url = Modular.model.PageContext.CONTEXT_ROOT + "/sycs/info/NoticeForAdminList_sheet.screen";
				var result = Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), false);
			}
		}); 
		
		pageinit();
		
	}
	
	function pageinit(){
		jQuery("#btnSearch").click();
	}
	
	/**
	 *	IBSheet object initialize
	 */
	function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:10000};
		init_sheet.Cols = [
		       			{Header:'Del',				Type:"DelCheck",		SaveName:"DEL_CHECK", 		Width:50, 	Align:"Center"},
		    			{Header:'Status',			Type:"Status", 			SaveName:"STATUS", 			Width:0, 	Align:"Center"},
		    			{Header:'No.',				Type:"Seq", 			SaveName:"NO",				Width:80, 	Align:"Center"},
		    			{Header:'Tel No.',			Type:"Text", 			SaveName:"tel_no", 			Width:100, 	Align:"Left"},
		    			{Header:'Mobile No.',		Type:"Text", 			SaveName:"hand_tel_no", 	Width:100, 	Align:"Left"},
		    			{Header:'E-mail',			Type:"Text", 			SaveName:"e_mail", 			Width:120, 	Align:"Left"},
		    			{Header:'Reg. Date',		Type:"Text", 			SaveName:"cre_date", 		Width:100, 	Align:"Center"},
		    			{Header:'acct_id',			Type:"Text", 			SaveName:"acct_id", 		Width:0, 	Align:"Left", Hidden:"True"}
		];

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

	
	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
	
	/**
	 *	IBSheet Event: Save End(IBSheet 데이터 저장 CallBack)
	 */
	function sheet1_OnSaveEnd(code, msg) {
	    if(code >= 0) {
	    	alert("저장 성공");
	    } else {
	    	alert(msg);
        }
	}
	
	/**
	 *	IBSheet Event: Click
	 */
	function sheet1_OnClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		 //masterSheetRow = Row;
	}
	
	/**
	 *	IBSheet size setting
	 */
	function setGridSize() {
		sheet1.FitColWidth();
	}
	
	/**
	 *	IBSheet Event: DBLCLICK
	 */
	 function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		 
		if (sheet1.ColSaveName(Col) == "user_name") {

			jQuery("#acct_id").val(sheet1.GetCellValue(Row, "acct_id"));
			jQuery("#fevent").val("GET_USERFORM_LIST");
			jQuery("#form1").attr("action", "/sycs/user/UserForm.screen");
			jQuery("#form1").attr("target", "_self");
			jQuery("#form1").attr("method", "post");
			jQuery("#form1").submit();
			
		}
		else if(sheet1.ColSaveName(Col) =="user_sabun"){
	        var user_sabun	= sheet1.GetCellValue(Row, "user_sabun");        
	        var user_pw	= sheet1.GetCellValue(Row, "user_pw");         
	    	f_gologin(user_sabun, user_pw );
		}
		else if(sheet1.ColSaveName(Col) =="e_mail"){
	    	if(!sheet1.CellValue(Row, "e_mail")==""){
	        	location.href = "mailto:" + sheet1.GetCellValue(Row,Col);
	        }
		    return;
		    	
		}
		else return;
		 
	 }

	
	//인사 정보 호출
	function getEhr(){
		if(dlgConfirm("Do you want EHR Data Sync?")){
			submitXmlRequest("/sycs/user/UserList_process.screen", "GET_EHR_DATA", document.form1);
		}
	}
	
	//자동로그인 기능
	function f_gologin(login_id,login_pw){
		var f = document.form1;
		if('<%= user.get("ACCT_TYPE_CODE")%>' != "ADMIN"){
			dlgAlert("User who logged in as administrator only can do automatic log-in.");
			return;
		}
	
		f.login_id.value = login_id;
		f.login_pw.value = login_pw;
	
		if( !submitXmlRequest("/sign_on_check", "", document.form1) ) {
			alert("Log-in is being processed.");
		};
	
	}

	function doResult(resultObj) {
		try {
			if( resultObj.getRequestEvent() == "" ) {
				if( resultObj.getSuccess() ) {				
					var f = document.form1;   				  				
					f.action = "/main.screen";				
	    			f.target = "_parent";             			
	    			f.submit();			
				}
				else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
			}else if( resultObj.getRequestEvent() == "GET_EHR_DATA" ) {
				if( resultObj.getSuccess() ) {
					alert("EHR Synchronize Complete");
					doSearch(document.all.sheet1);
				}
				else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
			}
		}
		catch(errorObject) {
	        showErrorDlg("doResult()", errorObject);
		}
	}


	function searchAccDept(p_dept_cd, p_dept_nm){
		
		result = window.showModalDialog(getDummyUrl('/lib/dlgSearchAccDept.screen'),'부서 찾기','dialogWidth:620px;dialogHeight:460px; center:yes; help:no; status:no; scroll:no; resizable:no');
		
		if( result == null ){
			document.form1.p_dept_cd.value = "";   //부서코드
			document.form1.p_dept_nm.value = "";   //부서명

		}else{
			document.form1.p_dept_cd.value = result[0];   //부서코드
			document.form1.p_dept_nm.value = result[1];   //부서명
		}

	}

	function doKeyPress() {
	
	    if( event.keyCode == 13 ) {
			doSearch(document.all.sheet1)
	    }
	}	

</SCRIPT>


<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<form id="form1" name="form1" method="post" modular:type="search">
<TABLE border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
<INPUT type="hidden" name="fevent" id="fevent" value="">
<INPUT type="hidden" name="formdata1" id="formdata1" value="formdata1Test">
	<TR height="1">
		<TD>
			<TABLE class="screen_title_table" border="0">
				<TR height="2">
					<TD colspan="2"></TD>
				</TR>
				<TR height="25">
	   				<TD width="16" valign="middle"><IMG src="/img/buyer/template/bullet_03.gif" ></TD>
   					<TD width="100%" class="screen_title_text">Notice List</TD>
 				</TR>
			</TABLE>
		</TD>
	</TR>

	<!-- 검색조건 영역 : 시작 -->
	<TR>
		<TD height="1">
			<TABLE cellspacing="1" cellpadding="0" class="search_table" border="0" width="100%" height="100%">
				<TR height="25"> 
   				<!-- 검색조건 타이틀 1 -->
					<TD width="10%" class="search_table_title"><img src="/img/buyer/button/bullet_01.gif" align="middle">Dept</TD>
					<TD width="30%" class="search_table_data">&nbsp;
						<%= InputText.get("p_dept_cd", params.get("p_dept_cd"), 30, 10, "ID,ReadOnly,PerSize") %>
						<%-- <%= InputText.get("p_dept_nm", DeptCodeManager.getDeptName(params.get("p_dept_cd")), 52, 30, "ID,PerSize") %> --%>
		  				<IMG onclick="searchAccDept(document.form1.p_dept_cd, document.form1.p_dept_nm)" src="/img/buyer/button/bt_search_right.gif" alt="부서찾기" border="0" align="absmiddle" style="cursor:hand;"> 
					</TD>

   					<TD width="8%" class="search_table_title"><img src="/img/buyer/button/bullet_01.gif" align="middle">Account Type</TD>
   					<TD witdh="5%" class="search_table_data"><%-- &nbsp;&nbsp;<%= HTMLMaker.getSelectTag(acctTypeRowSet, "ACCT_TYPE_ID", "ACCT_TYPE_NAME", "acct_type_id", "width:70%;height=18;", "<option value=''>--선택--</option>", "") %> --%></TD>

   					<TD width="8%" class="search_table_title"><img src="/img/buyer/button/bullet_01.gif" align="middle">Emp. No.</TD>
   					<TD width="10%" class="search_table_data">&nbsp;<%-- <%= InputText.get("user_sabun", "", 80, 50, "hangule, desc=사번, PerSize") %> --%></TD>
    					
   					<TD width="20%" rowspan="3" class="search_button">      
       					<!-- 검색버튼 영역 : 시작 -->
           				<TABLE border="0" cellpadding="0" cellspacing="0" align="center">
           					<TR>
				                <TD>
				                	<DIV id="btnSearch" class="button_style">
				                    	<TABLE border="0" cellpadding="0" cellspacing="0">
				                      		<TR> 
				                        		<TD class="button_left1"></TD>
				                        		<TD class="button_text1">Search&nbsp;</TD>
				                        		<TD class="button_right"></TD>
				                      		</TR>
				                    	</TABLE>
				                  	</DIV>
				                </TD>
				                <!-- 버튼 구분 여백 : 시작 -->                
               					<TD width="5"></TD>
               					<!-- 버튼 구분 여백 : 종료 -->
				                <TD>
               						<DIV id="btnSave" class="button_style">
                   						<TABLE border="0" cellpadding="0" cellspacing="0">
                   							<TR> 
					                        	<TD class="button_left1"></TD>
					                        	<TD class="button_text1">Save&nbsp;</TD>
					                        	<TD class="button_right"></TD>
                   							</TR>
                   						</TABLE>
               						</DIV>
               					</TD>
		                		<!-- 버튼 구분 여백 : 시작 -->                
               					<TD width="5"></TD>
               					<!-- 버튼 구분 여백 : 종료 -->
				                <TD>
               						<DIV id="btnAdd" class="button_style">
                   						<TABLE border="0" cellpadding="0" cellspacing="0">
                   							<TR> 
                       							<TD class="button_left1"></TD>
						                        <TD class="button_text1">Add&nbsp;</TD>
						                        <TD class="button_right"></TD>
                   							</TR>
                 						</TABLE>
               						</DIV>
				                </TD>
           					</TR>
           				</TABLE>     
           				<!-- 검색버튼 영역 : 종료 -->  
    				</TD>
  				</TR>
				<TR height="25"> 
    			<!-- 검색조건 타이틀 1 -->
    				<TD width="8%" class="search_table_title"><img src="/img/buyer/button/bullet_01.gif" align="middle">Site</TD>
    				<TD witdh="15%" class="search_table_data">&nbsp;
    					<INPUT type="text" name="dept_cd" class="input" value="" readOnly style="width:30%;background-color: #dedede;" > 
       					<INPUT type="text" name="dept_nm" class="input" value="" style="width:52%"> 
       					<IMG onclick="dlgSearchSpotDept(document.form1.dept_cd, document.form1.dept_nm);" src="/img/buyer/button/bt_search_right.gif" alt="현장찾기" border="0" align="absmiddle" style="cursor:hand;">
    				</TD>
				    <TD width="8%" class="search_table_title"><img src="/img/buyer/button/bullet_01.gif" align="middle">Name</TD>
    				<TD witdh="5%" class="search_table_data" colspan="3">&nbsp;
    					<%//= InputText.get("user_name", "", 60, 50, "hangule, desc=성명, PerSize") %>  
     					<INPUT type="text" name="user_name" value="<%=params.get("user_name") %>" maxlength="50" class="input" style="IME-MODE : active;width:30%;"   desc='성명' onKeyPress="doKeyPress();">  
      				</TD>
				</TR>
			</TABLE>
		</TD>
	</TR>
	<!-- 검색조건 영역 : 종료 -->
	<!-- 검색조건 영역, 테이터 영역 구분 여백 : 시작 -->
	<TR height="1">
		<TD>
			<TABLE border="0" cellspacing="0" cellpadding="0" class="search_data_div_height">
				<TR>
					<TD></TD>
				</TR>
			</TABLE>
		</TD>
	</TR>
	<!-- 검색조건 영역, 테이터 영역 구분 여백 : 종료 -->
	<!-- 데이터 영역 : 시작 -->
	<TR>
		<TD id="sheet1_td" >
			<!-- IBSheet7 그리드 생성 -->
			<script>createIBSheet('sheet1','100%', '100%');</script>
		</TD>
	</TR>
	<!-- 데이터 영역 : 종료 -->
</TABLE>
</FORM>