<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layout/layout}">
<th:block layout:fragment="css">
  <style>
    .orderNumInput{
      width:60px;
      text-align: center;
    }
  </style>
</th:block>
<th:block layout:fragment="script">
  <script type="text/javascript" th:src="@{/js/user/info.js}"></script>
  <script type="text/javascript" th:src="@{/js/modal/menuModal.js}"></script>
</th:block>
<div layout:fragment="content">
  <main class="pt-3">
    <h4>마이페이지</h4>
    <div class="row mx-0">
      <div class="col-12 card">
        <div class="card-body">
          <ul class="nav nav-tabs" id="userTab" role="tablist">
            <li class="nav-item" role="presentation">
              <button class="nav-link active" id="infoTab" data-bs-toggle="tab" data-bs-target="#infoTabPanel" type="button" role="tab" aria-controls="infoTabPanel" aria-selected="true">개인정보</button>
            </li>
            <li class="nav-item" role="presentation">
              <button class="nav-link" id="dashboardTab" data-bs-toggle="tab" data-bs-target="#dashboardTabPanel" type="button" role="tab" aria-controls="dashboardTabPanel" aria-selected="false">대시보드</button>
            </li>
          </ul>
          <div class="tab-content border border-top-0 p-2">
            <div class="tab-pane fade p-2 show active" id="infoTabPanel" role="tabpanel" aria-labelledby="infoTabPanel" tabindex="0">
              <div class="row justify-content-start">
                <div class="col-7">
                  <form id="userInfoUpdate" action="#" method="post">
                    <input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
                    <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
                    <div class="mb-3 mt-3 row">
                      <label for="dicCode" class="col-sm-2 col-form-label col-form-label-sm text-center ">공무원식별번호</label>
                      <div class="col-sm-4">
                        <input type="text" class="form-control form-control-sm" id="dicCode" name="dicCode" autocomplete="off" th:value="${userInfo.dicCode}">
                      </div>
                      <div class="col-sm-6">
                        <div class="row justify-content-end">
                          <div class="col-auto">
                            <button type="button" class="btn btn-sm btn-info" id="syncBtn" th:disabled="${#strings.isEmpty(userInfo.dicCode)}">인사시스템 정보 연동</button>
                            <label for="syncBtn" style="font-size: 12px" th:if="${#strings.isEmpty(userInfo.dicCode)}">공무원식별번호가 필요합니다.</label>
                          </div>
                          <div class="col-auto">
                            <button type="button" class="btn btn-sm btn-primary" id="updateBtn">수정</button>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="mb-3 row">
                      <label for="userId" class="col-sm-2 col-form-label col-form-label-sm text-center ">아이디</label>
                      <div class="col-sm-4">
                        <input type="text" class="form-control form-control-sm" id="userId" name="userId" autocomplete="off" th:value="${userInfo.userId}" readonly>
                        <label for="userId" style="font-size: 12px">아이디는 수정할 수 없습니다.</label>
                      </div>
                      <label for="userNm" class="col-sm-2 col-form-label col-form-label-sm text-center">이름</label>
                      <div class="col-sm-4">
                        <input type="text" class=" form-control form-control-sm" id="userNm" name="userNm" autocomplete="off" th:value="${userInfo.userNm}">
                      </div>
                    </div>
                    <div class="mb-3 row">
                      <label for="modalPassword" class="col-sm-2 col-form-label col-form-label-sm text-center">비밀번호</label>
                      <div class="col-sm-4">
                        <input type="password" class="form-control form-control-sm" id="modalPassword" name="password" autocomplete="off">
                        <label for="userId" style="font-size: 12px">8~16자 사이의 알파벳, 숫자, 특수문자 조합</label>
                      </div>
                      <label for="passwordConfirm" class="col-sm-2 col-form-label col-form-label-sm text-center">비밀번호 확인</label>
                      <div class="col-sm-4">
                        <input type="password" class="form-control form-control-sm" id="passwordConfirm">
                      </div>
                    </div>
                    <div class="mb-3 row">
                      <label for="phoneNo" class="col-sm-2 col-form-label col-form-label-sm text-center">휴대전화</label>
                      <div class="col-sm-4">
                        <input type="tel" class="form-control form-control-sm" id="phoneNo" name="phoneNo" th:value="${userInfo.phoneNo}">
                      </div>
                      <label for="email" class="col-sm-2 col-form-label col-form-label-sm text-center">이메일</label>
                      <div class="col-sm-4">
                        <input type="email" class="form-control form-control-sm" id="email" name="email" th:value="${userInfo.email}">
                      </div>
                    </div>
                    <div class="mb-3 row">
                      <label for="sex" class="col-sm-2 col-form-label col-form-label-sm text-center">성별</label>
                      <div class="col-sm-4">
                        <select class="form-select form-select-sm" id="sex" name="sex">
                          <option value="SEX002" th:selected="${userInfo.sex eq 'SEX002'}">남</option>
                          <option value="SEX001" th:selected="${userInfo.sex eq 'SEX001'}">여</option>
                        </select>
                      </div>
                    </div>
                    <div class="mb-3 row">
                      <label for="birthDate" class="col-sm-2 col-form-label col-form-label-sm text-center">생년월일</label>
                      <div class="col-sm-4">
                        <input type="text" class="form-control form-control-sm dateSelector" id="birthDate" name="birthDate" th:value="${userInfo.birthDate}" readonly>
                      </div>
                      <label for="policeInDate" class="col-sm-2 col-form-label col-form-label-sm text-center">해양경찰배명일</label>
                      <div class="col-sm-4">
                        <input type="text" class="form-control form-control-sm dateSelector" id="policeInDate" name="policeInDate" th:value="${userInfo.policeInDate}" readonly>
                      </div>
                    </div>
                    <div class="mb-3 row">
                      <label for="ogCd" class="col-sm-2 col-form-label col-form-label-sm text-center">관서</label>
                      <div class="col-sm-4">
                        <select class="form-select form-select-sm" id="ogCd" name="ogCd">
                          <option value="">--선택--</option>
                          <th:block th:each="code:${ogList}">
                            <option th:value="${code.itemCd}" th:text="${code.itemValue}" th:selected="${code.itemCd eq userInfo.ogCd}"></option>
                          </th:block>
                        </select>
                      </div>
                      <label for="organInDate" class="col-sm-2 col-form-label col-form-label-sm text-center">현관서전입일</label>
                      <div class="col-sm-4">
                        <input type="text" class="form-control form-control-sm dateSelector" id="organInDate" name="organInDate" th:value="${userInfo.organInDate}" readonly>
                      </div>
                    </div>
                    <div class="mb-3 row">
                      <label for="ofcCd" class="col-sm-2 col-form-label col-form-label-sm text-center">부서</label>
                      <div class="col-sm-4">
                        <select class="form-select form-select-sm" id="ofcCd" name="ofcCd">
                          <option value="">--선택--</option>
                          <th:block th:each="code:${ofcList}">
                            <option th:value="${code.itemCd}" th:text="${code.itemValue}" th:selected="${code.itemCd eq userInfo.ofcCd}"></option>
                          </th:block>
                        </select>
                      </div>
                      <label for="ofcInDate" class="col-sm-2 col-form-label col-form-label-sm text-center">현부서임용일</label>
                      <div class="col-sm-4">
                        <input type="text" class="form-control form-control-sm dateSelector" id="ofcInDate" name="ofcInDate" th:value="${userInfo.ofcInDate}" readonly>
                      </div>
                    </div>
                    <div class="mb-3 row">
                      <label for="ogCd" class="col-sm-2 col-form-label col-form-label-sm text-center">계급</label>
                      <div class="col-sm-4">
                        <select class="form-select form-select-sm" id="titleCd" name="titleCd">
                          <option value="">--선택--</option>
                          <th:block th:each="code:${titleList}">
                            <option th:value="${code.itemCd}" th:text="${code.itemValue}" th:selected="${code.itemCd eq userInfo.titleCd}"></option>
                          </th:block>
                        </select>
                      </div>
                      <label for="titleInDate" class="col-sm-2 col-form-label col-form-label-sm text-center">현계급임용일</label>
                      <div class="col-sm-4">
                        <input type="text" class="form-control form-control-sm dateSelector" id="titleInDate" name="titleInDate" th:value="${userInfo.titleInDate}" readonly>
                      </div>
                    </div>
                    <div class="mb-3 row">
                      <label for="outturnCd" class="col-sm-2 col-form-label col-form-label-sm text-center">경과</label>
                      <div class="col-sm-4">
                        <select class="form-select form-select-sm" id="outturnCd" name="outturnCd">
                          <option value="">--선택--</option>
                          <th:block th:each="code:${outturnList}">
                            <option th:value="${code.itemCd}" th:text="${code.itemValue}" th:selected="${code.itemCd eq userInfo.outturnCd}"></option>
                          </th:block>
                        </select>
                      </div>
                      <label for="seriesCd" class="col-sm-2 col-form-label col-form-label-sm text-center">직별</label>
                      <div class="col-sm-4">
                        <select class="form-select form-select-sm" id="seriesCd" name="seriesCd">
                          <option value="">--선택--</option>
                          <th:block th:each="code:${seriesList}">
                            <option th:value="${code.itemCd}" th:text="${code.itemValue}" th:selected="${code.itemCd eq userInfo.seriesCd}"></option>
                          </th:block>
                        </select>
                      </div>
                    </div>
                    <div class="mb-3 row">
                      <label for="languageCd" class="col-sm-2 col-form-label col-form-label-sm text-center">외국어특채</label>
                      <div class="col-sm-4">
                        <select class="form-select form-select-sm" id="languageCd" name="languageCd">
                          <option value="">--선택--</option>
                          <th:block th:each="code:${languageList}">
                            <option th:value="${code.itemCd}" th:text="${code.itemValue}" th:selected="${code.itemCd eq userInfo.languageCd}"></option>
                          </th:block>
                        </select>
                      </div>
                    </div>
                  </form>
                </div>
              </div>
            </div>
            <div class="tab-pane fade p-2" id="dashboardTabPanel" role="tabpanel" aria-labelledby="dashboardTab" tabindex="0">
              <div class="row justify-content-end">
                <div class="col-auto">
                  <button type="button" class="btn btn-outline-info" data-bs-toggle="modal" data-bs-target="#questionModal">
                    <i class="bi bi-question-lg"></i>
                  </button>
                </div>
              </div>
              <table class="table table-bordered table-hover">
                <thead>
                <tr class="table-secondary">
                  <th><input type="checkbox" class="allChk"></th>
                  <th>순번</th>
                  <th>대분류</th>
                  <th>중분류</th>
                  <th>소분류</th>
                  <th>url</th>
                  <th>위치변경</th>
                </tr>
                </thead>
                <tbody id="dashboardConfigTbody">
                <tr class="configTr" th:each="dashboardConfig, idx:${dashboardConfigList}">
                  <td><input type="checkbox" class="configChkBox" th:data-menukey="${dashboardConfig.menuKey}"></td>
                  <td>
                    <input type="text" class="border-0 orderNumInput" th:value="${dashboardConfig.orderNum}" readonly>
                  </td>
                  <th:block th:each="commonCode:${session.commonCode.get('CAT1')}">
                    <td th:if="${commonCode.itemCd eq dashboardConfig.cat1Cd}" th:text="${commonCode.itemValue}"></td>
                  </th:block>
                  <th:block th:if="${#strings.isEmpty(dashboardConfig.cat2Cd)}"><td></td></th:block>
                  <th:block th:unless="${#strings.isEmpty(dashboardConfig.cat2Cd)}" th:each="commonCode:${session.commonCode.get('CAT2')}">
                    <td th:if="${commonCode.itemCd eq dashboardConfig.cat2Cd}" th:text="${commonCode.itemValue}"></td>
                  </th:block>
                  <th:block th:if="${#strings.isEmpty(dashboardConfig.cat3Cd)}"><td></td></th:block>
                  <th:block th:unless="${#strings.isEmpty(dashboardConfig.cat3Cd)}" th:each="commonCode:${session.commonCode.get('CAT3')}">
                    <td th:if="${commonCode.itemCd eq dashboardConfig.cat3Cd}" th:text="${commonCode.itemValue}"></td>
                  </th:block>
                  <td th:text="${dashboardConfig.menuUrl}"></td>
                  <td class="moveTd">
                    <input type="button" class="btn btn-sm btn-outline-dark upBtn" value="▲">
                    <input type="button" class="btn btn-sm btn-outline-dark downBtn" value="▼">
                  </td>
                </tr>
                </tbody>
              </table>
              <div class="row justify-content-between">
                <div class="col-auto">
                  <input type="button" class="btn btn-danger" id="configDeleteBtn" value="삭제">
                </div>
                <div class="col-auto">
                  <input type="button" class="btn btn-success" id="configAddBtn" value="추가">
                  <input type="button" class="btn btn-primary" id="configSaveBtn" value="저장">
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </main>

  <div class="modal fade" id="menuModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="menuModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-xl modal-dialog-scrollable">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="menuModalLabel">메뉴 추가</h5>
          <input type="hidden" id="modalUrl" value="/modal/menuModal">
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body" id="subModalBody">
          <div class="row">
            <div class="col-12">
              <form method="get" action="#" id="modalSearchForm">
                <input type="hidden" name="pageIndex" id="modalPageIndex" value="1">
                <div class="row justify-content-between pe-3 py-1">
                  <div class="col-auto">
                    <input type="hidden" name="rowCnt" value="10">
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-primary" id="getMenuBtn">추가</button>
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
        </div>
      </div>
    </div>
  </div>

  <div class="modal fade" id="questionModal" tabindex="-1" aria-labelledby="questionModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h1 class="modal-title fs-5" id="questionModalLabel">안내</h1>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body">
          <p>대시보드에 노출될 게시판을 선택하여 저장합니다.</p>
          <p>저장에 제한은 없으나 상위 5건과 공지사항만 대시보드에 노출됩니다.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>
</div>
</html>