KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > ad_reports > ReportCashflowForecast


1 /*
2  *************************************************************************
3  * The contents of this file are subject to the Openbravo Public License
4  * Version 1.0 (the "License"), being the Mozilla Public License
5  * Version 1.1 with a permitted attribution clause; you may not use this
6  * file except in compliance with the License. You may obtain a copy of
7  * the License at http://www.openbravo.com/legal/license.html
8  * Software distributed under the License is distributed on an "AS IS"
9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
10  * License for the specific language governing rights and limitations
11  * under the License.
12  * The Original Code is Openbravo ERP.
13  * The Initial Developer of the Original Code is Openbravo SL
14  * All portions are Copyright (C) 2001-2006 Openbravo SL
15  * All Rights Reserved.
16  * Contributor(s): ______________________________________.
17  ************************************************************************
18  */

19 package org.openbravo.erpCommon.ad_reports;
20
21 import org.openbravo.erpCommon.utility.*;
22 import org.openbravo.erpCommon.businessUtility.WindowTabs;
23 import org.openbravo.base.secureApp.HttpSecureAppServlet;
24 import org.openbravo.base.secureApp.VariablesSecureApp;
25 import org.openbravo.xmlEngine.XmlDocument;
26 import java.io.*;
27 import javax.servlet.*;
28 import javax.servlet.http.*;
29
30 import org.openbravo.erpCommon.ad_combos.AccountNumberComboData;
31
32
33 public class ReportCashflowForecast extends HttpSecureAppServlet {
34
35
36   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
37     VariablesSecureApp vars = new VariablesSecureApp(request);
38
39     if (vars.commandIn("DEFAULT")) {
40       String JavaDoc strBankAccount = vars.getRequestGlobalVariable("inpcBankAccountId", "ReportCashflowForecast|AcctNo");
41       String JavaDoc strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportCashflowForecast|DateFrom");
42       String JavaDoc strBreakDate = vars.getRequestGlobalVariable("inpBreakDate", "ReportCashflowForecast|BreakDate");
43
44       printPageDataSheet(response, vars, strBankAccount, strDateFrom, strBreakDate, true);
45     } else if (vars.commandIn("FIND")) {
46       String JavaDoc strBankAccount = vars.getRequestGlobalVariable("inpcBankAccountId", "ReportCashflowForecast|AcctNo");
47       String JavaDoc strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportCashflowForecast|DateFrom");
48       String JavaDoc strBreakDate = vars.getRequestGlobalVariable("inpBreakDate", "ReportCashflowForecast|BreakDate");
49
50       printPageDataSheet(response, vars, strBankAccount, strDateFrom, strBreakDate, false);
51     }else pageError(response);
52   }
53
54   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strBankAccount, String JavaDoc strDateMax, String JavaDoc strBreakDate, boolean showDefault) throws IOException, ServletException {
55     String JavaDoc[] discard = {"",""};
56     XmlDocument xmlDocument = null;
57
58     if (showDefault)
59       discard[0] = "subrpt";
60     else {
61       if (strBreakDate.equals("")) discard[0] = "reportAccountDate";
62       else discard[0] = "reportAccount";
63     }
64
65     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportCashflowForecast", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
66
67     // ReportCashflowForecastData[] dataSummary = ReportCashflowForecastData.select(this,Utility.getContext(this, vars, "#User_Client", "ReportBank"), Utility.getContext(this, vars, "#User_Org", "ReportBank"));
68
ReportCashflowForecastData[] dataSummary = ReportCashflowForecastData.select(this,strDateMax,"",Utility.getContext(this, vars, "#User_Client", "ReportBank"), Utility.getContext(this, vars, "#User_Org", "ReportBank"));
69
70     if (!showDefault) {
71       ReportCashflowForecastData[][] data = null;
72       ReportCashflowForecastData[] dataAcct = null;
73       ReportCashflowForecastData[] dataDetail = null;
74
75       // dataAcct = ReportCashflowForecastData.select(this, strDateMax, strBankAccount);
76
dataAcct = ReportCashflowForecastData.select(this,strDateMax,strBankAccount,Utility.getContext(this, vars, "#User_Client", "ReportBank"), Utility.getContext(this, vars, "#User_Org", "ReportBank"));
77       data = new ReportCashflowForecastData[dataAcct.length][];
78
79       if (log4j.isDebugEnabled()) log4j.debug("length: "+dataAcct.length+" - bankaccount:"+strBankAccount);
80       if (dataAcct.length==0) {
81         discard[0] = "reportAccountDate";
82         discard[1] = "reportAccount";
83       } else {
84         for (int i =0; i < dataAcct.length; i++){
85           if (strBreakDate.equals(""))
86             dataDetail = ReportCashflowForecastData.selectLines(this, vars.getSqlDateFormat(), vars.getLanguage(), dataAcct[i].cBankaccountId, strDateMax, "2 DESC, 1");
87           else
88             dataDetail = ReportCashflowForecastData.selectLines(this, vars.getSqlDateFormat(), vars.getLanguage(), dataAcct[i].cBankaccountId, strDateMax, "1,2 DESC");
89           if (log4j.isDebugEnabled()) log4j.debug("length: "+dataAcct.length+" bankacct:"+dataAcct[i].cBankaccountId+" lenght:"+dataDetail.length);
90           data[i] = dataDetail;
91         }
92       }
93       xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportCashflowForecast",discard).createXmlDocument();
94
95       xmlDocument.setData("structureDetail",dataAcct);
96       if (strBreakDate.equals(""))
97         xmlDocument.setDataArray("reportAcct","structureAccount",data);
98       else
99         xmlDocument.setDataArray("reportAcctDate","structureAccount",data);
100     } else
101       xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportCashflowForecast",discard).createXmlDocument();
102
103
104     // ReportCashflowForecastData.select(this,Utility.getContext(this, vars, "#User_Client", "ReportBank"), Utility.getContext(this, vars, "#User_Org", "ReportBank"));
105

106     toolbar.prepareSimpleToolBarTemplate();
107     xmlDocument.setParameter("toolbar", toolbar.toString());
108     xmlDocument.setData("reportC_ACCOUNTNUMBER","liststructure",AccountNumberComboData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportCashflowForecast"), Utility.getContext(this, vars, "#User_Org", "ReportCashflowForecast")));
109     xmlDocument.setParameter("cBankAccount", strBankAccount);
110     xmlDocument.setParameter("dateFrom",strDateMax);
111     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
112     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
113     xmlDocument.setParameter("finalDate",strDateMax);
114     xmlDocument.setParameter("date",ReportCashflowForecastData.getDate(this, vars.getSqlDateFormat()));
115     xmlDocument.setParameter("date1",ReportCashflowForecastData.getDate(this, vars.getSqlDateFormat()));
116     xmlDocument.setParameter("breakDate",strBreakDate.equals("")?"0":"1");
117     xmlDocument.setData("structureSummary",dataSummary);
118
119    try {
120       KeyMap key = new KeyMap(this, vars, "ReportCashflowForecast.html");
121       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
122     } catch (Exception JavaDoc ex) {
123       throw new ServletException(ex);
124     }
125     try {
126       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportCashflowForecast");
127       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
128       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
129       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
130       xmlDocument.setParameter("theme", vars.getTheme());
131       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportCashflowForecast.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
132       xmlDocument.setParameter("navigationBar", nav.toString());
133       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportCashflowForecast.html", strReplaceWith);
134       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
135     } catch (Exception JavaDoc ex) {
136       throw new ServletException(ex);
137     }
138     {
139       OBError myMessage = vars.getMessage("ReportCashflowForecast");
140       vars.removeMessage("ReportCashflowForecast");
141       if (myMessage!=null) {
142         xmlDocument.setParameter("messageType", myMessage.getType());
143         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
144         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
145       }
146     }
147
148
149     response.setContentType("text/html; charset=UTF-8");
150     PrintWriter out = response.getWriter();
151     out.println(xmlDocument.print());
152     out.close();
153   }
154
155
156   public String JavaDoc getServletInfo() {
157     return "Servlet ReportCashflowForecast";
158   } // end of the getServletInfo() method
159
}
160
Popular Tags