<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:include page="${data._INCLUDE}/header.jsp"></jsp:include>
<script src="https://t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"></script>
<script>
$( function(){
    $( "#newForm" ).validate({
        rules: {
            centerNumber : {
                phoneValid : true
            },
            staffPhoneNumber : {
                phoneValid : true
            },
            staffNewPwConfirm : {
//                 equalTo: "#staffNewPw"
            },
            totalCapacity :{
                number:true
            },
            totalStaff :{
                number:true
            },
            staffNewPw :{
                passwordValid : true
            }
        },
        messages : {
            staffNewPwConfirm : {
                equalTo: "신규 비밀번호가 일치하지 않습니다."
            }
        },
        onkeyup: function( element, event ) {
            $( element ).valid();
        },
        onfocusout: function (element) {
            $( element ).val( $.trim( $( element ).val() ) );
            $( element ).valid();
        },
        submitHandler: function(form) {
            $("#mainAddr").removeAttr("disabled");
            form.submit();
        }
    });
})
</script>
</head>
<body>
    <div class="wrapper">
        <jsp:include page="${data._INCLUDE}/sidebar.jsp"></jsp:include>
        
        <div class="main">
            <jsp:include page="${data._INCLUDE}/top.jsp"></jsp:include>
            
            <main class="content">
                <div class="container-fluid p-0">
                    <!-- 환자관리 : 신규환자 등록 START -->
                    <div class="row">
                        <div class="col-12 col-lg-6">
                            <h1 class="h3 mb-3">
                            생활치료센터 수정
                            </h1>
                        </div>
                        <div class="col-12 col-lg-6  text-right">
                            <nav aria-label="breadcrumb">
                                <ol class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="javscript:;">Home</a></li>
                                    <li class="breadcrumb-item">생활치료센터 관리</li>
                                    <li class="breadcrumb-item active">생활치료센터 조회</li>
                                </ol>
                            </nav>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-12">
                            <div class="card">
                                <form action="./edit/update" method="post" id="newForm">
                                    <div class="card-body">
                                        <table class="table mobile-table">
                                            <colgroup>
                                                <col style="width:15%">
                                                <col style="width:35%">
                                                <col style="width:15%">
                                                <col style="width:35%">
                                            </colgroup>
                                            <tr>
                                                <th>생활치료센터명</th>
                                                <td>
                                                    <c:out value="${centerInfo.centerName}" />
                                                    <input type="hidden" name="centerName" value="${centerInfo.centerName}">
                                                    <input type="hidden" name="centerCode" value="${centerInfo.centerCode}">
                                                </td>
                                                <th>지역</th>
                                                <td>
                                                    <select class="custom-select" name="locationCode">
                                                        <option>지역</option>
                                                        <c:forEach var="i" items="${locationList}">
                                                            <option value="${i.locationCode}" <c:if test="${i.locationCode eq centerInfo.locationCode}"> selected="selected"</c:if>><c:out value="${i.locationName}"/></option>
                                                        </c:forEach>
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th><span class="fix">*</span>주소</th>
                                                <td colspan="3">
                                                    <div class="form-row">
                                                        <div class="col-lg-10"><input type="text" class="form-control" disabled id="mainAddr" name="centerAddress" value="${mainAddr}" /></div>
    <!--                                                     <div class="col-lg-2"><button class="btn btn-primary w100">주소찾기</button></div> -->
                                                        <div class="col-lg-2"><span class="btn btn-primary w100" onclick="juso();">주소찾기</span></div>
                                                        <div class="col-lg-10"><input type="text" class="form-control mt8" id="detailAddr" name="detailAddr" placeholder="상세주소" value="${detailAddr}" required></div>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th><span class="fix">*</span>전화번호</th>
                                                <td colspan="3">
                                                    <input type="text" class="form-control" name="centerNumber" placeholder="010-1234-1234" value="${centerInfo.centerNumber}" required onkeypress="onlyNumber();">
                                                </td>
                                            </tr>
                                            <tr>
                                                <th><span class="fix">*</span>수용인원(명)</th>
                                                <td>
                                                    <input type="text" class="form-control" name="totalCapacity" value="${centerInfo.totalCapacity}" required onkeypress="onlyNumber();">
                                                </td>
                                                <th><span class="fix">*</span>의료진수 (명)</th>
                                                <td>
                                                    <input type="text" class="form-control" name="totalStaff" value="${centerInfo.totalStaff}" required onkeypress="onlyNumber();">
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>담당자 아이디</th>
                                                <td>
                                                    <c:out value="${centerInfo.staffId}" />
                                                    <input type="hidden" name="staffId" value="${centerInfo.staffId}">
                                                </td>
                                                <th><span class="fix">*</span>담당자 이름</th>
                                                <td>
                                                    <input type="text" class="form-control" name="staffName" value="${centerInfo.staffName}" required>
                                                </td>
                                            </tr>
                                            <tr>
                                                
                                                <th><span class="fix">*</span>담당자 전화번호</th>
                                                <td colspan="3">
                                                    <input type="text" class="form-control" name="staffPhoneNumber" value="${centerInfo.staffPhoneNumber}" placeholder="010-1234-1234" required onkeypress="onlyNumber();">
                                                </td>
                                            </tr>
                                            <tr>
                                               <th><span class="fix">*</span>현재 비밀번호</th>
                                                <td colspan="3">
                                                    <input type="password" class="form-control" name="staffPw" placeholder="정보수정을 위해 비밀번호를 입력해주세요." required>
                                                </td>
                                            </tr>
                                            <tr>
                                               <th>신규 비밀번호</th>
                                                <td colspan="3">
                                                    <input type="password" class="form-control" id="staffNewPw" name="staffNewPw" placeholder="비밀번호 변경시에만 입력해주세요.(영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)">
                                                </td>
                                            </tr>
                                            <tr>
                                               <th>신규 비밀번호 확인</th>
                                                <td colspan="3">
                                                    <input type="password" class="form-control" id="staffNewPwConfirm" name="staffNewPwConfirm" placeholder="신규 비밀번호 확인을 위해 비밀번호를 한번 더 입력하세요.">
                                                </td>
                                            </tr>
                                        </table>
                                        <div class="row mt-3">
                                            <div class="col-12">
                                                <div class="text-right">
                                                    <button type="button" class="btn btn-outline-primary w100" onclick="location.href='./list';">취소</button>
                                                    <button type="submit" class="btn btn-primary w100">수정</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                    <!-- 환자관리 : 신규환자 등록 END -->
                </div>
            </main>

            <jsp:include page="${data._INCLUDE}/footer.jsp"></jsp:include>
        </div>
    </div>
</body>
</html>