<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
              <form id="infoPrefix-form">
                <div class="row g-3">
                  <div class="col-md-6">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="account"
                        >계정</label
                      >
                      <div class="col-sm-9">
                        <input name="id" type="hidden" data-map="USER_ID" />
                        <input name="institute" type="hidden" data-map="NSTT_CD" />
                        <input name="account" type="text" required data-map="USER_ACNT" class="form-control" placeholder="prefixName 계정" />
                      </div>
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="name"
                        >이름</label
                      >
                      <div class="col-sm-9">
                        <input name="name" type="text" required  data-map="USER_NM" class="form-control" placeholder="prefixName 이름" />
                      </div>
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="password"
                        >비밀번호</label
                      >
                      <div class="col-sm-9">
                        <input name="password" type="password" required class="form-control" placeholder="비밀번호" />
                      </div>
                    </div>
                  </div>
                  <div class="col-md-6 hidden">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="confirmPassword"
                        >비밀번호 확인</label
                      >
                      <div class="col-sm-9">
                        <input name="confirmPassword" type="password" required class="form-control" placeholder="비밀번호 확인" />
                      </div>
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="birthday"
                        >생년월일</label
                      >
                      <div class="col-sm-9">
                        <input name="birthday" type="text" data-map="BRDT" class="form-control dob-picker" placeholder="YYYY-MM-DD"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="gender"
                        >성별</label
                      >
                      <div class="col-sm-9">
						<div class="form-check form-check-inline mt-3">
						  <input name="gender" value="M" type="radio" data-map="GENDER" class="form-check-input"/>
						  <label class="form-check-label" for="male">남자</label>
						</div>
						<div class="form-check form-check-inline">
						  <input name="gender" value="F" type="radio" data-map="GENDER" class="form-check-input"/>
						  <label class="form-check-label" for="female">여자</label>
						</div>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="emailAddress"
                        >이메일 주소</label
                      >
                      <div class="col-sm-9">
                        <input name="emailAddress" type="email" required data-map="EML_ADRS" class="form-control" placeholder="이메일 주소" />
                      </div>
                    </div>
                  </div>
                  <div class="col-md-6 select2-primary">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="mobilePhoneNo"
                        >전화번호(무선)</label
                      >
                      <div class="col-sm-9">
                        <input name="mobilePhoneNo" type="text" data-map="MBL_TELNO" class="form-control phone-mask" placeholder="010-0000-0000" />
                      </div>
                    </div>
                  </div>
                  <div class="col-md-6 select2-primary">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="phoneNo"
                        >전화번호(유선)</label
                      >
                      <div class="col-sm-9">
                        <input name="phoneNo" type="text" data-map="TELNO" class="form-control phone-mask" placeholder="000-0000-0000" />
                      </div>
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="faxNo">팩스</label>
                      <div class="col-sm-9">
                        <input name="faxNo" type="text" data-map="FXNO" class="form-control phone-mask" placeholder="000-0000-0000"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for=positionName>직위</label>
                      <div class="col-sm-9">
                        <input name="positionName" type="text" data-map="POS_NM" class="form-control" placeholder="직위"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="status">상태</label>
                      <div class="col-sm-9">
                        <input name="status" type="text" data-map="STTS" class="form-control" placeholder="상태"/>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="row mt-4 justify-content-end">
                  <div class="col-md-6">
                    <div class="row justify-content-end">
                      <div class="col-sm-3">
                        <button onclick="saveinfoPrefix();" type="button" class="btn btn-primary">저장</button>
                      </div>
                    </div>
                  </div>
                </div>
              </form>
<script type="text/javascript">

var infoPrefixFields = new FormFields("#infoPrefix-form");

infoPrefixControl.setInfo = obj => {
	infoPrefixFields.set(obj);
	let create = isEmpty(obj.data.USER_ACNT);
	$("input[name='account']").prop("readonly", !create);
	$("input[type='password']").each(function(){
		let password = $(this).prop("required", create);
		let div = password.parent().parent().parent();
		if (create) {
			$("input[name='institute']").val("default");
			div.show();
		} else
			div.hide();
	});
	$("#infoPrefix-form input")
		.change(function() {
			let input = $(this),
				name = input.attr("data-map"),
				val = input.val();
			infoPrefixControl.setValue(name, val);
		})
		.onEnterPress(saveinfoPrefix);
	
	document.querySelector("input[name='" + (create ? "account" : "name") + "']").focus();
}

infoPrefixControl.onModify = (changed) => {
	if (["USER_NM", "EML_ADRS", "MBL_TELNO"].filter(e => changed.includes(e)).length < 1)
		return;
	
	renderinfoPrefixList();
	infoPrefixControl.dataset.setState();
}

function saveinfoPrefix() {
	if (!$("#infoPrefix-form input").validInputs()) return;
	
	let match = Array.from(document.querySelectorAll("input[type='password']"))
		.map(input => input.value)
		.reduce((total, current) => total == current);
	if (!match) {
		dialog.alert({
			content:"비밀번호와 비밀번호 확인이 다릅니다.",
			onClose:function(){
				document.querySelector("input[name='confirmPassword']").focus();
			}
		});
		return;
	}
	
	dialog.alert({
		content:"현재 prefixName 정보를 저장하시겠습니까?",
		onOK:() => {
			infoPrefixControl.save(infoPrefixFields.get());
		}
	});
}
//# sourceURL=user-info.jsp
</script>