<%@ 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="sgg-form">
                <div class="row g-3">
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end">시군구</label>
                      <div class="col-sm-9">
                      	<div class="row justify-content-between" style="padding: 0 .75rem;">
	                        <input name="sggID" type="text" required data-map="SGG_CD" maxlength="5" class="form-control" style="width: 28%;" placeholder="시군구 코드" />
                        	<input name="sggName" type="text" required  data-map="SGG_NM" maxlength="60" class="form-control" style="width: 70%;" placeholder="시군구 이름" />
                      	</div>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end">기관</label>
                      <div class="col-sm-9">
                      	<div class="row justify-content-between" style="padding: 0 .75rem;">
	                        <select name="instType" data-map="INST_SE_CD" class="form-control" style="width: 24%;">
	                        	<option value="">구분</option>
	                        	<option value="01">시청</option>
	                        	<option value="02">구청</option>
	                        	<option value="03">군청</option>
	                        	<option value="04">도청</option>
	                        	<option value="05">출장소</option>
	                        	<option value="06">사무소</option>
	                        </select>
                        	<input name="instCode" type="text" data-map="INST_CD" maxlength="7" class="form-control" style="width: 25%;" placeholder="기관 코드"/>
                        	<input name="instName" type="text" data-map="INST_NM" maxlength="100" class="form-control" style="width: 48%;" placeholder="기관 이름"/>
                      	</div>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end">주소</label>
                      <div class="col-sm-9">
                      	<div class="row justify-content-between" style="padding: 0 .75rem;">
	                        <input name="instAddress" type="text" data-map="INST_ADDR" maxlength="200" class="form-control" placeholder="주소"/>
                        	<input name="instDetailAddress" type="text" data-map="INST_DADDR" maxlength="200" class="form-control" style="margin: .5rem 0;" placeholder="상세주소"/>
                        	<input name="instZipCode" type="text" data-map="INST_ZIP" maxlength="6" class="form-control" style="width: 32%;" placeholder="기관 우편번호"/>
                      	</div>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end">직인 파일</label>
                      <div class="col-sm-9">
                      	<div class="row justify-content-between" style="padding: 0 .75rem;">
                        	<input name="officialSealFilepath" type="text" data-map="OFFCS_FILE_PATH" maxlength="200" class="form-control" placeholder="직인 파일경로"/>
                        	<input name="officialSealFilename" type="text" data-map="OFFCS_FILE_NM" maxlength="100" class="form-control" style="margin: .5rem 0;" placeholder="직인 파일이름"/>
                      	</div>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="createdBy">등록자</label>
                      <div class="col-sm-9">
                        <input type="text" data-map="RGTR" readonly class="form-control" placeholder="등록자"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end">등록일자</label>
                      <div class="col-sm-9">
                        <input type="text" data-map="REG_DT" readonly class="form-control" placeholder="등록일자"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end">사용여부</label>
                      <div class="col-sm-9" style="padding:.5em .7em;">
                        <input name="useYN" type="hidden" data-map="USE_YN" />
                      	<span id="sggInUse"></span>
                      </div>
                    </div>
                  </div>
                <div class="row mt-4 justify-content-end">
                      <div class="col-sm-12" style="text-align:right;">
                        <button onclick="saveSgg();" type="button" class="btn btn-primary">저장</button>
                      </div>
                </div>
              </form>
<script type="text/javascript">

var sggFields = new FormFields("#sgg-form");

sggDeptControl.sggs.setInfo = obj => {
	let info = obj.data;
	sggFields.set(sggDeptControl.sggs, obj);
	let create = isEmpty(info.SGG_CD);
	$("input[name='sggID']").prop("readonly", !create);
	$("#sgg-form input").onEnterPress(saveSgg);
	$("#sggInUse").html(info.USE_YN == "Y" ? "사용 중" : "사용하지 않음");
	
	document.querySelector("input[name='" + (create ? "sggID" : "sggName") + "']").focus();
}

sggDeptControl.sggs.onModify = (changed) => {
	if (["SGG_NM"].filter(e => changed.includes(e)).length < 1)
		return;
	
	renderSggList();
	sggDeptControl.sggs.dataset.setState();
}

function saveSgg() {
	if (!$("#sgg-form input").validInputs()) return;
	
	dialog.alert({
		content:"현재 시군구 정보를 저장하시겠습니까?",
		onOK:() => sggDeptControl.sggs.save(sggFields.get())
	});
}
//# sourceURL=sgg-info.jsp
</script>