<!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">
<%@ include file="nlsResource.jsp" %>
<%@page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.io.*, java.util.*, jet.cs.util.*, jet.server.api.*, jet.server.api.http.*, jet.server.log.*" %>

<%@ page errorPage="errorpage.jsp" %>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<style type="text/css">
td {
	font-family: Tahoma, Verdana, Arial, sans-serif;
	font-size: 11px;
}
input,textarea,option,select {
	font-size: 100%;
	color: #000000;
	font-family: Tahoma, Verdana, Arial, sans-serif;
}
a.stb:link {
	color: #000000;
	text-decoration: none;
}
a.stb:visited {
	color: #000000;
	text-decoration: none;
}
a.stb:hover {
	color: #CC0000;
	text-decoration: none;
}
hr.in{
		border-top: 1px solid #B5C6D1;
		border-bottom: 1px solid #FFFFFF;
}

</style>
<title>Print Customerlist</title>
</head>

<!-- 
 This JSP shows how to set parameters for printing the customerlist report 
 by using the ViewerApplet. This JSP calls printReport.jsp.
 Usage:
 Copy this file, printDemo.jsp and printReport.jsp into <server_install_home>/public_html/jinfonet. 
 Then start standalone report server and type url like 
 "http://localhost:8888/jinfonet/printDemo.jsp".
 -->

<%@ include file="AuthCheck.jsp" %>

<%
	HttpRptServer httpRptServer = HttpUtil.getHttpRptServer();

    String cat = "/SampleReports/SampleReports.cat"; //request.getParameter(APIConst.TAG_CATALOG);
    String rptName = "/SampleReports/CustomerAnalysis.cls"; //request.getParameter(APIConst.TAG_REPORT);
	
    String user = HttpUtil.getUser(request);

	ReportInfo rptInfo = httpRptServer.getReportInfo(user, cat, rptName);
	Vector params = rptInfo.getParamInfos();
	Vector grpCols = rptInfo.getAvailableGroupFields();
	Vector langs = rptInfo.getAvailableLanguages();
%>	

<script language=javascript>
function submitHide(srcFrame){
    srcFrame.submit();
    parent.frames[1].focus();
}
</script>	
<font face="Arial">
<!-- call printReport.jsp to print the report. -->
<form method="GET" action="printReport.jsp">
<table cellspacing="0" cellpadding="2" border="0" width="100%">
  <tr>
	<td>
<input type=hidden name="isPrint" value="true">
Print Report&nbsp;:&nbsp;<%= HttpUtil.decodeEsc(rptName)%>&nbsp;&nbsp;
<input type="button" value="PrintInCurrentFrame" name="Submit_Btn" onClick="isPrint.value='true'; form.target='desc'; submit();">
<input type="button" value="PrintInHiddenFrame" name="HidePrint_Btn" onClick="isPrint.value='true'; form.target='print'; submitHide(form);">
<input type="reset" value="Reset" name="RBtn1">
<input type="button" value="View" name="View_Btn" onClick="isPrint.value='false'; form.target='desc'; submit();">
	</td>
  </tr>
</table>
	<br>

<%
	//creates input fields for parameters of the report.
	if(params != null && params.size() > 0) {
		StringBuffer sb = new StringBuffer();
		int sz = params.size();
		ParamInfo desc= null;%>
	<table cellspacing="0" cellpadding="2" border="0" width="100%">
		<tr bgcolor="#000000"><td><%= (sz == 1 ? "Parameter" : "Parameters")%></td></tr>
	</table>

    <table cellspacing="0" cellpadding="2" border="0" width="100%">
<%
		for (int i = 0; i < sz; i++) {
			desc = (ParamInfo)params.elementAt(i);
			String pmt = desc.getPrompt();
%>
			<tr><td>
<%
            if(pmt != null && pmt.length() > 0){
%>
				<%= pmt%>
<%
            } else {
%>
				<%= desc.getName()%>
<%
			}
%>
			</td><td>
<%
			if (desc.isColumn() && grpCols != null) {
%>
				<select name="<%= APIConst.TAG_PARAM_PREFIX + desc.getName()%>" size="1">
<%					int sz1 = grpCols.size();
				for (int i1 = 0; i1 < sz1; i1++) {
					String s = (String)grpCols.elementAt(i1);
%>
					<option <%= (s.equalsIgnoreCase(desc.getDefaultValue()) ? "selected" : "")%>
					value="<%= s%>"><%= s%></option>
<%
				}
%>
				</select>
<%
			} else {
				String tn = "pval_"+String.valueOf(i);
%>
				<input type="text" name="<%= APIConst.TAG_PARAM_PREFIX + desc.getName()%>"
				value="<%= desc.getDefaultValue()%>" id="<%= tn%>">
<%
				Vector v = desc.getValueOptions(Locale.getDefault());

				if (v != null && v.size() > 0) {
					String on = "vopt_" + String.valueOf(i);
%>
					<select name="<%= on%>" onchange="<%= tn + ".value=this.value"%>">
<%					
					int sz1 = v.size();
					for (int i1 = 0; i1 < sz1; i1++) {
						String s = (String)v.elementAt(i1);
%>
						<option <%= (s.equalsIgnoreCase(desc.getDefaultValue()) ? "selected" : "")%>
						value="<%= s%>"><%= s%>
						</option>
<%
					}
%>
					</select>
<%
				}
			}
%>
			</td></tr>
<%
		}
%>
      </table>
<%
	}else{
%>
	<table cellspacing="0" cellpadding="2" border="0" width="100%">
		<tr><td><font color="#FF0000">No parameter needed</font></td></tr>
	</table>
<%
	}
	int rstType = APIUtil.parseInt(request.getParameter(APIConst.TAG_RESULT_TYPE), APIConst.HTML);
%>
	<br>
<table cellspacing="0" cellpadding="2" border="0" width="100%">
	<tr><td>Java applet:</td></tr>
<!-- Normal and Plug-in -->
	<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;
 Java Plug-In for Windows 
(Download <a class="stb" style="text-decoration:underline" href="<%= HttpUtil.getJSPWebAppName(APIConst.APPNAME_SENDFILE) + "/lib/jinfonet.cer" %>"> Certificate file </a> of JRViewer Applet for Java Plug-In )
	</td></tr>
	
	<tr><td>
<INPUT TYPE="CHECKBOX" NAME="<%= APIConst.TAG_FRAMEAPPLET %>" CHECKED> Pop-up Window
	</td></tr>
</table>
<br>
<hr class="in">
<br>
<table cellspacing="0" cellpadding="2" border="0" width="100%">
  <tr>
	<td>
<%
	String lang = request.getParameter(APIConst.TAG_REPORT_LANGUAGE);
	if (lang != null) {
		if (langs == null) {
			langs = new Vector(1);
		}
		if (langs.size() == 0) {
			langs.addElement(lang);
		}
	}
	if (langs != null && langs.size() > 0) {
%>
		Using Language:
		<select name="<%= APIConst.TAG_REPORT_LANGUAGE%>" size="1">
<%
		int sz = langs.size();
		String s;
		for (int i = 0; i < sz; i++) {
			s = (String)langs.elementAt(i);
%>
			<option <%= (s.equalsIgnoreCase(lang) ? "selected" : "")%> value="<%= s%>">
			<%= s%></option>
<%
		}
%>
		</select><br>
<%
	}
%>
	Encoding: <select name="<%= APIConst.TAG_REPORT_ENCODING%>>
<%
	String enc = request.getParameter(APIConst.TAG_REPORT_ENCODING);
	if (enc == null) {
		enc = System.getProperty("file.encoding");
	}
	String dn = null;
	if (enc != null) {
		dn = APIUtil.getEncodingDescriptionByName(enc);
	}
	String[][] encodings = APIUtil.getSupportedEncodings();
	int sz = encodings.length;
	for (int i = 0; i < sz; i++) {
%>
		<option value="<%= encodings[i][0]%>" 
		<%= (dn != null && dn.equals(encodings[i][1]) ? " selected" : "")%>>
		<%= encodings[i][1]%>
		</option>
<%
	}
%>
	</select>
	</td>
  </tr>
</table>
<table cellspacing="0" cellpadding="2" border="0" width="100%">
  <tr>
    <td>
      <INPUT TYPE="radio" NAME="<%= APIConst.TAG_USE_DEF_DB_USER %>" VALUE="true" CHECKED> Use the default DB user and password defined in catalog 
    </td>
  </tr>
  <tr>
    <td>
      <INPUT TYPE="radio" NAME="<%= APIConst.TAG_USE_DEF_DB_USER %>" VALUE="false"> 
		Use the DB user:
        <input type="text" name="<%= APIConst.TAG_DB_USER %>" style="width:100">
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		password: 
		<input type="password" name="<%= APIConst.TAG_DB_PSWD %>" style="width:100">
    </td>
  </tr>
</table>
<br>
<hr class="in">
<table cellspacing="0" cellpadding="2" border="0" width="100%">
  <tr>
    <td>
<input type="checkbox" name="interactive" value="true" > Interactive &nbsp;&nbsp;
<input type="checkbox" name="background" value="true" checked> Background &nbsp;&nbsp;
<input type="checkbox" name="wait" value="true" > Wait &nbsp;&nbsp;
<input type="checkbox" name="separateLargePage" value="true" > SeparateLargePage &nbsp;&nbsp;
<input type="checkbox" name="notifyComplete" value="true" checked> NotifyComplete &nbsp;&nbsp;
Printer: <input type="text" name="printer" value="" style="width:180">
<input type=hidden name="<%= APIConst.TAG_CMD %>" value="<%= APIConst.CMD_WEB_VIEW %>">
<input type=hidden name="<%= APIConst.TAG_CATALOG %>" value="<%= cat %>">
<input type=hidden name="<%= APIConst.TAG_REPORT %>" value="<%= rptName %>">
<p>
<input type="button" value="PrintInCurrentFrame" name="Submit_Btn" onClick="isPrint.value='true'; form.target='desc'; submit();">
<input type="button" value="PrintInHiddenFrame" name="HidePrint_Btn" onClick="isPrint.value='true'; form.target='print'; submitHide(form);">
<input type="reset" value="Reset" name="RBtn1">
<input type="button" value="View" name="View_Btn" onClick="isPrint.value='false'; form.target='desc'; submit();">
</p>
    </td>
  </tr>
</table>

</form>
</body>
</html>
