<%@ 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" style="flex-flow:column">
	<div class="card" style="max-width:1400px;height:100px;">
		<form id="frmFirst--${pageName}">
			<div class="row g-1">
				<div class="col-md-4">
					<label for="taskSeCd--${pageName}" 
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">과태료업무</label>
				    <select id="taskSeCd--${pageName}" name="taskSeCd" class="form-select" disabled>
						<c:forEach items="${FIM054List}" var="item">
							<option value="${item.code}"
								<c:if test="${item.code eq taskSeCd}"> selected="selected" </c:if>
							>${item.value}</option>
						</c:forEach>
					</select>
				</div>
				<div class="col-md-4">
					<label for="entType--${pageName}" 
					class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">장비업체</label>
					<select id="entType--${pageName}" name="entType" class="form-select">
						<option value="">선택하세요</option>
						<option value="KNL">KNL</option>
						<option value="이노">이노</option>
						<option value="가산정보통신">가산정보통신</option>
						<option value="앨리소프트">엘리소프트</option>
						<option value="하이테콤">하이테콤</option>
					</select>
				</div>
				<div class="col-md-4">
					<c:if test="${taskSeCd == 'PVS' or taskSeCd == 'BPV'}">
						<label for="cctvType--${pageName}" 
						class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">cctv 구분</label>
						<select id="cctvType--${pageName}" name="cctvType" class="form-select">
							<option value="">선택</option>
							<option value="고정형">고정형</option>
							<option value="주행형">주행형</option>
							<option value="버스장착형">버스장착형</option>
						</select>
					</c:if>
				</div>
				<c:if test="${taskSeCd == 'PVS' or taskSeCd == 'BPV' or taskSeCd == '미세먼지'}">
					<div class="col-md-4">
						<label for="localFile--${pageName}" 
						class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">파일</label>
						<input type="file" id="localFile--${pageName}" name="localFile" />
					</div>
				</c:if>
			</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">
							<c:if test="${taskSeCd == 'ECA' or taskSeCd == 'DPV'}">
								<button type="button" id="btnSearch--${pageName}" class="btn btn-primary">조회</button>
							</c:if>
							<c:if test="${taskSeCd == 'PVS' or taskSeCd == 'BPV' or taskSeCd == '미세먼지'}">
								<button type="button" id="btnFileUpload--${pageName}" class="btn btn-primary">등록</button>
							</c:if>
						</div>
					</div>
				</div>
			</div>
		</form>
		
	</div>
	<div class="card" style="max-width:1400px;height:300px;">
		<form id="frmGrid--${pageName}">
			<div class="card-datatable text-nowrap">
		        <div id="DataTables_Table_0_wrapper--${pageName}" class="dataTables_wrapper dt-bootstrap5 no-footer">
					<div id="table-responsive--${pageName}" class="table-responsive"
						style="overflow-x: scroll;height:298px;overflow-y: scroll;">
						<table id="DataTables_Table_0--${pageName}"
							class="datatables-ajax table table-bordered dataTable no-footer">
							<thead>
								<tr id="crdnTheadTr--${pageName}">
									<th style="min-width: 50px;">No.</th>
									<th style="min-width: 80px;">파일명</th>
									<th style="min-width: 80px;">타임스탬프</th>
									<th style="min-width: 80px;">사이즈</th>
									<th style="min-width: 80px;">디바이스ID</th>
									<th style="min-width: 80px;">날짜/시간</th>
									<th style="min-width: 80px;">차량번호</th>
									<th style="min-width: 80px;">총사진갯수</th>
									<th style="min-width: 80px;">사진시퀀스</th>
									<th style="min-width: 80px;">위치좌표x</th>
									<th style="min-width: 80px;">위치좌표y</th>
									<th style="min-width: 80px;">입력구분</th>
									<th style="min-width: 80px;">location</th>
									<th style="min-width: 80px;">address</th>
									<th style="min-width: 80px;">법정동</th>
									<th style="min-width: 80px;">파일확장자</th>
									
								</tr>
		                    </thead>
		                    <tbody id="crdnTbody--${pageName}"></tbody>
							<template id="crdnRow--${pageName}">
	                    		<tr data-key="{CRDN_ID}">
	                    			<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-end">{순번}</td>
	                    			<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-center">{파일명}</td>
	                    			<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-center">{타임스탬프}</td>
		                    		<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-center">{사이즈}</td>
		                    		<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-center">{디바이스ID}</td>
		                    		<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-start">{날짜/시간}</td>
		                    		<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-start">{차량번호}</td>
		                    		<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-start">{총사진갯수}</td>
		                    		<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-start">{사진시퀀스}</td>
		                    		<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-start">{위치좌표X}</td>
		                    		<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-start">{위치좌표Y}</td>
		                    		<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-start">{입력구분}</td>
		                    		<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-start">{address}</td>
		                    		<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-start">{법정동}</td>
		                    		<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-start">{파일확장자}</td>
		                    	</tr>
	                    	</template>
	                    	<template id="crdnNotFound--${pageName}">
	                    		<tr>
	                    			<td valign="top" colspan="16" class="dataTables_empty text-center">정보를 찾지 못했습니다.</td>
	                    		</tr>
	                    	</template>
						</table>
					</div>
				</div>
		    </div>
		</form>
	</div>
</div>

<script>

$("#btnSearch--${pageName}").on("click", function(){
	if($("#entType--${pageName}").val() == ""){
		dialog.alert("장비업체를 선택하세요.");
		return;
	}
	
	if($("#entType--${pageName}").val() != "KNL" && $("#entType--${pageName}").val() != "이노"){
		dialog.alert("해당 과태료 업무와 관련된 장비업체가 아닙니다.");
		return;
	}
	
	if($("#entType--${pageName}").val() == "KNL"){
		dialog.alert("KNL 파일 등록 기능은 서비스 준비 중입니다.");
	}
	
	if($("#entType--${pageName}").val() == "이노"){
		
	}
	
	ajax.post({
		url : wctx.url("/${taskSeCd}/crdn/crdn05/020/list.do"),
		data : { entType : $("#entType--${pageName}").val() }, 
		success : (resp) => {
			
		}
	});
});

$("#btnFileUpload--${pageName}").on("click", function(){
	
	if($("#entType--${pageName}").val() == ""){
		dialog.alert("장비업체를 선택하세요.");
		return;
	}

	if($("#entType--${pageName}").val() != "가산정보통신" 
			&& $("#entType--${pageName}").val() != "엘리소프트"
			&& $("#entType--${pageName}").val() != "하이테콤"
			){
		dialog.alert("해당 과태료 업무와 관련된 장비업체가 아닙니다.");
		return;
	}
	
	if($("#localFile--${pageName}").val() == ""){
		dialog.alert("파일이 없습니다.");
		return;
	}
	
	dialog.alert("주정차,전용차로,미세먼지 과태료 파일 등록 기능은 서비스 준비 중입니다.");
	return;
});

</script>