KickJava   Java API By Example, From Geeks To Geeks.

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


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
31 import org.openbravo.erpCommon.utility.DateTimeData;
32
33 public class ReportToInvoiceConsignment extends HttpSecureAppServlet {
34
35
36   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
37     VariablesSecureApp vars = new VariablesSecureApp(request);
38
39     if (vars.commandIn("DEFAULT")) {
40       String JavaDoc strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportToInvoiceConsignment|DateFrom", "");
41       String JavaDoc strDateTo = vars.getGlobalVariable("inpDateTo", "ReportToInvoiceConsignment|DateTo", "");
42       String JavaDoc strWarehouse = vars.getGlobalVariable("inpmWarehouseId","ReportToInvoiceConsignment|Warehouse", "");
43       printPageDataSheet(response, vars, strDateFrom, strDateTo, strWarehouse);
44     } else if (vars.commandIn("FIND")) {
45       String JavaDoc strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportToInvoiceConsignment|DateFrom");
46       String JavaDoc strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportToInvoiceConsignment|DateTo");
47       String JavaDoc strWarehouse = vars.getRequestGlobalVariable("inpmWarehouseId", "ReportToInvoiceConsignment|Warehouse");
48       printPagePDF(response, vars, strDateFrom, strDateTo, strWarehouse);
49     } else pageErrorPopUp(response);
50   }
51
52   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strDateFrom, String JavaDoc strDateTo, String JavaDoc strWarehouse)
53     throws IOException, ServletException {
54     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
55     response.setContentType("text/html; charset=UTF-8");
56     PrintWriter out = response.getWriter();
57     XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportToInvoiceConsignment").createXmlDocument();
58
59     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportToInvoiceConsignment", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
60     toolbar.prepareSimpleToolBarTemplate();
61     xmlDocument.setParameter("toolbar", toolbar.toString());
62
63     try {
64       KeyMap key = new KeyMap(this, vars, "ReportToInvoiceConsignment.html");
65       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
66     } catch (Exception JavaDoc ex) {
67       throw new ServletException(ex);
68     }
69     try {
70       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportToInvoiceConsignment");
71       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
72       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
73       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
74       xmlDocument.setParameter("theme", vars.getTheme());
75       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportToInvoiceConsignment.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
76       xmlDocument.setParameter("navigationBar", nav.toString());
77       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportToInvoiceConsignment.html", strReplaceWith);
78       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
79     } catch (Exception JavaDoc ex) {
80       throw new ServletException(ex);
81     }
82     {
83       OBError myMessage = vars.getMessage("ReportToInvoiceConsignment");
84       vars.removeMessage("ReportToInvoiceConsignment");
85       if (myMessage!=null) {
86         xmlDocument.setParameter("messageType", myMessage.getType());
87         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
88         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
89       }
90     }
91
92     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
93     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
94     xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
95     xmlDocument.setParameter("dateFrom", strDateFrom);
96     xmlDocument.setParameter("dateTo", strDateTo);
97     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
98     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
99     xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
100     xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
101     xmlDocument.setParameter("mWarehouseId", strWarehouse);
102     try {
103       ComboTableData comboTableData = new ComboTableData(vars, this, "TABLE", "M_Warehouse_ID", "M_Warehouse of Client", "", Utility.getContext(this, vars, "#User_Client",""), Utility.getContext(this, vars, "#AD_Client_ID", ""), 0);
104       Utility.fillSQLParameters(this, vars, null, comboTableData,"", "");
105       xmlDocument.setData("reportM_WAREHOUSEID","liststructure", comboTableData.select(false));
106       comboTableData = null;
107     } catch (Exception JavaDoc ex) {
108       throw new ServletException(ex);
109     }
110     out.println(xmlDocument.print());
111     out.close();
112   }
113
114   void printPagePDF(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strDateFrom, String JavaDoc strDateTo, String JavaDoc strWarehouse) throws IOException, ServletException {
115     if (log4j.isDebugEnabled()) log4j.debug("Output: PDF");
116     XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportToInvoiceConsignment_PDF").createXmlDocument();
117     ReportToInvoiceConsignmentData[] data = ReportToInvoiceConsignmentData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportToInvoiceConsignment"), Utility.getContext(this, vars, "#User_Org", "ReportToInvoiceConsignment"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strWarehouse);
118     String JavaDoc strTitle = "";
119     if (!strDateFrom.equals("")){
120       strTitle = strTitle+" desde "+strDateFrom;
121     }
122     if (!strDateTo.equals("")){
123       strTitle = strTitle+" hasta "+strDateTo;
124     }
125     xmlDocument.setParameter("title", strTitle);
126     xmlDocument.setData("structure1", data);
127     String JavaDoc strResult = xmlDocument.print();
128     if (log4j.isDebugEnabled()) log4j.debug(strResult);
129     renderFO(strResult, response);
130
131   }
132
133   public String JavaDoc getServletInfo() {
134     return "Servlet ReportToInvoiceConsignment. This Servlet was made by Jon Alegria";
135   } // end of getServletInfo() method
136
}
137
Popular Tags