<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
<span data-doctx="${pageName}">
	<form name="frmEdit">
		<div class="d-flex flex-row justify-content-evenly">
			<div class="card" style="width:1000px;min-height:200px;">
				<div class="row">
					<div class="col-4">
						<label is="name-label" for="taskSeCd" 
						class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">업무</label>
						<select is="id-select" name="taskSeCd" class="form-select">
							<c:forEach items="${taskSeCdList}" var="item">
								<option value="${item.CODE}">${item.CODE_VAL}</option>
							</c:forEach>
						</select>
					</div>
					<div class="col-4">
						<label is="name-label" for="srcSgg" 
						class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">소스 시군구</label>
						<select is="id-select" name="srcSgg" class="form-select">
							<c:forEach items="${sggList}" var="item">
								<option value="${item.SGG_CD}">${item.SGG_NM}</option>
							</c:forEach>	
						</select>
					</div>
					<div class="col-4">
						<label is="name-label" for="trgtSgg" 
						class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">타겟 시군구</label>
						<select is="id-select" name="trgtSgg" class="form-select">
							<c:forEach items="${sggList}" var="item">
								<option value="${item.SGG_CD}">${item.SGG_NM}</option>
							</c:forEach>
						</select>
					</div>
					<div class="col-12">
						<span class="float-end p-4">
							<button type="button" name="btnCopyStng" class="btn btn-primary">업무,위반 설정 복사</button>
						</span>
					</div>
				</div>
				
			</div>
		</div>
	</form>
</span>
<script>
pageObject['${pageName}'] = newDoctxFinder("${pageName}");
$(document).ready(function() {
	let $P = pageObject['${pageName}'];
	$P.$findn("btnCopyStng").on("click", function(){
		
		if($P.$findn("srcSgg").val() == $P.$findn("trgtSgg").val()){
			alert("동일한 시군구 선택 불가");
			return;
		}
		
		ajax.get({
			url : wctx.url("admin/copySggStng.do"),
			data : {
				taskSeCd : $P.$findn("taskSeCd").val(),
				srcSgg : $P.$findn("srcSgg").val(),
				trgtSgg : $P.$findn("trgtSgg").val()
			},
			success : (resp) => {
				if(resp.saved){
					alert('완료');
				}
			}
		});
	});
	
});
</script>