KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.openbravo.erpCommon.ad_combos.ProcessPlanComboData;
31 import org.openbravo.erpCommon.ad_combos.ProcessPlanVersionComboData;
32
33 public class ReportStandardCost extends HttpSecureAppServlet {
34
35
36   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
37     VariablesSecureApp vars = new VariablesSecureApp(request);
38
39     // if (!Utility.hasProcessAccess(this, vars, "", "RV_ReportOrderNotInvoiced")) {
40
// bdError(response, "AccessTableNoView", vars.getLanguage());
41
// return;
42
// }
43

44     if (vars.commandIn("DEFAULT")){
45       String JavaDoc strdate = vars.getGlobalVariable("inpDate", "ReportStandardCost|date", "");
46       String JavaDoc strProductId = vars.getGlobalVariable("inpProductId", "ReportStandardCost|product", "");
47       String JavaDoc strProcessPlan = vars.getGlobalVariable("inpmaProcessPlanId", "ReportStandardCost|ProcessPlanID", "");
48       String JavaDoc strVersion = vars.getGlobalVariable("inpmaProcessPlanVersionId", "ReportStandardCost|versionID", "");
49       printPageDataSheet(response, vars, strdate, strProductId, strProcessPlan, strVersion);
50     }else if (vars.commandIn("FIND")) {
51       String JavaDoc strdate = vars.getRequestGlobalVariable("inpDate", "ReportStandardCost|date");
52       String JavaDoc strProductId = vars.getRequestGlobalVariable("inpProductId", "ReportStandardCost|product");
53       String JavaDoc strProcessPlan = vars.getRequestGlobalVariable("inpmaProcessPlanId", "ReportStandardCost|ProcessPlanID");
54       String JavaDoc strVersion = vars.getRequestGlobalVariable("inpmaProcessPlanVersionId", "ReportStandardCost|versionID");
55       printPageHtml(response, vars, strdate, strProductId, strProcessPlan, strVersion);
56     } else pageError(response);
57   }
58
59   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strdate, String JavaDoc strProductId, String JavaDoc strProcessPlan, String JavaDoc strVersion) throws IOException, ServletException {
60     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
61     String JavaDoc discard[]={"discard"};
62     XmlDocument xmlDocument=null;
63     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportStandardCostFilter").createXmlDocument();
64
65     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportStandardCostFilter", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
66     toolbar.prepareSimpleToolBarTemplate();
67     xmlDocument.setParameter("toolbar", toolbar.toString());
68
69     try {
70       KeyMap key = new KeyMap(this, vars, "ReportStandardCost.html");
71       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
72     } catch (Exception JavaDoc ex) {
73       throw new ServletException(ex);
74     }
75     try {
76       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportStandardCost");
77       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
78       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
79       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
80       xmlDocument.setParameter("theme", vars.getTheme());
81       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportStandardCost.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
82       xmlDocument.setParameter("navigationBar", nav.toString());
83       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportStandardCost.html", strReplaceWith);
84       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
85     } catch (Exception JavaDoc ex) {
86       throw new ServletException(ex);
87     }
88     {
89       OBError myMessage = vars.getMessage("ReportStandardCost");
90       vars.removeMessage("ReportStandardCost");
91       if (myMessage!=null) {
92         xmlDocument.setParameter("messageType", myMessage.getType());
93         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
94         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
95       }
96     }
97
98     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
99     xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
100     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
101     xmlDocument.setParameter("date", strdate);
102     xmlDocument.setParameter("datedisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
103     xmlDocument.setParameter("datesaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
104     xmlDocument.setParameter("paramProductId", strProductId);
105     // xmlDocument.setParameter("paramProductDescription", ReportStandardCostData.ProductDescription(this, strProductId));
106
xmlDocument.setData("reportMA_PROCESSPLAN", "liststructure", ProcessPlanComboData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportStandardCost"), Utility.getContext(this, vars, "#User_Org", "ReportStandardCost")));
107     xmlDocument.setData("reportMA_PROCESSVERSIONPLAN", "liststructure", ProcessPlanVersionComboData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportStandardCost"), Utility.getContext(this, vars, "#User_Org", "ReportStandardCost")));
108     response.setContentType("text/html; charset=UTF-8");
109     PrintWriter out = response.getWriter();
110     out.println(xmlDocument.print());
111     out.close();
112   }
113
114   void printPageHtml(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strdate, String JavaDoc strProductId, String JavaDoc strProcessPlan, String JavaDoc strVersion) throws IOException, ServletException{
115     if (log4j.isDebugEnabled()) log4j.debug("Output: print html");
116     XmlDocument xmlDocument=null;
117     ReportStandardCostData[] data = null;
118     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportStandardCost").createXmlDocument();
119
120     data = ReportStandardCostData.select(this,strdate,strProductId,strProcessPlan,strVersion);
121     xmlDocument.setData("structure2", data);
122     response.setContentType("text/html; charset=UTF-8");
123     PrintWriter out = response.getWriter();
124     out.println(xmlDocument.print());
125     out.close();
126   }
127
128   public String JavaDoc getServletInfo() {
129     return "Servlet ReportStandardCostFilter. This Servlet was made by Pablo Sarobe";
130   } // end of getServletInfo() method
131
}
132
133
Popular Tags