<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript" src="<c:url value='/WEB-INF/jsp/adm/rcp/oprmanage/nlpSetting.jsp' />"></script>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>작업이력조회</title>
	<%@ include file="/WEB-INF/jsp/adm/include/topLinkTag.jsp" %>
</head>

<script>
	$(document).ready(function () {
	defaultDataSet(getDayFromToday(-1), getToday());

		getOpr();
		getMenu();
		getMenuCategory();

		PagingDataTable();

		$('#btnSearchOpr').on('click', function () {
			fnCustSearchBtn();
		});

		$("#Content").on("keyup", function (key) {
			if (key.keyCode == 13) {
				fnCustSearchBtn();
			}
		});
	});

	function getOpr() {
		$.ajax({
			type: "GET",
			contentType: "application/json; charset=utf-8",
			datatype: "JSON",
			url: "<c:url value='/adm/menu/oprmng'/>" + "?menuval=rcpmonitoringworkhistorymanage",
			success: function (data) {
				data.forEach(function (e, f) {
					$('#serviceGroup').append("<option value=" + e.serviceGroup + ">" + e.serviceGroupName + "</option>");
					$('#serviceGroup').niceSelect('update');
				});
			}
		})
	};


	function getMenu() {
		$.ajax({
			type: "GET",
			contentType: "application/json; charset=utf-8",
			datatype: "JSON",
			url: "<c:url value='/admin/rcp/statistics/monitoring/workhistory/menuList'/>",
			success: function (data) {
				data.forEach(function (e, f) {
					$('#menuName').append("<option value=" + e.authName + ">" + e.menuName + "</option>");
					$('#menuName').niceSelect('update');
				});
			}
		})
	};

	function getMenuCategory() {
		$.ajax({
			type: "GET",
			contentType: "application/json; charset=utf-8",
			datatype: "JSON",
			url: "<c:url value='/admin/rcp/statistics/monitoring/workhistory/menuCategoryList'/>",
			success: function (data) {
				data.forEach(function (e, f) {
					$('#menuCategory').append("<option value=" + e.categoryValue + ">" + e.typeName + "</option>");
					$('#menuCategory').niceSelect('update');
				});
			}
		})
	};

	var PagingDataTable = function () {
		var paging = JSON.stringify({'page': 0, 'size': 10})
		$('#listTable').DataTable(
				{
					ajax: {
						url: "<c:url value='/admin/rcp/statistics/monitoring/retrieveWorkHst.do'/>",
						contentType: "application/json; charset=utf-8",
						type: "POST",
						dataType: "JSON",
						data: function (data) {
							var json = {};
							if (data) {
								json.page = data.start / data.length;
								json.size = 10;
								json.serviceGroup = $("#serviceGroup option:selected").val();
								json.searchKey1 = $("#searchKey1 option:selected").val();
								json.codeText = $('#codeText').val();
								json.menuName = $("#menuName option:selected").val();
								json.menuCategory = $("#menuCategory option:selected").val();
								json.startDate = document.getElementById('startDate').value;
								json.endDate = document.getElementById('endDate').value;
							} else {
								json = JSON.stringify({'page': 0, 'size': 10});
							}
							return JSON.stringify(json);
						}
						,
						dataFilter: function (data) {
							var jsons = jQuery.parseJSON(data);

							var json = {};
							json.recordsTotal = jsons.getTotal;
							json.recordsFiltered = jsons.getTotal;
							json.data = jsons.getList;
							return JSON.stringify(json);
						}
					},
					columns: [
						{data: "seq"},
						{data: "registDate"},
						{data: "serviceGroup"},
						{data: "userId"},
						{data: "userName"},
						{data: "menuName"},
						{data: "actionCode"},
						{data: "ip"},
						{data: "remark"}
					],
					order: [0, "asc"],
					scrollX: false,
					scrollY: false,
					autoWidth: false,
					searching: false,
					bProcessing: false,
					sProcessing: false,
					bServerSide: true,
					sDom: '<"row view-filter"<"col-sm-12"<"pull-left"l><"pull-right"f><"clearfix">>>t<"row view-pager"<"col-sm-12"<"text-center"p>>>',

					columnDefs: [
						{
							targets: 0,
							/*render: function (data) {
								return '<a style="display: block;text-align: center;">' + data + '</a>';
							}*/
							render: function (data, type, row, meta) {
								return meta.row + meta.settings._iDisplayStart + 1;
							},

						},
						{
							targets: 1,
							render: function (data) {
								return data;
							}
						},
						{
							targets: 2,
							render: function (data) {
								return data;
							}
						},
						{
							targets: 3,
							render: function (data) {
								return data;
							}
						},
						{
							targets: 4,
							render: function (data) {
								return data;
							}
						},
						{
							targets: 5,
							render: function (data) {
								return data;
							}
						},
						{
							targets: 6,
							render: function (data) {
								return data;
							}
						},
						{
							targets: 7,
							render: function (data) {
								return data;
							}
						},
						{
							targets: 8,
							render: function (data) {
								return data;
							}
						}
					]
				}
		)
	};

	function fnCustSearchBtn() {
		$('#listTable').DataTable().ajax.reload();
	};

</script>

<body>

<div class="skip_navigation">
	<ul>
		<li>
			<a href="#Content" class="go_content">본문 바로가기</a>
		</li>
		<li>
			<a href="#Gnb">메뉴 바로가기</a>
		</li>
	</ul>
</div>

<header id="header">
	<%@ include file="/WEB-INF/jsp/adm/include/header.jsp" %>
</header>
<c:import url="/adm/menu/getLnbMenu.do"/>


<section id="Content" class="system_management">
	<div class="location">
		<ul>
			<li class="home"><a href="#">HOME</a></li>
			<li><a href="#">모니터링</a></li>
			<li><a href="#">작업이력조회</a></li>
		</ul>
	</div>

	<div class="sub_cont menu06_01_03">
		<div class="cont_box">
			<div class="box_title">
				<div class="fl">
					<h2 class="mt12">작업 이력 조회</h2>
				</div>
				<div class="fr">
					<dl class="customer fl">
						<dt class="fl">
							<c:if test="${'SYS_ADMIN'==LoginVO.authCode}">
								고객사 :
							</c:if>
						</dt>
						<dd class="fl">
							<div class="sel_box">
								<c:choose>
									<c:when test="${'SYS_ADMIN'==LoginVO.authCode}">
										<select class="top" name="custCode" id="custCode">
											<c:forEach var="siteInfo" items="${siteLists}" varStatus="status">
												<option value="<c:out value="${siteInfo.custCode}"/>"><c:out value="${siteInfo.custName}"/></option>
											</c:forEach>
										</select>
									</c:when>
									<c:otherwise>
										<input name="custCode" id="custCode"  type="hidden" value="${LoginVO.siteCode}"/>
									</c:otherwise>
								</c:choose>
							</div>
						</dd>
					</dl>
					<div class="btn_wrap fr">
						<a href="#" id="btnSearchOpr" class="btn">조회</a>
					</div>
				</div>
			</div>

			<div class="tbl">
				<table class="search block">
					<colgroup>
						<col width="140px">
						<col width="20%">
						<col width="120px">
						<col width="30%">
						<col width="120px">
						<col width="20%">
					</colgroup>
					<tbody>
					<tr>
						<th class="tl">시나리오그룹</th>
						<td>
							<div class="sel_box">
								<select id="serviceGroup" name="serviceGroup" class="wide">
									<option value="ALL">전체</option>
								</select>
							</div>
						</td>
						<th class="tl">작업일자</th>
						<td>
							<div class="datetimepicker_box">
								<div class='input-group date datetimepicker_from'>
									<input id="startDate" type='text' class="form-control" readonly/>
									<span for="startDate" class="input-group-addon">
											<span class="glyphicon glyphicon-calendar calender_ico"></span>
										</span>
								</div>
								<span class="form_bridge">~</span>
								<div class='input-group date datetimepicker_to'>
									<input id="endDate" type='text' class="form-control" readonly/>
									<span for="endDate" class="input-group-addon">
											<span class="glyphicon glyphicon-calendar calender_ico"></span>
										</span>
								</div>
							</div>
						</td>
						<th class="tl">작업유형</th>
						<td>
							<div class="sel_box">
								<select id="menuCategory" name="menuCategory" class="wide">
									<option value="ALL">--선택해주세요--</option>
								</select>
							</div>
						</td>
					</tr>

					<tr>
						<th class="tl">조회조건</th>
						<td>
							<div class="sel_box">
								<select id="searchKey1" name="searchKey1" class="wide">
									<option value="id">ID</option>
									<option value="userName">작업자명</option>
									<option value="ip">IP</option>
									<option value="remark">비고</option>
								</select>
							</div>
						</td>
						<th class="tl">조회명</th>
						<td>
							<div class="ipt_box listen">
								<input type="text" placeholder="검색어를 입력하세요" id="codeText" name="typeText">
							</div>
						</td>
						<th class="tl">작업메뉴</th>
						<td>
							<div class="sel_box">
								<select id="menuName" name="menuName" class="wide">
									<option value="ALL">--선택해주세요--</option>
								</select>
							</div>
						</td>
					</tr>
					</tbody>
				</table>
			</div>
		</div>
		<div class="cont_box">
			<div class="box_title">
				<div class="fl">
					<h2 class="mt12">작업 이력 리스트</h2>
				</div>
			</div>

			<div class="tbl">
				<form id="custListForm">
					<table id="listTable" class="">
						<colgroup>
							<col width="70px">
							<col width="200px">
							<col width="auto">
							<col width="auto">
							<col width="auto">
							<col width="auto">
							<col width="auto">
							<col width="auto">
							<col width="auto">
						</colgroup>
						<thead>
						<tr>
							<th>NO</th>
							<th>작업일자</th>
							<th>시나리오그룹</th>
							<th>ID</th>
							<th>사용자명</th>
							<th>작업메뉴</th>
							<th>작업유형</th>
							<th>IP</th>
							<th>비고</th>
						</tr>
						</thead>
						<tbody>

						</tbody>
					</table>
				</form>
			</div>
		</div>
	</div>
</section>

</body>
</html>
