<%@ page contentType="text/html;charset=utf-8" isErrorPage="true" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ page import="kr.co.udapsoft.common.commonSign.CommonSignThreadManager" %>
<%@ page import="kr.co.udapsoft.common.commonSign.CommonMailThreadManager" %>
<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />
<%
    ctx.init(request, response);
	HandlerStorage storage = ctx.getHandlerStorage();
	
	ValueObject params = ctx.getParams();

	if( "CommonThread".equals(params.get("thread_name")) ){
		if( "Start".equals(params.get("cmd")) ) {
			CommonSignThreadManager.doStart();
		}
		else if( "Stop".equals(params.get("cmd")) ) {
			CommonSignThreadManager.doStop();
		}
		
	}else if( "CommonMailThread".equals(params.get("thread_name")) ){
		if( "Start".equals(params.get("cmd")) ) {
			CommonMailThreadManager.doStart();
		}
		else if( "Stop".equals(params.get("cmd")) ) {
			CommonMailThreadManager.doStop();
		}
		
	}
%>

<SCRIPT language="JavaScript">

	$(document).ready(function(){
		jQuery("#btn_ACZ10100").click(function() {
			excuteProc('IF_GET_ACZ10100');
		});
		jQuery("#btn_ACZ10101").click(function() {
			excuteProc('IF_GET_ACZ10101');
		});
		jQuery("#btn_PUB0120T").click(function() {
			excuteProc('IF_GET_PUB0120T');
		});
		jQuery("#btn_ACZ10800").click(function() {
			excuteProc('IF_GET_ACZ10800');
		});
		jQuery("#btn_BUDGET").click(function() {
			excuteProc('IF_GET_BUDGET');
		});
		jQuery("#btn_PDF").click(function() {
	 
			var pop = window.open("/common/file/PdfViewer.screen?PROOF_DEPT=2054&PROOFDATE=20190331&PROOF_NO=3&PROOF_SEQ=1&PAGES_YN=N&zoom=100","pop","width=700,height=300, scrollbars=yes, resizable=yes"); 
		 
		});
	});
	
	function excuteProc(procName){
		var f = document.form1;
		f.procName.value = procName;
		submitXmlRequest("/common/util/getErpData.screen", "PROC", f, "SUCCESS");
	}
	
	function doCmd(threadName, cmd) {
		var f = document.form1;
		f.thread_name.value = threadName;
		f.cmd.value         = cmd;
		f.submit();
	}
	
	function doResult(resultObj) {
		document.form1.isSubmit = false;
		try {
			if( resultObj.getRequestEvent() == "PROC") {
				if( resultObj.getSuccess() ) {
					alert("완료되었습니다.");
				} else {
					dlgErrorMsg(resultObj);
				}
			}
		} catch(errorObject) {
			showErrorDlg("doResult()", errorObject);
		}
	}
	
	
	
</SCRIPT>
<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<form name="form1" method="post">
	<INPUT type="hidden" name="fevent" id="fevent" value="">
	<INPUT type="hidden" name="thread_name" value="">
	<INPUT type="hidden" name="cmd"         value="">
	<INPUT type="hidden" name="procName"    value="">
	<div align="left" id="title">
		<ul>
			<li>결제 데몬</li>
		</ul>
	</div>
	<table class="form-table">
		<colgroup>
			<col width="20%" />
			<col width="20%" />
			<col width="10%" />
			<col width="10%" />
			<col width="40%" />
		</colgroup>
		<tr>
			<th style="text-align: center;">Name</th>
			<th style="text-align: center;">Status</th>
			<th style="text-align: center;">Control 1</th>
			<th style="text-align: center;">Control 2</th>
			<th style="text-align: center;">Description</th>
		</tr>
		<tr height="25">
			<td style="text-align: center;">CommonSignThread</td>
			<td style="text-align: center;"><%= CommonSignThreadManager.isRun() %></td>
			<td style="text-align: center;"><a href="javascript:doCmd('CommonThread','Start');">Start</a></td>
			<td style="text-align: center;"><a href="javascript:doCmd('CommonThread','Stop');">Stop</a></td>
			<td style="text-align: center;">통합 결재 데몬</td>
		</tr>
		<tr height="25">	
			<td style="text-align: center;">CommonMailThread</td>
			<td style="text-align: center;"><%= CommonMailThreadManager.isRun() %></td>
			<td style="text-align: center;"><a href="javascript:doCmd('CommonMailThread','Start');">Start</a></td>
			<td style="text-align: center;"><a href="javascript:doCmd('CommonMailThread','Stop');">Stop</a></td>
			<td style="text-align: center;">메일발송데몬</td>
		</tr>
	</table>
	
	<div class="application-info magT15">
		<div class="application-sub-title">
			<span class="title">ERP 데이터 가져오기</span>
		</div>
	</div>
	<TABLE class="form-table">
		<colgroup>
			<col width="40%"/>
			<col width="40%"/>
			<col width="20%"/>
		</colgroup>
		<TR height="25"> 
			<TH style="text-align: center;">항목</TH>
			<TH style="text-align: center;">프로시저명</TH>
			<TH style="text-align: center;">실행</TH>
		</TR>
		<TR height="25"> 
			<TD style="text-align: center;">현장</TD>
			<TD style="text-align: center;">IF_GET_ACZ10100</TD>
			<TD style="text-align: center;"><span class="btnSearch center"  id="btn_ACZ10100"><a href="javascript:void(0);">실행</a></span></TD>
		</TR>
		<TR height="25"> 
			<TD style="text-align: center;">부서</TD>
			<TD style="text-align: center;">IF_GET_ACZ10101</TD>
			<TD style="text-align: center;"><span class="btnSearch center"  id="btn_ACZ10101"><a href="javascript:void(0);">실행</a></span></TD>
		</TR>
		<TR height="25"> 
			<TD style="text-align: center;">사용자</TD>
			<TD style="text-align: center;">IF_GET_PUB0120T</TD>
			<TD style="text-align: center;"><span class="btnSearch center"  id="btn_PUB0120T"><a href="javascript:void(0);">실행</a></span></TD>
		</TR>
		<TR height="25"> 
			<TD style="text-align: center;">거래처</TD>
			<TD style="text-align: center;">IF_GET_ACZ10800</TD>
			<TD style="text-align: center;"><span class="btnSearch center"  id="btn_ACZ10800"><a href="javascript:void(0);">실행</a></span></TD>
		</TR>
		<TR height="25"> 
			<TD style="text-align: center;">예산</TD>
			<TD style="text-align: center;">IF_GET_BUDGET</TD>
			<TD style="text-align: center;"><span class="btnSearch center"  id="btn_BUDGET"><a href="javascript:void(0);">실행</a></span></TD>
		</TR>
		<TR height="25"> 
			<TD style="text-align: center;">증빙</TD>
			<TD style="text-align: center;">PDF생성</TD>
			<TD style="text-align: center;"><span class="btnSearch center"  id="btn_PDF"><a href="javascript:void(0);">실행</a></span></TD>
		</TR>
	</TABLE>
</form>