KickJava   Java API By Example, From Geeks To Geeks.

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


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.utility.DateTimeData;
31
32 public class ReportProductionCost extends HttpSecureAppServlet {
33
34
35   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
36     VariablesSecureApp vars = new VariablesSecureApp(request);
37
38     if (!Utility.hasProcessAccess(this, vars, "", "RV_ReportProductionCost")) {
39       bdError(response, "AccessTableNoView", vars.getLanguage());
40       return;
41     }
42
43     if (vars.commandIn("DEFAULT")){
44       String JavaDoc strdateFrom = vars.getGlobalVariable("inpDateFrom", "ReportProductionCost|dateFrom", "");
45       String JavaDoc strdateTo = vars.getGlobalVariable("inpDateTo", "ReportProductionCost|dateTo", "");
46       //String strcBpartnerId = vars.getGlobalVariable("inpcBPartnerId", "ReportProductionCost|bpartner", "");
47
//String strCOrgId = vars.getGlobalVariable("inpCOrgId", "ReportProductionCost|orgID", "");
48
String JavaDoc strmProductId = vars.getGlobalVariable("inpmProductId", "ReportProductionCost|mProductId", "");
49       printPageDataSheet(response, vars, strdateFrom, strdateTo, strmProductId);
50     }else if (vars.commandIn("FIND")) {
51       String JavaDoc strdateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportProductionCost|dateFrom");
52       String JavaDoc strdateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportProductionCost|dateTo");
53       //String strcBpartnerId = vars.getRequestGlobalVariable("inpcBPartnerId", "ReportProductionCost|bpartner");
54
//String strCOrgId = vars.getRequestGlobalVariable("inpCOrgId", "ReportProductionCost|orgID");
55
String JavaDoc strmProductId = vars.getRequestGlobalVariable("inpmProductId", "ReportProductionCost|mProductId");
56       printPageDataSheet(response, vars, strdateFrom, strdateTo, strmProductId);
57     } else if (vars.commandIn("OPEN")) {
58       String JavaDoc strdateFrom = vars.getRequiredStringParameter("inpDateFrom");
59       String JavaDoc strdateTo = vars.getRequiredStringParameter("inpDateTo");
60       String JavaDoc strmProductId = vars.getRequiredStringParameter("inpProduct");
61       String JavaDoc strId = vars.getRequiredStringParameter("inpId");
62       String JavaDoc strLevel = vars.getRequiredStringParameter("inpLevel");
63       if (log4j.isDebugEnabled()) log4j.debug("***************************+: "+strdateFrom);
64       if (log4j.isDebugEnabled()) log4j.debug("***************************+: "+strdateTo);
65       if (log4j.isDebugEnabled()) log4j.debug("***************************+: "+strmProductId);
66       if (log4j.isDebugEnabled()) log4j.debug("***************************+: "+strId);
67       if (log4j.isDebugEnabled()) log4j.debug("***************************+: "+strLevel);
68
69       printPageOpen(response, vars, strdateFrom, strdateTo, strmProductId, strId, strLevel);
70     }else pageError(response);
71   }
72
73   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strdateFrom, String JavaDoc strdateTo, String JavaDoc strmProductId) throws IOException, ServletException {
74     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
75     String JavaDoc discard[]={"discard"};
76     XmlDocument xmlDocument=null;
77     String JavaDoc strLevel = "0";
78     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportProductionCost").createXmlDocument();
79
80     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportProductionCost", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
81     toolbar.prepareSimpleToolBarTemplate();
82     ReportProductionCostData[] data = null;
83
84     if (strdateFrom.equals("") && strdateTo.equals("")){
85       data = ReportProductionCostData.set();
86       discard[0] = "sectionDetail";
87     } else{
88       data = ReportProductionCostData.select(this, strLevel, strdateFrom, DateTimeData.nDaysAfter(this, strdateTo,"1"), strmProductId);
89       if (data == null || data.length == 0){
90         data = ReportProductionCostData.set();
91         discard[0] = "sectionDetail";
92       }
93     }
94
95
96     xmlDocument.setParameter("toolbar", toolbar.toString());
97
98     try {
99       KeyMap key = new KeyMap(this, vars, "ReportProductionCost.html");
100       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
101     } catch (Exception JavaDoc ex) {
102       throw new ServletException(ex);
103     }
104     try {
105       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportProductionCost");
106       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
107       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
108       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
109       xmlDocument.setParameter("theme", vars.getTheme());
110       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportProductionCost.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
111       xmlDocument.setParameter("navigationBar", nav.toString());
112       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportProductionCost.html", strReplaceWith);
113       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
114     } catch (Exception JavaDoc ex) {
115       throw new ServletException(ex);
116     }
117     {
118       OBError myMessage = vars.getMessage("ReportProductionCost");
119       vars.removeMessage("ReportProductionCost");
120       if (myMessage!=null) {
121         xmlDocument.setParameter("messageType", myMessage.getType());
122         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
123         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
124       }
125     }
126
127     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
128     xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
129     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
130     xmlDocument.setParameter("dateFrom", strdateFrom);
131     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
132     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
133     xmlDocument.setParameter("dateTo", strdateTo);
134     xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
135     xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
136     // xmlDocument.setParameter("adOrgId", strCOrgId);
137
// xmlDocument.setParameter("paramBPartnerId", strcBpartnerId);
138
// xmlDocument.setParameter("paramBPartnerDescription", ReportProductionCostData.bPartnerDescription(this, strcBpartnerId));
139
xmlDocument.setParameter("parammProductId", strmProductId);
140     xmlDocument.setParameter("paramProductDescription", ReportProductionCostData.mProductDescription(this, strmProductId));
141
142     // xmlDocument.setData("structureOrganizacion", OrganizationComboData.select(this, vars.getRole()));
143
xmlDocument.setData("structure", data);
144     response.setContentType("text/html; charset=UTF-8");
145     PrintWriter out = response.getWriter();
146     out.println(xmlDocument.print());
147     out.close();
148   }
149
150
151   void printPageOpen(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strdateFrom, String JavaDoc strdateTo, String JavaDoc strmProductId, String JavaDoc strId, String JavaDoc strLevel) throws IOException, ServletException {
152     //Ajax response
153
if (log4j.isDebugEnabled()) log4j.debug("Output: ajax");
154     XmlDocument xmlDocument = null;
155     String JavaDoc[] discard = {"discard", "discard", "discard", "discard"};
156     ReportProductionCostData[] dataMaterial = ReportProductionCostData.selectMaterial(this, strId, strLevel, strdateFrom, DateTimeData.nDaysAfter(this, strdateTo,"1"), strmProductId);
157     if (dataMaterial == null || dataMaterial.length == 0){
158       dataMaterial = ReportProductionCostData.set();
159       discard[0] = "structureMaterial";
160     }
161     ReportProductionCostData[] dataMachine = ReportProductionCostData.selectMachine(this, strLevel, strdateFrom, DateTimeData.nDaysAfter(this, strdateTo,"1"), strmProductId);
162     if (dataMachine == null || dataMachine.length == 0) {
163       dataMachine = ReportProductionCostData.set();
164       discard[1] = "structureMachine";
165     }
166     ReportProductionCostData[] dataIndirect = ReportProductionCostData.selectIndirect(this, strLevel, strdateFrom, DateTimeData.nDaysAfter(this, strdateTo,"1"), strmProductId);
167     if (dataIndirect == null || dataIndirect.length == 0) {
168       dataIndirect = ReportProductionCostData.set();
169       discard[2] = "structureIndirect";
170     }
171     ReportProductionCostData[] dataEmployee = ReportProductionCostData.selectEmployee(this, strLevel, strdateFrom, strdateTo, strmProductId);
172     if (dataEmployee == null || dataEmployee.length == 0) {
173       dataEmployee = ReportProductionCostData.set();
174       discard[3] = "structureEmployee";
175     }
176
177     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportProductionCostSubreport", discard).createXmlDocument();
178     // xmlDocument.setData("structure1", data);
179
xmlDocument.setData("structureMaterial", dataMaterial);
180     xmlDocument.setData("structureMachine", dataMachine);
181     xmlDocument.setData("structureIndirect", dataIndirect);
182     xmlDocument.setData("structureEmployee", dataEmployee);
183
184     response.setContentType("text/plain");
185     response.setHeader("Cache-Control", "no-cache");
186     PrintWriter out = response.getWriter();
187     // xmlDocument.setData("structure", data);
188
out.println(xmlDocument.print());
189     out.close();
190   }
191
192   /*void printPageHtml(HttpServletResponse response, VariablesSecureApp vars, String strdateFrom, String strdateTo, String strcBpartnetId, String strCOrgId, String strInvoiceRule, String strDetail) throws IOException, ServletException{
193     if (log4j.isDebugEnabled()) log4j.debug("Output: print html");
194     XmlDocument xmlDocument=null;
195     ReportOrderNotInvoiceData[] data = null;
196     if (!strDetail.equals("-1")) {
197     String[] discard = {"selEliminar"};
198     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportOrderNotInvoice", discard).createXmlDocument();
199     } else {
200     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportOrderNotInvoice").createXmlDocument();
201     }
202     data = ReportOrderNotInvoiceData.select(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", "ReportOrderNotInvoice"), Utility.getContext(this, vars, "#User_Org", "ReportOrderNotInvoice"), strcBpartnetId, strCOrgId, strInvoiceRule, strdateFrom, DateTimeData.nDaysAfter(this, strdateTo,"1"));
203     xmlDocument.setData("structure1", data);
204     response.setContentType("text/html; charset=UTF-8");
205     PrintWriter out = response.getWriter();
206     out.println(xmlDocument.print());
207     out.close();
208     }*/

209
210   public String JavaDoc getServletInfo() {
211     return "Servlet ReportProductionCost.";
212   } // end of getServletInfo() method
213
}
214
215
Popular Tags