<%@ 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 p-3">

		<div class="card-datatable text-nowrap">
			<div class="dataTables_wrapper dt-bootstrap5 no-footer">
				<div class="table-responsive ox-scroll oy-scroll h-px-300">
					<table name="table" 
					class="table-layout-fixed dataTable datatables-ajax table table-bordered no-footer">
						<thead class="sticky-thead" >
							<tr name="theadTr">
								<th>시군구명</th>
								<th style="width:180px">과태료명</th>
								<th style="width:200px">단속일시</th>
								<th>차량번호</th>
								<th>대체차량번호</th>
								<th>성명</th>
								<th>처리상태</th>
							</tr>
						</thead>
						<tbody name="tbody">
						</tbody>
						<template is="curly-brackets" name="found">
							<tr data-key="CRDN_ID" onclick="pageObject['${pageName}'].clickGrid(this);">
								<td>SGG_NM</td>
								<td>TASK_SE_NM</td>
								<td>CRDN_YMD_TM</td>
								<td>VHRNO</td>
								<td>RPM_SZR_VHRNO</td>
								<td>RTPYR_NM</td>
								<td>CRDN_STTS_NM</td>
							</tr>
						</template>
					</table>
				</div>
			</div>
		</div>
			
		<form name="frmEdit">

			<div class="row g-1 mt-2">
				<div class="col-md-12">
					<label is="name-label" for="etcCn" class="bg-lighter px-2 col-form-label">특기사항</label>
					<input type="text" is="id-input" name="etcCn" class="form-control w-px-700" required />
				</div>
			</div>
			
			<div class="row justify-content-end mb-1">
				<div class="col-md-12">
					<div class="float-end pe-2">
						<button type="button" name="btnInputEtcCn" class="btn btn-primary">
						특기사항등록(일괄)
						</button>
					</div>
				</div>
			</div>
		</form>
	</div>
</div>

<script>

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

$(document).ready(function(){

	var $P = pageObject["${pageName}"];
	
	$P.crdnIds = ${crdnIds};
	
	//그리드클릭
	$P.clickGrid = (element) => {
		var key = element.dataset.key;
		
		$P.$findn("tbody").setCurrentRow(key);
	}
	
	//특기사항 입력
	$P.fnInputEtcCn = () => {
		var etcCn = $P.$findn("etcCn").val();
		if(etcCn == ""){
			alert("특기사항을 입력하세요.");
			return;
		}

		ajax.get({
			url : wctx.url("/sprt/sprt01/100/update.do"),
			data : { 
				crdnIds : $P.crdnIds.join(","),
				etcCn : etcCn
			},
			success : (resp) => {
				if(resp.saved){
					alert("저장되었습니다.");

					dialog.close($P.selfDlgId());
				}
			}
		});
	}
	
	//버튼 이벤트
	$P.$findn("btnInputEtcCn").on("click", () => $P.fnInputEtcCn() );
	
	//첫번째 줄 클릭
	$P.$findn("tbody").find("tr:eq(0)").click();
});



</script>