<%@ 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>
$( function(){
    $( "#newForm" ).validate({
        rules: {
            name : {
                minlength : 2,
                maxlength : 100
            },
            id: {
                minlength : 4,
                maxlength : 20,
                idValid :  true,
                remote : { 
                    type : "POST",
                    url  : "/staff/duplicateIdCheck",
                    data : { 
                        staffId : function(){
                            return $( "input[name='id']" ).val();
                        }
                    }
                }
            },
            phoneNumber : {
                phoneValid : true
            },
            password : {
                minlength : 8,
                maxlength : 15,
                passwordValid : true,
            },
            passwordConfirm : {
                equalTo: "#password",
            }
        },
        messages : {
            id : {
                remote : "이미 존재하는 아이디입니다"
            },
            password : {
                minlength : "비밀번호를 확인하세요 (영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)",
                maxlength : "비밀번호를 확인하세요 (영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)"
            },
            passwordConfirm : {
                equalTo: "비밀번호가 일치하지 않습니다.",
            }
        },
        onkeyup: function( element, event ) {
            $( element ).valid();
        },
        onfocusout: function (element) {
            $( element ).val( $.trim( $( element ).val() ) );
            $( element ).valid();
        },
        submitHandler: function(form) {
            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="./new/regist" 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><span class="fix">*</span>아이디</th>
                                                <td>
                                                    <input type="text" class="form-control" name="id" required>
                                                    <!-- <button class="btn btn-primary">중복확인</button> -->
                                                </td>
                                                <th><span class="fix">*</span>이름</th>
                                                <td>
                                                    <input type="text" class="form-control" name="name" required>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th><span class="fix">*</span>비밀번호</th>
                                                <td colspan="3">
                                                    <input type="password" id="password" class="form-control pass-group" name="password" placeholder="숫자, 영문, 특수문자 조합 8~15자 이내" required>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th><span class="fix">*</span>비밀번호 확인</th>
                                                <td colspan="3">
                                                    <input type="password" id="passwordConfirm" class="form-control" name="passwordConfirm" placeholder="비밀번호 확인을 위해 비밀번호를 한번 더 입력하세요." required>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th><span class="fix">*</span>휴대폰번호</th>
                                                <td>
                                                    <input type="text" class="form-control" name="phoneNumber" placeholder="'-'를 제외한 숫자만 입력하세요" required>
                                                </td>
                                                <th>치료센터</th>
                                                <td>
                                                    <select class="custom-select" name="centerCode">
                                                        <c:forEach var="i" items="${centerList}">
                                                            <option value="${i.centerCode}"><c:out value="${i.centerName}" /></option>
                                                        </c:forEach>
                                                        
                                                        <!-- <option selected="">센터-2</option> -->
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th><span class="fix">*</span>권한</th>
                                                <td>
                                                    <select class="custom-select" name="encryptIdx">
                                                        <c:forEach var="gl" items="${groupList}"> 
                                                            <option value="${gl.encryptIdx}"><c:out value="${gl.groupName}"/></option>
                                                        </c:forEach>
                                                    </select>
                                                </td>
                                                <th><span class="fix">*</span>상태</th>
                                                <td>
                                                    <label class="form-check form-check-inline">
                                                        <input class="form-check-input" type="radio" name="useYn" value="Y" checked>
                                                        <span class="form-check-label">
                                                          활성화
                                                        </span>
                                                    </label>
                                                    <label class="form-check form-check-inline">
                                                        <input class="form-check-input" type="radio" name="useYn" value="N">
                                                        <span class="form-check-label">
                                                          비활성화
                                                        </span>
                                                    </label>
                                                </td>
                                            </tr>
                                        </table>
                                        <div class="row mt-3">
                                            <div class="col-12">
                                                <div class="text-right">
                                                    <button class="btn btn-outline-primary w100">취소</button>
                                                    <button 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>