<%@ 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 cnvsnName = "${param.cnvsnName}";
var tgt_layout = "${param.tgt_layout}"
var src_layout = "${param.src_layout}"
var url ='<c:url value="/onl/admin/rule/transformMan.json" />';

function messageFormater(cellvalue, options, rowObject){
	var srcFlag = rowObject["SRCEXIST"];
	var tgtFlag = rowObject["TGTEXIST"];
	var message = "";
	if(srcFlag!="O"){
		message = "변환명령의 경로와 소스레이아웃의 경로가 다릅니다.";
	}
	if(tgtFlag!="O"){
		message += "변환결과 항목경로와 타겟레이아웃의 경로가 다릅니다.";
	}
	return message;
}

$(document).ready(function() {
	$("input[name=cnvsnName]").val(cnvsnName);
	$('#grid').jqGrid({
		datatype : "json",
		mtype : 'POST',
		url : url,
		postData : { cmd : 'DETAIL_POP'
			       , cnvsnName : cnvsnName
			       , tgt_layout : tgt_layout
			       , src_layout : src_layout
		},
		colNames:[
                  '<%=localeMessage.getString("tranManDtPop.conRsItPtNm")%>',
                  '<%=localeMessage.getString("tranManDtPop.conOrd")%>',
                  '<%=localeMessage.getString("tranManDtPop.ItDft")%>',
                  '<%=localeMessage.getString("tranManDtPop.itSrlNmb")%>',
                  '타겟Flag',
                  '소스Flag',
                  '<%=localeMessage.getString("tranManDtPop.errMsg")%>'
                  ],
		colModel:[
				{ name : 'CNVSNRSULTITEMPATHNAME' , align:'left' },
				{ name : 'CNVSNCMDNAME'      , align:'left'  },
				{ name : 'CNVSNITEMBASCVAL'      , align:'left'   ,width : '30'},
				{ name : 'CNVSNITEMSERNO'  , align:'right' ,width : '30' },
				{ name : 'TGTEXIST'  , hidden:true },
				{ name : 'SRCEXIST'  , hidden:true },
				{ name : 'MESSAGE'   ,formatter :messageFormater , width : '80'}
				],
		jsonReader : {
			repeatitems : false
		},
		rowNum : 10000,
		autoheight : true,
		height : $("#container").height(),
		autowidth : true,
		viewrecords : true,
		rowList : eval('[${rmsDefaultRowList}]'),
		loadComplete:function (d){
			var rows = $(this).getDataIDs();
	    	for( var i= 0; i < rows.length; i++){
	    		var tgtVal = $("#grid").getCell(rows[i],'TGTEXIST');
	    		var srcVal = $("#grid").getCell(rows[i],'SRCEXIST');
	    		if(tgtVal !="O" || srcVal !="O"){
	    			$("#"+rows[i]).find("td").css("background-color","#FFCC99");
	    		}
	    	}
	    	
	    	
			var colModel = $(this).getGridParam("colModel");
			for(var i = 0 ; i< colModel.length; i++){
				$(this).setColProp(colModel[i].name, {sortable : false});
			}
		},
        loadError: function (jqXHR, textStatus, errorThrown) {
        	if(jqXHR.status == 401) {
 	    		alert('HTTP status code: ' + jqXHR.status + '\n' +
 	                    '에러:  세션이 종료되었습니다. ');
 	    		parent.location.href='<%=request.getContextPath()%>/';	
 	    	}
    	},		
		ondblClickRow: function(rowId) {

		}	
	});
	
	
	resizeJqGridWidth('grid','title','1000');

	$("#btn_close").click(function(){
		//debugger;
		window.close();
	});
	$("body").css("overflow-x","hidden");
}); 
 
</script>
</head>
	<body>
			<div class="popup_box" id="title">
				<div class="search_wrap">
<%-- 					<img id="btn_close" src="<c:url value="/img/btn_close.png"/>"  level="R"/> --%>
					<button type="button" class="cssbtn" id="btn_close" level="R"><i class="material-icons">cancel</i> <%= localeMessage.getString("button.close") %></button>
				</div>
				<div class="title"><%=localeMessage.getString("tranManDtPop.title")%></div>
				<table class="search_condition" cellspacing="0">
					<tr>
						<th style="width:180px;"><%=localeMessage.getString("tranManDtPop.conMapCd")%></th>
						<td>
							<input type="text" name="cnvsnName" readonly>
						</td>
					</tr>
				</table>
				<!-- grid -->
				<table id="grid" ></table>
				
			</div><!-- end content_middle -->
	</body>
</html>