KickJava   Java API By Example, From Geeks To Geeks.

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


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