KickJava   Java API By Example, From Geeks To Geeks.

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


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.ToolBar;
31
32 public class ReportInvoiceCustomerEdition 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_ReportInvoiceCustomer")) {
39       bdError(response, "AccessTableNoView", vars.getLanguage());
40       return;
41     }
42
43     if (vars.commandIn("DEFAULT")){
44       String JavaDoc strdateFrom = vars.getGlobalVariable("inpDateFrom", "ReportInvoiceCustomerEdition|DateFrom", "");
45       String JavaDoc strdateTo = vars.getGlobalVariable("inpDateTo", "ReportInvoiceCustomerEdition|DateTo", "");
46       String JavaDoc strcProjectId = vars.getGlobalVariable("inpcProjectId", "ReportInvoiceCustomerEdition|cProjectId", "");
47       String JavaDoc strcBpartnerId = vars.getInGlobalVariable("inpcBPartnerId_IN", "ReportInvoiceCustomerEdition|cBPartnerId_IN", "");
48       String JavaDoc strmCategoryId = vars.getInGlobalVariable("inpmProductCategoryId", "ReportInvoiceCustomerEdition|mCategoryId", "");
49       String JavaDoc strProjectkind = vars.getInGlobalVariable("inpProjectkind", "ReportInvoiceCustomerEdition|Projectkind", "");
50       String JavaDoc strProjectstatus = vars.getInGlobalVariable("inpProjectstatus", "ReportInvoiceCustomerEdition|Projectstatus", "");
51       String JavaDoc strProjectphase = vars.getInGlobalVariable("inpProjectphase", "ReportInvoiceCustomerEdition|Projectphase", "");
52       String JavaDoc strProduct = vars.getInGlobalVariable("inpmProductId_IN", "ReportInvoiceCustomerEdition|mProductId_IN", "");
53       String JavaDoc strProjectpublic = vars.getGlobalVariable("inpProjectpublic", "ReportInvoiceCustomerEdition|Projectpublic", "");
54       String JavaDoc strSalesRep = vars.getGlobalVariable("inpSalesRepId", "ReportInvoiceCustomerEdition|SalesRepId", "");
55       String JavaDoc strcRegionId = vars.getInGlobalVariable("inpcRegionId", "ReportInvoiceCustomerEdition|cRegionId", "");
56       printPageDataSheet(response, vars, strdateFrom, strdateTo, strcProjectId, strcBpartnerId, strmCategoryId, strProjectkind, strProjectstatus, strProjectphase, strProduct, strProjectpublic, strSalesRep, strcRegionId);
57     }else if (vars.commandIn("EDIT_HTML")) {
58       String JavaDoc strdateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportInvoiceCustomerEdition|DateFrom");
59       String JavaDoc strdateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportInvoiceCustomerEdition|DateTo");
60       String JavaDoc strcProjectId = vars.getRequestGlobalVariable("inpcProjectId", "ReportInvoiceCustomerEdition|cProjectId");
61       String JavaDoc strcBpartnerId = vars.getRequestInGlobalVariable("inpcBPartnerId_IN", "ReportInvoiceCustomerEdition|cBPartnerId_IN");
62       String JavaDoc strmCategoryId = vars.getRequestInGlobalVariable("inpmProductCategoryId", "ReportInvoiceCustomerEdition|mCategoryId");
63       String JavaDoc strProjectkind = vars.getRequestInGlobalVariable("inpProjectkind", "ReportInvoiceCustomerEdition|Projectkind");
64       String JavaDoc strProjectstatus = vars.getRequestInGlobalVariable("inpProjectstatus", "ReportInvoiceCustomerEdition|Projectstatus");
65       String JavaDoc strProjectphase = vars.getRequestInGlobalVariable("inpProjectphase", "ReportInvoiceCustomerEdition|Projectphase");
66       String JavaDoc strProduct = vars.getRequestInGlobalVariable("inpmProductId_IN", "ReportInvoiceCustomerEdition|mProductId_IN");
67       String JavaDoc strProjectpublic = vars.getRequestGlobalVariable("inpProjectpublic", "ReportInvoiceCustomerEdition|Projectpublic");
68       String JavaDoc strSalesRep = vars.getRequestGlobalVariable("inpSalesRepId", "ReportInvoiceCustomerEdition|SalesRepId");
69       String JavaDoc strcRegionId = vars.getRequestInGlobalVariable("inpcRegionId", "ReportInvoiceCustomerEdition|cRegionId");
70       printPageHtml(response, vars, strdateFrom, strdateTo, strcProjectId, strcBpartnerId, strmCategoryId, strProjectkind, strProjectstatus, strProjectphase, strProduct, strProjectpublic, strSalesRep, strcRegionId);
71     } else if (vars.commandIn("EDIT_PDF")) {
72       String JavaDoc strdateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportInvoiceCustomerEdition|DateFrom");
73       String JavaDoc strdateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportInvoiceCustomerEdition|DateTo");
74       String JavaDoc strcProjectId = vars.getRequestGlobalVariable("inpcProjectId", "ReportInvoiceCustomerEdition|cProjectId");
75       String JavaDoc strcBpartnerId = vars.getRequestInGlobalVariable("inpcBPartnerId_IN", "ReportInvoiceCustomerEdition|cBPartnerId_IN");
76       String JavaDoc strmCategoryId = vars.getRequestInGlobalVariable("inpmProductCategoryId", "ReportInvoiceCustomerEdition|mCategoryId");
77       String JavaDoc strProjectkind = vars.getRequestInGlobalVariable("inpProjectkind", "ReportInvoiceCustomerEdition|Projectkind");
78       String JavaDoc strProjectstatus = vars.getRequestInGlobalVariable("inpProjectstatus", "ReportInvoiceCustomerEdition|Projectstatus");
79       String JavaDoc strProjectphase = vars.getRequestInGlobalVariable("inpProjectphase", "ReportInvoiceCustomerEdition|Projectphase");
80       String JavaDoc strProduct = vars.getRequestInGlobalVariable("inpmProductId_IN", "ReportInvoiceCustomerEdition|mProductId_IN");
81       String JavaDoc strProjectpublic = vars.getRequestGlobalVariable("inpProjectpublic", "ReportInvoiceCustomerEdition|Projectpublic");
82       String JavaDoc strSalesRep = vars.getRequestGlobalVariable("inpSalesRepId", "ReportInvoiceCustomerEdition|SalesRepId");
83       String JavaDoc strcRegionId = vars.getRequestInGlobalVariable("inpcRegionId", "ReportInvoiceCustomerEdition|cRegionId");
84       printPagePdf(response, vars, strdateFrom, strdateTo, strcProjectId, strcBpartnerId, strmCategoryId, strProjectkind, strProjectstatus, strProjectphase, strProduct, strProjectpublic, strSalesRep, strcRegionId);
85     } else pageErrorPopUp(response);
86   }
87
88   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strdateFrom, String JavaDoc strdateTo, String JavaDoc strcProjectId, String JavaDoc strcBpartnerId, String JavaDoc strmCategoryId, String JavaDoc strProjectkind, String JavaDoc strProjectstatus, String JavaDoc strProjectphase, String JavaDoc strProduct, String JavaDoc strProjectpublic, String JavaDoc strSalesRep, String JavaDoc strcRegionId) throws IOException, ServletException {
89     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
90
91
92     String JavaDoc discard[]={"discard"};
93     XmlDocument xmlDocument=null;
94     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerFilter").createXmlDocument();
95
96     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportInvoiceCustomerFilter", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
97     toolbar.prepareSimpleToolBarTemplate();
98     xmlDocument.setParameter("toolbar", toolbar.toString());
99     try {
100       KeyMap key = new KeyMap(this, vars, "ReportInvoiceCustomerEdition.html");
101       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
102     } catch (Exception JavaDoc ex) {
103       throw new ServletException(ex);
104     }
105     try {
106       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportInvoiceCustomerEdition");
107       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
108       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
109       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
110       xmlDocument.setParameter("theme", vars.getTheme());
111       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportInvoiceCustomerEdition.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
112       xmlDocument.setParameter("navigationBar", nav.toString());
113       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportInvoiceCustomerEdition.html", strReplaceWith);
114       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
115     } catch (Exception JavaDoc ex) {
116       throw new ServletException(ex);
117     }
118     {
119       OBError myMessage = vars.getMessage("ReportInvoiceCustomerEdition");
120       vars.removeMessage("ReportInvoiceCustomerEdition");
121       if (myMessage!=null) {
122         xmlDocument.setParameter("messageType", myMessage.getType());
123         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
124         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
125       }
126     }
127
128     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
129     xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
130     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
131     xmlDocument.setParameter("dateFrom", strdateFrom);
132     xmlDocument.setParameter("dateTo", strdateTo);
133     xmlDocument.setParameter("paramBPartnerId", strcBpartnerId);
134     xmlDocument.setParameter("cProjectId", strcProjectId);
135     xmlDocument.setParameter("projectName", InvoiceCustomerEditionData.selectProject(this, strcProjectId));
136     xmlDocument.setParameter("mProductCatId", strmCategoryId);
137     xmlDocument.setParameter("cProjectKind", strProjectkind);
138     xmlDocument.setParameter("cRegionId", strcRegionId);
139     xmlDocument.setParameter("cProjectPhase", strProjectphase);
140     xmlDocument.setParameter("cProjectStatus", strProjectstatus);
141     xmlDocument.setParameter("cProjectPublic", strProjectpublic);
142     xmlDocument.setParameter("salesRep", strSalesRep);
143
144     try {
145       ComboTableData comboTableData = new ComboTableData(this, "LIST", "", "Projectkind", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerEdition"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerEdition"), 0);
146       Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerEdition", strProjectkind);
147       xmlDocument.setData("reportC_PROJECTKIND","liststructure", comboTableData.select(false));
148       comboTableData = null;
149     } catch (Exception JavaDoc ex) {
150       throw new ServletException(ex);
151     }
152
153     try {
154       ComboTableData comboTableData = new ComboTableData(this, "LIST", "", "Projectphase", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerEdition"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerEdition"), 0);
155       Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerEdition", strProjectphase);
156       xmlDocument.setData("reportC_PROJECTPHASE","liststructure", comboTableData.select(false));
157       comboTableData = null;
158     } catch (Exception JavaDoc ex) {
159       throw new ServletException(ex);
160     }
161
162     try {
163       ComboTableData comboTableData = new ComboTableData(this, "LIST", "", "ProjectStatus", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerEdition"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerEdition"), 0);
164       Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerEdition", strProjectstatus);
165       xmlDocument.setData("reportC_PROJECTSTATUS","liststructure", comboTableData.select(false));
166       comboTableData = null;
167     } catch (Exception JavaDoc ex) {
168       throw new ServletException(ex);
169     }
170
171     try {
172       ComboTableData comboTableData = new ComboTableData(this, "LIST", "", "PublicPrivate", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerEdition"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerEdition"), 0);
173       Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerEdition", strProjectpublic);
174       xmlDocument.setData("reportC_PROJECTPUBLIC","liststructure", comboTableData.select(false));
175       comboTableData = null;
176     } catch (Exception JavaDoc ex) {
177       throw new ServletException(ex);
178     }
179
180     xmlDocument.setData("reportC_PRODUCTCATREGORY","liststructure",SubCategoryProductData.select(this));
181
182
183     try {
184       ComboTableData comboTableData = new ComboTableData(this, "TABLEDIR", "C_REGION_ID", "", "C_Region of Country", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerEdition"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerEdition"), 0);
185       Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerEdition", strcRegionId);
186       xmlDocument.setData("reportC_REGIONID","liststructure", comboTableData.select(false));
187       comboTableData = null;
188     } catch (Exception JavaDoc ex) {
189       throw new ServletException(ex);
190     }
191
192     try {
193       ComboTableData comboTableData = new ComboTableData(this, "TABLE", "", "190", "AD_User SalesRep", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerEdition"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerEdition"), 0);
194       Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerEdition", strSalesRep);
195       xmlDocument.setData("reportSALESREP","liststructure", comboTableData.select(false));
196       comboTableData = null;
197     } catch (Exception JavaDoc ex) {
198       throw new ServletException(ex);
199     }
200
201     xmlDocument.setData("reportCBPartnerId_IN", "liststructure", ReportProjectBuildingSiteData.selectBpartner(this, Utility.getContext(this, vars, "#User_Org", ""), Utility.getContext(this, vars, "#User_Client", ""), strcBpartnerId));
202     xmlDocument.setData("reportMProductId_IN", "liststructure", ReportProjectBuildingSiteData.selectMproduct(this, Utility.getContext(this, vars, "#User_Org", ""), Utility.getContext(this, vars, "#User_Client", ""), strProduct));
203
204
205     
206     xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
207     xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
208     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
209     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
210     
211     response.setContentType("text/html; charset=UTF-8");
212     PrintWriter out = response.getWriter();
213     out.println(xmlDocument.print());
214     out.close();
215   }
216
217   void printPageHtml(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strdateFrom, String JavaDoc strdateTo, String JavaDoc strcProjectId, String JavaDoc strcBpartnerId, String JavaDoc strmCategoryId, String JavaDoc strProjectkind, String JavaDoc strProjectstatus, String JavaDoc strProjectphase, String JavaDoc strProduct, String JavaDoc strProjectpublic, String JavaDoc strSalesRep, String JavaDoc strcRegionId) throws IOException, ServletException{
218     if (log4j.isDebugEnabled()) log4j.debug("Output: print html");
219     XmlDocument xmlDocument=null;
220     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerEdition").createXmlDocument();
221     InvoiceCustomerEditionData[] data = null;
222     data = InvoiceCustomerEditionData.select(this, Utility.getContext(this, vars, "#User_Org", "InvoiceCustomerFilter"), Utility.getContext(this, vars, "#User_Client", "InvoiceCustomerFilter"), strdateFrom, strdateTo, strcBpartnerId, strcProjectId, strmCategoryId, strProjectkind, strProjectphase, strProjectstatus, strProjectpublic, strcRegionId, strSalesRep, strProduct);
223     xmlDocument.setData("structure1", data);
224
225     
226
227     response.setContentType("text/html; charset=UTF-8");
228     PrintWriter out = response.getWriter();
229     out.println(xmlDocument.print());
230     out.close();
231   }
232
233   void printPagePdf(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strdateFrom, String JavaDoc strdateTo, String JavaDoc strcProjectId, String JavaDoc strcBpartnerId, String JavaDoc strmCategoryId, String JavaDoc strProjectkind, String JavaDoc strProjectstatus, String JavaDoc strProjectphase, String JavaDoc strProduct, String JavaDoc strProjectpublic, String JavaDoc strSalesRep, String JavaDoc strcRegionId) throws IOException, ServletException{
234     if (log4j.isDebugEnabled()) log4j.debug("Output: print pdf");
235     XmlDocument xmlDocument=null;
236     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerEdition_Pdf").createXmlDocument();
237     InvoiceCustomerEditionData[] data = null;
238     data = InvoiceCustomerEditionData.select(this, Utility.getContext(this, vars, "#User_Org", "InvoiceCustomerFilter"), Utility.getContext(this, vars, "#User_Client", "InvoiceCustomerFilter"), strdateFrom, strdateTo, strcBpartnerId, strcProjectId, strmCategoryId, strProjectkind, strProjectphase, strProjectstatus, strProjectpublic, strcRegionId, strSalesRep, strProduct);
239     xmlDocument.setData("structure1", data);
240     String JavaDoc strResult = xmlDocument.print();
241     if (log4j.isDebugEnabled()) log4j.debug(strResult);
242     renderFO(strResult, response);
243   }
244
245   public String JavaDoc getServletInfo() {
246     return "Servlet InvoiceCustomerFilter. This Servlet was made by Jon Alegría";
247   } // end of the getServletInfo() method
248
}
249
Popular Tags