<%--
  Class Name : EgovNoticeRegist.jsp
  Description : 게시물  생성 화면
  Modification Information
 
      수정일         수정자                   수정내용
    -------    --------    ---------------------------
     2009.03.24   이삼섭              최초 생성
     2011.08.31   JJY       경량환경 버전 생성
 
    author   : 공통서비스 개발팀 이삼섭
    since    : 2009.03.24
--%>
<%@ 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="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-Type" content="text/html; charset=utf-8">
<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/EgovMultiFileItn.js'/>"></script> <!-- 파일첨부, 썸네일이미지 있으면 미리보기 -->
<%-- <script type="text/javascript" src="<c:url value='/js/EgovMultiFile.js'/>"></script> --%>
<script type="text/javascript" src="<c:url value='/js/EgovCalPopup.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">
$( document ).ready(function() {
	$(function () {

		$('#filebutton').click(function (e) {

		e.preventDefault();

		$('#file_temp').click();

		});

		});
	
});

function goList() {
	document.searchForm.submit(); 
}

function fn_egov_regist_notice() {
	CKEDITOR.instances.nttCn.updateElement();
	if (!validateBoard(document.board))
		return;

	//금지어 확인
	/* var prohibitCheck = false;
	var form = document.board ;
	form.checkProhibitCn.value = form.nttSj.value + form.nttCn.value ; 
	var data = new FormData(form);
	$.ajax({
	type: "POST",
	     url: "/uss/ion/cnf/prohiCheckAjax.do",
	     async:false,
	     data: data,
	     dataType:'json',
	     processData: false,
	     contentType: false,
	     cache: false,
	     timeout: 600000,
	     success: function (returnData, status) {
	     	if(status == 'success'){
		    	if(returnData.result == 'fail'){
		        }else if(returnData.result == 'auth_fail'){
		        }else if(returnData.result =='success'){
		        	if(null != returnData.prohibitVO.prohibitCn){
		        		alert( returnData.prohibitVO.prohibitCn + " 단어는 금지어로 등록되어 있는 단어입니다." );
		        		prohibitCheck = true;
		        	}
	           	}
           }else{
	           	//alert("등록에 실패하였습니다.");
           }
       },
       error: function (e) {
           //alert("등록에 실패하였습니다.");
       }
	});
  
	if(prohibitCheck){
		return;
	} */
	
	<c:if test="${bdMstr.noticeYn == 'Y' or bdMstr.bbsTyCode == 'BBST08'}"> 
		var tempTxt = "공지" ;
		<c:if test="${bdMstr.bbsTyCode == 'BBST08'}">
			tempTxt = "모집기간" ;
		</c:if>
		
		if($("input:checkbox[name='noticeAt']").is(":checked") || tempTxt=='모집기간'){
			{
				if($('#ntceBgndeYYYMMDD').val() == ''){
					alert(tempTxt+" 시작일은 필수입니다.");
					return;
				}
				if($('#ntceEnddeYYYMMDD').val() == ''){
					alert(tempTxt+" 마감일은 필수입니다.");
					return;
				}
				
				var iChkBeginDe = Number(($('#ntceBgndeYYYMMDD').val()+$('#ntceBgndeHH').val()+$('#ntceBgndeMM').val()).replaceAll("-","")   );
				var iChkEndDe =  Number(($('#ntceEnddeYYYMMDD').val()+$('#ntceEnddeHH').val()+$('#ntceEnddeMM').val()).replaceAll("-","")   );

				if(iChkBeginDe > iChkEndDe || iChkEndDe < iChkBeginDe ){
					alert("게시시작일자는 게시종료일자 보다 클수 없고,\n게시종료일자는 게시시작일자 보다 작을수 없습니다. ");
					return;
				}
				$('#ntceBgnde').val(iChkBeginDe) ;
				$('#ntceEndde').val(iChkEndDe) ;
			}
		}
	</c:if>
	
	if (confirm('<spring:message code="common.regist.msg" />')) {
		goSave();
	}
}

function goList() {
	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=850, height=570, 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>
<style>
.uploaded_obj{width: 100%;}
</style>
</head>
<body>
	<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='${bdMstr.bbsId}'/>" />
	<input type="hidden" name="previewImgs" value="" />
	<input type="hidden" name="checkProhibitCn" value="" />
	<input type="hidden" name="siteId" value="<c:out value='${bdMstr.siteId}'/>"  />
	<input type="hidden" name="pageType" id="pageType" value="insert" />
	
	<input id="ntceBgnde" name="ntceBgnde" type="hidden" value="">
	<input id="ntceEndde" name="ntceEndde" type="hidden" value="">
	
	<!-- 드래그앤 드롭 파라미터 -->
	<input type="hidden" name="limitcount" value="${bdMstr.posblAtchFileNumber}" />
	
	
	<!-- cont_tit -->
	<div class="content_title">
		<h3><c:out value='${bdMstr.bbsNm}' />- 글 등록  (<c:out value='${bdMstr.menuNm}' />)</h3>
		<ul class="breadcrumb">
			<li class="home"><a href="/"><i></i></a></li>
			<li><p>게시판관리</p></li>
			<li><p>게시판관리</p></li>
			<li><p><c:out value='${bdMstr.bbsNm}' /> 목록</p></li>
			<li><strong class="current_location"><c:out value='${bdMstr.bbsNm}' /> 등록</strong></li>
		</ul>
	</div>
	<!-- //cont_tit -->
	
	<div class="cont">
		<div class="table table_type_rows">
			<table>
				<colgroup>
					<col style="width:200px;">
					<col style="width:auto;">
				</colgroup>
				<tbody>
					<tr>
						<th>
							<span class="required">*</span>
							<c:out value='${bdMstr.bbsTyCode eq "BBST07" ? "항목" : bdMstr.menuNo eq "9510000" ? "질문" : "제목"}' />
							<c:out value="${msgNttSj}" />
						</th>
						<td>
							<form:input path="nttSj" title="${msgNttSj}" cssClass="input w100per"/>
							<form:errors path="nttSj" cssClass="input w100per"/>
						</td>
					</tr>
	               <c:if test="${'9650000' eq bdMstr.menuNo}">
					<tr>
						<th>
							<span class="required">*</span>
							URL
						</th>
						<td>
							<form:input path="linkUrl" class="text" size="50" cssClass="w100per input"/>
							<form:errors path="linkUrl" />
						</td>
	               </tr>		  
	               </c:if>  							
					<tr>
						<th>
							<span class="required">*</span>
							<c:out value='${brdMstrVO.menuNo eq "9510000" ? "답변" : "내용"}' />
						</th>
						<td>
							<form:textarea path="nttCn" class="textarea" cols="500" rows="20" />
							<ckeditor:replace replace="nttCn" basePath="${pageContext.request.contextPath}/html/egovframework/com/cmm/utl/ckeditor/" />
							<form:errors path="nttCn" />
						</td>
					</tr>
					<%-- <tr>
						<th><span class="reqArea">모집상태</span></th>
						<td>
							<select name="seCd" id="seCd" title="모집상태">
								<c:forEach var="result" items="${codeList}" varStatus="status">
									<option value="${result.code}" <c:if test="${result.code eq board.seCd }">selected="selected"</c:if> ><c:out value='${result.codeNm}' /></option>
							</c:forEach>
							</select>
						</td>
					</tr> --%>
					
					
					<%-- <tr>
						<th>파일 첨부</th>
						<td class="upload_area">
							<div class="file_upload_box no_img_box fileWrap">
								<table>	
									<colgroup>
										<col style="width: 60%">
										<col style="width: 10%">
										<col style="width: 20%">
										<col style="width: 10%">
									</colgroup>
									<thead>
										<tr>
										<th>파일명</th>
										<th>크기</th>
										<th>등록일시</th>
										<th>삭제</th>
										</tr>
									</thead>
								</table>
							</div>
							<div class="fileWrap fileAfter file_list_div">
								<table>
									<colgroup>
										<col style="width: 60%">
										<col style="width: 10%">
										<col style="width: 20%">
										<col style="width: 10%">
									</colgroup>
									<thead>
										<tr>
											<th>파일명</th>
											<th>크기</th>
											<th>등록일시</th>
											<th>삭제</th>
										</tr>
									</thead>
									<tbody id="tbody_fiielist">
										<c:forEach var="fileList" items="${fileList}" varStatus="status">
		                        			<tr class="item_<c:out value='${fileList.fmsImageFile}' />_<c:out value='${fileList.fileSn}' /> uploaded_obj">
												<input type="hidden" name="fileSize" class="item_file_size" value="${fileList.fileSize}">
												<td class="file_name">
													<img src="/direct/img/upload_hwp_img.png" alt="" />
													<span class="file_name_text"><c:out value='${fileList.orignlFileNm}' /></span>
												</td>
												<td>
													<span class="file_size_text" value="<c:out value="${fileList.fileSize}"/>"></span>
													
												</td>
												<td>
													<c:out value="${fileList.regdt}"/>
												</td>
												<td>
													<input type="button" class="delBtn" onclick="delAtchFile('<c:out value='${fileList.fmsImageFile}' />', '<c:out value='${fileList.fileSn}' />'); return false;">
												</td>
											</tr>
		                        		</c:forEach>
									</tbody>
								</table>
							</div>
							<div class="fileInfo file_list_div">
								<ul class="inline">
									<li>
										<p>최대 <span class="c_e40000 fwBold limitcount_li"><c:out value='${bdMstr.posblAtchFileNumber}' /></span>개 ｜ <span class="c_e40000 fwBold upload_number">50MB</span>제한</p>
									</li>
									<li>
										<p><span class="c_456ded fwBold totalfileCount">1</span>개 ｜ <span class="c_456ded fwBold totalfileSize">72.01KB</span></p>
									</li>
								</ul>
							</div>
							<div class="uploadBtm">
								<input type="file" id="file_temp" name="file_temp" class="uploadFile">
							</div>
						</td>
					</tr> --%>
					<c:if test="${bdMstr.fileAtchPosblAt == 'Y'}">
					<tr>
						<th>
							<span class="required">*</span>
							첨부파일
						</th>
						<td>
							<!-- <input type="text" id="fileNm" size="30" class="file_input" readonly> --><!-- <button type="button" class="btnType01 btn_add_file">파일 첨부하기</button> -->
							<div class="file_upload_wrap">
								<input type="file" id="file_temp" name="file_temp" class="uploadFile" style="display:none"/>
								<button type="button" id="filebutton" class="btn medium line primary">파일 첨부하기</button>
							</div>
							
							<div class="file_table before_file_table">
								<table>
									<caption>첨부파일 리스트 : 파일명, 종류, 크기, 삭제</caption>
									<colgroup>
										<col style="width: 60%;">
										<col style="width: auto;">
										<col style="width: 20%;">
										<col style="width: 10%;">
									</colgroup>
									<thead>
										<!-- <th>
											<input type="checkbox" id="all_check"><label for="all_check"></label>
										</th> -->
										<th style="text-align:center;">파일 명</th>
										<th style="text-align:center;">종류</th>
										<th style="text-align:center;">크기</th>
										<th style="text-align:center;">삭제</th>
									</thead>
									<tbody class="tb_file_before">
										<tr>
											<td colspan="4">
												<i class="icon file_bg"></i>
                                    			<p>첨부하실 파일을 <b>마우스로 끌어서</b> 넣어주세요.</p>
											</td>
										</tr>
									</tbody>
								</table>
							</div>
							<div class="file_table">
								<table>
									<caption>첨부파일 리스트 : 파일명, 종류, 크기, 삭제</caption>
									<colgroup>
										<col style="width: 60%">
										<col style="width: 10%">
										<col style="width: 20%">
										<col style="width: 10%">
									</colgroup>
									<thead>
										<!-- <th>
											<input type="checkbox" id="all_check"><label for="all_check"></label>
										</th> -->
										<th style="text-align:center;">파일 명</th>
										<th style="text-align:center;">종류</th>
										<th style="text-align:center;">크기</th>
										<th style="text-align:center;">삭제</th>
									</thead>
									<tbody id="tbody_fiielist" class="tb_file_after">
										<c:forEach var="fileList" items="${fileList}" varStatus="status">
		                        			<tr class="item_<c:out value='${fileList.atchFileId}' />_<c:out value='${fileList.fileSn}' /> uploaded_obj">
												<input type="hidden" name="fileSize" class="item_file_size" value="${fileList.fileSize}">
												<td class="td_filename">
													<!-- <img src="/direct/img/upload_hwp_img.png" alt="" /> -->
													<span class="file_name_text"><c:out value='${fileList.orignlFileNm}' /></span>
												</td>
												<td class="td_filesort">
													<span class="file_filesort_text" value="<c:out value="${fileList.fileExtsn}"/>"><c:out value="${fileList.fileExtsn}"/></span>
												</td>
												<td class="td_filesize">
													<span class="file_size_text" value="<c:out value="${fileList.fileMg}"/>"><c:out value="${fileList.fileMg}"/></span>
												</td>
												<td>
													<button type="button" class="btn line lightgray ssmall only_icon btn_delete" onclick="delAtchFile('<c:out value='${fileList.atchFileId}' />', '<c:out value='${fileList.fileSn}' />'); return false;" title="파일삭제"><i class="icon delete red"></i></button>
													<%-- <button type="button" class="btn btn_text btn_30 red_border btn_del" onclick="delAtchFile('<c:out value='${fileList.atchFileId}' />', '<c:out value='${fileList.fileSn}' />'); return false;" title="파일삭제">삭제</button> --%>
												</td>
											</tr>
		                        		</c:forEach>
									</tbody>
								</table>
							</div>
						</td>
					</tr>
					</c:if>
					<tr>
						<th>
							<c:out value="작성자" />
						</th>
						<td>
							<form:input path="ntcrNm" cssClass="input w50per"/>
							<form:errors path="ntcrNm" cssClass="input w50per"/>
						</td>
					</tr>
					<tr>
						<th>
							<c:out value="담당부서" />
						</th>
						<td>
							<form:input path="pubLoc" cssClass="input w50per"/>
							<form:errors path="pubLoc" cssClass="input w50per"/>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		
		<!-- btn_wrap -->
		<div class="btn_wrap">
			<div class="left">
				<c:if test="${!empty fmsFileList[0].fmsId }">
					<button class="btn line xlarge red" onclick="fn_fmsfile_delete(); return false;">삭 제</button>
				</c:if>
			</div>
			<div class="right">
				<!-- <button class="btnType04" onclick="fn_egov_regist_preview(); return false;">미리보기</button> -->
				<c:if test="${!empty fmsFileList[0].fmsId }">
					<button class="btn fill xlarge primary" onclick="goSave('fmsFile_U'); return false;">수 정</button>
				</c:if>
				<c:if test="${empty fmsFileList[0].fmsId }">
					<button class="btn fill xlarge primary" onclick="fn_egov_regist_notice(); return false;">등 록</button>
				</c:if>						
				<button class="btn fill xlarge gray" onclick="goList(); return false;">목 록</button>
			</div>
		</div>
		<!-- //btn_wrap -->
	</div>
		
	
</form:form>

	<!-- //content 끝 -->
</body>
</html>
