<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/jsp/common/include/localemessage.jsp" %>
<%
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setHeader("Expires", "0");
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<jsp:include page="/jsp/common/include/css.jsp"/>
<jsp:include page="/jsp/common/include/script.jsp"/>
<script language="javascript" >
var url      = '<c:url value="/common/acl/deploy/ruleDeployJobMan.json" />';
var url_view = '<c:url value="/common/acl/deploy/ruleDeployJobMan.view" />';

$(document).ready(function() {
	var gridPostData = getSearchForJqgrid("cmd","LIST");
	gridPostData["sortName"] ='SCHEDULEDDATETIME';
    gridPostData["sortOrder"]='DESC';
	$('#grid').jqGrid({
		datatype:"json",
		mtype: 'POST',
		url: url,
		postData : gridPostData,
		colNames:['<%= localeMessage.getString("ruleDeployJobMan.jobId") %>',
                  '<%= localeMessage.getString("ruleDeployJobMan.jobName") %>',
                  '<%= localeMessage.getString("ruleDeployJobMan.serviceType") %>',
                  '<%= localeMessage.getString("ruleDeployJobMan.schduledDateTime") %>',
                  '<%= localeMessage.getString("ruleDeployJobMan.lastJobTime") %>',
                  '<%= localeMessage.getString("ruleDeployJobMan.status") %>',
                  '<%= localeMessage.getString("ruleDeployJobMan.userId") %>'
                  ],
		colModel:[
				{ name : 'JOBID', align:'left', sortable:false, hidden:true },
				{ name : 'JOBTITLE', align:'left', sortable:false },
				{ name : 'SERVICETYPE', align:'center', sortable:false },
				{ name : 'SCHEDULEDDATETIME', align:'center', sortable:false, formatter:dateTimeFormater },
				{ name : 'LASTJOBTIME', align:'center', sortable:false, formatter:dateTimeFormater },
				{ name : 'STATUS', align:'center', sortable:false },
				{ name : 'USERID', align:'center', sortable:false }
				],
        jsonReader: {
             repeatitems:false
        },
		pager : $('#pager'),
		page : '${param.page}',
		rowNum : '${rmsDefaultRowNum}',
	    autoheight: true,
	    height: $("#container").height(),
		autowidth: true,
		viewrecords: true,
		sortname : '${param.sortName}',
		sortorder : '${param.sortOrder}',
		rowList : eval('[${rmsDefaultRowList}]'),
		ondblClickRow: function(rowId) {
			var rowData = $(this).getRowData(rowId);
            var url2 = url_view;
            url2 += '?cmd=DETAIL';
            url2 += '&page=' + $(this).getGridParam("page");
            url2 += '&returnUrl=' + getReturnUrl();
            url2 += '&menuId=' + '${param.menuId}';
            url2 += '&sortName=' + $("#grid").getGridParam("sortname");
        	url2 += '&sortOrder=' + $("#grid").getGridParam("sortorder");
			//검색값
            url2 += '&' + getSearchUrl();
            //key값
            url2 += '&jobId=' + rowData['JOBID'];
            goNav(url2);
        }
	});
	
	resizeJqGridWidth('grid','content_middle','1000');

	$("#btn_search").click(function(){
		var postData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
		$("#grid").setGridParam({ postData: postData ,page : "1"  }).trigger("reloadGrid");

	});
	
	$("input[name^=search]").keydown(function(key){
		if (key.keyCode == 13){
			$("#btn_search").click();
		}
	});
	
	buttonControl();
});

function dateTimeFormater(cellvalue, options, rowObject){ //20190513134307
	if (cellvalue.trim().length < 14) return "";
	var display = "";
	display=display+cellvalue.substr(0,4)+"-";
	display=display+cellvalue.substr(4,2)+"-";
	display=display+cellvalue.substr(6,2)+" ";
	display=display+cellvalue.substr(8,2)+":";
	display=display+cellvalue.substr(10,2)+":";
	display=display+cellvalue.substr(12,2);
	return display;
}

</script>
</head>
	<body>
		<div class="right_box">
			<div class="content_top">
				<ul class="path">
					<li><a href="#">${rmsMenuPath}</a></li>
				</ul>
			</div><!-- end content_top -->
			<div class="content_middle" id="content_middle">
				<div class="search_wrap">
					<button type="button" class="cssbtn" id="btn_search" level="R" ><i class="material-icons">search</i> <%= localeMessage.getString("button.search") %></button>
				</div>
				<div class="title"><%= localeMessage.getString("ruleDeployJobMan.title") %></div>
				
				<table class="search_condition" cellspacing=0;>
					<tbody>
						<tr>
							<th style="width:180px;"><%= localeMessage.getString("ruleDeployJobMan.jobName") %></th>
							<td><input type="text" name="searchJobTitle" value="${param.searchJobTitle}"></td>
							<th style="width:180px;"><%= localeMessage.getString("ruleDeployJobMan.status") %></th>
							<td>
								<div class="select-style">
									<select name="searchStatus" value="${param.searchStatus}">
										<option value=""><%= localeMessage.getString("combo.all") %></option>
										<option value="standby"><%= localeMessage.getString("ruleDeployJobMan.status.standby") %></option>
										<option value="finished"><%= localeMessage.getString("ruleDeployJobMan.status.finished") %></option>
										<option value="failed"><%= localeMessage.getString("ruleDeployJobMan.status.failed") %></option>
									</select>
								</div>
							</td>
						</tr>
					</tbody>
				</table>
				
				<table id="grid" ></table>
				<div id="pager"></div>
				
			</div><!-- end content_middle -->
		</div><!-- end right_box -->
	</body>
</html>