<%@ page contentType="text/html"%>
<%@ page
	import="javax.xml.parsers.DocumentBuilderFactory,javax.xml.parsers.DocumentBuilder,org.w3c.dom.*"%>
<%@page import="ibase.dashboard.sfa.ejb.*"%>
<!--<%@page import="ibase.webitm.reports.utility.ResourceConstants"%>
-->
<%@page import="ibase.utility.CommonConstants"%>
<%@ page import="javax.naming.InitialContext"%>
<%@page import="javax.naming.Context"%>
<%@page import="org.w3c.dom.Node"%>
<%@page import="org.w3c.dom.NodeList"%>
<%@page import="ibase.webitm.utility.GenericUtility"%>

<%!GenericUtility genericUtility = GenericUtility.getInstance();
	String xmlString = "";
	String rptTitle = "";
	Document dom = null;
	NodeList dtlList = null;
	Node parentNode = null;
	NodeList childNodeList = null;
	Node currDetail = null;
	String childNodeName = "";
	String salePersnName = "", submitted_date = "", amount = "", period = " ",
	        status = " ", doctorsName = "", notMetSince = "", visitMissed = "";
 %>
<%
	response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
	response.setHeader("Cache-Control", "no-store, no-cache,must-revalidate");
	response.addHeader("Cache-Control", "post-check=0, pre-check=0");
	response.setHeader("Pragma", "no-cache");
	int ctr = 0;
	CommonConstants.setAPPLICATION_CONTEXT(config.getServletContext().getRealPath("/"));
%>

<html>
<head>
<style type="text/css">
.reportName {
	FONT-FAMILY: Arial;
	FONT-SIZE: 12pt;
	font-weight: bold;
}

.reportTitle {
	FONT-FAMILY: Arial;
	FONT-SIZE: 10pt;
}

.reportDetail {
	FONT-FAMILY: Arial;
	FONT-SIZE: 10pt;
	width: 280px;
	border: 1px solid;
}
.tblHeader 
{
 font-weight: bold;
}
</style>
</head>
<body>

<%
	try
	{
		
		rptTitle   = request.getParameter("rtitle");
		if (rptTitle == null || rptTitle.trim().length() == 0)
		{
			rptTitle =" " ;
		} else
		{
			if(rptTitle.equalsIgnoreCase("Y") && rptTitle.trim().length()!= 0)
			{
				rptTitle ="Expense Request Status" ;
		      }
			else{
				rptTitle =" " ;
			}
		}

		ibase.utility.UserInfoBean userInfo = (ibase.utility.UserInfoBean) session.getAttribute("USER_INFO");

		String user = userInfo.getLoginCode();
		System.out.println("user ::" + user);
		Context context = new InitialContext();
		ExpenseProcessStatusRemote dashboardPortal = (ExpenseProcessStatusRemote) context.lookup("ibase/ExpenseProcessStatus/remote");

		//DashboardPortal dashboardPortal=(DashboardPortal)context.lookup("ibase.dashboard.sfa.ejb.DashboardPortal.class.getName()");
		if (user != null && user.trim().length() != 0)
		{
			xmlString = dashboardPortal.getData(user);
			System.out.println("Return xmlString====" + xmlString);
		}
%>
<%
	if (xmlString != null && xmlString.trim().length() > 0)
		{
%>

<table class="reportName">
	<tr>
		<td><%=rptTitle%></td>
	</tr>
</table>
<table>
	<tr class="reportTitle">
		<td><b>Sales Person:</b></td>
		<td><%=dashboardPortal.getSalePersn()%></td>
	</tr>
</table>

<table class="reportDetail"  rules="rows"   FRAME=BOX >
	<tr class="tblHeader">
		<th> </th>
		<th align="center">Period</th>
		<th align="right">Amount</th>
		<th align="right">Submitted Date</th>
	</tr>
	<%
		dom = genericUtility.parseString(xmlString);
		if(dom !=null )
			{
	
	           dtlList = dom.getElementsByTagName("Detail");
				for (int cntr = 0; cntr < dtlList.getLength(); cntr++)
				{
					parentNode = dtlList.item(cntr);
					childNodeList = parentNode.getChildNodes();

					for (int nodCtr = 0; nodCtr < childNodeList.getLength(); nodCtr++)
					{
						currDetail = childNodeList.item(nodCtr);
						childNodeName = currDetail.getNodeName();
						if (childNodeName.trim().equals("period"))
						{
							period = genericUtility.getColumnValueFromNode("period", parentNode);
						}
						if (childNodeName.trim().equals("amount"))
						{
							amount = genericUtility.getColumnValueFromNode("amount", parentNode);

						}
						if (childNodeName.trim().equals("submitted_date"))
						{
							submitted_date = genericUtility.getColumnValueFromNode("submitted_date", parentNode);
						}
						if (childNodeName.trim().equals("apporval_status"))
						{
							status = genericUtility.getColumnValueFromNode("apporval_status", parentNode);
						}
					}
	%>
	<tr>
		<td>
		<%
			if (status.equals("S"))
						{
		%> <img alt="" height="10" width="10" src="../images/check_mark.png">
		<%
			}

						if (status.equals("U"))
						{
		%> <img alt="" height="10" width="10" src="../images/clock.png">
		<%
			}

						if (status.equals("R"))
						{
		%> <img alt="" height="10" width="10" src="../images/Reject.jpg">
		<%
			}
		%>
		</td>
		<td align="center"><%=period%></td>
		<td align="right"><%=amount%></td>
		<td align="center"><%=submitted_date%></td>
	</tr>
	<%
		}
				}
	%>

</table>
<%
	}

	} catch (Exception ex)
	{
		System.out.println("Exception : ExpenseProcessStatus:" + ex.getMessage()); 
	}
%>

</body>
</html>
