KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class ReportPricelist extends HttpSecureAppServlet {
31
32
33   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
34     VariablesSecureApp vars = new VariablesSecureApp(request);
35
36     if (vars.commandIn("DEFAULT")) {
37       String JavaDoc strProductCategory = vars.getGlobalVariable("inpProductCategory", "ReportPricelist|productCategory", "");
38       String JavaDoc strPricelistversionId = vars.getGlobalVariable("inpmPricelistVersion", "ReportPricelist|pricelistversion", "");
39       String JavaDoc strmProductId = vars.getInGlobalVariable("inpmProductId_IN", "ReportPricelist|mProductId", "");
40       printPageDataSheet(response, vars, strProductCategory, strPricelistversionId,strmProductId);
41       /*} else if (vars.commandIn("DIRECT")) {
42         String strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportPricelist|dateFrom", "");
43         String strDateTo = vars.getGlobalVariable("inpDateTo", "ReportPricelist|dateTo", "");
44         String strcBpartnerId = vars.getGlobalVariable("inpcBPartnerId", "ReportPricelist|cBpartnerId", "");
45         String strPartner = vars.getGlobalVariable("inpPartner", "ReportPricelist|partner", "");
46         setHistoryCommand(request, "DIRECT");
47         printPageDataSheet(response, vars, strDateFrom, strDateTo, strcBpartnerId, strPartner);*/

48   } else if (vars.commandIn("FIND")) {
49     String JavaDoc strProductCategory = vars.getRequestGlobalVariable("inpProductCategory", "ReportPricelist|productCategory");
50     String JavaDoc strPricelistversionId = vars.getRequestGlobalVariable("inpmPricelistVersion", "ReportPricelist|pricelistversion");
51     String JavaDoc strmProductId = vars.getRequestInGlobalVariable("inpmProductId_IN", "ReportPricelist|mProductId");
52     /*setHistoryCommand(request, "DIRECT");*/
53     printPageDataSheet(response, vars, strProductCategory, strPricelistversionId, strmProductId);
54   } else if (vars.commandIn("EDIT_PDF")) {
55     String JavaDoc strProductCategory = vars.getRequestGlobalVariable("inpProductCategory", "ReportPricelist|productCategory");
56     String JavaDoc strPricelistversionId = vars.getRequestGlobalVariable("inpmPricelistVersion", "ReportPricelist|pricelistversion");
57     String JavaDoc strmProductId = vars.getRequestInGlobalVariable("inpmProductId_IN", "ReportPricelist|mProductId");
58     printPagePdf(response, vars, strProductCategory, strPricelistversionId, strmProductId);
59   } else pageError(response);
60   }
61
62   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strProductCategory, String JavaDoc strPricelistversionId, String JavaDoc strmProductId)
63     throws IOException, ServletException {
64     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
65     response.setContentType("text/html; charset=UTF-8");
66     PrintWriter out = response.getWriter();
67     XmlDocument xmlDocument=null;
68     ReportPricelistData[] data = null;
69     String JavaDoc discard[] = {"discard"};
70     if (vars.commandIn("DEFAULT") && strProductCategory.equals("") && strPricelistversionId.equals("") && strmProductId.equals("")){
71       discard[0] = "sectionPricelistVersion";
72       data = ReportPricelistData.set();
73     } else {
74       data = ReportPricelistData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportPricelist"), Utility.getContext(this, vars, "#User_Org", "ReportPricelist"), strPricelistversionId, strProductCategory, strmProductId);
75     }
76     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportPricelist", discard).createXmlDocument();
77
78     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportPricelist", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
79     toolbar.prepareSimpleToolBarTemplate();
80     xmlDocument.setParameter("toolbar", toolbar.toString());
81
82     try {
83       KeyMap key = new KeyMap(this, vars, "ReportPricelist.html");
84       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
85     } catch (Exception JavaDoc ex) {
86       throw new ServletException(ex);
87     }
88     try {
89       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportPricelist");
90       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
91       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
92       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
93       xmlDocument.setParameter("theme", vars.getTheme());
94       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportPricelist.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
95       xmlDocument.setParameter("navigationBar", nav.toString());
96       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportPricelist.html", strReplaceWith);
97       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
98     } catch (Exception JavaDoc ex) {
99       throw new ServletException(ex);
100     }
101     {
102       OBError myMessage = vars.getMessage("ReportPricelist");
103       vars.removeMessage("ReportPricelist");
104       if (myMessage!=null) {
105         xmlDocument.setParameter("messageType", myMessage.getType());
106         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
107         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
108       }
109     }
110
111     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
112     xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
113     xmlDocument.setParameter("mProductCategoryId", strProductCategory);
114     xmlDocument.setParameter("mPricelistVersionId", strPricelistversionId);
115
116     try {
117       ComboTableData comboTableData = new ComboTableData(vars, this, "LIST", "MProductId_IN", "null", "", Utility.getContext(this, vars, "#User_Org", ""), Utility.getContext(this, vars, "#User_Client", ""), 0);
118       Utility.fillSQLParameters(this, vars, null, comboTableData, "", strmProductId);
119       xmlDocument.setData("reportMProductId_IN", "liststructure", comboTableData.select(false));
120       comboTableData = null;
121     } catch (Exception JavaDoc ex) {
122       throw new ServletException(ex);
123     }
124
125
126     try {
127       ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Product_Category_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportPricelist"), Utility.getContext(this, vars, "#User_Client", "ReportPricelist"), 0);
128       Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportPricelist", strProductCategory);
129       xmlDocument.setData("reportM_PRODUCT_CATEGORYID","liststructure", comboTableData.select(false));
130       comboTableData = null;
131     } catch (Exception JavaDoc ex) {
132       throw new ServletException(ex);
133     }
134
135
136     try {
137       ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_PriceList_Version_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportPricelist"), Utility.getContext(this, vars, "#User_Client", "ReportPricelist"), 0);
138       Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportPricelist", strPricelistversionId);
139       xmlDocument.setData("reportM_PRICELIST_VERSIONID","liststructure", comboTableData.select(false));
140       comboTableData = null;
141     } catch (Exception JavaDoc ex) {
142       throw new ServletException(ex);
143     }
144
145
146     xmlDocument.setData("structure1", data);
147
148     out.println(xmlDocument.print());
149     out.close();
150   }
151
152   void printPagePdf(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strProductCategory, String JavaDoc strPricelistversionId, String JavaDoc strmProductId) 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/ReportPricelist_Pdf").createXmlDocument();
156     xmlDocument.setData("structure1", ReportPricelistData.selectPDF(this, Utility.getContext(this, vars, "#User_Client", "ReportPricelist"), Utility.getContext(this, vars, "#User_Org", "ReportPricelist"), strPricelistversionId, strProductCategory, strmProductId));
157     String JavaDoc strResult = xmlDocument.print();
158     if (log4j.isDebugEnabled()) log4j.debug(strResult);
159     renderFO(strResult, response);
160   }
161
162   public String JavaDoc getServletInfo() {
163     return "Servlet ReportPricelist. This Servlet was made by Pablo Sarobe";
164   } // end of getServletInfo() method
165
}
166
Popular Tags