<%@page contentType="text/html"%>
<%@page
	import="javax.xml.parsers.DocumentBuilderFactory,javax.xml.parsers.DocumentBuilder,org.w3c.dom.*"%>
<%@page import="ibase.dashboard.mfg.bean.*"%>
<%@page import="javax.naming.Context"%>
<%@page import="org.w3c.dom.Node"%>
<%@page import="org.w3c.dom.NodeList"%>
<%@page import="ibase.webitm.utility.GenericUtility"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.Enumeration"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page errorPage="error.jsp"%>
<%@ page import="java.io.File,ibase.utility.CommonConstants" %>

<%@page import="java.text.SimpleDateFormat"%>
<jsp:useBean id="productionVsBudgetBean" scope="request"
	class="ibase.dashboard.mfg.bean.ProductionVsBudgetReportBean" />
<%!GenericUtility genericUtility = GenericUtility.getInstance();
	String objName = "";
	Document dom = null;
	NodeList dtlList = null;
	Node parentNode = null;
	NodeList childNodeList = null;
	Node currDetail = null;
	ArrayList<String> chartDataList = null;
	List<String> geoLocList = new ArrayList<String>();
	List<String> unitFormList = new ArrayList<String>();
	String childNodeName = "";
	String period = "";
	String netsales = "";
	String amount = "";
	String fin_entity = "";
	StringBuffer chartData = null;
	String xmlDataString = "";
	String selectedEntity = "";
	String entity = "", descr = "";
	String user = "TA821";
	String rptTitle = "";
	String srcJSPath = "";
	String srcImagesPath = "";
	Calendar calendar = null;
	String frmDate = "";
	String toDate = "", unitForm = "";
	String dayQty = "", fldValue = "", fldDescr;
	NodeList locationList = null;
	NodeList detailList = null;
	NodeList unitList = null;
	NodeList dateList = null;
	NodeList dayQtyList = null;
	Node locationNode = null;
	NodeList foreCastList = null;
	Node unitNode = null;
	Node dateNode = null;
	Node dayNode = null;
	Node foreCastNode = null;
	String date = "";
	int lastDayOfMonth = 0;
	int todaysDay = 0;
	String month = "";
	int preyear = 0;
	int year = 0;
	String[] geo_loc = null;
	String[] unit_form = null;
	String unitFrmXml = "";
	String geoLocCodeXml = "";
	String checkGeoLoc = "";
	String checkUnitForm = "";
	List<String> sumDayPro = new ArrayList<String>();
	List<String> cumLstYear = new ArrayList<String>();
	List<Double> cumuQty = new ArrayList<Double>();
	List<String> LBEList = new ArrayList<String>();
	SimpleDateFormat simpleDateFormat = null;%>
<%
	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");
%>
<%
	String userAgent = request.getHeader("user-agent");
	System.out.println("userAgent ==" + userAgent);
	if (userAgent.indexOf("Android") > 0 || userAgent.indexOf("iPhone") > 0 || userAgent.indexOf("iPad") > 0)
	{
		srcJSPath = "ibase/FusionChart/js/FusionCharts.js";
		srcImagesPath = "ibase/FusionChart/images/MSCombi3D.swf";

	} else
	{
		srcJSPath = "/ibase/FusionChart/js/FusionCharts.js";
		srcImagesPath = "/ibase/FusionChart/images/MSCombi3D.swf";

		System.out.println("srcJSPath ==" + srcJSPath);
		System.out.println("srcImagesPath ==" + srcImagesPath);

	}
%>

<%@page import="java.util.ArrayList"%><html>
<head>
<style type="text/css">
.tdLabel {
	FONT-FAMILY: Arial;
	font-size: 12pt;
}

.title {
	FONT-FAMILY: Arial;
	font-size: 14pt;
}

.combox {
	border-radius: 5px;
	width: 1000px;
	align: center;
	background-color: #F5F5F5;
}

.headerTable {
	height: 50px;
	width: 100px;
	border: 1;
	align: center;
}

.headerTr {
	background-color: green;
	height: 30px;
	font-size: 7pt;
}

.detailTr {
	background-color: yellow;
	height: 20px;
	font-size: 7pt;
}
</style>
<script type="text/javascript" src="<%=srcJSPath%>"></script>
<link rel="stylesheet" type="text/css"
	href="/ibase/dashboard/mfg/css/ui.dropdownchecklist.css" />
<script type="text/javascript"
	src="/ibase/dashboard/mfg/jquery/jquery.js"></script>
<script type="text/javascript"
	src="/ibase/dashboard/mfg/jquery/ui.core.js"></script>
<script type="text/javascript"
	src="/ibase/dashboard/mfg/jquery/ui.dropdownchecklist.js"></script>

</head>
<script type="text/javascript">
$(document).ready(function(){
	$("#geo_loc").dropdownchecklist({ firstItemChecksAll: true, maxDropHeight: 100 });
 });
 
$(document).ready(function(){
	$("#unit_form").dropdownchecklist({ firstItemChecksAll: true, maxDropHeight: 100 });
 });

function getData(geoLocation,unitForm)
{

   var element  = document.getElementById("geo_loc");
   var location =geoLocation.split(","); 
   
     for(i=0;i<location.length;i++)
     {
      	for (var j = 0; j < element.options.length; j++) 
        	 {
    	     var checkLoc= "'"+element.options[j].value+"'";
    		   if(checkLoc== location[i])
				   {
			    	element.options[j].selected = true;
				   }
		       }
      }

     var elementForm  = document.getElementById("unit_form");
     var unitForm =unitForm.split(","); 
       for(k=0;k <unitForm.length;k++)
       {
      	for (var l = 0; l < elementForm.options.length; l++) 
          	 {
      	     var checkUnit= "'"+elementForm.options[l].value+"'";
      		   if(checkUnit== unitForm[k])
  				  {
      			   elementForm.options[l].selected = true;
  				  }
  		       }
        }
  }


function isLocationSelected()
 {
	 if (document.getElementById("geo_loc").selectedIndex == -1 )
	{
		 alert("Please select at least one Location code");
		 return false;
	}
	else if(document.getElementById("unit_form").selectedIndex==-1)
     {
	        alert("Please select at least one Unit Form");
	        return false;
	 }
	 return true;
  }

</script>
<body>

<%
	try
	{

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

                   //if(userInfo == null || userInfo.getLoginCode() == null)
	              // {
		         
		         // response.sendRedirect(".." + File.separator + ".." + File.separator + "jsp" + File.separator +"login.html"); 
		         // return;
	               // }	
                                    

		simpleDateFormat = new SimpleDateFormat("dd-MMM-yy");
		calendar = Calendar.getInstance();
		preyear = calendar.get(Calendar.YEAR) - 1;
		year = calendar.get(Calendar.YEAR);
		month = new SimpleDateFormat("MMM").format(calendar.getTime());

		String currDate = simpleDateFormat.format(calendar.getTime());
		calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
		toDate = simpleDateFormat.format(calendar.getTime());

		//out.print("max day ="+calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
		//out.print("min day ="+calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
		calendar = Calendar.getInstance();
		calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
		frmDate = simpleDateFormat.format(calendar.getTime());
		todaysDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
		lastDayOfMonth = Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH);
		//frmDate = "01-apr-12";
		//toDate  = "30-apr-12";		
		rptTitle = "Production Vs Budget Report - " + currDate;
		unitFrmXml    = productionVsBudgetBean.getUnitFormXmlData();
		geoLocCodeXml = productionVsBudgetBean.getGeoLoCodeXmlData();
		System.out.println("rptTitle=====" + rptTitle);
		
%>
<form method="post" action="ProductionVsBudgetReport.jsp"
	name="ProductionVsBudgetReport">
<table align="center">
	<tr>
		<td class="title"><%=rptTitle%></td>
	</tr>
</table>
<br>
<table class="combox">
	<tr>
		<td>Geo Location: <select id="geo_loc" name="geo_loc"	multiple="multiple" size="5">

			<%
			dom = genericUtility.parseString(geoLocCodeXml);

			 if (dom != null)
					{
			%>
			<option value="0">All</option>
			<%
				dtlList = dom.getElementsByTagName("Detail");
						for (int cntr = 0; cntr < dtlList.getLength(); cntr++)
						{
							parentNode = dtlList.item(cntr);

							childNodeList = parentNode.getChildNodes();
							if (childNodeList.getLength() > 0)
							{
								fldValue = childNodeList.item(0).getTextContent();
								descr = childNodeList.item(1).getTextContent();
			%>
			<option value="<%=fldValue%>"><%=descr%></option>
			<%
				}

						}
					}
			%>
		</select></td>
		<td>Unit Form: <select id="unit_form" name="unit_form" 	multiple="multiple" size="5">

			<%
				dom = genericUtility.parseString(unitFrmXml);

					if (dom != null)
					{
			%>
			<option value="0">All</option>
			<%
				dtlList = dom.getElementsByTagName("Detail");
						for (int cntr = 0; cntr < dtlList.getLength(); cntr++)
						{
							parentNode = dtlList.item(cntr);

							childNodeList = parentNode.getChildNodes();

							if (childNodeList.getLength() > 0)
							{
								unitForm = childNodeList.item(0).getTextContent();
			%>
			<option value="<%=unitForm%>"><%=unitForm%></option>
			<%
				}

						}
					}
			%>
		</select></td>
		<td><input type="submit" name="showChart" value="view Report" 	onclick="return isLocationSelected();" /></td>
	</tr>
</table>
<br>
</form>

<%
	       geo_loc   = request.getParameterValues("geo_loc");
		unit_form = request.getParameterValues("unit_form");
		String geoLoc = "", unitFrm = "";
		if (geo_loc == null)
		{
			geoLoc = request.getParameter("geoLocation");
			if (geoLoc != null && geoLoc.trim().length() != 0)
			{
				geo_loc = geoLoc.split(",");
			}
		}

		if (unit_form == null)
		{
			unitFrm = request.getParameter("unitForm");
			if (unitFrm != null && unitFrm.trim().length() != 0)
			{
				unit_form = unitFrm.split(",");
			}
		}

		checkGeoLoc = "";
		if (geo_loc != null && geo_loc.length != 0)
		{
			for (int i = 0; i < geo_loc.length; i++)
			{
				if (!geo_loc[i].equals("0"))
				{

					if (i == geo_loc.length - 1)

						checkGeoLoc += "'" + geo_loc[i] + "'";

					else
						checkGeoLoc += "'" + geo_loc[i] + "',";

				}

			}
		}
		checkUnitForm = "";
		if (unit_form != null && unit_form.length != 0)
		{
			for (int i = 0; i < unit_form.length; i++)
			{
				if (!geo_loc[i].equals("0"))
				{
					if (i == unit_form.length - 1)
						checkUnitForm += "'" + unit_form[i] + "'";

					else
						checkUnitForm += "'" + unit_form[i] + "',";
				}
			}
		}
              
             // out.println("checkGeoLoc ==="+checkGeoLoc +"checkUnitForm ="+checkUnitForm );
		//here set selected value of geoLocation and unitForm with final utput 
		
		xmlDataString = productionVsBudgetBean.getProductionBudget(frmDate, toDate, this.checkGeoLoc, this.checkUnitForm);
		System.out.print("Final xmlDataString inside jsp= " + xmlDataString);
		//parse xml
		dom = genericUtility.parseString(xmlDataString);
		//End here set selected value of geoLocation and unitForm with final utput 
		if (dom != null)
		{

			chartDataList = new ArrayList<String>();
			detailList = dom.getElementsByTagName("Detail");

			if (detailList.item(0).getFirstChild() != null)
			{
				locationList = dom.getElementsByTagName("geo_loc");
				for (int cntr = 0; cntr < locationList.getLength(); cntr++)
				{

					locationNode = locationList.item(cntr);
					//start  Labling  setting 1			
					geoLocList.add(locationNode.getAttributes().getNamedItem("glocdescr").getNodeValue());
					chartData = new StringBuffer("<chart caption='");
					chartData.append("' palette='1' showValues='0' yAxisValuesPadding='10' numberPrefix='' chartOrder='line,area,column' startAngX='8' startAngY='-32' endAngX='8' endAngY='-32' zdepth='50' zgapPlot='10' showPlotBorder='0' dynamicShading='1' showAlternateHGridColor='1' labelDisplay='Stagger' legendNumColumns='2'>");
					chartData.append("<categories>");

					unitList = locationNode.getChildNodes();
					for (int nodCtr = 0; nodCtr < unitList.getLength(); nodCtr++)
					{
						unitNode = unitList.item(nodCtr);
						//Add unit form in unitForm List
						unitFormList.add(unitNode.getAttributes().getNamedItem("unitdescr").getNodeValue());
						//geoLocList.add(locationNode.getAttributes().getNamedItem("glocdescr").getNodeValue());

						dateList = unitNode.getChildNodes();
						for (int dateCtr = 0; dateCtr < dateList.getLength(); dateCtr++)
						{

							dateNode = dateList.item(dateCtr);
							date = dateNode.getAttributes().item(0).getNodeValue();
							chartData.append("<category label='" + date + "'/>");
						}
					}

					chartData.append("<category label='" + "fc" + "'/>");
					chartData.append("</categories>");
					//End of  Labling  setting 1		
					//2. Start dataset for Forecasting	
					chartData.append("<dataset seriesName='Forecast' >");

					for (int nodCtr = 0; nodCtr < unitList.getLength(); nodCtr++)
					{
						double cumulativeQty = 0.0;
						unitNode = unitList.item(nodCtr);
						dateList = unitNode.getChildNodes();
						for (int dateCtr = 0; dateCtr < dateList.getLength(); dateCtr++)
						{
							dateNode = dateList.item(dateCtr);
							dayQtyList = dateNode.getChildNodes();
							int day = Integer.parseInt(dateNode.getAttributes().item(0).getNodeValue());

							for (int dayCtr = 0; dayCtr < dayQtyList.getLength(); dayCtr++)
							{
								dayNode = dayQtyList.item(dayCtr);
								foreCastList = dayNode.getChildNodes();

								for (int prevCtr = 0; prevCtr < foreCastList.getLength(); prevCtr++)
								{
									foreCastNode = foreCastList.item(prevCtr);

									if (foreCastNode.getNodeName().equals("cur_cumqty"))
									{
										//out.println("day:"+day+"--todaysDay"+todaysDay);
										if (day == todaysDay)
										{
											cumulativeQty = Double.parseDouble(foreCastNode.getTextContent());

											cumulativeQty = Math.round(cumulativeQty * lastDayOfMonth) / day;
											cumuQty.add(cumulativeQty);

											for (int dayOfMonth = 1; dayOfMonth <= lastDayOfMonth; dayOfMonth++)
											{
												chartData.append("<set value='0'/>");
											}
											chartData.append("<set value='" + cumulativeQty + "'/>");

										}

									}

								}
							}
						}
					}

					chartData.append("</dataset>");
					//2. End dataset for Forecasting				
					//3. Start dataset for Daily Budget Quantity
					chartData.append("<dataset seriesName='Cumulative Production' >");
					String curCumQtyTem = "";
					for (int nodCtr = 0; nodCtr < unitList.getLength(); nodCtr++)
					{
						unitNode = unitList.item(nodCtr);
						dateList = unitNode.getChildNodes();

						for (int dateCtr = 0; dateCtr < dateList.getLength(); dateCtr++)
						{
							dateNode = dateList.item(dateCtr);
							int day = Integer.parseInt(dateNode.getAttributes().item(0).getNodeValue());
							dayQtyList = dateNode.getChildNodes();
							if (day <= todaysDay)
							{
								for (int dayCtr = 0; dayCtr < dayQtyList.getLength(); dayCtr++)
								{
									dayNode = dayQtyList.item(dayCtr);
									NodeList curCumQtyList = dayNode.getChildNodes();

									for (int curCumCtr = 0; curCumCtr < curCumQtyList.getLength(); curCumCtr++)
									{
										Node curCumQtyNode = curCumQtyList.item(curCumCtr);
										if (curCumQtyNode.getNodeName().equals("cur_cumqty"))
										{

											curCumQtyTem = curCumQtyNode.getTextContent();

											chartData.append("<set value='" + curCumQtyNode.getTextContent() + "'/>");
										}
									}
								}
							} else
							{
								for (int p = todaysDay + 1; p <= lastDayOfMonth; p++)
								{
									chartData.append("<set value='0'/>");
								}
							}
						}
					}
					sumDayPro.add(curCumQtyTem);
					chartData.append("</dataset>");
					//3. End dataset for Daily Budget Quantity	
					//4. start dataset for Day wise Quantity
					chartData.append("<dataset seriesName='Day Production'>");

					for (int nodCtr = 0; nodCtr < unitList.getLength(); nodCtr++)
					{
						unitNode = unitList.item(nodCtr);
						dateList = unitNode.getChildNodes();

						for (int dateCtr = 0; dateCtr < dateList.getLength(); dateCtr++)
						{
							dateNode = dateList.item(dateCtr);
							int day = Integer.parseInt(dateNode.getAttributes().item(0).getNodeValue());
							dayQtyList = dateNode.getChildNodes();
							if (day <= todaysDay)
							{
								for (int dayCtr = 0; dayCtr < dayQtyList.getLength(); dayCtr++)
								{
									dayNode = dayQtyList.item(dayCtr);
									dayQty = dayNode.getAttributes().item(0).getNodeValue();

									chartData.append("<set value='" + dayQty + "'/>");
								}
							} else
							{
								for (int p = todaysDay + 1; p <= lastDayOfMonth; p++)
								{
									chartData.append("<set value='0'/>");
								}
							}
						}

					}
					chartData.append("</dataset>");
					//4. End dataset for Day wise Quantity	
					//5. start dataset for Last year Quantity

					chartData.append("<dataset seriesName='Cumulative Last Year'  renderAs='Line'>");
					String prevYearQtyTemp = "";
					for (int nodCtr = 0; nodCtr < unitList.getLength(); nodCtr++)
					{
						unitNode = unitList.item(nodCtr);
						dateList = unitNode.getChildNodes();
						for (int dateCtr = 0; dateCtr < dateList.getLength(); dateCtr++)
						{
							dateNode = dateList.item(dateCtr);
							dayQtyList = dateNode.getChildNodes();

							for (int dayCtr = 0; dayCtr < dayQtyList.getLength(); dayCtr++)
							{
								//dayNode = dayQtyList.item(dateCtr);
								dayNode = dayQtyList.item(dayCtr);
								NodeList prevYearQtyList = dayNode.getChildNodes();

								for (int prevCtr = 0; prevCtr < prevYearQtyList.getLength(); prevCtr++)
								{
									Node prevYearQtyNode = prevYearQtyList.item(prevCtr);

									if (prevYearQtyNode.getNodeName().equals("pyr_cumqty"))
									{
										prevYearQtyTemp = (prevYearQtyNode.getTextContent());
										chartData.append("<set value='" + prevYearQtyNode.getTextContent() + "'/>");
									}
								}
							}
						}
					}
					cumLstYear.add(prevYearQtyTemp);
					chartData.append("</dataset>");
					//5. End dataset for Last year Quantity
					//6. Start dataset for Daily Budget Quantity				
					chartData.append("<dataset seriesName='Cumulative Budget'  renderAs='Line'>");
					String LBETEMP = "";
					for (int nodCtr = 0; nodCtr < unitList.getLength(); nodCtr++)
					{
						unitNode = unitList.item(nodCtr);
						dateList = unitNode.getChildNodes();
						for (int dateCtr = 0; dateCtr < dateList.getLength(); dateCtr++)
						{
							dateNode = dateList.item(dateCtr);
							dayQtyList = dateNode.getChildNodes();

							for (int dayCtr = 0; dayCtr < dayQtyList.getLength(); dayCtr++)
							{
								dayNode = dayQtyList.item(dayCtr);
								NodeList dailyBdgtList = dayNode.getChildNodes();

								for (int dBdgtCtr = 0; dBdgtCtr < dailyBdgtList.getLength(); dBdgtCtr++)
								{
									Node dailyBdgtNode = dailyBdgtList.item(dBdgtCtr);

									if (dailyBdgtNode.getNodeName().equals("cum_budqty"))
									{
										LBETEMP = dailyBdgtNode.getTextContent();										
										chartData.append("<set value='" + LBETEMP + "'/>");
									}
								}
							}
						}
					}
					LBEList.add(LBETEMP);
					chartData.append("</dataset>");
					//6. End dataset for Daily Budget Quantity

					chartData.append("</chart>");
					chartDataList.add(chartData.toString());
					//System.out.println("chartData is  :" + chartData.toString() + "Chart data List sizeee is =" + chartDataList.size());
					chartData.setLength(0);

				}
			} else
			{
%>
<table cellspacing="1" cellpadding="2" align="center">
	<tr>
		<td>
		<h4>No data found !</h4>
		</td>
	</tr>
</table>
<%
	}
		}

		int chartDivId = 0;
		int countChart = 0;
		int tablId = 0;
%>
<table border="1" cellspacing="1" cellpadding="2">
	<%
		for (String chartDatFrmList : chartDataList)
			{
				chartDivId++;
	%>
	<%
		if (tablId == 0 || (tablId % 3 == 0))
				{
	%>
	<tr>
		<%
			tablId = 0;
					}
		%>



		<td align="left" style="font-size: 12px"><b> <%=geoLocList.get(countChart)%>
		- <%=unitFormList.get(countChart)%> </b>
		<div id="chartContainer<%=chartDivId%>">Chart will load here !</div>
		<script type="text/javascript"> 
		         FusionCharts.setCurrentRenderer('javascript');
		         var myChart = new FusionCharts("<%=srcImagesPath%>", "myChartId", "400", "350", "0", "0");
		         myChart.setXMLData("<%=chartDatFrmList%>");          
		         myChart.render("chartContainer<%=chartDivId%>");      
              </script>



		<table class="headerTable" align="center">
			<tr class="headerTr">
				<td>Month</td>
				<td>Actual</td>
				<td>LBE</td>
				<td>Actual/LBE</td>
				<td>Pace(EOM)</td>
				<td>Pace(EOM)/LBE</td>
				<td><%=preyear%>/<%=month%></td>
			</tr>
			<tr class="detailTr">
				<td><%=year%>/<%=month%></td>

				<%
					Double cumulativePro = 0.0, cumuQtyInDoubl = 0.0, cumLstYearInDouble = 0.0, lbeInDouble = 0.0;
							String cumulativeProStr = "", cumuQtyStr = "", cumLstYearStr = "", lbeValStr = "";
							cumulativePro = Double.parseDouble(sumDayPro.get(countChart));
							if (cumulativePro >= 1000000)
							{

								cumulativePro = Math.round(cumulativePro / 1000000 * Math.pow(10, 2)) / Math.pow(10, 2);
								cumulativeProStr = cumulativePro.toString() + "M";

							} else
							{
								cumulativePro = Math.round(cumulativePro / 1000 * Math.pow(10, 2)) / Math.pow(10, 2);
								cumulativeProStr = cumulativePro.toString() + "K";

							}

							cumuQtyInDoubl = cumuQty.get(countChart);
							if (cumuQtyInDoubl >= 1000000)
							{
								cumuQtyInDoubl = Math.round(cumuQtyInDoubl / 1000000 * Math.pow(10, 2)) / Math.pow(10, 2);
								cumuQtyStr = cumuQtyInDoubl.toString() + "M";

							} else
							{
								cumuQtyInDoubl = Math.round(cumuQtyInDoubl / 1000 * Math.pow(10, 2)) / Math.pow(10, 2);
								cumuQtyStr = cumuQtyInDoubl.toString() + "K";

							}
							Double actLBE = 0.0;
							Double cumuQtyLBE = 0.0;
							if (Double.parseDouble(LBEList.get(countChart)) == 0.0)
							{
								actLBE = 0.0;
								cumuQtyLBE = 0.0;

							}

							else
							{
								actLBE = ((Double.parseDouble(sumDayPro.get(countChart)) / Double.parseDouble(LBEList.get(countChart)) * 100));
								cumuQtyLBE = (cumuQty.get(countChart) / Double.parseDouble(LBEList.get(countChart)) * 100);
							}

							cumLstYearInDouble = Double.parseDouble(cumLstYear.get(countChart));
							if (cumLstYearInDouble >= 1000000)
							{

								cumLstYearInDouble = Math.round(cumLstYearInDouble / 1000000 * Math.pow(10, 2)) / Math.pow(10, 2);
								cumLstYearStr = cumLstYearInDouble.toString() + "M";

							} else
							{
								cumLstYearInDouble = Math.round(cumLstYearInDouble / 1000 * Math.pow(10, 2)) / Math.pow(10, 2);
								cumLstYearStr = cumLstYearInDouble.toString() + "K";

							}

							lbeInDouble = Double.parseDouble(LBEList.get(countChart));
							if (lbeInDouble >= 1000000)
							{

								lbeInDouble = Math.round(lbeInDouble / 1000000 * Math.pow(10, 2)) / Math.pow(10, 2);
								lbeValStr = lbeInDouble.toString() + "M";

							} else
							{
								lbeInDouble = Math.round(lbeInDouble / 1000 * Math.pow(10, 2)) / Math.pow(10, 2);
								lbeValStr = lbeInDouble.toString() + "K";

							}
				%>
				<td><%=cumulativeProStr%></td>
				<td><%=lbeValStr%></td>
				<td><%=String.format("%.2f", actLBE)%> %</td>
				<td><%=cumuQtyStr%></td>
				<td><%=String.format("%.2f",cumuQtyLBE)%> %</td>
				<td><%=cumLstYearStr%></td>
			</tr>
		</table>
		</td>

		<%
			if (tablId > 0 && tablId % 3 == 0)
					{
		%>
	</tr>
	<%
		}
	%>

	<%
		tablId++;
				countChart++;
			}
	%>
</table>
<%
	} catch (Exception ex)
	{
		System.out.println("Exception : ProductionVsBudgetReport.jsp :" + ex.getMessage());
	}
%>
<script>
var geoLoc   ="<%=this.checkGeoLoc%>";
var unitform  ="<%=this.checkUnitForm%>";
window.onload=getData(geoLoc,unitform);




</script>
</body>
</html>
