KickJava   Java API By Example, From Geeks To Geeks.

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


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
20 package org.openbravo.erpCommon.ad_reports;
21
22
23 import org.openbravo.erpCommon.utility.Utility;
24 import org.openbravo.erpCommon.businessUtility.Tree;
25 import org.openbravo.base.secureApp.HttpSecureAppServlet;
26 import org.openbravo.base.secureApp.VariablesSecureApp;
27 import org.openbravo.xmlEngine.XmlDocument;
28 import java.io.*;
29 import javax.servlet.*;
30 import javax.servlet.http.*;
31 import org.openbravo.erpCommon.utility.*;
32 import org.openbravo.erpCommon.businessUtility.WindowTabs;
33
34 import org.openbravo.erpCommon.utility.DateTimeData;
35
36 public class ReportTrialBalanceDetail extends HttpSecureAppServlet {
37
38
39   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
40     VariablesSecureApp vars = new VariablesSecureApp(request);
41
42     if (!Utility.hasProcessAccess(this, vars, "", "ReportTrialBalanceDetail")) {
43       bdError(response, "AccessTableNoView", vars.getLanguage());
44       return;
45     }
46
47     if (vars.commandIn("DEFAULT")) {
48       String JavaDoc strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportTrialBalanceDetailDetail|DateFrom", "");
49       String JavaDoc strDateTo = vars.getGlobalVariable("inpDateTo", "ReportTrialBalanceDetailDetail|DateTo", "");
50       String JavaDoc strOrg = vars.getGlobalVariable("inpOrg", "ReportTrialBalanceDetailDetail|Org", "");
51       String JavaDoc strLevel = vars.getGlobalVariable("inpLevel", "ReportTrialBalanceDetailDetail|Level", "");
52       String JavaDoc strId = vars.getGlobalVariable("inpcElementValueId", "ReportTrialBalanceDetailDetail|Id", "");
53       printPageDataSheet(response, vars, strDateFrom, strDateTo, strOrg, strLevel, strId);
54     } else if (vars.commandIn("FIND")) {
55       String JavaDoc strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportTrialBalanceDetailDetail|DateFrom");
56       String JavaDoc strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportTrialBalanceDetailDetail|DateTo");
57       String JavaDoc strOrg = vars.getRequestGlobalVariable("inpOrg", "ReportTrialBalanceDetailDetail|Org");
58       String JavaDoc strLevel = vars.getRequestGlobalVariable("inpLevel", "ReportTrialBalanceDetailDetail|Level");
59       String JavaDoc strId = vars.getRequestGlobalVariable("inpcElementValueId", "ReportTrialBalanceDetailDetail|Id");
60       printPageDataSheet(response, vars, strDateFrom, strDateTo, strOrg, strLevel, strId);
61     }else pageError(response);
62   }
63
64   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strDateFrom, String JavaDoc strDateTo, String JavaDoc strOrg, String JavaDoc strLevel, String JavaDoc strId)
65     throws IOException, ServletException {
66     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
67     response.setContentType("text/html; charset=UTF-8");
68     PrintWriter out = response.getWriter();
69     String JavaDoc discard[]={"sectionDiscard"};
70     XmlDocument xmlDocument=null;
71     String JavaDoc strTreeOrg = ReportTrialBalanceDetailData.treeOrg(this, vars.getClient());
72     String JavaDoc strOrgFamily = getFamily(strTreeOrg, strOrg);
73     String JavaDoc strTreeAccount = ReportTrialBalanceDetailData.treeAccount(this, vars.getClient());
74     ReportTrialBalanceDetailData [] data = null;
75     if (strDateFrom.equals("") && strDateTo.equals("")) {
76       xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTrialBalanceDetail", discard).createXmlDocument();
77       data = ReportTrialBalanceDetailData.set();
78     } else {
79       xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTrialBalanceDetail").createXmlDocument();
80       if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - getFamily - strTreeAccount = " + strTreeAccount);
81       if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - getFamily - strId = " + strId);
82       String JavaDoc strIdFamily = getFamily(strTreeAccount, strId);
83       if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - strOrgFamily = " + strOrgFamily);
84       if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - #User_Client = " + Utility.getContext(this, vars, "#User_Client", "ReportTrialBalanceDetail"));
85       if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - #User_Org = " + Utility.getContext(this, vars, "#User_Org", "ReportTrialBalanceDetail"));
86       if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - strDateFrom = " + strDateFrom);
87       if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - strDateTo = " + DateTimeData.nDaysAfter(this, strDateTo,"1"));
88       if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - strIdFamily = " + strIdFamily);
89       if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - strId = " + strId);
90       data = ReportTrialBalanceDetailData.select(this, strOrgFamily, Utility.getContext(this, vars, "#User_Client", "ReportTrialBalanceDetail"), Utility.getContext(this, vars, "#User_Org", "ReportTrialBalanceDetail"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strIdFamily, strId);
91     }
92
93     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportTrialBalanceDetail", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
94 toolbar.prepareSimpleToolBarTemplate();
95     xmlDocument.setParameter("toolbar", toolbar.toString());
96     try {
97       KeyMap key = new KeyMap(this, vars, "ReportTrialBalanceDetail.html");
98       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
99     } catch (Exception JavaDoc ex) {
100       throw new ServletException(ex);
101     }
102     try {
103       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportTrialBalanceDetail");
104       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
105       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
106       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
107       xmlDocument.setParameter("theme", vars.getTheme());
108       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportTrialBalanceDetail.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
109       xmlDocument.setParameter("navigationBar", nav.toString());
110       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportTrialBalanceDetail.html", strReplaceWith);
111       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
112     } catch (Exception JavaDoc ex) {
113       throw new ServletException(ex);
114     }
115     {
116       OBError myMessage = vars.getMessage("ReportTrialBalanceDetail");
117       vars.removeMessage("ReportTrialBalanceDetail");
118       if (myMessage!=null) {
119         xmlDocument.setParameter("messageType", myMessage.getType());
120         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
121         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
122       }
123     }
124
125     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
126     xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
127     xmlDocument.setParameter("account", ReportTrialBalanceDetailData.selectAccountName(this, strId));
128     xmlDocument.setData("structure1", data);
129     out.println(xmlDocument.print());
130     out.close();
131   }
132
133   public String JavaDoc getFamily(String JavaDoc strTree, String JavaDoc strChild) throws IOException, ServletException {
134     return Tree.getMembers(this, strTree, strChild);
135     /* ReportGeneralLedgerData [] data = ReportGeneralLedgerData.selectChildren(this, strTree, strChild);
136           TreeData [] data = Tree.getMembers(this, strTree, strChild);
137           String strFamily = "";
138           if(data!=null && data.length>0) {
139           for (int i = 0;i<data.length;i++){
140           if (i>0) strFamily = strFamily + ",";
141           strFamily = strFamily + data[i].id;
142           }
143           return strFamily;
144           }else return "'1'";*/

145   }
146
147   public String JavaDoc getServletInfo() {
148     return "Servlet ReportTrialBalanceDetail. This Servlet was made by Eduardo Argal";
149   } // end of getServletInfo() method
150
}
151
152
Popular Tags