<%
/**
 * <pre>
 * @Class Name : updateQnAForm.jsp
 * 
 * @Description : 묻고답하기 수정화면을 표출한다. 
 * 
 * 
 * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
 *
 * </pre>
 *
 * @ ------------    --------    ---------------------------
 * @ 수정일                     수정자             수정내용
 * @ ------------    --------    ---------------------------
 * @ 2021. 7. 23.    KNKIM       최초 생성
 *
 * 
 * @author 이씨플라자 * DIGITALSHIP KNKIM
 * @since 2021. 7. 23.
 * @version 1.0
 *
 */
 %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ 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" %>

<c:set var="pageTitle">묻고답하기 - 수정</c:set>

<!DOCTYPE html>
<html>
<head>
<title>${pageTitle}</title>

<script type="text/javaScript">

//선택한 게시글 상세 보기로 이동
function fn_viewDetail(articleNo) {
	$('#articleForm').removeAttr('onsubmit');
	
    $("#articleNo").val(articleNo);
    $("#articleForm").attr("action", "${pageContext.request.contextPath}/board/selectQnA.do");
    $("#articleForm").submit();
}

// 선택한 게시글 상세 보기로 이동
function fn_list() {
    $("#articleForm").attr("action", "${pageContext.request.contextPath}/board/listQnAs.do");
    $("#articleForm").submit();
}

// 수정 처리 
function fn_update() {
    if(!validEmail($("#email").val())) {
    	alert("이메일 형식에 맞지 않습니다. 다시 확인하여 주시기 바랍니다.");
    	$("#email").focus();
    	return false;
    }
    
    $("#articleForm").attr("action", "${pageContext.request.contextPath}/board/updateQnA.do");
    if(!confirm("저장하시겠습니까?")) return false;
    
    return true;
}

</script>
</head>

<body>

<h1>${pageTitle }</h1>

메시지 : <span style="color:red;">${message }</span>
<br />

<form name="articleForm" id="articleForm"  
      action="${pageContext.request.contextPath}/board/updateQnA.do" 
      method="post"
      onsubmit="return fn_update();"> 
    
    <!-- HIDDEN 영역 : 시작 -->
    <input type="text" name="pageIndex"       id="pageIndex"       title="페이지번호"        value="${pageIndex}"       readonly />
    <input type="text" name="pageSize"        id="pageSize"        title="목록에 보여줄 글 개수" value="${pageSize}"       readonly />
    <input type="text" name="searchKeyword"   id="searchKeyword"   title="검색어"           value="${searchKeyword}"   readonly />
    <input type="text" name="articleNo"       id="articleNo"       title="선택글번호"        value="${articleNo}"       readonly />

	&nbsp;<br/>
	&nbsp;<br/>

    <table class="table_content" style="width:100% !important;">
        <tr>
            <th>제목</th>
            <td><input type="text" name="title" id="title" title="제목" value="${article.title}" size="100" maxlength="200" required /></td>
        </tr>
        <tr>
            <th>작성자</th>
            <td><input type="text" name="regUserName" id="regUserName" title="작성자" value="${article.regUserName}" size="100" maxlength="200" required /></td>
        </tr>
        <tr>
            <th>이메일</th>
            <td><input type="email" name="email" id="email" title="이메일" value="${article.email}" size="100" maxlength="200" required /></td>
        </tr>
        <tr>
            <th>기존비밀번호</th>
            <td><input type="text" name="encArticlePassword" id="encArticlePassword" title="제목" value="${encArticlePassword}" size="100" maxlength="200"  /></td>
        </tr>
        <tr>
            <th>비밀번호<br/>(변경시 입력)</th>
            <td><input type="text" name="articlePassword" id="articlePassword" title="비밀번호" value="" size="100" maxlength="200" /><br/>
                * 비밀번호 : SHA-256 암호화 처리 후, DB에 저장되며, 웹 화면에 표출될 때는 Aria로 AuthKey를 Salt값으로 하여 재암호화처리하고 BASE64로 다시한번 인코딩하여 표출함 
            </td>
        </tr>
        <tr>
            <th>질문내용</th>
            <td><textarea name="contentQeust" id="contentQeust" cols="80" rows="10">${article.contentQeust}</textarea></td>
        </tr>
    </table>        
    
    <br/>
    
    <input type="button" name="btnCancel" id="btnCancel" title="취소버튼" class="float" value="취소"
        onclick="fn_viewDetail('${articleNo}')" />
    <input type="submit" name="btnSave" id="btnSave" title="저장버튼" class="float" value="저장" />

</form>

</body>
</html>
