<%--
  Class Name : EgovNoticeUpdt.jsp
  Description : 게시물 수정 화면
  Modification Information
 
      수정일         수정자                   수정내용
    -------    --------    ---------------------------
     2009.03.19   이삼섭              최초 생성
     2011.08.31   JJY       경량환경 버전 생성
 
    author   : 공통서비스 개발팀 이삼섭
    since    : 2009.03.19
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="validator" uri="http://www.springmodules.org/tags/commons-validator"%>
<%@ taglib prefix="ckeditor" uri="http://ckeditor.com"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Language" content="ko">
<script type="text/javascript" src="<c:url value='/js/EgovBBSMng.js' />"></script>
<script type="text/javascript" src="<c:url value='/js/EgovMultiFile.js'/>"></script>
<script type="text/javascript" src="<c:url value="/validator.do"/>"></script>
<validator:javascript formName="board" staticJavascript="false" xhtml="true" cdata="false" />
<script type="text/javascript">
	function fn_egov_validateForm(obj) {
		return true;
	}

	function fn_egov_regist_notice() {
		CKEDITOR.instances.nttCn.updateElement();

		if (!validateBoard(document.board))
			return;

		/* <c:if test="${bdMstr.bbsTyCode == 'BBST05' or bdMstr.bbsTyCode == 'BBST06'}">
		// EgovMultiFile.js - 첨부파일 개수: _base.count default 1 | 수정 시 기첨부파일 개수: _base.update_count default 0 
		if ((_base.count + _base.update_count)  < 2) {
			alert("이미지 게시판의 경우 이미지 파일 첨부는 필수 입력값입니다.");
			return false;
		}
		</c:if> */

		/* <c:if test="${bdMstr.noticeYn == 'Y' && bdMstr.openYn == 'Y' }">
		if (document.board.noticeAt.checked && document.board.secretAt.checked) {
			alert("공지 글 등록 시 비밀글로 등록할 수 없습니다.");
			//return false;
		}
		</c:if> */

		if (confirm('<spring:message code="common.update.msg" />')) {
			document.board.action = "<c:url value='/cop/bbs/updateBoardArticle.do'/>";
			document.board.target = "_self";
			document.board.submit();
		}
	}

	function fn_egov_select_noticeList() {
		document.searchForm.action = "<c:url value='/cop/bbs/selectBoardList.do'/>";
		document.searchForm.submit();
	}
	
	function fn_egov_regist_preview() {
		var PCC_window = window.open('', 'PCCV3Window', 'width=1200, height=700, resizable=1, scrollbars=yes, status=0, titlebar=0, toolbar=0, left=350, top=50' );
		
		var previewImgs = "";
		var i = 0;
		
		$("#DIV_IMG_VIEW").find("img").each(function() {
			previewImgs += $(this).get(0).src + "^";
			i++;
		});
		
		document.board.previewImgs.value = previewImgs;
		document.board.action = "<c:url value='/cop/bbs/bbsPreview.do'/>";
		document.board.target = "PCCV3Window";
		document.board.submit();
	}
</script>
<title><c:out value='${bdMstr.bbsNm}' /> - 게시글 수정</title>
</head>
<body>
	<div class="ad_content">
		<div class="ad_con_head">
			<div class="ad_head_text">
				<p class="today_txt">
					<c:out value='${bdMstr.bbsNm}' /> - 글 수정
				</p>
				<div class="ad_head_ment">
					<p class="today_last_txt"><span id="cnt_cate_list"></span></p>
				</div>
			</div>
		</div>

		<div class="ad_subcon">
			<form:form commandName="searchForm" name="searchForm" method="get" action="">
				<input name="pageIndex" type="hidden" value="<c:out value='${searchVO.pageIndex}'/>" />
				<input name="searchCnd" type="hidden" value="<c:out value='${searchVO.searchCnd}'/>" />
				<input name="searchWrd" type="hidden" value="<c:out value='${searchVO.searchWrd}'/>" />
				<input name="bbsId" type="hidden" value="<c:out value='${searchVO.bbsId}'/>" />
			</form:form>
			<form:form commandName="board" name="board" method="post" enctype="multipart/form-data">
				<input type="hidden" name="pageIndex" value="<c:out value='${searchVO.pageIndex}'/>" />
				<input type="hidden" name="searchCnd" value="<c:out value='${searchVO.searchCnd}'/>" />
				<input type="hidden" name="searchWrd" value="<c:out value='${searchVO.searchWrd}'/>" />
				<input type="hidden" name="bbsId" value="<c:out value='${board.bbsId}'/>" />
				<input type="hidden" name="nttId" value="<c:out value='${board.nttId}'/>" />
				<input type="hidden" name="atchFileCnt" value="<c:out value='${board.atchFileCnt}'/>" />
				<input type="hidden" name="previewImgs" value="" />
				<!-- 기 업로드 파일 개수 -->

				<!-- 다언다청대통 게시판 구분 -->
				<c:if test="${bdMstr.bbsId == 'BBSMSTR_000000000221'}">
				<input type="hidden" name="ddTyCd" value="<c:out value='${board.ddTyCd}'/>" />
				</c:if>

				<!-- 통합신고게시판 -->
				<c:if test="${bdMstr.bbsTyCode == 'BBST03'}">
				<input type="hidden" name="reportTyCd" value="<c:out value='${board.reportTyCd}'/>" />
				</c:if>

				<div class="main1_div2">
					<table class="main1_table">
						<tr>
							<th>
								<spring:message code="cop.nttSj" var="msgNttSj" />
								<span class="star_t">* </span>
								<c:out value="${msgNttSj}" />
							</th>
							<td colspan="3">
								<form:input path="nttSj" title="${msgNttSj}" />
								<form:errors path="nttSj" />
							</td>
						</tr>

						<%-- 비밀번호 사용안함.
                          <!-- 비밀번호   -->
                            <c:if test="${brdMstrVO.passwordYn == 'Y' }">
							<c:set var="title"></c:set>
							<tr>
								<th><label for="password">비밀번호 <span class="pilsu"></span></label></th>
								<td class="left">
								    <form:password path="password" title="비밀번호" size="30" maxlength="30" />
					   				<div><form:errors path="password" cssClass="error" /></div>     
								</td>
								<th><label for="password1">비밀번호 확인</label></th>
								<td class="left">
								   <form:password path="password2" title="비밀번호" size="30" maxlength="30" />
					   				<div><form:errors path="password2" cssClass="error" /></div>  
								</td>
							</tr>
							</c:if>
							<!-- 비밀번호   --> --%>

						<tr>
							<th>
								<span class="star_t">* </span><spring:message code="cop.nttCn" />
							</th>
							<td colspan="3">
								<textarea id="nttCn" name="nttCn" title="<spring:message code="cop.nttCn" />" cols="500" rows="20">
									<c:out value="${board.nttCn}" escapeXml="false" />
								</textarea>
								<ckeditor:replace replace="nttCn" basePath="${pageContext.request.contextPath}/html/egovframework/com/cmm/utl/ckeditor/" />
								<form:errors path="nttCn" />
							</td>
						</tr>
						<c:if test="${bdMstr.fileAtchPosblAt == 'Y'}">
							<c:set var="isImgView" value="false" />
							<c:set var="isImgBbs" value="false" />
							<c:if test="${bdMstr.bbsTyCode == 'BBST05' || bdMstr.bbsTyCode == 'BBST06'}">
								<c:set var="isImgView" value="true" />
								<c:set var="isImgBbs" value="true" />
								<tr>
									<th>이미지</th>
									<td colspan="3">
										<div>
											<c:import url="/cmm/fms/selectImageFileInfs.do" charEncoding="utf-8">
												<c:param name="atchFileId" value="${board.atchFileId}" />
											</c:import>
										</div>
										<div id="DIV_IMG_VIEW"></div>
									</td>
								</tr>
							</c:if>
							<c:if test="${not empty board.atchFileId}">
								<tr>
									<th>첨부파일목록</th>
									<td colspan="3">
										<c:import url="/cmm/fms/selectBBSFileInfsForUpdate.do" charEncoding="utf-8">
											<c:param name="param_atchFileId" value="${board.atchFileId}" />
											<c:param name="updateFlag" value="Y" />
											<c:param name="isImgView" value="${isImgView}" />
										</c:import>
									</td>
								</tr>
							</c:if>
							<tr>
								<th>
									<label for="egovComFileUploader"><spring:message code="cop.atchFile" /></label>
								</th>
								<td colspan="3">
									<div>
										<input name="file_1" id="egovComFileUploader" type="file" />
										<div id="egovComFileList"></div>
									</div>
									<%-- <c:if test="${empty board.atchFileId}">
	                                <input type="hidden" name="fileListCnt" value="0" />
	                            </c:if> --%>
								</td>
							</tr>
						</c:if>

						<!-- 공지 여부  -->
						<c:choose>
							<c:when test="${bdMstr.noticeYn == 'Y'}">
								<c:set var="title">공지여부 </c:set>
								<tr>
									<th>
										<label for="noticeAt">${title}</label>
									</th>
									<td class="left" colspan="3">
										<form:checkbox path="noticeAt" class="cb1" value="Y" />
										<form:errors path="noticeAt" cssClass="error" />
									</td>
								</tr>
							</c:when>
							<c:otherwise>
								<form:hidden path="noticeAt" value="N" />
							</c:otherwise>
						</c:choose>
						<!-- 공지 여부  -->

						<!-- 공개/비공개 여부 -->
						<c:choose>
							<c:when test="${bdMstr.openYn == 'Y' && bdMstr.bbsTyCode != 'BBST02' && bdMstr.bbsTyCode != 'BBST03'}">
								<c:set var="title">비공개여부</c:set>
								<tr>
									<th>
										<label for="secretAt">${title}</label>
									</th>
									<td colspan="3">
										<form:checkbox path="secretAt" class="cb1" value="Y" />
										<form:errors path="secretAt" cssClass="error" />
									</td>
								</tr>
							</c:when>
							<c:otherwise>
								<form:hidden path="secretAt" value="N" />
							</c:otherwise>
						</c:choose>
						<!-- 공개/비공개 여부 -->
					</table>
					
					<c:if test="${bdMstr.fileAtchPosblAt == 'Y'}">
						<script type="text/javascript">
							var maxFileNum = "<c:out value='${bdMstr.posblAtchFileNumber}'/>";
							var maxFileSize = "<c:out value='${bdMstr.posblAtchFileSize}'/>";
							if (maxFileNum == null || maxFileNum == "") {
								maxFileNum = 0;
							}
							var multi_selector = new MultiSelector(document.getElementById('egovComFileList'),
									maxFileNum, null,
									<c:out value="${isImgView}" />,
									maxFileSize, <c:out value="${isImgBbs}" />);
							multi_selector.addElement(document.getElementById('egovComFileUploader'));

							<c:if test="${not empty board.atchFileId}">
								fn_egov_multi_selector_update_setting(multi_selector);
							</c:if>
						</script>
					</c:if>
				</div>

				<!-- 버튼 시작(상세지정 style로 div에 지정) -->
				<div class="main1_btn_div">
					<button class="main1_btn" onclick="javascript:history.go(-1); return false;">취 소</button>
					<button class="main1_btn" onclick="javascript:fn_egov_select_noticeList(); return false;">목 록</button>
					<button class="main1_btn" onclick="javascript:fn_egov_regist_preview(); return false;">미리보기</button>
					<button class="main1_btn main1_save_btn" id="main1_save_btn" onclick="javascript:fn_egov_regist_notice(); return false;">수 정 </button>
				</div>
				<!-- 버튼 끝 -->
			</form:form>
			
		</div>
	</div>
</body>
</html>

