<%--
  - kName   : SuppReferenceList.jsp
  - Author(s)  : gyeongmo an
  - Date       : 2014.07.18
  - 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.*" %>
<%@ 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();
    
    //레이어로 띄웠는지 체크
    String layerYn = params.get("layerYn");
    String tempWidth = "";
    if(layerYn.equals("Y")) {
    	tempWidth="770px";
    } else {
    	tempWidth="100%";
    }
    
    String pop_win_id = "";
    if(!"".equals(params.get("pop_win_id"))) {
    	pop_win_id = params.get("pop_win_id");
    }
    
%>
<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() {
			jQuery("#fevent").val("GET_SUPP_REFERENCE_LIST");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/supplier/portal/center/SuppReferenceList_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 10, "");
		});
		
		jQuery("#btnClose").click(function() {
			setTimeout(function(){parent.searchReferenceClose();},100);
		});

		autoResize();
		
		jQuery("#btnSearch").click();
	}
	
	function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:10};
		init_sheet.Cols = [
		       			{Header:'번호',				Type:"Text",		SaveName:"bunho", 		Width:15, 	Align:"Center"},
		       			{Header:'번호',				Type:"Text",		SaveName:"seq", 		Width:15, 	Align:"Center", Hidden:"True"},
		    			{Header:'일자',			Type:"Date", 			SaveName:"noti_dy", 			Width:35, 	Align:"Center"},
		    			{Header:'☞제목',				Type:"Text", 			SaveName:"title",				Width:245, 	Align:"Left", Cursor:"pointer"},
		    			{Header:'작성자',		Type:"Text", 			SaveName:"write_nm", 		Width:30,	Align:"Center"},
		    			{Header:'구분',			Type:"Text", 			SaveName:"noti_div", 		Width:15, 	Align:"Center", Hidden:"True"},
		    			{Header:'업체공개여부',			Type:"Text", 			SaveName:"supp_open_yn", 		Width:20, 	Align:"Center", Hidden:"True"}
		];

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

	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
	    	sheet1.SetColFontColor("title", "#0000ff");
		} else {
			//조회 에러 수행
			//alert(message);
			alert("조회 실패");
		}
	}
	
	/**
	 *	IBSheet size setting
	 */
	function setGridSize() {
		sheet1.FitColWidth();
	}
	
	/**
	 *	IBSheet Event: DBLCLICK
	 */
	 function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		 
		if (sheet1.ColSaveName(Col) == "title") {
			jQuery("#seq").val(sheet1.GetCellValue(Row, "seq"));
			jQuery("#layerYn").val('<%=layerYn%>');
			jQuery("#pop_win_id").val('<%=pop_win_id%>');
			jQuery("#fevent").val("GET_SUPP_REFERENCE_DETAIL");
			jQuery("#form1").attr("action", "/supplier/portal/center/SuppReferenceDetail.screen");
			jQuery("#form1").attr("target", "_self");
			jQuery("#form1").attr("method", "post");
			jQuery("#form1").submit();
		}
	 }
	
	function doKeyPress() {
	    if( event.keyCode == 13 ) {
	    	jQuery("#btnSearch").click();
	    }
	}	
	
	function doKeyPressEvent(param1, param2) {

	}
	
	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); 
	}	
	
	document.body.onresize = addEvent( document.body.onresize, "autoResize()");
</SCRIPT>

<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>

<form id="form1" name="form1" method="post" modular:type="search" style="width:<%=tempWidth %>;height:100%;">
<STYLE>
BODY {
 	OVERFLOW-X : HIDDEN ;
}
</STYLE>

<INPUT type="hidden" name="fevent" value="">
<INPUT type="hidden" name="seq" value="">
<INPUT type="hidden" name="layerYn">
<INPUT type="hidden" name="pop_win_id">


<div align="left" id="title">
    <ul>
     <li>자료실</li>
    </ul>
  </div> 
	<!-- 검색조건 시작 -->
	<table id="search-table" class="search-form-table">
		<colgroup>
			<col width="150" />
			<col width="*" />
			<col width="200" />
		</colgroup>
		<tr>
			<th>제목</th>
			<td>
		   		<%= InputText.get("p_title", params.get("p_title"), 90, 10, "ID,PerSize") %> 				
			</td>
			<td class="button">
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnSearch">검색</a></span>
				<%if(layerYn.equals("Y")) { %>
					<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: 400px; overflow: auto;">
	<script>createIBSheet('sheet1','100%', '400px');</script>
</div>
</FORM>