  <%--
  - FileName   : SuppReferenceDetail.jsp
  - Author     : gyeongmo an
  - Date       : 2014.07.18
  - Copyright  : Copyright (c) 2014 www.udapsoft.co.kr, Inc.
  - All rights reserved.
  - 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.*" %>
<%@ page import="kr.co.udapsoft.ebid.buyer.common.file.FileManager" %>
<%@ page import="com.udapsoft.waf.common.util.DateUtil" %>
<%@ include file="/jsp/work/taglib.jsp" %>
<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />
<%
    ctx.init(request, response);
	String fevent = ctx.get("fevent");

    HandlerStorage storage = ctx.getHandlerStorage();
    ValueObject params = storage.getParams();
    ValueObject user = storage.getUser();
    
    String acct_id = "";
    if( user != null ) {
    	acct_id = user.get("acct_id");
    }
    
    ValueObject vo = storage.getValueObject("suppReferenceDetailRowSet");
    
    //레이어로 띄웠는지 체크
    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">
	function _onReady(){
		var f = document.form1;
		
		jQuery("#btnList").click(function() {
			var f = document.form1;
		    
			f.fevent.value ="";
			f.layerYn.value = '<%=layerYn%>';
			f.pop_win_id.value = '<%=pop_win_id%>';
		    f.action = "/supplier/portal/center/SuppReferenceListPopup.screen";
		    f.target = "_self";
		    f.submit();
		});
		
		jQuery("#btnClose").click(function() {
			setTimeout(function(){parent.searchReferenceClose();},100);
		});
	}
	
	//첨부파일   
	function doAttachFile(obj) {
		 if(obj.value==''){
			alert("저장을 한 후 파일을 첨부할 수 있습니다.");
		}
		else if(obj.value != ''){
			viewFileListNew('REFERENCE_DETAIL', obj.value, document.form1.p_AttachFile, "N", "");
		} 
	}
	
	function doDownFile(fileId){
 		var url="/common/file/FileDownloadServlet";
 		url += "?file_id=" + fileId;
 		
 		window.open(url, "_fileDown", "toolbar=no, width=400, height=100, top=500, left=400, toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,target=new")
	}
	
	function doAttachFileDiv(obj) {
		 if(obj==''){
			alert("저장을 한 후 파일을 첨부할 수 있습니다.");
		}
		else if(obj != ''){ 
			viewFileListNew('REFERENCE_DETAIL', obj.value, document.getElementById("attach_file_view"), "N", "");
		} 
	}
	
	/**
	 * 첨부파일 예약 함수
	 */
	function fileDown(file_id){
			var url="/common/file/FileDownloadServlet";
	 		url += "?file_id=" + file_id;
	 		
	 		window.open(url, "_fileDown", "toolbar=no, width=400, height=100, top=500, left=400, toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,target=new")
	}
	
</script>

<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="<%= params.get("fevent") %>">
<INPUT type="hidden" name="write_id" value="<%=acct_id%>">
<INPUT type="hidden" name="seq" value="<%=vo.get("seq")%>">
<INPUT type="hidden" name="supp_open_yn_value">
<INPUT type="hidden" name="layerYn">
<INPUT type="hidden" name="pop_win_id">

<!-- 제목 및 버튼 -->
   	<table width="100%">
		<colgroup>
			<col width="500" />
			<col width="*" />
		</colgroup>
	<tr>
	   <td align="right">
			<span class="btnSearch center"><a href="javascript:void(0);" id="btnList">목록</a></span>
			<%if(layerYn.equals("Y")) { %>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnClose">닫기</a></span>
			<%} %>
	   </td>
   	</tr>
   	</table>
	
<TABLE class="form-table"">
	<col width="18%">
	<col width="44%">
	<col width="18%">
	<col width="20%">
	<tr> 
		<th style="text-align: left;">
			제목
		</th>
		<td>
			<%= InputText.get("supp_reference_title", vo.get("title"), 45, 30, "class=input_blank, readOnly=white, string, left, tabIndex=-1", "string") %>
		</td>
		<th style="text-align: left;">
	     	일자
	 	</th>
	 	<td>
	 		<%= InputText.get("noti_dy", DateUtil.formatDateTime(vo.get("noti_dy"), "yyyyMMdd", "yyyy-MM-dd"), 45, 30, "class=input_blank, readOnly=white, string, left, tabIndex=-1", "string") %>
	 	</td>
	</tr>
	<tr> 
		<th style="text-align: left;">
	    	작성자
	 	</th>
	 	<td colspan="3">
	 		<%= InputText.get("write_nm", vo.get("write_nm"), 45, 30, "class=input_blank, readOnly=white, string, left, tabIndex=-1", "string") %>
	 	</td>
	</tr>
	<tr> 
		<th style="text-align: left;">
			내용
	 	</th>
	 	<td colspan="3">
	 		<%=HTMLCvt.cvtHTML(vo.get("content")) %>
	 	</td>
	</tr>
	<tr> 
		<th style="text-align: left;">
			첨부파일
	 	</th>
		<%-- 
		<td width="30%" style="padding-top: 3px;" COLSPAN='3'>
			<TABLE cellspacing="0" cellpadding="0">
				<%
					RowSet fileList = FileManager.getFileList("REFERENCE_DETAIL", vo.get("seq"));
					for(int i = 0; i < fileList.size(); i++){
				%>
					<TR height="25">
						<TD class="search_table_data">
							<a href="javascript:doDownFile('<%=fileList.getRow(i).get("FILE_ID") %>');"><%=fileList.getRow(i).get("FILE_NAME")%></a>
						</TD>
					</TR>
				<%
					}	
				%>
			</TABLE>
		
		 
			<TEXTAREA name="p_AttachFile" style="width:95%" rows="1" class="input" readOnly><%=vo.get("SUPP_REFERENCE_DETAIL_FILE") %></TEXTAREA>
			<IMG src="/img/buyer/icon/icon_plus.gif" alt="adjust size" border="0" align="top" onClick="JavaScript:toggleTextarea(this, document.form1.p_AttachFile, 1, 5);" style="cursor:hand;">
	        <IMG id='search_spot_button' onClick="doAttachFile(document.form1.seq);" src='/img/buyer/button/bt_change.gif' border='0'  align="top" align='absmiddle' alt='[Attach File]' style='cursor:hand;'>  		 	
	    
	    </td>
	     --%>
	    <td colspan="3">
	    	<div id="attach_file_view" class="attach_file_view">
			    <!-- 첨부 파일 화면에 바로보일때 사용 -->
			    <%=FileManager.getFileListForDiv("REFERENCE_DETAIL", vo.get("seq")) %>
		    </div>
	    </td>
 	</tr>
</table>
</form>