KickJava   Java API By Example, From Geeks To Geeks.

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


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 ABCproduct 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 strFrom = vars.getGlobalVariable("inpFrom", "ABCproduct|From", "");
38       String JavaDoc strTo = vars.getGlobalVariable("inpTo", "ABCproduct|To", "");
39       String JavaDoc strCategory = vars.getGlobalVariable("inpCategory", "ABCproduct|Category", "");
40       printPageDataSheet(response, vars, strFrom, strTo, strCategory);
41     } else if (vars.commandIn("FIND")) {
42       String JavaDoc strFrom = vars.getRequestGlobalVariable("inpFrom", "ABCproduct|From");
43       String JavaDoc strTo = vars.getRequestGlobalVariable("inpTo", "ABCproduct|To");
44       String JavaDoc strCategory = vars.getGlobalVariable("inpCategory", "ABCproduct|Category", "");
45       printPageDataSheet(response, vars, strFrom, strTo, strCategory);
46     } else pageError(response);
47   }
48
49   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strFrom, String JavaDoc strTo, String JavaDoc strCategory)
50     throws IOException, ServletException {
51     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
52     response.setContentType("text/html; charset=UTF-8");
53     PrintWriter out = response.getWriter();
54     XmlDocument xmlDocument=null;
55     ABCproductData[] data=null;
56     if (strFrom.equals("") || strTo.equals("")){
57       String JavaDoc discard[]= {"selEliminar"};
58       xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ABCproduct", discard).createXmlDocument();
59       data = ABCproductData.set("0","0");
60     } else {
61       xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ABCproduct").createXmlDocument();
62       data = ABCproductData.select(this,strFrom, strTo, strCategory);
63     }
64
65     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ABCproduct", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
66     toolbar.prepareSimpleToolBarTemplate();
67     xmlDocument.setParameter("toolbar", toolbar.toString());
68     try {
69       KeyMap key = new KeyMap(this, vars, "ABCproduct.html");
70       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
71     } catch (Exception JavaDoc ex) {
72       throw new ServletException(ex);
73     }
74     try {
75       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ABCbproduct");
76       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
77       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
78       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
79       xmlDocument.setParameter("theme", vars.getTheme());
80       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ABCproduct.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
81       xmlDocument.setParameter("navigationBar", nav.toString());
82       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ABCproduct.html", strReplaceWith);
83       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
84     } catch (Exception JavaDoc ex) {
85       throw new ServletException(ex);
86     }
87     {
88       OBError myMessage = vars.getMessage("ABCproduct");
89       vars.removeMessage("ABCproduct");
90       if (myMessage!=null) {
91         xmlDocument.setParameter("messageType", myMessage.getType());
92         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
93         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
94       }
95     }
96
97
98     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
99     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
100     xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
101     xmlDocument.setParameter("from", strFrom);
102     xmlDocument.setParameter("to", strTo);
103     xmlDocument.setParameter("category", strCategory);
104
105     try {
106       ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Product_Category_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ABCproduct"), Utility.getContext(this, vars, "#User_Client", "ABCproduct"), 0);
107       Utility.fillSQLParameters(this, vars, null, comboTableData, "ABCproduct", "");
108       xmlDocument.setData("reportCategory","liststructure", comboTableData.select(false));
109       comboTableData = null;
110     } catch (Exception JavaDoc ex) {
111       throw new ServletException(ex);
112     }
113
114     xmlDocument.setData("structure", data);
115     out.println(xmlDocument.print());
116     out.close();
117   }
118
119   public String JavaDoc getServletInfo() {
120     return "Servlet ABCproduct. This Servlet was made by Eduardo Argal";
121   } // end of getServletInfo() method
122
}
123
124
Popular Tags