<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ page import="com.eactive.eai.rms.common.login.SessionManager"%>
<%@ page import="com.eactive.eai.common.util.SystemUtil"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
	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>
			function fileTrsmtHmsFormatter(cellvalue, options, rowObject){
				if (cellvalue == null || cellvalue == undefined || cellvalue == ""){
					return "";
				} else {
					var str = $.trim(cellvalue);
					
					str = str.slice(0, 4) + "-" + str.slice(4, 6) + "-" + str.slice(6, 8) + " " + str.slice(8, 10) + ":" + str.slice(10, 12) + ":" + str.slice(12, 14)
					
					return str;
				}
			}
			
			function thisStgePrcssRsultCdFormatter(cellvalue, options, rowObject){
				if (cellvalue == null || cellvalue == undefined || cellvalue == ""){
					return "";
				} else {
					if(cellvalue == "L"){
						return "지연";
					} else if(cellvalue == "F"){
						return "미도래";
					} else if(cellvalue == "Q"){
						return "큐대기";
					} else if(cellvalue == "S"){
						return "진행중";
					} else if(cellvalue == "T"){
						return "정상종료";
					} else if(cellvalue == "E"){
						return "비정상종료";
					} else if(cellvalue == "C"){
						return "사용자중지";
					} else if(cellvalue == "N"){
						return "파일없음";
					}
				}
			}
		
			function list(){
				var gridPostData = getSearchForJqgrid("cmd", "LIST");

				gridPostData["searchIsDetail"] = 'Y';
				gridPostData["searchBjobMsgDstcd"] = '${param.bjobMsgDstcd}';
				
				var start = '${param.searchStartYYYYMMDD}'.replace(/-/gi,"") + '${param.searchStartHHMM}'.replace(":","");
				var end = $("input[name=searchEndYYYYMMDD]").val().replace(/-/gi,"")+$("input[name=searchEndHHMM]").val().replace(":","");

				gridPostData["searchStartTime"] = start + "000";
				gridPostData["searchEndTime"] = end + "000";
				
				$("#grid").jqGrid({
					datatype: 'json',
					mtype: 'POST',
					url: '<c:url value="/bap/admin/schedule/scheduleMonitorMan.json" />',
					postData: gridPostData,
					colNames: [
						"UUID",
						"SUBUUID",
						"파일크기",
						"파일명",
						"전송상태",
						"거래시작시간",
						"거래종료시간"
					],
					colModel: [
						{ name: "BJOBDMNDMSGID", align: "center" },
						{ name: "BJOBDMNDSUBMSGID", align: "center" },
						{ name: "SNDRCVFILESIZE", align: "center" },
						{ name: "SNDRCVFILENAME", align: "center" },
						{ name: "THISSTGEPRCSSRSULTCD", align: "center", formatter: thisStgePrcssRsultCdFormatter },
						{ name: "FILETRSMTSTARTHMS", align: "center", formatter: fileTrsmtHmsFormatter },
						{ name: "FILETRSMTENDHMS", align: "center", formatter: fileTrsmtHmsFormatter }
					],
					jsonReader: {
						repeatitems: false
					},
					pager: $("#pager"),
					page: '1',
					rowNum: '${rmsDefaultRowNum}',
				    autowidth: true,
				    autoheight: true,
					height: $("#container").height(),
					viewrecords: true,
					multiselect: false,
					multiboxonly: false,
					rowList: eval('[${rmsDefaultRowList}]'),
					gridComplete: function(){
						var colModel = $(this).getGridParam("colModel");
						
						for(let i=0; i < colModel.length; i++){
							$(this).setColProp(colModel[i].name, {sortable: false});
						}
					},
					ondblClickRow: function(rowId){
						var rowData = $(this).getRowData(rowId);
						
						var args = new Object();
				    	args['check'] = "";
						
						var url2 = '<c:url value="/bap/transaction/transactionStatusMan.view" />';
					    
					    url2= url2 + "?cmd=DETAIL";
				        url2= url2 + '&popup='+true;
			            url2= url2 + '&menuId=' + '${param.menuId}';
			            url2= url2 + '&page='+$(this).getGridParam("page");
					    url2= url2 + "&bjobDmndMsgID="    + rowData['BJOBDMNDMSGID'];
					    url2= url2 + "&bjobDmndSubMsgID=" + rowData['BJOBDMNDSUBMSGID'];
					    
					    var ret = showModal2(url2, args, 1300, 760, function(arg){
					    	var args = null;
					    	
						    if(arg == null || arg == undefined ) { //chrome
						        args = this.dialogArguments;
						    } else {//ie
						        args = arg;
						    }
						    
						    if( !args || !args.returnValue ) return;
					    }, "scroll:yes;");
					},
					loadError: function(jqXHR, textStatus, errorThrown){
						if(jqXHR.status == 400) {
							alert(jqXHR.responseText);
						}
						
			      		if(jqXHR.status == 401) {
							var location = '<%=request.getContextPath()%>/';
							comloadError(jqXHR, textStatus, errorThrown ,location);
						}
					}
				});
			}
		
			$(document).ready(function(){
				var returnUrl = getReturnUrlForReturn();
				
				$("input[name=searchStartYYYYMMDD],input[name=searchEndYYYYMMDD]").inputmask("yyyy-mm-dd",{'autoUnmask':true});
				$("input[name=searchStartHHMM],input[name=searchEndHHMM]").inputmask("hh:mm:ss",{'autoUnmask':true});
				
				var searchStartYYYYMMDD = "${param.searchStartYYYYMMDD}";
				var searchEndYYYYMMDD   = "${param.searchEndYYYYMMDD}";
				var searchStartHHMM     = "${param.searchStartHHMM}";
				var searchEndHHMM       = "${param.searchEndHHMM}";
				
				if(searchStartYYYYMMDD == null || searchStartYYYYMMDD == ''){
					$("input[name=searchStartYYYYMMDD]").val(getToday());
				}
				
				if(searchEndYYYYMMDD == null || searchEndYYYYMMDD == ''){
					$("input[name=searchEndYYYYMMDD]").val(getToday());
				}
				
				if(searchStartHHMM == null || searchStartHHMM == ''){
					$("input[name=searchStartHHMM]").val('000000');
				}
				
				if(searchEndHHMM == null || searchEndHHMM == ''){
					$("input[name=searchEndHHMM]").val('235959');
				}
				
				$("#btn_previous").click(function(){
					goNav(returnUrl);
				});
				
				list();
			});
		</script>
	</head>
	
	<body>
		<div class="right_box">
			<div class="content_top">
				<ul class="path">
					<li> <a href="#">${rmsMenuPath}</a> </li>
				</ul>
			</div>
			
			<div class="content_middle">
				<div class="search_wrap">
					<img id="btn_previous" src="<c:url value="/img/btn_previous.png"/>" level="R" />	
				</div>
				
				<div class="title">
					파일 송수신 모니터링 상세
					<span class="tooltip">
						일괄 전송 스케쥴을 기준으로 거래 로그를 확인할 수 있습니다. <br/>
						해당 로그와 관련된 모든 정보를 확인할 수 있습니다.
					</span>
				</div>
				
				<table class="search_condition" cellspacing=0>
					<tr>
						<th style="width: 150px;">분류명</th>
						<td style="width: 150px;"> <input name="bjobBzwkName" type="text" value="${param.bjobBzwkName}" readonly /> </td>
						
						<th style="width: 150px;">대외일괄업무명</th>
						<td style="width: 150px;"> <input name="osidInstiName" type="text" value="${param.osidInstiName}" readonly /> </td>
						
						<th style="width: 150px;">거래시간</th>
						<td style="width: 300px;">
							<input name="searchStartYYYYMMDD" type="text" value="${param.searchStartYYYYMMDD}" readonly style="width: 20%;" />
							<input name="searchStartHHMM" type="text" value="${param.searchStartHHMM}" readonly style="width: 20%;" />
							~
							<input name="searchEndYYYYMMDD" type="text" value="${param.searchEndYYYYMMDD}" readonly style="width: 20%;" />
							<input name="searchEndHHMM" type="text" value="${param.searchEndHHMM}" readonly style="width: 20%;" />
						</td>
					</tr>
					
					<tr>
						<th style="width: 150px;">인터페이스ID</th>
						<td style="width: 150px;"> <input name="bjobMsgDstcd" type="text" value="${param.bjobMsgDstcd}" readonly /> </td>
						
						<th style="width: 150px;">파일코드</th>
						<td> <input name="bjobTranDstcdName" type="text" value="${param.bjobTranDstcdName}" readonly /> </td>
						
						<th style="width: 150px;">사용여부</th>
						<td> <input name="thisMsgUseYn" type="text" value="${param.thisMsgUseYn}" readonly /> </td>
					</tr>
				</table>
				<table id="grid"></table>
				<div id="pager"></div>
			</div>
		</div>
	</body>
</html>