KickJava   Java API By Example, From Geeks To Geeks.

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


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.utility.DateTimeData;
31
32 public class ReportInvoices extends HttpSecureAppServlet {
33
34
35   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
36     VariablesSecureApp vars = new VariablesSecureApp(request);
37
38     if (!Utility.hasProcessAccess(this, vars, "", "RV_C_InvoiceLine")) {
39       bdError(response, "AccessTableNoView", vars.getLanguage());
40       return;
41     }
42
43     if (vars.commandIn("DEFAULT")) {
44       String JavaDoc strC_BPartner_ID = vars.getGlobalVariable("inpcBpartnerId", "ReportInvoices|C_BPartner_ID", "");
45       String JavaDoc strM_Product_ID = vars.getGlobalVariable("inpmProductId", "ReportInvoices|M_Product_ID", "");
46       String JavaDoc strDateFrom = vars.getGlobalVariable("inpDateInvoiceFrom", "ReportInvoices|DateFrom", "");
47       String JavaDoc strDateTo = vars.getGlobalVariable("inpDateInvoiceTo", "ReportInvoices|DateTo", "");
48       String JavaDoc strDocumentNo = vars.getGlobalVariable("inpInvoicedocumentno", "ReportInvoices|DocumentNo", "");
49       String JavaDoc strOrder = vars.getGlobalVariable("inpOrder", "ReportInvoices|Order", "SalesOrder");
50       String JavaDoc strC_BpGroup_ID = vars.getGlobalVariable("inpcBpGroupId", "ReportInvoices|C_BpGroup_ID", "");
51       String JavaDoc strM_Product_Category_ID = vars.getGlobalVariable("inpmProductCategoryId", "ReportInvoices|M_Product_Category_ID", "");
52       printPageDataSheet(response, vars, strC_BPartner_ID, strM_Product_ID, strDateFrom, strDateTo, strDocumentNo, strOrder, strC_BpGroup_ID, strM_Product_Category_ID);
53     } else if (vars.commandIn("FIND")) {
54       String JavaDoc strC_BPartner_ID = vars.getRequestGlobalVariable("inpcBpartnerId", "ReportInvoices|C_BPartner_ID");
55       String JavaDoc strM_Product_ID = vars.getRequestGlobalVariable("inpmProductId", "ReportInvoices|M_Product_ID");
56       String JavaDoc strDateFrom = vars.getRequestGlobalVariable("inpDateInvoiceFrom", "ReportInvoices|DateFrom");
57       String JavaDoc strDateTo = vars.getRequestGlobalVariable("inpDateInvoiceTo", "ReportInvoices|DateTo");
58       String JavaDoc strDocumentNo = vars.getRequestGlobalVariable("inpInvoicedocumentno", "ReportInvoices|DocumentNo");
59       String JavaDoc strOrder = vars.getGlobalVariable("inpOrder", "ReportInvoices|Order");
60       String JavaDoc strC_BpGroup_ID = vars.getRequestGlobalVariable("inpcBpGroupId", "ReportInvoices|C_BpGroup_ID");
61       String JavaDoc strM_Product_Category_ID = vars.getRequestGlobalVariable("inpmProductCategoryId", "ReportInvoices|M_Product_Category_ID");
62       printPageDataHtml(response, vars, strC_BPartner_ID, strM_Product_ID, strDateFrom, strDateTo, strDocumentNo, strOrder, strC_BpGroup_ID, strM_Product_Category_ID);
63     } else pageError(response);
64   }
65
66   void printPageDataHtml(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strC_BPartner_ID, String JavaDoc strM_Product_ID, String JavaDoc strDateFrom, String JavaDoc strDateTo, String JavaDoc strDocumentNo, String JavaDoc strOrder, String JavaDoc strC_BpGroup_ID, String JavaDoc strM_Product_Category_ID)
67     throws IOException, ServletException {
68     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
69     response.setContentType("text/html; charset=UTF-8");
70     PrintWriter out = response.getWriter();
71     String JavaDoc discard[]={"sectionBPartner"};
72     XmlDocument xmlDocument=null;
73     ReportInvoicesData[] data=null;
74     if (strC_BPartner_ID.equals("") && strM_Product_ID.equals("") && strDateFrom.equals("") && strDateTo.equals("") && strDocumentNo.equals("") && strC_BpGroup_ID.equals("") && strM_Product_Category_ID.equals("")) {
75       xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoicesEdit", discard).createXmlDocument();
76       data = ReportInvoicesData.set();
77     } else {
78       xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoicesEdit").createXmlDocument();
79       data = ReportInvoicesData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportInvoices"), Utility.getContext(this, vars, "#User_Org", "ReportInvoices"), strC_BpGroup_ID, strM_Product_Category_ID, strC_BPartner_ID, strM_Product_ID, strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strDocumentNo, (strOrder.equals("PurchaseOrder"))?"":"sales", (strOrder.equals("PurchaseOrder"))?"purchase":"");
80     }
81
82     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
83     xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
84   
85
86     xmlDocument.setData("structure1", data);
87     out.println(xmlDocument.print());
88     out.close();
89   }
90   
91   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strC_BPartner_ID, String JavaDoc strM_Product_ID, String JavaDoc strDateFrom, String JavaDoc strDateTo, String JavaDoc strDocumentNo, String JavaDoc strOrder, String JavaDoc strC_BpGroup_ID, String JavaDoc strM_Product_Category_ID)
92     throws IOException, ServletException {
93     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
94     response.setContentType("text/html; charset=UTF-8");
95     PrintWriter out = response.getWriter();
96    
97     XmlDocument xmlDocument=null;
98     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoices").createXmlDocument();
99     
100     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportInvoices", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
101     toolbar.prepareSimpleToolBarTemplate();
102     xmlDocument.setParameter("toolbar", toolbar.toString());
103     try {
104       KeyMap key = new KeyMap(this, vars, "ReportInvoices.html");
105       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
106     } catch (Exception JavaDoc ex) {
107       throw new ServletException(ex);
108     }
109     try {
110       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportInvoices");
111       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
112       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
113       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
114       xmlDocument.setParameter("theme", vars.getTheme());
115       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportInvoices.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
116       xmlDocument.setParameter("navigationBar", nav.toString());
117       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportInvoices.html", strReplaceWith);
118       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
119     } catch (Exception JavaDoc ex) {
120       throw new ServletException(ex);
121     }
122     {
123       OBError myMessage = vars.getMessage("ReportInvoices");
124       vars.removeMessage("ReportInvoices");
125       if (myMessage!=null) {
126         xmlDocument.setParameter("messageType", myMessage.getType());
127         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
128         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
129       }
130     }
131
132
133     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
134     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
135     xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
136     xmlDocument.setParameter("paramBPartnerId", strC_BPartner_ID);
137     xmlDocument.setParameter("paramMProductId", strM_Product_ID);
138     xmlDocument.setParameter("dateFrom", strDateFrom);
139     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
140     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
141     xmlDocument.setParameter("dateTo", strDateTo);
142     xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
143     xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
144     xmlDocument.setParameter("paramDocumentNo", strDocumentNo);
145     xmlDocument.setParameter("paramCBpGroupID", strC_BpGroup_ID);
146     xmlDocument.setParameter("paramMProductCategoryID", strM_Product_Category_ID);
147     xmlDocument.setParameter("sales", strOrder);
148     xmlDocument.setParameter("purchase", strOrder);
149     xmlDocument.setParameter("paramBPartnerDescription", ReportInvoicesData.bPartnerDescription(this, strC_BPartner_ID));
150     xmlDocument.setParameter("paramMProductIDDES", ReportInvoicesData.mProductDescription(this, strM_Product_ID));
151
152
153     try {
154       ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "C_BP_Group_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoices"), Utility.getContext(this, vars, "#User_Client", "ReportInvoices"), 0);
155       Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoices", strC_BpGroup_ID);
156       xmlDocument.setData("reportC_Bp_Group","liststructure", comboTableData.select(false));
157       comboTableData = null;
158     } catch (Exception JavaDoc ex) {
159       throw new ServletException(ex);
160     }
161
162
163
164     try {
165       ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Product_Category_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoices"), Utility.getContext(this, vars, "#User_Client", "ReportInvoices"), 0);
166       Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoices", strM_Product_Category_ID);
167       xmlDocument.setData("reportM_Product_Category","liststructure", comboTableData.select(false));
168       comboTableData = null;
169     } catch (Exception JavaDoc ex) {
170       throw new ServletException(ex);
171     }
172
173
174     
175     out.println(xmlDocument.print());
176     out.close();
177   }
178   
179  /* void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strC_BPartner_ID, String strM_Product_ID, String strDateFrom, String strDateTo, String strDocumentNo, String strOrder, String strC_BpGroup_ID, String strM_Product_Category_ID)
180     throws IOException, ServletException {
181     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
182     response.setContentType("text/html; charset=UTF-8");
183     PrintWriter out = response.getWriter();
184     String discard[]={"sectionBPartner"};
185     XmlDocument xmlDocument=null;
186     ReportInvoicesData[] data=null;
187     if (strC_BPartner_ID.equals("") && strM_Product_ID.equals("") && strDateFrom.equals("") && strDateTo.equals("") && strDocumentNo.equals("") && strC_BpGroup_ID.equals("") && strM_Product_Category_ID.equals("")) {
188       xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoices", discard).createXmlDocument();
189       data = ReportInvoicesData.set();
190     } else {
191       xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoices").createXmlDocument();
192       data = ReportInvoicesData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportInvoices"), Utility.getContext(this, vars, "#User_Org", "ReportInvoices"), strC_BpGroup_ID, strM_Product_Category_ID, strC_BPartner_ID, strM_Product_ID, strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strDocumentNo, (strOrder.equals("PurchaseOrder"))?"":"sales", (strOrder.equals("PurchaseOrder"))?"purchase":"");
193     }
194
195     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportInvoices", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
196     toolbar.prepareSimpleToolBarTemplate();
197     xmlDocument.setParameter("toolbar", toolbar.toString());
198     try {
199       KeyMap key = new KeyMap(this, vars, "ReportInvoices.html");
200       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
201     } catch (Exception ex) {
202       throw new ServletException(ex);
203     }
204     try {
205       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportInvoices");
206       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
207       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
208       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
209       xmlDocument.setParameter("theme", vars.getTheme());
210       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportInvoices.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
211       xmlDocument.setParameter("navigationBar", nav.toString());
212       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportInvoices.html", strReplaceWith);
213       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
214     } catch (Exception ex) {
215       throw new ServletException(ex);
216     }
217     {
218       OBError myMessage = vars.getMessage("ReportInvoices");
219       vars.removeMessage("ReportInvoices");
220       if (myMessage!=null) {
221         xmlDocument.setParameter("messageType", myMessage.getType());
222         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
223         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
224       }
225     }
226
227
228     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
229     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
230     xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
231     xmlDocument.setParameter("paramBPartnerId", strC_BPartner_ID);
232     xmlDocument.setParameter("paramMProductId", strM_Product_ID);
233     xmlDocument.setParameter("dateFrom", strDateFrom);
234     xmlDocument.setParameter("dateTo", strDateTo);
235     xmlDocument.setParameter("paramDocumentNo", strDocumentNo);
236     xmlDocument.setParameter("paramCBpGroupID", strC_BpGroup_ID);
237     xmlDocument.setParameter("paramMProductCategoryID", strM_Product_Category_ID);
238     xmlDocument.setParameter("sales", strOrder);
239     xmlDocument.setParameter("purchase", strOrder);
240     xmlDocument.setParameter("paramBPartnerDescription", ReportInvoicesData.bPartnerDescription(this, strC_BPartner_ID));
241     xmlDocument.setParameter("paramMProductIDDES", ReportInvoicesData.mProductDescription(this, strM_Product_ID));
242
243
244     try {
245       ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "C_BP_Group_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoices"), Utility.getContext(this, vars, "#User_Client", "ReportInvoices"), 0);
246       Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoices", strC_BpGroup_ID);
247       xmlDocument.setData("reportC_Bp_Group","liststructure", comboTableData.select(false));
248       comboTableData = null;
249     } catch (Exception ex) {
250       throw new ServletException(ex);
251     }
252
253
254
255     try {
256       ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Product_Category_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoices"), Utility.getContext(this, vars, "#User_Client", "ReportInvoices"), 0);
257       Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoices", strM_Product_Category_ID);
258       xmlDocument.setData("reportM_Product_Category","liststructure", comboTableData.select(false));
259       comboTableData = null;
260     } catch (Exception ex) {
261       throw new ServletException(ex);
262     }
263
264
265     xmlDocument.setData("structure1", data);
266     out.println(xmlDocument.print());
267     out.close();
268   }*/

269
270   public String JavaDoc getServletInfo() {
271     return "Servlet ReportInvoices. This Servlet was made by Pablo Sarobe";
272   } // end of getServletInfo() method
273
}
274
275
Popular Tags