<%--
  - FileName   : ChargeList.jsp
  - Author(s)  : Sung Min Lee
  - Date       : 2014.06.24
  -
  - 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 fevent = storage.getEvent();
   
%>
<script type="text/javascript">
<!--

	/*예약함수*/
	var sheet1 = new ibsheetObject();
	var sheet1Row;
	var sheet1PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;
	
	$(document).ready(function(){
	    
		gridInit(sheet1);
	    
	    search();
	    
	    autoResize();
	    
	});
	
	
	function gridInit(sheetName){
		
	    var init_sheet = {};
		init_sheet.Cfg = {SearchMode:0, MergeSheet:msHeaderOnly};
		
		init_sheet.Cols = [
									{Header:'Status',					Type:"Status", 			SaveName:"STATUS", 						Width:0, 	 Align:"Center", Hidden:"True"},
									{Header:"삭제",					Type:"DelCheck", 			SaveName:"DEL_CHK", 						Width:50, 	 Align:"Center"},
									{Header:"ID",	 					Type:"Text", 				SaveName:"USER_ID",	 					Width:100, 	 Align:"Center", Edit:"False"},
									{Header:"☞담당자명",	 		Type:"Text", 				SaveName:"USER_NAME",	 				Width:100,	 Align:"Center", Edit:"False"},
									{Header:"비밀번호",	 			Type:"Text", 				SaveName:"PASSWD",						Width:100, 	 Align:"Center", Hidden:"True"},
									{Header:"부서명",	 				Type:"Text", 				SaveName:"DIVISION",						Width:100, 	 Align:"Center", Edit:"False"},
									{Header:"직위",	 				Type:"Text", 				SaveName:"POSITION",						Width:100, 	 Align:"Center", Edit:"False"},
									{Header:"이메일",	 				Type:"Text", 				SaveName:"EMAIL",							Width:100, 	 Align:"Center", Edit:"False"},
									{Header:"전화번호",	 			Type:"Text", 				SaveName:"TEL_NUM",						Width:100, 	 Align:"Center", Edit:"False"},
									{Header:"FAX번호",	 			Type:"Text", 				SaveName:"FAX_NUM",						Width:100, 	 Align:"Center", Edit:"False"},
									{Header:"휴대전화",	 			Type:"Text", 				SaveName:"H_PHON",						Width:100, 	 Align:"Center", Edit:"False"},
									{Header:"사용여부",	 			Type:"Combo", 			SaveName:"USE_YN",						Width:100, 	 Align:"Center", ComboText:"사용|미사용", ComboCode:"Y|N", Edit:"False"},
									{Header:"사용자관리구분",	 	Type:"Text", 				SaveName:"DEFAULT_YN",					Width:100, 	 Align:"Center", Edit:"False"},
									{Header:"사용자관리코드",	 	Type:"Text", 				SaveName:"DEFAULT_YN_CODE",			Width:100, 	 Align:"Center", Edit:"False", Hidden:"True"},
									{Header:"CORP_ID",	 			Type:"Text", 				SaveName:"CORP_ID",						Width:100, 	 Align:"Center" , Hidden:"True", Edit:"False"}
		                   		];
		
		
		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheet1, init_sheet);
		sheet1.SetDataAutoTrim(0);
// 		sheet1.SetEditable(false);
		sheetName.SetDataLinkMouse("USER_NAME", 1);
		sheetName.SetColFontColor("USER_NAME", "#0000ff");
		
		sheet1.FitColWidth();
	}
	
	
	
	
	function sheet1_OnSmartResize(Width, Height) { 
		sheet1.FitColWidth();
		autoResize();
		
	}

	function autoResize(){
		var t1_height = document.getElementById("search-table").scrollHeight + document.getElementById("title").scrollHeight + 24;
		var iframeHeight= document.body.scrollHeight - t1_height;   
		var iframeWidth= document.body.scrollWidth;   
		
		
		sheet1.SetSheetHeight(iframeHeight); 
	}	
	
	
	function sheet1_OnDblClick(Row, Col)
	{
	    var s_name = sheet1.ColSaveName(Col);
	    
	    if(s_name == "USER_NAME")
        {
	        $("#fevent").val("GET_DETAIL");
	        $("#p_user_id").val(sheet1.GetCellValue(Row, "USER_ID"));
	        $("#p_corp_id").val(sheet1.GetCellValue(Row, "CORP_ID"));
	        
	        $("#form1").attr("action", "/portal/own/ChargeDetail.screen");
			$("#form1").attr("target", "_self");
			$("#form1").attr("method", "post");
			$("#form1").submit();
        }
	}
	
	function sheet1_OnSearchEnd(Row, Col)
	{
	    var s_name = sheet1.ColSaveName(Col);
	    
	    for(i=1; i <= sheet1.LastRow(); i++)
        {
	        if(sheet1.GetCellValue(i, "DEFAULT_YN_CODE") == "Y")
            {
	            sheet1.SetCellEditable(i, "DEL_CHK", false);
            }
        }
	}
	
	
	function sheet1_OnSaveEnd(code, msg)
	{
		var event = $("#fevent").val();
		var f = document.form1;
		
		document.form1.isSubmit = false;
		
		if(event == "DELETE_DATA")
		{
		    if(code >= "0")
			{
				alert("삭제되었습니다.");
				$("#btn_search").click();
			}
			else
			{
				alert("삭제에 실패하였습니다. 관리자에게 문의하시기 바랍니다.");
			}
		}
	}
	
	
	function search()
	{
	    $("#fevent").val("GET_CHARGE_LIST");
		
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/own/ChargeList_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, $("#form1"), 30, "");
	}
	
	
	
	
	$(function(){
	    
	    $(document).on("keyup", "input[type=text]", function(key){
	        if(key.keyCode == "13")
            {
	            search();
            }
	     });
	    
	    
		$("#btn_search").click(function(){
	        
			
	        $("#fevent").val("GET_CHARGE_LIST");
			
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/own/ChargeList_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, $("#form1"), 30, "");
	    });
		
		
		$("#btn_reg").click(function(){
		    
		    $("#fevent").val("GET_DETAIL");
		    
		    
		    $("#form1").attr("action", "/portal/own/ChargeDetail.screen");
			$("#form1").attr("target", "_self");
			$("#form1").attr("method", "post");
			$("#form1").submit();
		    
		});
		
		
		$("#btn_delete").click(function(){
		    
		    $("#fevent").val("DELETE_DATA");                
		    
		    if(confirm("담당자를 삭제 하시겠습니까?"))
	        {
		        var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/own/ChargeList_sheet.screen";
				var result = Modular.view.IBSheet7.doSave(sheet1, url, $("#form1"), false);
	        }
		});
		
		
	});
	
	
	
	
//-->
</script>


<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<form id="form1" name="form1" method="post" modular:type="search">
<INPUT type="hidden" name="fevent" id="fevent" value="">
<input type="hidden" name="p_corp_id" id="p_corp_id" value="<%=user.get("corp_id") %>" />
<input type="hidden" name="p_user_id" id="p_user_id" value="" />

<div align="left" id="title">
	<ul>
		<li>담당자 관리</li>
	</ul>
</div> 	

<table id="search-table" border="0" cellspacing="0" cellpadding="0" width="100%" style="height: auto;">
	<!-- 검색조건 영역 : 시작 -->
	<tr>
		<td height="1">
			<table class="search-form-table">
				<colgroup>
				<col style="width:100px"/>
				<col/>
				<col style="width:100px"/>
				<col/>
				<col style="width:250px"/>
				</colgroup>
				
				<tr height="25"> 
    			<!-- 검색조건 타이틀 1 -->
    				<th>담당자명</th>
   					<td >
  						&nbsp;<input type="text" name="s_user_name" id="s_user_name" style="width: 85%;" value="<%=params.get("s_user_name")%>"/>
					</td>
    				<th>담당자 ID</th>
    				<td >
    					&nbsp;<input type="text" name="s_user_id" id="s_user_id" style="width: 85%;"  value="<%=params.get("s_user_id")%>"/>
    				</td>
    				<td class="button">
    					<span class="btnSearch center"><a href="javascript:void(0);" id="btn_search">검색</a></span>
    					<span class="btnSearch center"><a href="javascript:void(0);" id="btn_delete">삭제</a></span>
    					<span class="btnSearch center"><a href="javascript:void(0);" id="btn_reg">담당자 신규등록</a></span>
					</td>
  				</tr>
			</table>
		</td>
	</tr>
	<!-- 검색조건 영역 : 종료 -->

	<!-- 검색조건 영역, 테이터 영역 구분 여백 : 시작 -->
	<tr>
		<td height="1">
		</td>
	</tr>
</table>
<div style="width: 100%; height: 100%; margin-top: 5px;">
	<!-- 데이터 영역 : 시작 -->
	<!-- ibsheet7 그리드 생성 -->
		<script>createIBSheet("sheet1","100%", "300px");</script>
	<!-- 데이터 영역 : 종료 -->
</div>
</form>
		

	