KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.HashMap JavaDoc;
30
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
39 public class ReportShipmentEditionJR extends HttpSecureAppServlet {
40
41
42   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
43     VariablesSecureApp vars = new VariablesSecureApp(request);
44
45     if (!Utility.hasProcessAccess(this, vars, "", "RV_ReportShipment")) {
46       bdError(response, "AccessTableNoView", vars.getLanguage());
47       return;
48     }
49
50     if (vars.commandIn("DEFAULT")){
51       String JavaDoc strdateFrom = vars.getStringParameter("inpDateFrom", "");
52       String JavaDoc strdateTo = vars.getStringParameter("inpDateTo", "");
53       printPageDataSheet(response, vars, strdateFrom, strdateTo);
54     } else if (vars.commandIn("EDIT_PDF","EDIT_HTML")) {
55       log4j.info("EDITAMOS EL PDF");
56       String JavaDoc strdateFrom = vars.getStringParameter("inpDateFrom");
57       String JavaDoc strdateTo = vars.getStringParameter("inpDateTo");
58       String JavaDoc strcBpartnetId = vars.getStringParameter("inpcBPartnerId");
59       String JavaDoc strmWarehouseId = vars.getStringParameter("inpmWarehouseId");
60       String JavaDoc strcProjectId = vars.getStringParameter("inpcProjectId");
61       String JavaDoc strissotrx = "Y";
62       printPagePdf(response, vars, strdateFrom, strdateTo, strcBpartnetId, strmWarehouseId, strcProjectId ,strissotrx);
63     } else pageErrorPopUp(response);
64
65   }
66
67   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strdateFrom, String JavaDoc strdateTo) throws IOException, ServletException {
68     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
69     String JavaDoc discard[]={"discard"};
70     XmlDocument xmlDocument=null;
71     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportShipmentFilterJR").createXmlDocument();
72
73
74     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportShipmentFilterJR", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
75     toolbar.prepareSimpleToolBarTemplate();
76     xmlDocument.setParameter("toolbar", toolbar.toString());
77
78     try {
79       KeyMap key = new KeyMap(this, vars, "ReportShipmentEditionJR.html");
80       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
81     } catch (Exception JavaDoc ex) {
82       throw new ServletException(ex);
83     }
84     try {
85       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportShipmentEditionJR");
86       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
87       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
88       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
89       xmlDocument.setParameter("theme", vars.getTheme());
90       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportShipmentEditionJR.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
91       xmlDocument.setParameter("navigationBar", nav.toString());
92       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportShipmentEditionJR.html", strReplaceWith);
93       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
94     } catch (Exception JavaDoc ex) {
95       throw new ServletException(ex);
96     }
97     {
98       OBError myMessage = vars.getMessage("ReportShipmentEditionJR");
99       vars.removeMessage("ReportShipmentEditionJR");
100       if (myMessage!=null) {
101         xmlDocument.setParameter("messageType", myMessage.getType());
102         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
103         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
104       }
105     }
106
107     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
108     xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
109     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
110     xmlDocument.setParameter("dateFrom", strdateFrom);
111     xmlDocument.setParameter("dateTo", strdateTo);
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", "ShipmentFilter"), Utility.getContext(this, vars, "#User_Client", "ShipmentFilter"), 0);
118       Utility.fillSQLParameters(this, vars, null, comboTableData, "ShipmentFilter", "");
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
132   void printPagePdf(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strdateFrom, String JavaDoc strdateTo, String JavaDoc strcBpartnetId, String JavaDoc strmWarehouseId, String JavaDoc strcProjectId, String JavaDoc strissotrx) throws IOException, ServletException{
133     if (log4j.isDebugEnabled()) log4j.debug("Output: print pdf");
134         JasperPrint jasperPrint;
135       
136 /* String strLanguage = vars.getLanguage();
137       if (strBaseDesignPath.endsWith("/")) strDefaultDesignPath = strDefaultDesignPath.substring(0, strDefaultDesignPath.length()-1);
138       log4j.info("*********************Base path: " + strBaseDesignPath);
139       String strNewAddBase = strDefaultDesignPath;
140       String strFinal = strBaseDesignPath;
141       if (!strLanguage.equals("") && !strLanguage.equals("en_US")) strNewAddBase = strLanguage;
142       if (!strFinal.endsWith("/" + strNewAddBase)) strFinal += "/" + strNewAddBase;
143       log4j.info("*********************Base path: " + strFinal);
144       String strBaseDesign = prefix + "/" + strFinal;*/

145     String JavaDoc strOutput=new String JavaDoc(vars.commandIn("EDIT_PDF")?"pdf":"html");
146
147       String JavaDoc strReportName = "@basedesign@/org/openbravo/erpCommon/ad_reports/ReportShipmentEdition.jrxml";
148       if (strOutput.equals("pdf")) response.setHeader("Content-disposition", "inline; filename=ReportShipmetEditionJR.pdf");
149
150         InoutEditionData[] data = InoutEditionData.select(this, Utility.getContext(this, vars, "#User_Org", "ShipmentFilter"), Utility.getContext(this, vars, "#User_Client", "ShipmentFilter"), strdateFrom, strdateTo, strcBpartnetId, strmWarehouseId, strcProjectId, strissotrx);
151         HashMap JavaDoc<String JavaDoc, Object JavaDoc> parameters = new HashMap JavaDoc<String JavaDoc, Object JavaDoc>();
152         String JavaDoc strTitle = classInfo.name;
153         parameters.put("REPORT_TITLE", strTitle);
154         //parameters.put("PRODUCT_LEVEL", new Integer(intProductLevel));
155
if (log4j.isDebugEnabled()) log4j.debug("data"+data.length);
156       renderJR(vars, response, strReportName, strOutput, parameters, data, null );
157
158 /* XmlDocument xmlDocument=null;
159     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportShipmentEdition_Pdf").createXmlDocument();
160     InoutEditionData[] data = null;
161     data = InoutEditionData.select(this, Utility.getContext(this, vars, "#User_Org", "ShipmentFilter"), Utility.getContext(this, vars, "#User_Client", "ShipmentFilter"), strdateFrom, strdateTo, strcBpartnetId, strmWarehouseId, strcProjectId, strissotrx);
162     xmlDocument.setData("structure1", data);
163     String strResult = xmlDocument.print();
164     if (log4j.isDebugEnabled()) log4j.debug(strResult);
165     renderFO(strResult, response);*/

166
167   }
168
169   public String JavaDoc getServletInfo() {
170     return "Servlet PurchaseOrderFilter. This Servlet was made by Jon Alegría";
171   } // end of getServletInfo() method
172
}
173
174
Popular Tags