<%@ 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="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

<div class="row justify-content-between bg-white mx-3 py-2">
    <form:form commandName="userVO" name="updateForm" id="updateForm" action="/admin/userUpdate" method="post">
        <div class="section_content">
            <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
            <input type="hidden" name="userid" value="${userVO.userid}"/>

            <table class="join_table">
                <tbody>
                <tr>
                    <th>아이디</th>
                    <td>${userVO.userid}</td>
                </tr>
                <tr>
                    <th><label for="password">비밀번호</label></th>
                    <td>
                        <p><label for="changePw"><input type="checkbox" id="changePw"/> 비밀번호 변경</label></p>
                        <input type="password" class="form-control" id="password" name="password" value=""
                               disabled="true"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="passwordCheck">비밀번호 확인</label></th>
                    <td><input type="password" class="form-control" id="passwordCheck" name="passwordCheck" value=""
                               disabled="true"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="name">이름</label></th>
                    <td><input type="text" class="form-control" name="name" id="name" value="${userVO.name}"/></td>
                </tr>
                <tr>
                    <th><label for="company">소속기관</label></th>
                    <td><input type="text" class="form-control" name="company" id="company" value="${userVO.company}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="phonenum">연락처</label></th>
                    <td><input type="text" class="form-control" name="phonenum" id="phonenum"
                               value="${userVO.phonenum}"/></td>
                </tr>
                <tr>
                    <th><label for="email">이메일</label></th>
                    <td>
                        <div>
                            <input type="text" class="form-control" name="email" id="email" value="${userVO.email}"/>
                        </div>
                    </td>
                </tr>

                <c:if test="${userVO.auth ne '99'}">
                    <tr>
                        <th>권한</th>
                        <td>
                            <input type="radio" name="auth" id="auth2" value="2"
                                   <c:if test="${userVO.auth eq '2'}">checked</c:if>/>
                            <label for="auth2" class="auth-label">사용자</label>
                            <input type="radio" name="auth" id="auth1" value="1"
                                   <c:if test="${userVO.auth eq '1'}">checked</c:if>/>
                            <label for="auth1" class="auth-label">관리자</label>
                        </td>
                    </tr>
                </c:if>
                </tbody>
            </table>
            <div class="join_top mt-3">
              <p class="search_p1">
                <input class="btn btn-secondary" type="button" value="닫기" data-bs-dismiss="modal"/>
              </p>
                <p class="search_p2">
                    <c:choose>
                        <c:when test="${userVO.auth eq '99'}">
                            <input type="button" class="btn btn-success" value="승인"
                                   onclick="confirmBtn('${userVO.userid}','2'); return false;"/>
                            <input type="button" class="btn btn-danger" value="삭제"
                                   onclick="confirmBtn('${userVO.userid}','-1'); return false;"/>
                        </c:when>
                        <c:otherwise>
                            <input class="btn btn-success" type="button" value="수정" onclick="update();"/>
                        </c:otherwise>
                    </c:choose>
                </p>
            </div>
        </div>
    </form:form>
</div>
