KickJava   Java API By Example, From Geeks To Geeks.

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


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 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 public class ReportInvoiceVendorJR extends HttpSecureAppServlet {
39
40
41   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
42     VariablesSecureApp vars = new VariablesSecureApp(request);
43
44     if (!Utility.hasProcessAccess(this, vars, "", "ReportInvoiceVendorJR")) {
45       bdError(response, "AccessTableNoView", vars.getLanguage());
46       return;
47     }
48
49     if (vars.commandIn("DEFAULT")){
50       String JavaDoc strdateFrom = vars.getStringParameter("inpdateFrom", "");
51       String JavaDoc strdateTo = vars.getStringParameter("inpdateTo", "");
52       printPageDataSheet(response, vars, strdateFrom, strdateTo);
53     }else if (vars.commandIn("EDIT_HTML","EDIT_PDF")) {
54       String JavaDoc strdateFrom = vars.getStringParameter("inpdateFrom");
55       String JavaDoc strdateTo = vars.getStringParameter("inpdateTo");
56       String JavaDoc strcBpartnetId = vars.getStringParameter("inpcBPartnerId");
57       String JavaDoc strcProjectId = vars.getStringParameter("inpcProjectId");
58       String JavaDoc strissotrx = "N";
59       printPageHtml(response, vars, strdateFrom, strdateTo, strcBpartnetId, strcProjectId ,strissotrx);
60     } else pageErrorPopUp(response);
61   }
62
63   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strdateFrom, String JavaDoc strdateTo) throws IOException, ServletException {
64     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
65     String JavaDoc discard[]={"discard"};
66     XmlDocument xmlDocument=null;
67     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceVendorFilterJR").createXmlDocument();
68
69     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportInvoiceVendorFilter", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
70     toolbar.prepareSimpleToolBarTemplate();
71     xmlDocument.setParameter("toolbar", toolbar.toString());
72
73     try {
74       KeyMap key = new KeyMap(this, vars, "ReportInvoiceVendorEdition.html");
75       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
76     } catch (Exception JavaDoc ex) {
77       throw new ServletException(ex);
78     }
79     try {
80       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportInvoiceVendorJR");
81       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
82       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
83       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
84       xmlDocument.setParameter("theme", vars.getTheme());
85       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportInvoiceVendorFilterJR.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
86       xmlDocument.setParameter("navigationBar", nav.toString());
87       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportInvoiceVendorFilterJR.html", strReplaceWith);
88       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
89     } catch (Exception JavaDoc ex) {
90       throw new ServletException(ex);
91     }
92     {
93       OBError myMessage = vars.getMessage("ReportInvoiceVendorJR");
94       vars.removeMessage("ReportInvoiceVendorJR");
95       if (myMessage!=null) {
96         xmlDocument.setParameter("messageType", myMessage.getType());
97         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
98         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
99       }
100     }
101
102
103     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
104     xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
105     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
106     xmlDocument.setParameter("dateFrom", strdateFrom);
107     xmlDocument.setParameter("dateTo", strdateTo);
108     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
109     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
110     xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
111     xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
112     xmlDocument.setParameter("paramBPartnerId", "");
113     xmlDocument.setParameter("mWarehouseId", "");
114     xmlDocument.setParameter("cProjectId", "");
115     xmlDocument.setParameter("projectName", "");
116     try {
117       ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Warehouse_ID", "", "", Utility.getContext(this, vars, "#User_Org", "InvoiceVendorJR"), Utility.getContext(this, vars, "#User_Client", "InvoiceVendorJR"), 0);
118       Utility.fillSQLParameters(this, vars, null, comboTableData, "InvoiceVendorFilter", "");
119       xmlDocument.setData("reportM_WAREHOUSEID","liststructure", comboTableData.select(false));
120       comboTableData = null;
121     } catch (Exception JavaDoc ex) {
122       throw new ServletException(ex);
123     }
124
125     response.setContentType("text/html; charset=UTF-8");
126     PrintWriter out = response.getWriter();
127     out.println(xmlDocument.print());
128     out.close();
129   }
130
131   void printPageHtml(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strdateFrom, String JavaDoc strdateTo, String JavaDoc strcBpartnetId, String JavaDoc strcProjectId, String JavaDoc strissotrx) throws IOException, ServletException{
132     if (log4j.isDebugEnabled()) log4j.debug("Output: print html");
133     
134     InvoiceEditionData[] data = null;
135     data = InvoiceEditionData.select(this, Utility.getContext(this, vars, "#User_Org", "InvoiceVendorJR"), Utility.getContext(this, vars, "#User_Client", "InvoiceVendorJR"), strdateFrom, strdateTo, strcBpartnetId, strcProjectId, strissotrx);
136         
137     JasperPrint jasperPrint;
138     String JavaDoc strOutput = vars.commandIn("EDIT_HTML")?"html":"pdf";
139     String JavaDoc strReportName = "@basedesign@/org/openbravo/erpCommon/ad_reports/ReportInvoiceVendorJR.jrxml";
140     
141     HashMap<String JavaDoc, Object JavaDoc> parameters = new HashMap<String JavaDoc, Object JavaDoc>();
142     parameters.put("Title", classInfo.name);
143     //parameters.put("Subtitle",strSubtitle);
144
renderJR(vars, response, strReportName, strOutput, parameters, data, null );
145   }
146
147
148
149   public String JavaDoc getServletInfo() {
150     return "Servlet PurchaseOrderFilter. This Servlet was made by Jon Alegría";
151   } // end of getServletInfo() method
152
}
153
154
Popular Tags