<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" import="java.util.*"%>
<%
/*
proxy jsp 외부 서버에서 연동 할 경우 사용
연동 화면에서는 hidden iframe을 사용 하여 호출

ex1 : http://localhost:9099/websquare/proxy.jsp?proxy_kind=room_login&cmpnCd=S0001&lginId=TC10203

//회의실예약
http://localhost:9099/websquare/proxy.jsp?proxy_kind=room_login&cmpnCd=S0001&lginId=admin			로컬
https://portal2.sgc.co.kr/websquare/proxy.jsp?proxy_kind=room_login&cmpnCd=S0001&lginId=admin		개발
	ex4 : https://portal.sgc.co.kr/websquare/proxy.jsp?proxy_kind=room_login&cmpnCd=S0001&lginId=admin		운영
//회의실예약
ex2 : http://localhost:9099/websquare/proxy.jsp?proxy_kind=room_login&cmpnCd=S0001&lginId=admin			로컬
ex3 : https://portal2.sgc.co.kr/websquare/proxy.jsp?proxy_kind=room_login&cmpnCd=S0001&lginId=admin		개발
ex4 : https://portal.sgc.co.kr/websquare/proxy.jsp?proxy_kind=room_login&cmpnCd=S0001&lginId=admin		운영
*/

/* Enumeration params = request.getParameterNames();
while (params.hasMoreElements()) {
	String name = (String) params.nextElement();
	String value = request.getParameter(name);
	System.out.println(name + " = " + value);
}
*/
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xmlns:ev='http://www.w3.org/2001/xml-events' xmlns:w2='http://www.inswave.com/websquare' xmlns:xf='http://www.w3.org/2002/xforms'>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>SGC Portal</title>
<script type="text/javascript" src="javascript.wq?q=/bootloader"></script>
<script type="text/javascript">
//var _w2xPath_ = $w.getParameter("w2xPath");
<%
String proxy_kind = request.getParameter("proxy_kind");
if ("room_login".equals(proxy_kind)) {//회의실예약
	String cmpnCd = request.getParameter("cmpnCd");
	String lginId = request.getParameter("lginId");
%>
	function init() {
		try {
			
			var lginId = "<%=lginId%>";
			var cmpnCd = "<%=cmpnCd%>";
			
			if(cmpnCd == "TEC"){
				cmpnCd = "S0001";
			} else if(cmpnCd == "GJE") { 
				cmpnCd = "S0002";
			} else if(cmpnCd == "SMG") { 
				cmpnCd = "S0003";
			} else if(cmpnCd == "SKG") { 
				cmpnCd = "S0004";
			}
			
			ajaxLib.ajax("loginRom", {
				requestData: {
					lginId: lginId,
					cmpnCd: cmpnCd
				},
				async: false,
				callback: function(result, e) {
					var userInfo = result; //json 스트링으로 바꿔서 구분자 넣어서 암호화해서 전달하기
					WebSquare.session.setAttribute( "user" , result);
					popupLib.open("CW08040001U", "/ux/cw/cw0804/CW08040001U.xml", {
						title: "회의실예약",
						useLayer: false,     //레어어팝업여부
						modal: false,        //모달팝업
						width: "1920",
						height: "1080",
						top : 0,
						left : 0,
						useIFrame : false,
						scrollbars: true,
						resizable: false,
						param: {
							gubun : "pop",
							prgId : "1736",
							sysCd : "CW"
						},
						callback: "roomLogin"
					});
				}
			});
			
		} catch (e) {
			alert(e.message);
		}
	}
	/* 회의실예약 팝업 콜백 함수.*/
	function roomLogin() {
	}
<%} else if ("insa_login".equals(proxy_kind)) {//proxy_kind 추가시 로직 추가 구현.
	String cmpnCd = request.getParameter("cmpnCd");
	String lginId = request.getParameter("lginId");
%>
	function init() {
		try {
			
			var lginId = "<%=lginId%>";
			var cmpnCd = "<%=cmpnCd%>";
			
			if(cmpnCd == "TEC"){
				cmpnCd = "S0001";
			} else if(cmpnCd == "GJE") { 
				cmpnCd = "S0002";
			} else if(cmpnCd == "SMG") { 
				cmpnCd = "S0003";
			} else if(cmpnCd == "SKG") { 
				cmpnCd = "S0004";
			}
			
			ajaxLib.ajax("loginRom", {
				requestData: {
					lginId: lginId,
					cmpnCd: cmpnCd
				},
				async: false,
				callback: function(result, e) {
					var userInfo = result; //json 스트링으로 바꿔서 구분자 넣어서 암호화해서 전달하기
					if (result.alreadyUsed) {
                        alert("이미 사용중인 사용자입니다.\n기존 로그인에 대해서 로그아웃 처리되었습니다.");
                    }
                    var entxt = JSON.stringify(userInfo);
                    var data = WebSquare.text.BASE64URLEncoder(entxt);

                    //2019.09.01
                    //이인오
                    //포탈 페이지 이동
                    $("#main").prop("method", "post");
                    $("#main").prop("action", "/websquare/");
                    $("#main").submit();
				}
			});
			
		} catch (e) {
			alert(e.message);
		}
	}
<%} else {//proxy_kind 추가시 로직 추가 구현.%>
	function init() {
		alert('proxy_kind 없음.');
	}
<%}%>
window.onload = init;
</script>
</head>
<body></body>
</html>