<%@ 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 companyName = window.dialogArguments["companyName"];

var url ='<c:url value="/onl/admin/service/companyMan.json" />';


$(document).ready(function() {	
	
	$('input[name=searchCompanyName]').val(companyName);

	$('#grid').jqGrid({
		datatype : "json",
		mtype : 'POST',
		url : url,
		postData : {cmd : "LIST_POP",companyName : companyName },
		colNames : [ 
		            '<%=localeMessage.getString("company.appCode")%>',
			 		'<%=localeMessage.getString("company.compCd")%>',
            		'<%=localeMessage.getString("company.compName")%>',
            		'<%=localeMessage.getString("company.bzwkDstcd")%>',
			  		'<%=localeMessage.getString("company.bzwkDstcd")%>',
            		'<%=localeMessage.getString("company.compItcontName")%>',
            		'<%=localeMessage.getString("company.bzwkContPrsnName")%>',
            		'<%=localeMessage.getString("company.itContPrsnName1")%>'
		              ],
		colModel : [ 
					{ name : 'APPCODE'					, align:'center'	},
					{ name : 'COMPANYCODE'				, align:'left'		},
					{ name : 'COMPANYNAME'				, align:'left'		},
					{ name : 'BZWKNAME'					, align:'left'	},
					{ name : 'BZWKDSTCODE'				, hidden:true	},
					{ name : 'COMPANYITCONTACTNAME'		, align:'left'		},
					{ name : 'BZWKCONTACTPERSON'		, align:'left'	},
					{ name : 'ITCONTACTPOINTPERSON1'	, align:'left'		}
 					],
		jsonReader : {
			repeatitems : false
		},
		pager : $('#pager'),
		page : '${param.page}',
		rowNum : '${rmsDefaultRowNum}',
		autoheight : true,
		height : $("#container").height(),
		autowidth : true,
		viewrecords : true,
		rowList : eval('[${rmsDefaultRowList}]'),
		loadComplete:function (d){
			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) {

        	var location ='<%=request.getContextPath()%>/';
        	comloadError(jqXHR, textStatus, errorThrown ,location);
        	
    	},		
		ondblClickRow: function(rowId) {
			var rowData = $(this).getRowData(rowId);
			var key = rowData['COMPANYNAME'];
			var companyCode = rowData['COMPANYCODE'];
			var retData=new Object() ;
			retData['key'] = key;
			retData['companyCode'] = companyCode;
			
			window.returnValue = retData;
			$("#btn_close").trigger("click");
        }	
		
	
	});
	
	resizeJqGridWidth('grid','title','1000');

	$("#btn_search").click(function(){
	   
	   var _companyName = $('input[name=searchCompanyName]').val();


		$("#grid").setGridParam({ postData:{cmd:"LIST_POP",companyName:_companyName} ,page : "1" }).trigger("reloadGrid");
	});
	$("#btn_close").click(function(){
		window.close();
	});
	
	$("input[name^=search]").keydown(function(key){
		if (key.keyCode == 13){
			$("#btn_search").click();
		}
	});
	
	//buttonControl();
	
}); 
 
</script>
</head>
	<body>
		<div class="popup_box">
			<div class="search_wrap">
<%-- 				<img src="<c:url value="/img/btn_search.png"/>" alt="" id="btn_search" level="W" /> --%>
<%-- 				<img src="<c:url value="/img/btn_close.png"/>" alt="" id="btn_close" level="R" />	 --%>
				<button type="button" class="cssbtn" id="btn_search" level="W"><i class="material-icons">search</i> <%= localeMessage.getString("button.search") %></button>
				<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("company.title")%></div>
			<table class="search_condition" cellspacing=0;>
				<tbody>
					<tr>
						<th style="width:180px;"><%=localeMessage.getString("company.compName")%></th>
						<td><input type="text" name="searchCompanyName" value=""></td>							
					</tr>
				</tbody>
			</table>
			<table id="grid" ></table>
			<div id="pager"></div>
			
		</div><!-- end.popup_box -->
	</body>
</html>