<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
<c:set var="pageKorName" scope="request">단속자료 수기 등록</c:set>
<div class="d-flex flex-row justify-content-evenly" data-doctx="${pageName}">
	<div class="card mw-px-1000">
		<form name="frmEdit">
			<input type="hidden" name="crdnId" data-map="CRDN_ID" />
			<input type="hidden" name="rtpyrId" data-map="RTPYR_ID"/>
			<input type="hidden" name="addrSn" data-map="ADDR_SN"/>
			<input type="hidden" name="sggCd" value="${sggCd}" />
			<input type="hidden" name="taskSeCd" value="${taskSeCd}" />
			<div class="row g-1">
				<div class="col-md-12" slot="edit">
					<template class="rvs pvs bpv">
						<slot>
							<label is="name-label" for="crdnSeCd"
							class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
							단속구분
							</label>
							<select is="id-select" name="crdnSeCd"
							data-map="CRDN_SE_CD" class="form-select">
								<c:forEach items="${FIM002List}" var="item">
									<option value="${item.code}">${item.value}</option>
				                </c:forEach>
							</select>
						</slot>
					</template>
				</div>
				<div class="col-md-4">
					<label is="name-label" for="crdnYmd"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end required">
						위반일자
					</label>
					<input type="text" is="id-input" name="crdnYmd" data-map="CRDN_YMD"
						class="form-control form-date" data-fmt-type="day" maxlength="10" required />
		            <button type="button" class="bx bx-lg bx-calendar bg-white"></button>
				</div>
				<div class="col-md-4">
					<label is="name-label" for="crdnTm"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end required">
						위반시간
					</label>
		            <input type="text" is="id-input" name="crdnTm" data-map="CRDN_TM"
		            	class="form-control form-time" data-fmt-type="time" maxlength="8" required
		            	placeholder="시:분:초" autofocus />
				</div>
				<div class="col-md-4">
					<label is="name-label" for="vhrno"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end required">
						차량번호
					</label>
					<input type="text" is="id-input" name="vhrno" data-map="VHRNO" class="form-control"
						data-maxlengthb="30" required />
				</div>
				<div class="col-md-4">
					<label is="name-label" for="vltnCd"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
						위반내용
					</label>
					<select is="id-select" name="vltnCd" class="form-select" data-map="VLTN_CD">
						<c:forEach items="${VLTNList}" var="item">
							<option value="${item.code}">${item.value}</option>
		                </c:forEach>
					</select>
				</div>
				<div class="col-md-4 select2-primary">
					<label is="name-label" for="crdnStdgNm"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
						법정동
					</label>
					<input type="text" is="id-input" name="crdnStdgNm" data-map="CRDN_STDG_NM"
						class="form-control w-px-150" list="stdgNmList" />
					<datalist is="id-datalist" name="stdgNmList">
						<c:forEach items="${stdgNmList}" var="item">
							<option value="${item}"></option>
						</c:forEach>
					</datalist>
				</div>
				<div class="col-md-4 select2-primary">
					<label is="name-label" for="crdnRoadNm"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
					도로명
					</label>
					<input type="text" is="id-input" name="crdnRoadNm" data-map="CRDN_ROAD_NM"
						class="form-control" />
				</div>
				<div class="col-md-6">
					<label is="name-label" for="crdnPlc"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
					단속장소
					</label>
					<input type="text" is="id-input" name="crdnPlc" data-map="CRDN_PLC"
						class="form-control w-px-300" data-maxlengthb="200" />
				</div>
				<div class="col-md-6" slot="edit">
					<template class="bpv">
						<slot>
							<label is="name-label" for="dtlCrdnPlc"
							class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
							상세단속장소
							</label>
							<input type="text" is="id-input" name="dtlCrdnPlc"
							data-map="DTL_CRDN_PLC" class="form-control"
								data-maxlenghb="200" />
						</slot>
					</template>
					<template class="pvs">
						<slot>
							<label is="name-label" for="crdnSpareaCd"
							class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
							특별구역
							</label>
							<select is="id-select" name="crdnSpareaCd"
							data-map="CRDN_SPAREA_CD" class="form-select">
								<c:forEach items="${FIM007List}" var="item">
									<option value="${item.code}">${item.value}</option>
				                </c:forEach>
							</select>
						</slot>
					</template>
				</div>
				<div class="col-md-12">
					<label is="name-label" for="etcCn"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
					특기사항
					</label>
					<input type="text" is="id-input" name="etcCn"
					data-map="ETC_CN" class="form-control"
						data-maxlengthb="1000" />
				</div>
			</div>
			<div class="row my-1 mx-4 g-1 border-card rounded-3">
				<div class="col-md-4">
					<label is="name-label" for="rtpyrNm"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">납부자명</label>
					<input type="text" is="id-input" name="rtpyrNm" data-map="RTPYR_NM"
						class="form-control" readonly
						/>
				</div>
				<div class="col-md-3">
					<label is="name-label" for="rtpyrSeCd"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">납부자구분</label>
					<select is="id-select" name="rtpyrSeCd" data-map="RTPYR_SE_CD"
						class="form-select" disabled>
						<option value=""></option>
						<c:forEach items="${FIM011List}" var="item">
							<option value="${item.code}">${item.value}</option>
		                </c:forEach>
					</select>
				</div>
				<div class="col-md-5">
					<label is="name-label" for="rtpyrNo"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">납부자번호</label>
					<input type="text" is="id-input" name="rtpyrNo" data-map="RTPYR_NO"
						class="form-control privacy" readonly />
					<input type="text" is="id-input" name="mask-rtpyrNo"
					class="form-control privacy-mask" disabled value="******"/>
				</div>
				<div class="col-md-12">
					<label is="name-label" for="zip" class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
					우편번호
					</label>
					<input type="text" is="id-input" name="zip" data-map="ZIP" class="form-control w-px-100"
						readonly maxlength="7" pattern="(\d{3}-\d{3}|\d{6}|\d{5})" />
				</div>
				<div class="col-md-12">
					<label is="name-label" for="addr" class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
					주소
					</label>
					<input type="text" is="id-input" name="addr" data-map="ADDR"
						class="form-control w-px-700" readonly data-maxlengthb="320" />
				</div>
				<div class="col-md-12">
					<label is="name-label" for="dtlAddr"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
					상세주소
					</label>
					<input type="text" is="id-input" name="dtlAddr" data-map="DTL_ADDR"
						class="form-control w-px-700" readonly data-maxlengthb="200" />
				</div>
			</div>
			<div class="row g-1">
				<div class="col-md-12">
					<label is="name-label" for="vin"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
					차량
					</label>
					<input type="text" is="id-input" name="vhclNm" data-map="VHCL_NM" class="form-control" readonly placeholder="명칭" />
					<input type="text" is="id-input" name="vhclColr" data-map="VHCL_COLR" class="form-control" readonly placeholder="색상" />
					<input type="text" is="id-input" name="vhclCpct" data-map="VHCL_CPCT" class="form-control text-end" readonly placeholder="정원" />
					<input type="text" is="id-input" name="vin" data-map="VIN" class="form-control" readonly placeholder="차대번호" title="차대번호" />
				</div>
<%--
				<div class="col-md-4">
					<label is="name-label" for="vin"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
					차대번호
					</label>
					<input type="text" is="id-input" name="vin"
					data-map="VIN" class="form-control" readonly
						placeholder="입력항목이 아닙니다." />
				</div>
				<div class="col-md-4">
					<label is="name-label" for="vhclNm"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
					차량명칭
					</label>
					<input type="text" is="id-input" name="vhclNm"
					data-map="VHCL_NM" class="form-control" readonly
						placeholder="입력항목이 아닙니다." />
				</div>
				<div class="col-md-4">
					<label is="name-label" for="vhclColr"
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
					차량색상
					</label>
					<input type="text" is="id-input" name="vhclColr"
					data-map="VHCL_COLR" class="form-control" readonly
						placeholder="입력항목이 아닙니다." />
				</div>
--%>
				<div class="col-md-12" slot="edit">
					<template class="pvs bpv">
						<slot>
							<label is="name-label" for="ffnlgCarmdlCd"
							class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
							차종
							</label>
							<select is="id-select" name ="ffnlgCarmdlCd"
							data-map="FFNLG_CARMDL_CD" class="form-select">
								<option value=""></option>
								<c:forEach items="${FIM009List}" var="item">
									<option value="${item.code}">${item.value}</option>
				                </c:forEach>
							</select>
						</slot>
					</template>
				</div>
				<div class="col-md-12" slot="edit">
					<template class="eca">
						<slot>
							<label is="name-label" for="useFuelCd"
							class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
							연료구분
							</label>
							<select is="id-select" name="useFuelCd"
							data-map="USE_FUEL_CD" class="form-select" disabled>
								<option value=""></option>
								<c:forEach items="${LVS005List}" var="item">
									<option value="${item.code}">${item.value}</option>
				                </c:forEach>
							</select>
						</slot>
					</template>
				</div>
				<div class="col-md-4" slot="edit">
					<template class="dpv eca pvs">
						<slot>
							<label is="name-label" for="towngYn"
							class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
							견인지시
							</label>
							<select is="id-select" name="towngYn" class="form-select" data-map="TOWNG_YN">
								<c:forEach items="${FIM053List}" var="item">
									<option value="${item.code}">${item.value}</option>
				                </c:forEach>
							</select>
						</slot>
					</template>
				</div>
				<div class="col-md-4" slot="edit">
					<template class="dpv eca pvs">
						<slot>
							<label is="name-label" for="crdnSn"
							class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
							스티커번호
							</label>
							<input type="text" is="id-input" name="crdnSn"
							data-map="CRDN_SN" class="form-control"
								maxlength="20" data-maxlengthb="20" />
						</slot>
					</template>
				</div>
				<div class="col-md-4" slot="edit">
					<template class="dpv">
						<slot>
							<label is="name-label" for="prkPsbltyRsltCd"
							class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
							장애차량확인
							</label>
							<select is="id-select" name="prkPsbltyRsltCd"
							data-map="PRK_PSBLTY_RSLT_CD" class="form-select">
								<c:forEach items="${FIM034List}" var="item">
									<c:if test="${item.code == '0' or item.code == '1'}">
										<option value="${item.code}">${item.value}</option>
									</c:if>
				                </c:forEach>
							</select>
						</slot>
					</template>
				</div>
				<div class="col-md-12" slot="edit">
					<template class="pvs bpv">
						<slot>
							<label is="name-label" for="teamId"
							class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">
							단속조
							</label>
							<select is="id-select" name="teamId" data-map="TEAM_ID" class="form-select">
								<option value=""></option>
								<c:forEach items="${TeamList}" var="item">
									<option value="${item.TEAM_ID}">${item.TEAM_NM}</option>
				                </c:forEach>
							</select>
						</slot>
					</template>
				</div>
				<div class="col-md-12" slot="edit">
					<template class="pvs bpv">
						<slot>
							<label class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">단속원</label>
							<input type="text" name="teamer1"
							data-map="TEAMER_1" class="form-control" />
							<input type="text" name="teamer2"
							data-map="TEAMER_2" class="form-control" />
							<input type="text" name="teamer3"
							data-map="TEAMER_3" class="form-control" />
							<input type="text" name="teamer4"
							data-map="TEAMER_4" class="form-control" />
						</slot>
					</template>
				</div>
				<div class="col-md-6">
					<label is="name-label" for="doWarning">
						<input type="checkbox" is="id-input" name="doWarning" class="form-check-input" />
						계도처리
					</label>
					<label is="name-label" for="doExempt" class="hidden" style="margin-left: 1rem;">
						<input type="checkbox" is="id-input" name="doExempt" class="form-check-input" />
						면제차량 부과제외
					</label>
				</div>
			</div>

			<div class="row mt-4 justify-content-end mb-3">
				<div class="col-md-6">
					<div class="row justify-content-end">
						<div class="col-sm-3">
							<button type="button" name="btnInst" class="btn btn-primary">등록</button>
						</div>
					</div>
				</div>
			</div>

		</form>
	</div>
	<div class="card w-px-400 min-w-px-400">
		<form name="frmFile" method="post" enctype="multipart/form-data">
			<input type="file" name="newFileList"
			multiple accept="image/*" hidden />
		</form>

		<form name="frmUploadSet" method="post" enctype="multipart/form-data">
			<input type="file" name="inputUploadSet"
			multiple accept="image/*" hidden />
		</form>
		<div class="col-md-12">
			<button type="button" name="btnAddFile" class="btn btn-primary">사진 추가</button>
			<button type="button" name="btnCancelAddFile" class="btn btn-primary">선택 사진 삭제</button>
		</div>
		<div name="display" class="oy-scroll h-px-600 border-default">

		</div>
	</div>

</div>

<script>
LoadScript("crdn05030Script",wctx.url("/resources/js/fims/crdn/crdn05030.js?ver=${ver}"));

/**************************************************************************
 * Global Variable
 **************************************************************************/

pageObject["${pageName}"] = newDoctxFinder("${pageName}");

$(document).ready(function(){

	var $P = pageObject["${pageName}"];

	$P.captureFileArr = [];
	$P.localUploadArr = [];

	/**************************************************************************
	* DatasetControl, DatasetSupport, FormFields
	**************************************************************************/
	$P.formFields = new FimsFormFields($P.selectorn("frmEdit"));

	$P.uploadSet = uploadSupport($P.selectorn("inputUploadSet"));

	var ctrl = newCrdn05030Control($P, { taskSeCd : "${taskSeCd}" });

	$P.uploadSet.onDatasetChange  = () => {
		var files = $P.uploadSet.getDataset();
		files.forEach(item => $P.localUploadArr.push(item));

		$P.fnDisplay();
	};
	$P.uploadSet.onRemove = () => { };

	/**************************************************************************
	* pageObject.function
	**************************************************************************/
	$P.fnMakeImgForNewFile = (fileArr) => {
		var tagsText = "";

		for(var index = 0; index < fileArr.length; index++){
			var item = fileArr[index];

			tagsText += "<label class='mx-2 mt-1'>";
			tagsText += "<input type='checkbox' name='newPhoto' class='form-check-input' value='"+item.id +"' ";
			tagsText += " />";
			tagsText += "<img src='"+ item.url +"' width='200' height='200' />";
			tagsText += "</label>";

			if (index % 2 == 1){
				tagsText += "<br />";
			}
		}

		return tagsText;
	}

	$P.fnDisplay = () => {
		var displayArea = $P.findn("display");

		var concatArr = $P.localUploadArr.concat($P.captureFileArr);
		var tagsText = $P.fnMakeImgForNewFile(concatArr);
		displayArea.innerHTML = tagsText;
	};

	$P.fnSave = async() => {

		if (!AppSupport.customValidate($P.$findn("frmEdit").find("input"))) return;

		if ($P.$findn("doWarning").is(":checked")){

			var rtpyrNm = $P.findn("rtpyrNm");
			if (!rtpyrNm.value)
				return dialog.alert({
					content:"계도 처리를 하기 위해선 소유주정보가 입력되어야 합니다.",
					init : function(){
						AppSupport.setDialogZindex();
						AppSupport.focusClose();
					},
					onClose:function(){rtpyrNm.focus();}
				});
		}

		if (await confirm2("현재 단속 정보를 저장하시겠습니까?")){
			var info = $P.formFields.get();
			if (!info) return;

			var formData = new FormData($P.findn("frmFile"));
			for(var key in info) {
			    var value = info[key];
			    formData.append(key,value);
			}

			formData.delete("newFileList");

			if ($P.localUploadArr.length > 0){
				$P.localUploadArr.forEach(item => formData.append("newFileList",item));
			}

			if ($P.captureFileArr.length > 0){
				$P.captureFileArr.forEach(item => formData.append("newFileList",item));
			}

			ajax.post({
				url : ctrl.urls.create,
				data : formData, contentType : false, processData : false,
				success : (resp) => {
					$P.saveCallback(resp);
				}
			});
		}

	};

	$P.saveCallback = (resp) => {
		if (resp.saved) {
			dialog.alert({
				content : "저장됐습니다.",
				init : function(){
					AppSupport.setDialogZindex();
					AppSupport.focusClose();
				}
			});
			dialog.close($P.selfDlgId());
		}
	}

	$P.videoCallback = (snapshots) => {
		snapshots.forEach(function(canvas, index, array){
			canvas.toBlob(function(blob){
				var identify = new Date().getTime()+ "-" + index;
				var file = new File([blob], "capture-"+identify+".png", {type: "image/png"});
				file.id = "file-" + identify;
				file.url = (window.URL || window.webkitURL).createObjectURL(file);
				$P.captureFileArr.push(file);
				if (index === array.length - 1){
					$P.fnDisplay();
				}
			});
		});

	}

	/**************************************************************************
	* 초기화(업무별 입력항목)
	**************************************************************************/
	var clsForTask = $P.$findn("taskSeCd").val().toLowerCase();
	//업무별 입력 항목
	FimsSupport.renderForTask($P.findn("frmEdit"), clsForTask);

	/**************************************************************************
	* element.on
	**************************************************************************/

	$P.$findn("btnInst").on('click', () => $P.fnSave());

	$P.$findn("btnAddFile").on('click', () => {
		$P.$findn("inputUploadSet").trigger("click");
	});

	$P.$findn("btnOpenVideoCapture").on('click', () => {
		var popupWidth = 1800;
		var popupHeight = 950;
		var popupX = (window.screen.width / 2) - (popupWidth / 2);
		var popupY= (window.screen.height / 2) - (popupHeight / 2);

		var popup = window.open(wctx.url("/sprt/sprt03/010/main.do?openerPageName=${pageName}")
				,"newVideoCapture"
				,"width="+popupWidth+", height="+popupHeight+", left="+popupX+", top="+popupY
		);

		popup.onload = () => {
			popup.addEventListener('beforeunload', function() {
				$.unblockUI();
			});
		};
	});

	$P.$findn("btnCancelAddFile").on('click', () => {
		var checked = $P.$findn("display").find("[name='newPhoto']:checked");
		if (checked.length < 1)
			return alert("선택된 사진이 없습니다.");

		var checkedArr = [];
		for(var i=0; i < checked.length; i++){
			checkedArr.push(checked[i].value);
		}

		$P.captureFileArr = $P.captureFileArr.filter(item => checkedArr.indexOf(item.id) == -1);
		$P.localUploadArr = $P.localUploadArr.filter(item => checkedArr.indexOf(item.id) == -1);

		$P.fnDisplay();
	});
	
	let getPayerInfo = async () => {
		var crdnYmd = $P.$findn("crdnYmd").val().replaceAll("-", "");
		var vhrnoEl = event.target;
		var vhrno = vhrnoEl.value;
		if (!crdnYmd)
			return dialog.alert({
				content : "단속일자를 입력하세요.",
				init : function(){
					AppSupport.setDialogZindex();
					AppSupport.focusClose();
				},
				onClose : function(){ $P.$findn("crdnYmd").focus(); }
			});

		if (!vhrno)
			return dialog.alert({
				content:"차량번호를 입력하세요.",
				init : function(){
					AppSupport.setDialogZindex();
					AppSupport.focusClose();
				},
				onClose:function(){ $(vhrnoEl).focus(); }
			});
		
		let resp = await FimsSupport.getVhclInfo($P.$findn("sggCd").val(), vhrno, crdnYmd);
		if (!resp.found){
			dialog.alert({
				content : "차량정보가 없습니다.",
				init : function(){
					AppSupport.setDialogZindex();
					AppSupport.focusClose();
				}
			});
			
			["rtpyrId", "addrSn", "rtpyrNm", "rtpyrSeCd", "rtpyrNo", "vin", "vhclNm", "vhclColr", "vhclCpct", "useFuelCd", "ffnlgCarmdlCd", "zip", "addr", "dtlAddr"]
				.forEach(name => $P.$findn(name).val(""))
			return;
		}

		$P.$findn("rtpyrId").val(resp.rtpyrId);
		$P.$findn("addrSn").val(resp.addrSn);

		var vehicle = resp.vehicle;

		$P.$findn("rtpyrNm").val(vehicle.mber_nm);

		var pyrSeCd = "";
		switch(vehicle.mber_se_code){
			case "11" : pyrSeCd = "01"; break;
			case "12" : pyrSeCd = "02"; break;
			case "13" : pyrSeCd = "03"; break;
			case "14" : pyrSeCd = "04"; break;
			case "15" : pyrSeCd = "05"; break;
		}
		$P.$findn("rtpyrSeCd").val(pyrSeCd);

		$P.$findn("rtpyrNo").val(vehicle.mber_se_no);

		$P.$findn("vin").val(vehicle.vin);
		$P.$findn("vhclNm").val(vehicle.cnm);
		$P.$findn("vhclColr").val(vehicle.color_nm);
		$P.$findn("vhclCpct").val(vehicle.tkcar_pscap_co);
		$P.$findn("useFuelCd").val(vehicle.use_fuel_code);

		if (vehicle.vhcty_asort_code == "1"){ //승용
			$P.$findn("ffnlgCarmdlCd").val("11");
		} else if (vehicle.vhcty_asort_code == "2"){ //승합
			$P.$findn("ffnlgCarmdlCd").val("12");
		} else if (vehicle.vhcty_asort_code == "3"){ //화물
			if (vehicle.mxmm_ldg <= 4000){
				$P.$findn("ffnlgCarmdlCd").val("13");
			} else {
				$P.$findn("ffnlgCarmdlCd").val("14");
			}
		} else if (vehicle.vhcty_asort_code == "4"){ //특수
			$P.$findn("ffnlgCarmdlCd").val("15");
		} else {
			$P.$findn("ffnlgCarmdlCd").val("");
		}

		$P.$findn("zip").val(vehicle.zip_code); //우편번호
		$P.$findn("addr").val(vehicle.road_nm_adres); //주소
		$P.$findn("dtlAddr").val(vehicle.use_strnghld_adres_nm); //상세주소
		
		document.querySelector("input[name='doExempt']").checked = resp.exempted;
		let doExempt = document.querySelector('label[for^=doExempt]').classList;
		if (resp.exempted) {
			doExempt.remove('hidden');
			dialog.alert("면제차량이 설정됐습니다.");
		} else {
			if (!doExempt.contains('hidden'))
				doExempt.add('hidden');
		}
	};

	let input = $P.$findn("vhrno");
	input.onEnterPress(getPayerInfo);
	input.on("dblclick", getPayerInfo);

	$P.$findn("teamId").on("change",function(){
		$P.$findn("teamer1").val("");
		$P.$findn("teamer2").val("");
		$P.$findn("teamer3").val("");
		$P.$findn("teamer4").val("");

		if (this.value != ""){
			ajax.get({
				url: wctx.url("/crdn/crdn07/010/info.do"),
				data: { "teamId" : this.value},
				success : (resp) => {
					if (resp.teamInfo != null){
						var teamInfo = resp.teamInfo;
						$P.$findn("teamer1").val(teamInfo.TEAMER_1);
						$P.$findn("teamer2").val(teamInfo.TEAMER_2);
						$P.$findn("teamer3").val(teamInfo.TEAMER_3);
						$P.$findn("teamer4").val(teamInfo.TEAMER_4);
					}
				}
			});
		}
	});

	/**************************************************************************
	* 초기화
	**************************************************************************/
	AppSupport.initDatepicker($P.findn("frmEdit")); //달력 초기화

	$P.$findn("frmEdit").find(".form-date").each(function(){
		$(this).on("input",function(){
			var value = this.value.replaceAll("-","");

			if (value.length > 7){
				this.value = value.substring(0,4) + "-" + value.substring(4,6) + "-" + value.substring(6);
			} else if (value.length > 5){
				this.value = value.substring(0,4) + "-" + value.substring(4);
			}

		});
	});
	$P.$findn("frmEdit").find(".form-time").each(function(){
		$(this).on("input",function(){
			var value = this.value.replaceAll(":","");

			if (value.length > 5){
				this.value = value.substring(0,2) + ":" + value.substring(2,4) + ":" + value.substring(4);
			} else if (value.length > 3){
				this.value = value.substring(0,2) + ":" + value.substring(2);
			}

		});
	});
	document.querySelector("div[data-doctx='crdn05030'] input[name='crdnYmd']").value = dateFormat.format("${today}");
	

	//보안모드
    fn_securityModeToggle($("#securityMode--top").is(":checked"));

    ctrl.dataset.append({});
    
    let inputs = document.querySelectorAll("form[name='frmEdit'] select:not([disabled]), form[name='frmEdit'] input[type='text']:not([readonly]):not([disabled])");
    inputs.forEach((input, index) => {
    	input.addEventListener('keydown', evt => {
    		if (evt.key !== 'Enter') return;
    		
    		evt.preventDefault();
    		
    		let next = inputs[index < 8 ? index + 1 : 2];
    		if (next)
    			next.focus(); 
    	});
    });

});
//# sourceURL=crdn05030-info.jsp
</script>