KickJava   Java API By Example, From Geeks To Geeks.

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


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
20 package org.openbravo.erpCommon.ad_reports;
21
22 import org.openbravo.erpCommon.utility.*;
23 import org.openbravo.erpCommon.businessUtility.WindowTabs;
24 import org.openbravo.base.secureApp.HttpSecureAppServlet;
25 import org.openbravo.base.secureApp.VariablesSecureApp;
26 import org.openbravo.xmlEngine.XmlDocument;
27 import java.io.*;
28 import javax.servlet.*;
29 import javax.servlet.http.*;
30
31 public class ReportMaterialTransactionEdition extends HttpSecureAppServlet {
32
33
34   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
35     VariablesSecureApp vars = new VariablesSecureApp(request);
36
37     if (!Utility.hasProcessAccess(this, vars, "", "RV_ReportMaterialTransaction")) {
38       bdError(response, "AccessTableNoView", vars.getLanguage());
39       return;
40     }
41
42     if (vars.commandIn("DEFAULT")){
43       String JavaDoc strdateFrom = vars.getStringParameter("inpDateFrom", "");
44       String JavaDoc strdateTo = vars.getStringParameter("inpDateTo", "");
45       printPageDataSheet(response, vars, strdateFrom, strdateTo);
46     }else if (vars.commandIn("EDIT_HTML")) {
47       String JavaDoc strdateFrom = vars.getStringParameter("inpDateFrom");
48       String JavaDoc strdateTo = vars.getStringParameter("inpDateTo");
49       String JavaDoc strcBpartnetId = vars.getStringParameter("inpcBPartnerId");
50       String JavaDoc strmWarehouseId = vars.getStringParameter("inpmWarehouseId");
51       String JavaDoc strcProjectId = vars.getStringParameter("inpcProjectId");
52       String JavaDoc strissotrx = "N";
53       printPageHtml(response, vars, strdateFrom, strdateTo, strcBpartnetId, strmWarehouseId, strcProjectId ,strissotrx);
54     } else if (vars.commandIn("EDIT_PDF")) {
55       if (log4j.isDebugEnabled()) log4j.debug("WE EDIT THE 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 = "N";
62       printPagePdf(response, vars, strdateFrom, strdateTo, strcBpartnetId, strmWarehouseId, strcProjectId ,strissotrx);
63     } else pageErrorPopUp(response);
64   }
65
66   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strdateFrom, String JavaDoc strdateTo) throws IOException, ServletException {
67     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
68     String JavaDoc discard[]={"discard"};
69     XmlDocument xmlDocument=null;
70     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportMaterialTransactionFilter").createXmlDocument();
71
72     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportMaterialTransactionEdition", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
73     toolbar.prepareSimpleToolBarTemplate();
74     xmlDocument.setParameter("toolbar", toolbar.toString());
75     try {
76       KeyMap key = new KeyMap(this, vars, "ReportMaterialTransactionEdition.html");
77       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
78     } catch (Exception JavaDoc ex) {
79       throw new ServletException(ex);
80     }
81     try {
82       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportMaterialTransactionEdition");
83       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
84       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
85       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
86       xmlDocument.setParameter("theme", vars.getTheme());
87       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportMaterialTransactionEdition.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
88       xmlDocument.setParameter("navigationBar", nav.toString());
89       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportMaterialTransactionEdition.html", strReplaceWith);
90       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
91     } catch (Exception JavaDoc ex) {
92       throw new ServletException(ex);
93     }
94     {
95       OBError myMessage = vars.getMessage("ReportMaterialTransactionEdition");
96       vars.removeMessage("ReportMaterialTransactionEdition");
97       if (myMessage!=null) {
98         xmlDocument.setParameter("messageType", myMessage.getType());
99         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
100         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
101       }
102     }
103
104
105
106     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
107     xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
108     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
109     xmlDocument.setParameter("dateFrom", strdateFrom);
110     xmlDocument.setParameter("dateTo", strdateTo);
111     xmlDocument.setParameter("paramBPartnerId", "");
112     xmlDocument.setParameter("mWarehouseId", "");
113     xmlDocument.setParameter("cProjectId", "");
114     try {
115       ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Warehouse_ID", "", "", Utility.getContext(this, vars, "#User_Org", "MaterialReceiptFilter"), Utility.getContext(this, vars, "#User_Client", "MaterialReceiptFilter"), 0);
116       Utility.fillSQLParameters(this, vars, null, comboTableData, "MaterialReceiptFilter", "");
117       xmlDocument.setData("reportM_WAREHOUSEID","liststructure", comboTableData.select(false));
118       comboTableData = null;
119     } catch (Exception JavaDoc ex) {
120       throw new ServletException(ex);
121     }
122
123
124     try {
125       ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "C_Project_ID", "", "", Utility.getContext(this, vars, "#User_Org", "MaterialReceiptFilter"), Utility.getContext(this, vars, "#User_Client", "MaterialReceiptFilter"), 0);
126       Utility.fillSQLParameters(this, vars, null, comboTableData, "MaterialReceiptFilter", "");
127       xmlDocument.setData("reportC_PROJECTID","liststructure", comboTableData.select(false));
128       comboTableData = null;
129     } catch (Exception JavaDoc ex) {
130       throw new ServletException(ex);
131     }
132
133     response.setContentType("text/html; charset=UTF-8");
134     PrintWriter out = response.getWriter();
135     out.println(xmlDocument.print());
136     out.close();
137   }
138
139   void printPageHtml(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{
140     if (log4j.isDebugEnabled()) log4j.debug("Output: print html");
141     XmlDocument xmlDocument=null;
142     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportMaterialTransactionEdition").createXmlDocument();
143     InoutEditionData[] data = null;
144     data = InoutEditionData.select(this, Utility.getContext(this, vars, "#User_Org", "MaterialReceiptFilter"), Utility.getContext(this, vars, "#User_Client", "MaterialReceiptFilter"), strdateFrom, strdateTo, strcBpartnetId, strmWarehouseId, strcProjectId, strissotrx);
145     xmlDocument.setData("structure1", data);
146     response.setContentType("text/html; charset=UTF-8");
147     PrintWriter out = response.getWriter();
148     out.println(xmlDocument.print());
149     out.close();
150   }
151
152   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{
153     if (log4j.isDebugEnabled()) log4j.debug("Output: print pdf");
154     XmlDocument xmlDocument=null;
155     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportMaterialTransactionEdition_Pdf").createXmlDocument();
156     InoutEditionData[] data = null;
157     data = InoutEditionData.select(this, Utility.getContext(this, vars, "#User_Org", "MaterialReceiptFilter"), Utility.getContext(this, vars, "#User_Client", "MaterialReceiptFilter"), strdateFrom, strdateTo, strcBpartnetId, strmWarehouseId, strcProjectId, strissotrx);
158     xmlDocument.setData("structure1", data);
159     String JavaDoc strResult = xmlDocument.print();
160     if (log4j.isDebugEnabled()) log4j.debug(strResult);
161     renderFO(strResult, response);
162   }
163
164   public String JavaDoc getServletInfo() {
165     return "Servlet PurchaseOrderFilter. This Servlet was made by Jon Alegría";
166   } // end of getServletInfo() method
167
}
168
169
Popular Tags