
<%    /**
     * **********************************************************@@ Program Name
     * : popup_content_write.jsp Description	: /보고자/내문서함/임시보고함/임시보고 Author	:
     * 기현테크 Create Date	: 2010-11-27 History	:
     * @@***********************************************************
     */
%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="java.net.URLEncoder"%>
<%@ page import="javax.jdo.PersistenceManager"%>
<%@ page import="javax.jdo.Transaction"%>

<%@ page import="kr.co.kihyun.beans.user.HttpSSOLogin"%>
<%@ page import="kr.co.kihyun.lang.MString"%>
<%@ page import="kr.co.kihyun.util.MUtil"%>
<%@ page import="kr.co.kihyun.moumi.Moumi"%>
<%@ page import="kr.co.kihyun.text.html.TagFilter"%>
<%@ page import="kr.co.kihyun.beans.entity.Category"%>
<%@ page import="kr.co.kihyun.beans.entity.Board"%>
<%@ page import="kr.co.kihyun.beans.entity.util.*"%>
<%@ page import="kr.co.kihyun.lang.StringConverter"%>
<%@ page import="kr.co.kihyun.beans.entity.TotDoc"%>
<%@ page import="kr.co.kihyun.db.CommonDBManager"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="kr.co.kihyun.io.FileUtil"%>
<%@ page import="kr.co.kihyun.prop.QueryStringList"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.util.Map.Entry"%>
<%@ page import="java.util.List"%>
<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>
<%

		CommonDBManager db = new CommonDBManager();
		ResultSet rs = null;
	    try {

	    boolean isAttach 	 = false;
    	Long boardID 		 = MLong.parseLong(request.getParameter("docID"), null);
        String boardTitle	 = null;
        String boardContents = null;
      	String boardType 	 = "";
    	String sql			 = QueryStringList.NoticeWithOutFileSql;

    	rs = db.execQuery(sql, boardID);
    	System.out.println("rs === " + rs);

    	if(rs.next()){
			ArrayList<String> fns = FileUtil.getBoardAttachmentsFileNames(boardID, request, false);
			System.out.println("fns === " + fns);
    		if(fns != null && fns.size()>0) isAttach = true;
    		boardTitle 		= rs.getString("TITLE");
            boardContents 	= StringConverter.toHtmlBr(rs.getString("CONTENTS"));
            boardContents 	= TagFilter.unconvertedMeta(boardContents);
            boardType 		= Moumi.getMessageBundle().getString("moumi.message.board.notice");
    	}
%>
<%@page import="kr.co.kihyun.lang.MLong"%>
<!DOCTYPE html>
<html lang="ko">
	<head>
		<meta charset="UTF-8">
		<title>자료입력시 작성요령</title>
        <link rel="stylesheet" href="/totsys/common/css/text.css" type="text/css">
        <link rel="stylesheet" href="/totsys/common/css/kecttep.css" type="text/css">
        <link rel="stylesheet" href="/totsys/common/css/basic.css" type="text/css">
        <link rel="stylesheet" href="/totsys/common/css/popup.css" type="text/css">
        <script src="/totsys/common/js/rollover.js"></script>
        <script src="/totsys/common/js/jquery-1.12.4.min.js"></script>
        <script src="/totsys/common/js/popup.js"></script>
        <script src="/totsys/common/js/jquery.custom.indicator.js"></script>
        <script>


            function popupViewInner(p_boardID) {
                gEventY = window.event.clientY + document.body.scrollTop;
                gEventX = window.event.clientX + document.body.scrollLeft;

                $.ajax({
                    url: "/servlet/kr.co.kihyun.service.servlet.AjaxProcessServlet",
                    type: "POST",
                    dataType: "json",
                    data: {
                        proc_type: "board_attatch_file",
                        board_id: p_boardID
                    },
                    success: function(data) {
                        $("#fileview").css("display","none");
                        fn_callBackForSuccess(data);
                    },
                    error: function(e) {
                        alert("동시접속자가 많아 파일을 조회할 수 없습니다.");
                    },
                    beforeSend: function() {
                        $.customIndicator.show(window.self);
                    },
                    complete: function() {
                        $.customIndicator.hide(window.self);
                    }
                });
            }

            /**
             * attachmentsMapByBoardID 함수의 성공 시 호출되는 함수
             * @param {type} data
             * @returns {undefined}
             */
            function fn_callBackForSuccess(data) {
                var fileList = "";
                var boardID = "";
                var fileName = "";
                var fileNameEncode = "";

                if (data != null) {
                    for (var i = 0; i < data.length; i++) {
                        boardID = data[i].boardID;
                        fileName = data[i].fileName;
                        fileNameEncode = data[i].fileNameEncode;
                        //fileList += "<a onclick=\"popupClose(\'"+fileIndex+"\');\" href=\'/servlet/kr.co.kihyun.text.html.HttpViewer?saveAs="+ fileNameEncode+ "\&fileName="+ fileNameEncode +"\&reportID="+reportID+"\' target=\'new\'>"+ fileName+ "</a><br/>\n" ;
                        fileList += "<span style='color: #FF9C1B; font-weight: bold;'>+첨부파일 " + (i + 1) + " : </span><a onclick='godown(this);' style='white-space: nowrap;' href=\"#\" url=\'/servlet/kr.co.kihyun.text.html.HttpViewer?fileName=" + fileNameEncode + "\&boardID=" + boardID + "\' target=\'\'>" + fileName + "</a><br/>\n";
                    }
                    document.getElementById("fileNameList").innerHTML = fileList;
                }
            }
             function godown(link){
            	 var url=$(link).attr('url');
            	 location.href=url;
             }
        </script>
    </head>

    <body class="mp_0">
     <div class="frameblock" style="display:none;text-align: center; color: #000; background-color: #fff; font-family: dotum; font-size: 13px; font-weight: bold;position: absolute;top:0;left:0;width:100%;height:100%; z-index: 1001; opacity: 0.5;-ms-filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=50);filter:alpha(opacity=50);"><div style="margin-top:30%;opacity: 1;-ms-filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100);filter:alpha(opacity=100);"><img src="/totsys/common/js/img/ajax-loader1.gif">&nbsp;처리중입니다...</div></div>
        <table style="width: 100%;">
            <tr>
                <td style width="29">
                    <img alt="테두리" src="images/popupt_top_left.gif">
                </td>
                <td style="background-image: url('images/popupt_top_center.gif');">&nbsp;</td>
                <td width="30">
                    <img alt="테두리" src="images/popupt_top_right.gif">
                </td>
            </tr>
            <tr>
                <td style="background-image: url('images/popupt_center_left.gif');">&nbsp;</td>
                <td style="vertical-align: top;">
                    <table style="width: 100%">

                        <!--타이틀-->
                        <tr>
                            <td style="padding-top: 10px; padding-bottom: 10px;">
                                <table style="width: 100%">
                                    <tr>
                                        <td style="width: 39px; height:30px; background-image: url('images/title1.gif');">&nbsp;</td>
                                        <td class="kecttep_title" style="background-image: url('images/titlebg.gif');"><%= Moumi.getMessageBundle().getString("moumi.message.tot_report.make")%><%= Moumi.getMessageBundle().getString("moumi.message.tot_doc.trick")%>
                                            <%= Moumi.getMessageBundle().getString("moumi.message.tot_doc.and")%>
                                            <%= Moumi.getMessageBundle().getString("moumi.message.button_small.totperInfo")%></td>
                                        <td style="width: 13px; background-image: url('images/title2.gif');">&nbsp;</td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <!--타이틀 끝-->
                        <tr>
                            <td style="padding-left: 10px; padding-right: 10px; vertical-align: top; height: 66px;">
                                <table style="width: 100%; height: 264px;">
                                    <!---- 작성자 정보  시작 ---->

                                    <tr>
                                        <td style="padding-left: 0px">
                                            <table>
                                                <tr>
                                                    <td colspan="3">
                                                        <!-- textarea class="body" readonly style="padding-left: 0px; border: 1px solid #ccc; width: 520px;  height: 100px; height: 15em; white-space: normal; overflow-y: auto;" -->
                                                        <%=MString.checkNull(boardContents)%>
                                                        <!--/textarea -->
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="padding-left: 20px; height: 20px;"></td>
                                                </tr>

                                                <tr>
                                                    <td class="body" style="padding-left: 20px; padding-top: 4px; height: 17px;">
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>

                                </table>
                            </td>
                        </tr>
                    </table>

                                            <!---- 파일첨부 테이블 시작 ---->
                                            <table width="100%" border="0" cellspacing="0" cellpadding="0"
                                                   align="center">
                                                <%--
                                                <% if (board.getAttachments().size() == 0) {%>
                                                 --%>
                                                 <% if (!isAttach) {%>
                                                    &nbsp;
                                                <%} else {%>
                                                <tr>
                                                    <td id = "fileview" class="kecttep_list_graytd" height="20"
                                                        style="padding-left: 3;"><font color="#FF6600"><b>+</b><%= Moumi.getMessageBundle().getString("moumi.message.file")%>
                                                        <a href="javascript:void(0);" onclick="popupViewInner('<%=boardID%>');"><img src="/totsys/totper/mydocbox/prssbox/reports/images/disk.gif"></a>
                                                        </font></td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2" bgcolor="white" style="padding: 2px; white-space: nowrap;">
                                                        <span id="fileNameList" style="white-space: nowrap;">

                                                        </span>
                                                    </td>
                                                </tr>
                                                <%}%>
                                            </table>
                                            <!---- 파일첨부 테이블 끝 ---->
                    <!---- 내용 끝 ---->
					<br/>
                    <!---- 확인,취소버튼 테이블 시작 ---->
                    <table border="0" cellspacing="0" cellpadding="0" align="center">
                        <tr>
                            <td>
                                <a href="javascript:self.close();">
                                    <img name="bt_enter" border="0" src="/totsys/common/images/bt_ok.gif">
                                </a>
                            </td>
                        </tr>
                    </table>
                </td>
                <td background="images/popupt_center_right.gif">&nbsp;</td>
            </tr>
            <tr>
                <td><img src="images/popupt_bottom_left.gif" width="29" height="24"></td>
                <td background="images/popupt_bottom_center.gif" height="24">&nbsp;</td>
                <td><img src="images/popupt_bottom_right.gif" width="30" height="24"></td>
            </tr>
        </table>
        <iframe name="hiddenIframe" width="0" height="0" style="display: none;"></iframe>
    </body>
</html>
<%

    } catch (Exception ex) {
        ex.printStackTrace();
        out.println(kr.co.kihyun.text.html.ServletUtil.getJavaScript("location='/servlet/kr.co.kihyun.beans.user.HttpSSOLogin?mode=logout';"));
    } finally{
        if (null != rs) {
            rs.close();
        }
        db.execClose();
    }
%>
