<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ page import="com.eactive.eai.rms.common.login.SessionManager"%>
<%@ page import="com.eactive.eai.common.util.SystemUtil"%>
<%
	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 roleString	= "<%=SessionManager.getRoleIdString(request)%>";
var devSvr		= <%=SystemUtil.isDevServer()%>;
var prdSvr		= <%=SystemUtil.isProdServer()%>;
var stgSvr		= <%=SystemUtil.isStagingServer()%>;
var svrType		= '';
function init(callback,url){
	$.ajax({  
		type : "POST",
		url: '<c:url value="/bap/transaction/messageReqMan.json" />',
		dataType:"json",
		data:{cmd: 'LIST_INIT_COMBO'},
		success:function(json){
			new makeOptions("CODE","NAME").setObj($("select[name=searchThisMsgUseYn]")).setNoValueInclude(true).setNoValue("", "전체").setData(json.useYn).rendering();
			putSelectFromParam();
			if(typeof callback === 'function') {
				callback(url);
    		}
		},
		error:function(e){
			alert(e.responseText);
		}
	});
}
function resend(bjobDmndMsgID, fileIdx) {
	var fileNameId = "fileName_"+fileIdx;
	var fileName = document.getElementById(fileNameId).value;
	if ( confirm( "해당 건을 재 전송 하시겠습니까? :" + fileName ) != true ) return;
	
	var postData = new Array();
	postData.push({ name: "cmd"       		 , value:"TRANSACTION_RESEND"});
	postData.push({ name: "bjobDmndMsgID"    , value:bjobDmndMsgID});
	postData.push({ name: "sndRecvFileName"  , value:fileName});
	$.ajax({
		type : "POST",
		url:'<c:url value="/bap/transaction/messageReqMan.json" />',
		data:postData,
		success:function(args){
			
			if ( args.result_resend != '' ) {
				alert( args.result_resend );
			}
			$("#grid").trigger("reloadGrid");
		},
		error:function(e){
			alert(e.responseText);
		}
	});
}
function formatter (cellvalue, options, rowObject){
}	
function list(url){
	var gridPostData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로
	$('#grid').jqGrid({
		datatype:"json",
		mtype: 'POST',
		url: '<c:url value="/bap/transaction/messageReqMan.json" />',
		postData : gridPostData,
		colNames:[
				  '메시지구분코드',
				  '인터페이스ID',
        		  '대외일괄업무코드',
				  '대외일괄업무명',
                  '송수신파일명',
                  '송수신파일설명',
                  '재요청 파일명',
                  '재전송'
                  ],
		colModel:[
				{ name : 'BJOBMSGDSTCD'       , hidden:true   },
				{ name : 'INFID'      , align:'left'  },
				{ name : 'OUTBIZCD'       , align:'left'  },
				{ name : 'OSIDINSTINAME'           , align:'left'	,sortable:false  },
				{ name : 'BJOBTRANDSTCDNAME'  , align:'left'  },
				{ name : 'BJOBMSGDSTICNAME'   , align:'left'  },
				{ name : 'SNDRCVFILENAME'   , align:'center'}, 
				{ name : 'RESEND'   , align:'center'}
				],
        jsonReader: {
             repeatitems:false
        },	          
		pager : $('#pager'),
		page : '${param.page}',
		rowNum : '${rmsDefaultRowNum}',
	    autoheight: true,
	    height: $("#container").height(),
		autowidth: true,
		viewrecords: true,
		multiselect: true,
		multiboxonly: false,
		rowList : eval('[${rmsDefaultRowList}]'),
		gridComplete:function (d){
			var ids = $(this).getDataIDs();
			
			for(var i = 0 ; i< ids.length; i++) {
				var cl = ids[i];
        		var rowData = $(this).getRowData(cl); 
				var bjobDmndMsgID = rowData['BJOBMSGDSTCD'];
				
				var be = "<input style='height:20px;width:60px;' type='button' value='재전송' onclick=\"resend('"+bjobDmndMsgID+"','"+i+"');\" />";
    			var ed = "<input stype='height:45px;width:60px;' type='text' id='fileName_"+i+"'/>";
    			$(this).setRowData(ids[i],{SNDRCVFILENAME:ed});
    			$(this).setRowData(ids[i],{RESEND:be});
			
			}
		},
		loadError: function (jqXHR, textStatus, errorThrown) {
      		if(jqXHR.status == 401) {
	        		var location ='<%=request.getContextPath()%>/';
		        	comloadError(jqXHR, textStatus, errorThrown ,location);
		    	}	
    	}
	});
}

$(document).ready(function() {	

	// 일괄전송전문관리 모든 TAB의 조회조건을 특정 업무구분코드로 동기화한다.
	<% String sessionAttr = (String)session.getAttribute("searchBjobBzwkName"); %>
	var sessionAttr = "<%= sessionAttr %>";
	if (sessionAttr != "null" && sessionAttr != "") {
		$("input[name=likeBjobBzwkName]").val(sessionAttr); 
	}
	
	resizeJqGridWidth('grid','title','1000');
	var url ='<c:url value="/bap/transaction/messageReqMan.json" />';
	
	
	
	init(list,url);

	$("#btn_search").click(function(){
		var postData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
		$("#grid").setGridParam({url:url, postData: postData,page:"1" }).trigger("reloadGrid");
	});
	
	
	$("input[name^=search]").keydown(function(key){
		if (key.keyCode == 13){
			$("#btn_search").click();
		}
	});
	$("input[name^=like]").keydown(function(key){
		if (key.keyCode == 13){
			$("#btn_search").click();
		}
	});
	
	
	
	buttonControl();	
});
 
</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">
				<div class="search_wrap">
					<!-- <img src="<c:url value="/img/btn_clone.png"/>" alt="" id="btn_clone_stg" level="W" /> -->
					<!-- <img src="<c:url value="/img/btn_clone_prod.png"/>" alt="" id="btn_clone_prod" level="W" /> -->
					<!-- <img src="<c:url value="/img/btn_clone_dev.png"/>" alt="" id="btn_clone_dev" level="W" /> -->
					<img src="<c:url value="/img/btn_search.png"/>" alt="" id="btn_search" level="R" />	
				</div>
				<div class="title">송수신 파일 관리<span class="tooltip">일괄 전송에서 사용하는 송수신 파일을 관리 하는 화면입니다</span></div>
				
				<table class="search_condition" cellspacing=0;>
					<tbody>
						<tr>
							<th style="width:180px;">인터페이스ID</th>
							<td><input type="text" name="likeInfId" value="${param.likeInfId}"></td>
							<th style="width:180px;">대외일괄업무코드</th>
							<td colspan="3"><input type="text" name="likeOutExtCd" value="${param.likeOutExtCd}"></td>
							<th style="width:180px;">대외일괄업무명</th>
							<td><input type="text" name="searchOsidInstiName" value="${param.searchOsidInstiName}"></td>

						</tr>
						<tr>
							<th style="width:180px;">송수신파일명</th>
							<td><input type="text" name="likeBjobTranDstcdName" value="${param.likeBjobTranDstcdName}"></td>
							<th style="width:180px;">송수신파일설명</th>
							<td colspan="3"><input type="text" name="likeBjobMsgDsticName" value="${param.likeBjobMsgDsticName}"></td>
							<th style="width:180px;" hidden="hidden">어플리케이션코드</th>
							<td hidden="hidden"><input type="text" name="likeUapplCd" value="${param.likeUapplCd}"></td>
							<th style="width:180px;" hidden="hidden">담당자ID</th>
							<td hidden="hidden"><input type="text" name="likeThisMsgChrgIDs" value="${param.likeThisMsgChrgIDs}"></td>
							<th style="width:150px;">사용여부</th>
							<td colspan="4"><div class="select-style"><select name="searchThisMsgUseYn" value="${param.searchThisMsgUseYn}"></select></div></td>
						</tr>
					</tbody>
				</table>
				
				<table id="grid" ></table>
				<div id="pager"></div>	
				
			</div><!-- end content_middle -->
		</div><!-- end right_box -->				
	</body>	
</html>

